1 # =============================================================================
2 # Rocks'n'Diamonds Makefile (src)
3 # -----------------------------------------------------------------------------
4 # (c) 1995-2006 Holger Schemel <info@artsoft.org>
5 # =============================================================================
7 # -----------------------------------------------------------------------------
9 # -----------------------------------------------------------------------------
11 .EXPORT_ALL_VARIABLES:
13 ifndef PLATFORM # unknown platform -- try auto detection
21 ifdef X11_PATH # path to X11 from top level Makefile
22 XINC_PATH = $(X11_PATH)/include
23 XLIB_PATH = $(X11_PATH)/lib
24 X11_INCL = -I$(XINC_PATH)
25 X11_LIBS = -L$(XLIB_PATH) -lX11
36 PROGBASE = rocksndiamonds
38 ifdef SPECIAL_EDITION # create special edition
39 PROGBASE = $(SPECIAL_EDITION)
42 PROGNAME = ../$(PROGBASE)
45 # -----------------------------------------------------------------------------
46 # configuring platform
47 # -----------------------------------------------------------------------------
49 ifeq ($(PLATFORM),solaris) # native compiling to Solaris
50 EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
54 ifeq ($(PLATFORM),macosx) # native compiling to Mac OS X
55 EXTRA_LDFLAGS = -lstdc++
60 ifeq ($(PLATFORM),os2) # native compiling to OS/2
62 PROGNAME = ../$(PROGBASE).exe
63 EXTRA_CFLAGS = -Zbin-files -D__ST_MT_ERRNO__ -Zmtd -fomit-frame-pointer
64 EXTRA_LDFLAGS = -lsocket
69 ifeq ($(PLATFORM),unix) # native compiling to Unix (generic)
73 ifeq ($(PLATFORM),cross-win32) # cross-compiling to Windows
74 PROGNAME = ../$(PROGBASE).exe
75 EXTRA_LDFLAGS = -lshfolder -lwsock32
79 ifeq ($(PLATFORM),cross-msdos) # cross-compiling to MS-DOS
81 PROGNAME = ../$(PROGBASE).exe
85 ifeq ($(PLATFORM),msdos) # native compiling to MS-DOS
87 PROGNAME = ../$(PROGBASE).exe
88 SYS_CFLAGS = -DTARGET_X11
89 SYS_LDFLAGS = -s -lalleg
94 # -----------------------------------------------------------------------------
96 # -----------------------------------------------------------------------------
98 ifeq ($(TARGET),x11) # compiling for X11 target
99 SYS_CFLAGS = -DTARGET_X11 $(X11_INCL)
100 SYS_LDFLAGS = $(X11_LIBS)
103 ifeq ($(TARGET),sdl) # compiling for SDL target
104 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
105 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg
106 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --libs)
109 ifeq ($(TARGET),sdl-static) # compiling for SDL target (static)
110 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
111 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg
112 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --static-libs)
115 ifeq ($(TARGET),allegro) # compiling for Allegro target
116 SYS_CFLAGS = -DTARGET_ALLEGRO -I$(CROSS_PATH_MSDOS)/include
117 SYS_LDFLAGS = -lalleg
121 # -----------------------------------------------------------------------------
122 # configuring compile-time definitions
123 # -----------------------------------------------------------------------------
125 ifdef RO_GAME_DIR # path to read-only game data specified
126 CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\""
129 ifdef RW_GAME_DIR # path to writable game data specified
130 CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\""
133 ifdef SCORE_ENTRIES # number of score entries per player
134 CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES)
137 ifdef SPECIAL_EDITION
138 ifeq ($(SPECIAL_EDITION),rnd_jue) # create special edition
139 CONFIG_SPECIAL = -DCREATE_SPECIAL_EDITION -DCREATE_SPECIAL_EDITION_RND_JUE
143 CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
144 CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL)
146 CONFIG = $(CONFIG_GAME) $(JOYSTICK)
148 # PROFILING = $(PROFILING_FLAGS)
150 # OPTIONS = $(DEBUG) -Wall # only for debugging purposes
151 # OPTIONS = $(DEBUG) -O3 -Wall # only for debugging purposes
152 OPTIONS = $(DEBUG) -Wall # only for debugging purposes
153 # OPTIONS = $(DEBUG) -Wall -ansi -pedantic # only for debugging purposes
154 # OPTIONS = -O3 -Wall -ansi -pedantic
155 # OPTIONS = -O3 -Wall
157 # OPTIONS = -DSYSV -Ae # may be needed for HP-UX
159 ifdef BUILD_DIST # distribution build
163 CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG)
164 LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
221 CNFS_CMD = ../Scripts/create_element_defs.pl
223 TIMESTAMP_FILE = conftime.h
225 LIBGAME_DIR = libgame
226 LIBGAME = $(LIBGAME_DIR)/libgame.a
228 GAME_EM_DIR = game_em
229 GAME_EM = $(GAME_EM_DIR)/game_em.a
231 GAME_SP_DIR = game_sp
232 GAME_SP = $(GAME_SP_DIR)/game_sp.a
234 RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP)
236 ICONBASE = windows_icon
237 ifeq ($(PLATFORM),cross-win32)
238 ifdef SPECIAL_EDITION
239 ICONSUFFIX = 32x32_$(SPECIAL_EDITION)
243 ICON32X32 = ../graphics/$(ICONBASE)_$(ICONSUFFIX).bmp
248 # -----------------------------------------------------------------------------
250 # -----------------------------------------------------------------------------
252 all: libgame_dir game_em_dir game_sp_dir $(PROGNAME)
254 $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON)
255 $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME)
258 @$(MAKE) -C $(LIBGAME_DIR)
260 @$(MAKE) -C $(LIBGAME_DIR)
263 @$(MAKE) -C $(GAME_EM_DIR)
265 @$(MAKE) -C $(GAME_EM_DIR)
268 @$(MAKE) -C $(GAME_SP_DIR)
270 @$(MAKE) -C $(GAME_SP_DIR)
273 @for i in $(CNFS); do \
274 echo "$(CNFS_CMD) $$i > $$i"; \
275 $(CNFS_CMD) $$i > $$i; \
278 conf_gfx.h: conf_gfx.c
281 conf_snd.h: conf_snd.c
284 conf_mus.h: conf_mus.c
287 $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
288 @date '+"%Y-%m-%d %H:%M"' \
289 | sed -e 's/^/#define COMPILE_DATE_STRING /' \
293 $(BMP2ICO) -transparent $(ICONBASE).ico $(ICON32X32)
294 echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
297 $(CC) $(PROFILING) $(CFLAGS) -c $*.c
300 $(MAKE) -C $(LIBGAME_DIR) clean
301 $(MAKE) -C $(GAME_EM_DIR) clean
302 $(MAKE) -C $(GAME_SP_DIR) clean
309 $(RM) $(ICONBASE).ico
316 clean: clean-obj clean-ico clean-bin
319 # -----------------------------------------------------------------------------
320 # run and test targets
321 # -----------------------------------------------------------------------------
324 cd .. && ./$(PROGBASE) --verbose
327 cd .. && gdb -batch -x GDB_COMMANDS ./$(PROGBASE)
330 cd .. && valgrind -v --leak-check=yes ./$(PROGBASE) 2> valgrind.out
333 # -----------------------------------------------------------------------------
335 # -----------------------------------------------------------------------------
337 dist-clean: clean-obj
340 $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch]
343 $(MAKE) -C $(LIBGAME_DIR) depend
344 $(MAKE) -C $(GAME_EM_DIR) depend
345 $(MAKE) -C $(GAME_SP_DIR) depend
346 for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
348 ifeq (.depend,$(wildcard .depend))