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 RNDLIBS = $(LIBGAME) $(GAME_EM)
233 ICONBASE = windows_icon
234 ifeq ($(PLATFORM),cross-win32)
235 ifdef SPECIAL_EDITION
236 ICONSUFFIX = 32x32_$(SPECIAL_EDITION)
240 ICON32X32 = ../graphics/$(ICONBASE)_$(ICONSUFFIX).bmp
245 # -----------------------------------------------------------------------------
247 # -----------------------------------------------------------------------------
249 all: libgame_dir game_em_dir $(PROGNAME)
251 $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON)
252 $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME)
255 @$(MAKE) -C $(LIBGAME_DIR)
257 @$(MAKE) -C $(LIBGAME_DIR)
260 @$(MAKE) -C $(GAME_EM_DIR)
262 @$(MAKE) -C $(GAME_EM_DIR)
265 @for i in $(CNFS); do \
266 echo "$(CNFS_CMD) $$i > $$i"; \
267 $(CNFS_CMD) $$i > $$i; \
270 conf_gfx.h: conf_gfx.c
273 conf_snd.h: conf_snd.c
276 conf_mus.h: conf_mus.c
279 $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM)
280 @date '+"%Y-%m-%d %H:%M"' \
281 | sed -e 's/^/#define COMPILE_DATE_STRING /' \
285 $(BMP2ICO) -transparent $(ICONBASE).ico $(ICON32X32)
286 echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
289 $(CC) $(PROFILING) $(CFLAGS) -c $*.c
292 $(MAKE) -C $(LIBGAME_DIR) clean
293 $(MAKE) -C $(GAME_EM_DIR) clean
299 $(RM) $(ICONBASE).ico
306 clean: clean-obj clean-ico clean-bin
309 # -----------------------------------------------------------------------------
310 # run and test targets
311 # -----------------------------------------------------------------------------
314 $(PROGNAME) --verbose
317 gdb -batch -x ../GDB_COMMANDS $(PROGNAME)
320 valgrind -v --leak-check=yes $(PROGNAME) 2> ../valgrind.out
323 # -----------------------------------------------------------------------------
325 # -----------------------------------------------------------------------------
327 dist-clean: clean-obj
330 $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch]
333 $(MAKE) -C $(LIBGAME_DIR) depend
334 $(MAKE) -C $(GAME_EM_DIR) depend
335 for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
337 ifeq (.depend,$(wildcard .depend))