1 # =============================================================================
2 # Rocks'n'Diamonds - McDuffin Strikes Back!
3 # -----------------------------------------------------------------------------
4 # (c) 1995-2014 by Artsoft Entertainment
7 # http://www.artsoft.org/
8 # -----------------------------------------------------------------------------
10 # =============================================================================
12 # -----------------------------------------------------------------------------
14 # -----------------------------------------------------------------------------
16 .EXPORT_ALL_VARIABLES:
18 ifndef PLATFORM # unknown platform -- default to Unix
30 CONVERT_ICON_ARGS = -transparent black -background transparent
32 PROGBASE = rocksndiamonds
34 ifdef SPECIAL_EDITION # create special edition
35 PROGBASE = $(SPECIAL_EDITION)
38 PROGNAME = ../$(PROGBASE)
41 # -----------------------------------------------------------------------------
42 # configuring platform
43 # -----------------------------------------------------------------------------
45 ifeq ($(PLATFORM),solaris) # compiling on Solaris
46 EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
47 override PLATFORM = unix
50 ifeq ($(PLATFORM),macosx) # compiling on Mac OS X
51 EXTRA_LDFLAGS = -lstdc++
52 override PLATFORM = unix
55 ifeq ($(PLATFORM),unix) # compiling on Unix/Linux (generic)
59 ifeq ($(PLATFORM),cross-win32) # cross-compiling to Windows
60 PROGNAME = ../$(PROGBASE).exe
61 EXTRA_LDFLAGS = -lshfolder -lwsock32
65 # -----------------------------------------------------------------------------
67 # -----------------------------------------------------------------------------
69 ifndef TARGET # auto-detect compiling for SDL or SDL2
70 SDL_VERSION := $(shell sdl2-config --version 2> /dev/null)
74 SDL_VERSION := $(shell sdl-config --version 2> /dev/null)
78 $(error SDL/SDL2 library not found)
83 ifeq ($(STATIC),true) # check for static linking
84 override TARGET := $(TARGET)-static
87 # $(info Using SDL version $(SDL_VERSION) [TARGET == $(TARGET)])
89 ifeq ($(TARGET),sdl) # compiling for SDL target
90 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
91 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg
92 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --libs)
95 ifeq ($(TARGET),sdl2) # compiling for SDL2 target
96 SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags)
97 SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net -lsmpeg2
98 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl2-config --libs)
101 ifeq ($(TARGET),sdl-static) # compiling for SDL target (static)
102 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
103 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg -lmikmod
104 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --static-libs)
107 ifeq ($(TARGET),sdl2-static) # compiling for SDL2 target (static)
108 SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags)
109 SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net -lsmpeg2 -lmikmod
110 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl2-config --static-libs)
114 # -----------------------------------------------------------------------------
115 # configuring compile-time definitions
116 # -----------------------------------------------------------------------------
118 ifdef RO_GAME_DIR # path to read-only game data specified
119 CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\""
122 ifdef RW_GAME_DIR # path to writable game data specified
123 CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\""
126 ifdef SCORE_ENTRIES # number of score entries per player
127 CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES)
130 ifdef SPECIAL_EDITION
131 ifeq ($(SPECIAL_EDITION),rnd_jue) # create special edition
132 CONFIG_SPECIAL = -DCREATE_SPECIAL_EDITION -DCREATE_SPECIAL_EDITION_RND_JUE
136 CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
137 CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL)
139 CONFIG = $(CONFIG_GAME) $(JOYSTICK)
141 # PROFILING = $(PROFILING_FLAGS)
143 # OPTIONS = $(DEBUG) -Wall # only for debugging purposes
144 # OPTIONS = $(DEBUG) -O3 -Wall # only for debugging purposes
145 OPTIONS = $(DEBUG) -Wall # only for debugging purposes
146 # OPTIONS = $(DEBUG) -Wall -ansi -pedantic # only for debugging purposes
147 # OPTIONS = -O3 -Wall -ansi -pedantic
148 # OPTIONS = -O3 -Wall
150 # OPTIONS = -DSYSV -Ae # may be needed for HP-UX
152 ifdef BUILD_DIST # distribution build
156 CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG)
157 LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
214 CNFS_CMD = ../build-scripts/create_element_defs.pl
216 TIMESTAMP_FILE = conftime.h
218 LIBGAME_DIR = libgame
219 LIBGAME = $(LIBGAME_DIR)/libgame.a
221 GAME_EM_DIR = game_em
222 GAME_EM = $(GAME_EM_DIR)/game_em.a
224 GAME_SP_DIR = game_sp
225 GAME_SP = $(GAME_SP_DIR)/game_sp.a
227 RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP)
228 AUTOCONF = conf_gfx.h conf_snd.h conf_mus.h
230 ICONBASE = windows_icon
231 ICON_BASEPATH = ../Special/Icons/windows_icons
232 ifeq ($(PLATFORM),cross-win32)
233 ifdef SPECIAL_EDITION
234 # ICONSUFFIX = 32x32_$(SPECIAL_EDITION)
235 ICON_PATH = $(ICON_BASEPATH)/$(SPECIAL_EDITION)
238 ICON_PATH = $(ICON_BASEPATH)/default
240 # ICON32X32 = ../graphics/$(ICONBASE)_$(ICONSUFFIX).bmp
244 GRAPHICS_DIR = ../graphics
247 # -----------------------------------------------------------------------------
249 # -----------------------------------------------------------------------------
251 all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir $(PROGNAME) graphics_dir
253 $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON)
254 $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME)
257 @$(MAKE) -C $(LIBGAME_DIR)
259 @$(MAKE) -C $(LIBGAME_DIR)
262 @$(MAKE) -C $(GAME_EM_DIR)
264 @$(MAKE) -C $(GAME_EM_DIR)
267 @$(MAKE) -C $(GAME_SP_DIR)
269 @$(MAKE) -C $(GAME_SP_DIR)
272 @for i in $(CNFS); do \
273 echo "$(CNFS_CMD) $$i > $$i"; \
274 $(CNFS_CMD) $$i > $$i; \
278 @for i in $(CNFS); do \
283 conf_gfx.h: conf_gfx.c $(CNFS_CMD)
286 conf_snd.h: conf_snd.c $(CNFS_CMD)
289 conf_mus.h: conf_mus.c $(CNFS_CMD)
292 # $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
293 $(TIMESTAMP_FILE): $(SRCS) $(RNDLIBS)
294 @date '+"%Y-%m-%d %H:%M"' \
295 | sed -e 's/^/#define COMPILE_DATE_STRING /' \
299 # $(CONVERT) $(ICON32X32) $(CONVERT_ICON_ARGS) $(ICONBASE).ico
300 $(CONVERT) $(ICON_PATH)/*.png $(CONVERT_ICON_ARGS) $(ICONBASE).ico
301 echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
304 $(CC) $(PROFILING) $(CFLAGS) -c $*.c
307 @$(MAKE) -C $(GRAPHICS_DIR)
310 $(MAKE) -C $(LIBGAME_DIR) clean
311 $(MAKE) -C $(GAME_EM_DIR) clean
312 $(MAKE) -C $(GAME_SP_DIR) clean
320 $(RM) $(ICONBASE).ico
327 clean: clean-obj clean-ico clean-bin
329 clean-git: clean auto-conf-clean
330 @$(MAKE) -C $(GRAPHICS_DIR) clean
333 # -----------------------------------------------------------------------------
334 # run and test targets
335 # -----------------------------------------------------------------------------
338 cd .. && ./$(PROGBASE) --verbose
341 cd .. && gdb -batch -x GDB_COMMANDS ./$(PROGBASE)
344 cd .. && valgrind -v --leak-check=yes ./$(PROGBASE) 2> valgrind.out
347 # -----------------------------------------------------------------------------
349 # -----------------------------------------------------------------------------
351 dist-clean: clean-obj
354 $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch]
357 $(MAKE) -C $(LIBGAME_DIR) depend
358 $(MAKE) -C $(GAME_EM_DIR) depend
359 $(MAKE) -C $(GAME_SP_DIR) depend
360 for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
362 ifeq (.depend,$(wildcard .depend))