1 # =============================================================================
2 # Rocks'n'Diamonds Makefile (src)
3 # -----------------------------------------------------------------------------
4 # (c) 1995-2005 Holger Schemel <info@artsoft.org>
5 # =============================================================================
7 # -----------------------------------------------------------------------------
9 # -----------------------------------------------------------------------------
11 .EXPORT_ALL_VARIABLES:
13 ifndef PLATFORM # no platform specified -- try auto detection
21 ifdef X11_PATH # path to X11 specified by 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
35 ifeq ($(PLATFORM),msdos) # MS-DOS native compiling
40 PROGNAME = ../$(PROGBASE).exe
42 SYS_CFLAGS = -DTARGET_X11
43 SYS_LDFLAGS = -s -lalleg
45 else # Unix or cross-compiling for MS-DOS and Win32
49 PROGBASE = rocksndiamonds
50 PROGNAME = ../$(PROGBASE)
52 ifeq ($(PLATFORM),solaris)
53 EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
57 ifeq ($(PLATFORM),macosx)
62 ifeq ($(PLATFORM),os2)
64 PROGNAME = ../$(PROGBASE).exe
65 EXTRA_CFLAGS = -Zbin-files -D__ST_MT_ERRNO__ -Zmtd -fomit-frame-pointer
66 EXTRA_LDFLAGS = -lsocket
71 ifeq ($(PLATFORM),unix)
75 ifeq ($(PLATFORM),cross-msdos)
77 PROGNAME = ../$(PROGBASE).exe
81 ifeq ($(PLATFORM),cross-win32)
82 EXTRA_LDFLAGS = -lshfolder -lwsock32
83 PROGNAME = ../$(PROGBASE).exe
88 SYS_CFLAGS = -DTARGET_X11 $(X11_INCL)
89 SYS_LDFLAGS = $(X11_LIBS)
93 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
94 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg
95 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --libs)
98 ifeq ($(TARGET),sdl-static)
99 SYS_CFLAGS = -DTARGET_SDL $(shell sdl-config --cflags)
100 SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg
101 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --static-libs)
104 ifeq ($(TARGET),allegro)
105 SYS_CFLAGS = -DTARGET_ALLEGRO -I$(CROSS_PATH_MSDOS)/include
106 SYS_LDFLAGS = -lalleg
109 endif # (PLATFORM != msdos)
112 ifdef RO_GAME_DIR # path to read-only game data specified
113 CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\""
116 ifdef RW_GAME_DIR # path to writable game data specified
117 CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\""
120 ifdef SCORE_ENTRIES # number of score entries per player specified
121 CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES)
124 CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
127 CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(JOYSTICK)
129 # PROFILING = $(PROFILING_FLAGS)
131 # OPTIONS = $(DEBUG) -Wall # only for debugging purposes
132 # OPTIONS = $(DEBUG) -O3 -Wall # only for debugging purposes
133 OPTIONS = $(DEBUG) -Wall # only for debugging purposes
134 # OPTIONS = $(DEBUG) -Wall -ansi -pedantic # only for debugging purposes
135 # OPTIONS = -O3 -Wall -ansi -pedantic
136 # OPTIONS = -O3 -Wall
138 # OPTIONS = -DSYSV -Ae # may be needed for HP-UX
140 ifdef BUILD_DIST # distribution build
144 CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG)
145 LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
200 CNFS_CMD = ../Scripts/create_element_defs.pl
202 TIMESTAMP_FILE = conftime.h
204 LIBGAME_DIR = libgame
205 LIBGAME = $(LIBGAME_DIR)/libgame.a
207 GAME_EM_DIR = game_em
208 GAME_EM = $(GAME_EM_DIR)/game_em.a
210 RNDLIBS = $(LIBGAME) $(GAME_EM)
212 ICONBASE = windows_icon
213 ifeq ($(PLATFORM),cross-win32)
214 ICON32X32 = ../graphics/$(ICONBASE)_32x32.bmp
219 # -----------------------------------------------------------------------------
221 # -----------------------------------------------------------------------------
223 all: libgame_dir game_em_dir $(PROGNAME)
225 $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON)
226 $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME)
229 @$(MAKE) -C $(LIBGAME_DIR)
231 @$(MAKE) -C $(LIBGAME_DIR)
234 @$(MAKE) -C $(GAME_EM_DIR)
236 @$(MAKE) -C $(GAME_EM_DIR)
239 @for i in $(CNFS); do \
240 echo "$(CNFS_CMD) $$i > $$i"; \
241 $(CNFS_CMD) $$i > $$i; \
244 conf_gfx.h: conf_gfx.c
247 conf_snd.h: conf_snd.c
250 conf_mus.h: conf_mus.c
253 $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM)
254 @date '+"[%Y-%m-%d %H:%M]"' \
255 | sed -e 's/^/#define COMPILE_DATE_STRING /' \
259 $(BMP2ICO) -transparent $(ICONBASE).ico $(ICON32X32)
260 echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
263 $(CC) $(PROFILING) $(CFLAGS) -c $*.c
266 $(MAKE) -C $(LIBGAME_DIR) clean
267 $(MAKE) -C $(GAME_EM_DIR) clean
273 $(RM) $(ICONBASE).ico
280 clean: clean-obj clean-ico clean-bin
283 # -----------------------------------------------------------------------------
285 # -----------------------------------------------------------------------------
287 dist-clean: clean-obj
290 $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch]
293 $(MAKE) -C $(LIBGAME_DIR) depend
294 $(MAKE) -C $(GAME_EM_DIR) depend
295 for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
297 ifeq (.depend,$(wildcard .depend))