can now build outside maemo
authorJavier S. Pedro <javier@javispedro.com>
Mon, 19 Oct 2009 17:46:00 +0000 (19:46 +0200)
committerJavier S. Pedro <javier@javispedro.com>
Mon, 19 Oct 2009 17:46:00 +0000 (19:46 +0200)
Makefile
debian/rules
platform/config.cpp
platform/sdl.cpp

index bf5d5a3..ba45765 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
 #!/usr/bin/make
 
-CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11) -I/usr/include/hgw
-LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11) -lpopt -lhgw
+CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11)
+LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11) -lpopt
 
 -include config.mk
 
 # Sane defaults
+CONF_GUI?=1
+CONF_HGW?=$(CONF_GUI)
 ifeq ($(ARCH),armel)
        CONF_BUILD_ASM_CPU?=1
        CONF_BUILD_ASM_SPC700?=1
@@ -56,15 +58,21 @@ OBJS += unzip.o ioapi.o
 # my extensions to snes9x (speedhacks support)
 OBJS += hacks.o
 # the glue code that sticks it all together in a monstruous way
-OBJS += platform/path.o platform/config.o platform/hgw.o
+OBJS += platform/path.o platform/config.o
 OBJS += platform/sdl.o platform/sdlv.o platform/sdla.o platform/sdli.o
 
+ifeq ($(CONF_HGW), 1)
+       CPPFLAGS += -DCONF_HGW=1 -I/usr/include/hgw
+       LDLIBS += -lhgw
+       OBJS += platform/hgw.o
+endif
+
 # automatic dependencies
 DEPS := $(OBJS:.o=.d)
 
-all: drnoksnes gui
+all: drnoksnes
 
-clean: gui_clean
+clean:
        rm -f drnoksnes *.o *.d platform/*.o platform/*.d
        rm -f build-stamp configure-stamp
 
@@ -77,7 +85,6 @@ drnoksnes: $(OBJS)
 
 install: drnoksnes
        install drnoksnes $(DESTDIR)/usr/games
-       $(MAKE) -C gui install DESTDIR="$(DESTDIR)"
 
 deps: $(DEPS)
 %.d: %.cpp
@@ -87,11 +94,21 @@ deps: $(DEPS)
 %.d: %.s
        @touch $@
 
+# GUI
 gui:
        $(MAKE) -C gui all
 
 gui_clean:
        $(MAKE) -C gui clean
+       
+gui_install:
+       $(MAKE) -C gui install DESTDIR="$(DESTDIR)"
+       
+ifeq ($(CONF_GUI), 1)
+all: gui
+clean: gui_clean
+install: gui_install
+endif
 
 .PHONY: all clean remake deps install gui gui_clean
 
index 25a1d33..ea8e09c 100755 (executable)
@@ -61,6 +61,8 @@ configure-stamp:
        $(M4) $(M4DEFS) debian/drnoksnes.postinst.m4 > debian/drnoksnes.postinst
        
        echo ARCH="$(ARCH)" > config.mk
+       echo CONF_GUI=1 >> config.mk
+       echo CONF_HGW=1 >> config.mk
 ifeq ($(shell expr "$(MAEMO_VERSION)" ">" 4), 1)
        # Maemo 5 devices do not support Xsp
        echo CONF_XSP=0 >> config.mk
index cf01595..82a5b6c 100644 (file)
@@ -424,14 +424,24 @@ void S9xLoadConfig(int argc, const char ** argv)
        // Command line parameters (including --conf args)
        parseArgs(optCon);
 
+#if CONF_HGW
        if (!gotRomFile() && !hgwLaunched) {
                // User did not specify a ROM file, 
                // and we're not being launched from D-Bus.
                fprintf(stderr, "You need to specify a ROM, like this:\n");
                poptPrintUsage(optCon, stdout, 0);
-               poptFreeContext(optCon); 
+               poptFreeContext(optCon);
                exit(2);
        }
+#else
+       if (!gotRomFile()) {
+               // User did not specify a ROM file
+               fprintf(stderr, "You need to specify a ROM, like this:\n");
+               poptPrintUsage(optCon, stdout, 0);
+               poptFreeContext(optCon);
+               exit(2);
+       }
+#endif
 
        poptFreeContext(optCon);
 }
index 5d19d67..8cab4cc 100644 (file)
@@ -191,6 +191,7 @@ static inline void pollEvents() {
        }
 }
 
+#if CONF_HGW
 /** Wraps HgwPollEvents, taking care of kPollHgwEveryNFrames */
 static inline void pollHgwEvents() {
        static int frames = 0;
@@ -202,6 +203,7 @@ static inline void pollHgwEvents() {
                frames = 0;
        }
 }
+#endif
 
 int main(int argc, const char ** argv) {       
        // Initialise SDL
@@ -209,9 +211,13 @@ int main(int argc, const char ** argv) {
                DIE("SDL_Init: %s", SDL_GetError());
 
        // Configure snes9x
+#if CONF_HGW
        HgwInit();                                              // Hildon-games-wrapper initialization.
+#endif
        S9xLoadConfig(argc, argv);              // Load config files and parse cmd line.
+#if CONF_HGW
        HgwConfig();                                    // Apply specific hildon-games config.
+#endif
 
        // S9x initialization
        S9xInitDisplay(argc, argv);
@@ -236,7 +242,9 @@ int main(int argc, const char ** argv) {
                frameSync();                    // May block, or set frameskip to true.
                S9xMainLoop();                  // Does CPU things, renders if needed.
                pollEvents();
+#if CONF_HGW
                pollHgwEvents();
+#endif
        } while (!Config.quitting);
        
        // Deinitialization
@@ -253,7 +261,9 @@ int main(int argc, const char ** argv) {
        S9xGraphicsDeinit();
        Memory.Deinit();
        S9xUnloadConfig();
+#if CONF_HGW
        HgwDeinit();
+#endif
 
        SDL_Quit();