X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2FMakefile;h=f9fb4581ca5b7947ab0f1b588b1df918e3338286;hb=3f1999929dd6662da92c8f1b20c2fcbbce0c0ed7;hp=6885c601ac19af7726a91fa73fc1007d4b615574;hpb=3da843584f5e953c68b8934c2b315a0944e880c8;p=rocksndiamonds.git diff --git a/src/Makefile b/src/Makefile index 6885c601..f9fb4581 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,6 +39,8 @@ WINDRES = windres CONVERT_ICON_ARGS = -transparent black -background transparent +DEBUGGER = gdb -batch -ex "run" -ex "bt" + PROGBASE = rocksndiamonds PROGNAME = ../$(PROGBASE) @@ -58,8 +60,17 @@ PROGNAME = ../$(PROGBASE).exe EXTRA_LDFLAGS = -lshfolder -lwsock32 endif -ifdef BUILD_DIST # distribution build +ifeq ($(PLATFORM),emscripten) # compiling with Emscripten +PROGNAME = ../$(PROGBASE).js +CC = emcc +AR = emar +RANLIB = emranlib +STRIP = true +endif + ifeq ($(shell uname -s),Darwin) # compiling on Mac OS X +DEBUGGER = lldb --batch -o "run" -k "bt" -k "quit" +ifdef BUILD_DIST # distribution build MAC_TARGET_VERSION_MIN = 10.7 EXTRA_FLAGS_MAC = -mmacosx-version-min=$(MAC_TARGET_VERSION_MIN) EXTRA_CFLAGS = $(EXTRA_FLAGS_MAC) @@ -85,7 +96,15 @@ endif # $(info Using SDL version $(SDL_VERSION) [TARGET == $(TARGET)]) ifeq ($(TARGET),sdl2) # compiling for SDL2 target +ifeq ($(PLATFORM),emscripten) +SDL_LIBS = -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_NET=2 -s USE_ZLIB=1 +SDL_FMTS = -s SDL2_IMAGE_FORMATS='["bmp","png","pcx","xpm"]' +EXTRA_CFLAGS = $(SDL_LIBS) +EXTRA_LDFLAGS = $(SDL_FMTS) -s INITIAL_MEMORY=81920000 -s ALLOW_MEMORY_GROWTH=1 --preload-file ../conf/ --preload-file ../docs/ --preload-file ../levels/ --preload-file ../graphics/ --preload-file ../sounds/ --preload-file ../music/ -s NO_EXIT_RUNTIME=0 -s ASYNCIFY -O2 -lidbfs.js +else SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net +endif + SYS_CFLAGS := -DTARGET_SDL2 $(shell sdl2-config --cflags) SYS_LDFLAGS := $(SDL_LIBS) $(shell sdl2-config --libs) -lm -lz endif @@ -95,15 +114,11 @@ endif # configuring compile-time definitions # ----------------------------------------------------------------------------- -ifdef RO_GAME_DIR # path to read-only game data specified -CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\"" -endif - -ifdef RW_GAME_DIR # path to writable game data specified -CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\"" +ifdef BASE_PATH # path to read-only game data +CONFIG_BASE_PATH = -DBASE_PATH="\"$(BASE_PATH)\"" endif -CONFIG = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR) $(JOYSTICK) +CONFIG = $(CONFIG_BASE_PATH) $(JOYSTICK) DEBUG = -DDEBUG -g @@ -118,6 +133,10 @@ OPTIONS = $(DEBUG) -Wall -Wstrict-prototypes -Wmissing-prototypes # OPTIONS = -O2 -Wall # OPTIONS = -O2 +ifdef BUILD_TEST # test build +OPTIONS := $(OPTIONS) -DTESTING +endif + ifdef BUILD_DIST # distribution build SYS_LDFLAGS := $(shell echo $(SYS_LDFLAGS) | \ sed -e "s%-rpath,[^ ]*%-rpath,'\$$ORIGIN/lib'%") @@ -173,6 +192,8 @@ CNFS = conf_gfx.h \ conf_cus.h \ conf_grp.c \ conf_grp.h \ + conf_emp.c \ + conf_emp.h \ conf_e2g.c \ conf_esg.c \ conf_e2s.c \ @@ -317,7 +338,10 @@ clean-ico: clean-bin: $(RM) $(PROGNAME) - $(RM) ../*.exe + $(RM) $(PROGNAME).exe + $(RM) $(PROGNAME).js + $(RM) $(PROGNAME).wasm + $(RM) $(PROGNAME).data clean: clean-obj clean-ico clean-bin @@ -335,7 +359,7 @@ run: cd .. && ./$(PROGBASE) --verbose gdb: - cd .. && gdb -batch -x GDB_COMMANDS ./$(PROGBASE) + cd .. && $(DEBUGGER) $(PROGBASE) valgrind: cd .. && valgrind -v --leak-check=yes ./$(PROGBASE) 2> valgrind.out