X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2FMakefile;h=e42d5370f7c73fb0b4170e001fe3a45b4d48cd72;hp=ea1325d8ef0a2ad6738063e6b9a70b0fe584569a;hb=1be3e5c990b84f8548a80ccd6b7b209a88312141;hpb=120fe36da3055f5b869d0a72307c6013fae865f7 diff --git a/src/Makefile b/src/Makefile index ea1325d8..e42d5370 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ # ============================================================================= # Rocks'n'Diamonds - McDuffin Strikes Back! # ----------------------------------------------------------------------------- -# (c) 1995-2014 by Artsoft Entertainment +# (c) 1995-2015 by Artsoft Entertainment # Holger Schemel # info@artsoft.org # http://www.artsoft.org/ @@ -30,23 +30,15 @@ WINDRES = windres CONVERT_ICON_ARGS = -transparent black -background transparent PROGBASE = rocksndiamonds - -ifdef SPECIAL_EDITION # create special edition -PROGBASE = $(SPECIAL_EDITION) -endif - PROGNAME = ../$(PROGBASE) +EDITION ?= default + # ----------------------------------------------------------------------------- # configuring platform # ----------------------------------------------------------------------------- -ifeq ($(PLATFORM),solaris) # compiling on Solaris -EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH) -override PLATFORM = unix -endif - ifeq ($(PLATFORM),macosx) # compiling on Mac OS X EXTRA_LDFLAGS = -lstdc++ override PLATFORM = unix @@ -66,50 +58,27 @@ endif # configuring target # ----------------------------------------------------------------------------- -ifndef TARGET # auto-detect compiling for SDL or SDL2 +ifndef TARGET # auto-detect compiling for SDL2 SDL_VERSION := $(shell sdl2-config --version 2> /dev/null) ifdef SDL_VERSION TARGET = sdl2 else - SDL_VERSION := $(shell sdl-config --version 2> /dev/null) - ifdef SDL_VERSION - TARGET = sdl - else - $(error SDL/SDL2 library not found) - endif + $(error SDL2 library not found) endif endif -ifeq ($(STATIC),true) # check for static linking -override TARGET := $(TARGET)-static -endif - # $(info Using SDL version $(SDL_VERSION) [TARGET == $(TARGET)]) ifeq ($(TARGET),sdl) # compiling for SDL target -SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags) -SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg -SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --libs) + $(error SDL library version 1.2 not supported anymore) endif ifeq ($(TARGET),sdl2) # compiling for SDL2 target SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags) -SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net -lsmpeg2 +SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl2-config --libs) endif -ifeq ($(TARGET),sdl-static) # compiling for SDL target (static) -SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags) -SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg -lmikmod -SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --static-libs) -endif - -ifeq ($(TARGET),sdl2-static) # compiling for SDL2 target (static) -SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags) -SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net -lsmpeg2 -lmikmod -SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl2-config --static-libs) -endif - # ----------------------------------------------------------------------------- # configuring compile-time definitions @@ -123,38 +92,29 @@ ifdef RW_GAME_DIR # path to writable game data specified CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\"" endif -ifdef SCORE_ENTRIES # number of score entries per player -CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES) -endif - -ifdef SPECIAL_EDITION -ifeq ($(SPECIAL_EDITION),rnd_jue) # create special edition -CONFIG_SPECIAL = -DCREATE_SPECIAL_EDITION -DCREATE_SPECIAL_EDITION_RND_JUE -endif -endif - -CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR) -CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL) +CONFIG = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR) $(JOYSTICK) -CONFIG = $(CONFIG_GAME) $(JOYSTICK) DEBUG = -DDEBUG -g + # PROFILING = $(PROFILING_FLAGS) # OPTIONS = $(DEBUG) -Wall # only for debugging purposes # OPTIONS = $(DEBUG) -O3 -Wall # only for debugging purposes -OPTIONS = $(DEBUG) -Wall # only for debugging purposes +# OPTIONS = $(DEBUG) -Wall # only for debugging purposes +OPTIONS = $(DEBUG) -Wall -Wstrict-prototypes -Wmissing-prototypes # OPTIONS = $(DEBUG) -Wall -ansi -pedantic # only for debugging purposes # OPTIONS = -O3 -Wall -ansi -pedantic # OPTIONS = -O3 -Wall # OPTIONS = -O3 -# OPTIONS = -DSYSV -Ae # may be needed for HP-UX ifdef BUILD_DIST # distribution build +SYS_LDFLAGS := $(shell echo $(SYS_LDFLAGS) | \ + sed -e "s%-rpath,[^ ]*%-rpath,'\$$ORIGIN/lib'%") OPTIONS = -O3 -Wall endif CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG) -LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm +LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm -lz SRCS = main.c \ @@ -171,7 +131,7 @@ SRCS = main.c \ editor.c \ files.c \ tape.c \ - cartoons.c \ + anim.c \ network.c \ netserv.c @@ -189,7 +149,7 @@ OBJS = main.o \ editor.o \ files.o \ tape.o \ - cartoons.o \ + anim.o \ network.o \ netserv.o @@ -214,6 +174,13 @@ CNFS = conf_gfx.h \ CNFS_CMD = ../build-scripts/create_element_defs.pl TIMESTAMP_FILE = conftime.h +TIMESTAMP_FORMAT = %Y-%m-%d %H:%M + +# use SOURCE_DATE_EPOCH, or else last Git commit date, or else current date +SOURCE_DATE_EPOCH ?= $(shell test -d ../.git && test `git ls-files -m | wc -l` -eq 0 && git show -s --format=%ct || date +%s) + +# get source date string from either GNU / Linux or BSD / Mac OS X style "date" +SOURCE_DATE_STRING := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIMESTAMP_FORMAT)" 2>/dev/null || date -u "+$(TIMESTAMP_FORMAT)") LIBGAME_DIR = libgame LIBGAME = $(LIBGAME_DIR)/libgame.a @@ -224,20 +191,17 @@ GAME_EM = $(GAME_EM_DIR)/game_em.a GAME_SP_DIR = game_sp GAME_SP = $(GAME_SP_DIR)/game_sp.a -RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP) +GAME_MM_DIR = game_mm +GAME_MM = $(GAME_MM_DIR)/game_mm.a + +RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP) $(GAME_MM) AUTOCONF = conf_gfx.h conf_snd.h conf_mus.h ICONBASE = windows_icon ICON_BASEPATH = ../Special/Icons/windows_icons + ifeq ($(PLATFORM),cross-win32) -ifdef SPECIAL_EDITION -# ICONSUFFIX = 32x32_$(SPECIAL_EDITION) -ICON_PATH = $(ICON_BASEPATH)/$(SPECIAL_EDITION) -else -# ICONSUFFIX = 32x32 -ICON_PATH = $(ICON_BASEPATH)/default -endif -# ICON32X32 = ../graphics/$(ICONBASE)_$(ICONSUFFIX).bmp +ICON_PATH = $(ICON_BASEPATH)/$(EDITION) ICON = $(ICONBASE).o endif @@ -248,10 +212,13 @@ GRAPHICS_DIR = ../graphics # build targets # ----------------------------------------------------------------------------- -all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir $(PROGNAME) graphics_dir +all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir game_mm_dir $(PROGNAME) graphics_dir $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON) $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME) +ifdef BUILD_DIST + strip $(PROGNAME) +endif libgame_dir: @$(MAKE) -C $(LIBGAME_DIR) @@ -268,6 +235,11 @@ game_sp_dir: $(GAME_SP): @$(MAKE) -C $(GAME_SP_DIR) +game_mm_dir: + @$(MAKE) -C $(GAME_MM_DIR) +$(GAME_MM): + @$(MAKE) -C $(GAME_MM_DIR) + auto-conf: @for i in $(CNFS); do \ echo "$(CNFS_CMD) $$i > $$i"; \ @@ -289,10 +261,8 @@ conf_snd.h: conf_snd.c $(CNFS_CMD) conf_mus.h: conf_mus.c $(CNFS_CMD) @$(MAKE) auto-conf -# $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP) $(TIMESTAMP_FILE): $(SRCS) $(RNDLIBS) - @date '+"%Y-%m-%d %H:%M"' \ - | sed -e 's/^/#define COMPILE_DATE_STRING /' \ + @echo '#define SOURCE_DATE_STRING "$(SOURCE_DATE_STRING)"' \ > $(TIMESTAMP_FILE) $(ICON): @@ -304,17 +274,15 @@ $(ICON): $(CC) $(PROFILING) $(CFLAGS) -c $*.c graphics_dir: - @$(MAKE) -C $(GRAPHICS_DIR) + @test -f $(GRAPHICS_DIR)/Makefile && $(MAKE) -C $(GRAPHICS_DIR) || true clean-obj: $(MAKE) -C $(LIBGAME_DIR) clean $(MAKE) -C $(GAME_EM_DIR) clean $(MAKE) -C $(GAME_SP_DIR) clean + $(MAKE) -C $(GAME_MM_DIR) clean $(RM) $(OBJS) $(RM) $(RNDLIBS) -# $(RM) $(LIBGAME) -# $(RM) $(GAME_EM) -# $(RM) $(GAME_SP) clean-ico: $(RM) $(ICONBASE).ico @@ -329,6 +297,8 @@ clean: clean-obj clean-ico clean-bin clean-git: clean auto-conf-clean @$(MAKE) -C $(GRAPHICS_DIR) clean +dist-clean: clean-obj clean-ico + # ----------------------------------------------------------------------------- # run and test targets @@ -348,15 +318,14 @@ valgrind: # development only # ----------------------------------------------------------------------------- -dist-clean: clean-obj - tags: - $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch] + $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch] $(GAME_MM_DIR)/*.[ch] depend: $(MAKE) -C $(LIBGAME_DIR) depend $(MAKE) -C $(GAME_EM_DIR) depend $(MAKE) -C $(GAME_SP_DIR) depend + $(MAKE) -C $(GAME_MM_DIR) depend for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend ifeq (.depend,$(wildcard .depend))