rocksndiamonds-3.3.1.1
[rocksndiamonds.git] / src / Makefile
index 973fdeadd74f539c7f5525d0a08a5585da101790..853c415baba744c7f14e357977e28b1d5f9c452e 100644 (file)
@@ -1,7 +1,7 @@
 # =============================================================================
 # Rocks'n'Diamonds Makefile (src)
 # -----------------------------------------------------------------------------
-# (c) 1995-2005 Holger Schemel <info@artsoft.org>
+# (c) 1995-2006 Holger Schemel <info@artsoft.org>
 # =============================================================================
 
 # -----------------------------------------------------------------------------
@@ -10,7 +10,7 @@
 
 .EXPORT_ALL_VARIABLES:
 
-ifndef PLATFORM                        # no platform specified -- try auto detection
+ifndef PLATFORM                                # unknown platform -- try auto detection
 ifdef COMSPEC
 PLATFORM = msdos
 else
@@ -18,7 +18,7 @@ PLATFORM = unix
 endif
 endif
 
-ifdef X11_PATH                 # path to X11 specified by top level Makefile
+ifdef X11_PATH                         # path to X11 from top level Makefile
 XINC_PATH = $(X11_PATH)/include
 XLIB_PATH = $(X11_PATH)/lib
 X11_INCL = -I$(XINC_PATH)
@@ -28,38 +28,38 @@ endif
 AR = ar
 RANLIB = ranlib
 ETAGS = etags
+RM = rm -f
 
-BMP2ICO = bmp2ico
+CONVERT = convert
 WINDRES = windres
 
-ifeq ($(PLATFORM),msdos)       # MS-DOS native compiling
-
-RM = del
+CONVERT_ICON_ARGS = -transparent black -background transparent
 
-PROGBASE = rocks
-PROGNAME = ../$(PROGBASE).exe
+PROGBASE = rocksndiamonds
 
-SYS_CFLAGS = -DTARGET_X11
-SYS_LDFLAGS = -s -lalleg
+ifdef SPECIAL_EDITION                  # create special edition
+PROGBASE = $(SPECIAL_EDITION)
+endif
 
-else                           # Unix or cross-compiling for MS-DOS and Win32
+PROGNAME = ../$(PROGBASE)
 
-RM = rm -f
 
-PROGBASE = rocksndiamonds
-PROGNAME = ../$(PROGBASE)
+# -----------------------------------------------------------------------------
+# configuring platform
+# -----------------------------------------------------------------------------
 
-ifeq ($(PLATFORM),solaris)
+ifeq ($(PLATFORM),solaris)             # native compiling to Solaris
 EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
 PLATFORM = unix
 endif
 
-ifeq ($(PLATFORM),macosx)
+ifeq ($(PLATFORM),macosx)              # native compiling to Mac OS X
+EXTRA_LDFLAGS = -lstdc++
 PLATFORM = unix
 TARGET = sdl
 endif
 
-ifeq ($(PLATFORM),os2)
+ifeq ($(PLATFORM),os2)                 # native compiling to OS/2
 RANLIB = echo
 PROGNAME = ../$(PROGBASE).exe
 EXTRA_CFLAGS = -Zbin-files -D__ST_MT_ERRNO__ -Zmtd -fomit-frame-pointer
@@ -68,63 +68,84 @@ PLATFORM = unix
 TARGET = x11
 endif
 
-ifeq ($(PLATFORM),unix)
+ifeq ($(PLATFORM),unix)                        # native compiling to Unix (generic)
 PROFILING_FLAGS = -pg
 endif
 
-ifeq ($(PLATFORM),cross-msdos)
+ifeq ($(PLATFORM),cross-win32)         # cross-compiling to Windows
+PROGNAME = ../$(PROGBASE).exe
+EXTRA_LDFLAGS = -lshfolder -lwsock32
+TARGET = sdl
+endif
+
+ifeq ($(PLATFORM),cross-msdos)         # cross-compiling to MS-DOS
 PROGBASE = rocks
 PROGNAME = ../$(PROGBASE).exe
 TARGET = allegro
 endif
 
-ifeq ($(PLATFORM),cross-win32)
-EXTRA_LDFLAGS = -lshfolder -lwsock32
+ifeq ($(PLATFORM),msdos)               # native compiling to MS-DOS
+PROGBASE = rocks
 PROGNAME = ../$(PROGBASE).exe
-TARGET = sdl
+SYS_CFLAGS = -DTARGET_X11
+SYS_LDFLAGS = -s -lalleg
+RM = del
 endif
 
-ifeq ($(TARGET),x11)
+
+# -----------------------------------------------------------------------------
+# configuring target
+# -----------------------------------------------------------------------------
+
+ifeq ($(TARGET),x11)                   # compiling for X11 target
 SYS_CFLAGS  = -DTARGET_X11 $(X11_INCL)
 SYS_LDFLAGS = $(X11_LIBS)
 endif
 
-ifeq ($(TARGET),sdl)
+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)
 endif
 
-ifeq ($(TARGET),sdl-static)
+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
+SDL_LIBS = -lSDL_image -lSDL_mixer -lSDL_net -lsmpeg -lmikmod
 SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl-config --static-libs)
 endif
 
-ifeq ($(TARGET),allegro)
+ifeq ($(TARGET),allegro)               # compiling for Allegro target
 SYS_CFLAGS = -DTARGET_ALLEGRO -I$(CROSS_PATH_MSDOS)/include
 SYS_LDFLAGS = -lalleg
 endif
 
-endif                          # (PLATFORM != msdos)
 
+# -----------------------------------------------------------------------------
+# configuring compile-time definitions
+# -----------------------------------------------------------------------------
 
-ifdef RO_GAME_DIR              # path to read-only game data specified
+ifdef RO_GAME_DIR                      # path to read-only game data specified
 CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\""
 endif
 
-ifdef RW_GAME_DIR              # path to writable game data specified
+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 specified
+ifdef SCORE_ENTRIES                    # number of score entries per player
 CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES)
 endif
 
-CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
+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_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(JOYSTICK)
+CONFIG = $(CONFIG_GAME) $(JOYSTICK)
 # DEBUG = -DDEBUG -g
 # PROFILING = $(PROFILING_FLAGS)
 
@@ -135,9 +156,9 @@ OPTIONS = $(DEBUG) -Wall                    # only for debugging purposes
 # OPTIONS = -O3 -Wall -ansi -pedantic
 # OPTIONS = -O3 -Wall
 # OPTIONS = -O3
-# OPTIONS = -DSYSV -Ae                         # may be needed for HP-UX
+# OPTIONS = -DSYSV -Ae                 # may be needed for HP-UX
 
-ifdef BUILD_DIST                               # distribution build
+ifdef BUILD_DIST                       # distribution build
 OPTIONS = -O3 -Wall
 endif
 
@@ -195,9 +216,11 @@ CNFS =     conf_gfx.h      \
        conf_e2s.c      \
        conf_fnt.c      \
        conf_g2s.c      \
-       conf_g2m.c
+       conf_g2m.c      \
+       conf_var.c      \
+       conf_act.c
 
-CNFS_CMD = ../Scripts/create_element_defs.pl
+CNFS_CMD = ../build-scripts/create_element_defs.pl
 
 TIMESTAMP_FILE = conftime.h
 
@@ -207,11 +230,23 @@ LIBGAME = $(LIBGAME_DIR)/libgame.a
 GAME_EM_DIR = game_em
 GAME_EM = $(GAME_EM_DIR)/game_em.a
 
-RNDLIBS = $(LIBGAME) $(GAME_EM)
+GAME_SP_DIR = game_sp
+GAME_SP = $(GAME_SP_DIR)/game_sp.a
+
+RNDLIBS = $(LIBGAME) $(GAME_EM) $(GAME_SP)
+AUTOCONF = conf_gfx.h conf_snd.h conf_mus.h
 
 ICONBASE = windows_icon
+ICON_BASEPATH = ../Special/Icons/windows_icons
 ifeq ($(PLATFORM),cross-win32)
-ICON32X32 = ../graphics/$(ICONBASE)_32x32.bmp
+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 = $(ICONBASE).o
 endif
 
@@ -220,7 +255,7 @@ endif
 # build targets
 # -----------------------------------------------------------------------------
 
-all: libgame_dir game_em_dir $(PROGNAME)
+all: $(AUTOCONF) libgame_dir game_em_dir game_sp_dir $(PROGNAME)
 
 $(PROGNAME): $(RNDLIBS) $(TIMESTAMP_FILE) $(OBJS) $(ICON)
        $(CC) $(PROFILING) $(OBJS) $(ICON) $(RNDLIBS) $(LDFLAGS) -o $(PROGNAME)
@@ -235,6 +270,11 @@ game_em_dir:
 $(GAME_EM):
        @$(MAKE) -C $(GAME_EM_DIR)
 
+game_sp_dir:
+       @$(MAKE) -C $(GAME_SP_DIR)
+$(GAME_SP):
+       @$(MAKE) -C $(GAME_SP_DIR)
+
 auto-conf:
        @for i in $(CNFS); do                   \
                echo "$(CNFS_CMD) $$i > $$i";   \
@@ -250,13 +290,14 @@ conf_snd.h: conf_snd.c
 conf_mus.h: conf_mus.c
        @$(MAKE) auto-conf
 
-$(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM)
-       @date '+"[%Y-%m-%d %H:%M]"' \
+$(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
+       @date '+"%Y-%m-%d %H:%M"' \
        | sed -e 's/^/#define COMPILE_DATE_STRING /' \
        > $(TIMESTAMP_FILE)
 
 $(ICON):
-       $(BMP2ICO) -transparent $(ICONBASE).ico $(ICON32X32)
+#      $(CONVERT) $(ICON32X32) $(CONVERT_ICON_ARGS) $(ICONBASE).ico
+       $(CONVERT) $(ICON_PATH)/*.png $(CONVERT_ICON_ARGS) $(ICONBASE).ico
        echo "$(ICONBASE) ICON $(ICONBASE).ico" | $(WINDRES) -o $(ICON)
 
 .c.o:
@@ -265,9 +306,11 @@ $(ICON):
 clean-obj:
        $(MAKE) -C $(LIBGAME_DIR) clean
        $(MAKE) -C $(GAME_EM_DIR) clean
+       $(MAKE) -C $(GAME_SP_DIR) clean
        $(RM) $(OBJS)
        $(RM) $(LIBGAME)
        $(RM) $(GAME_EM)
+       $(RM) $(GAME_SP)
 
 clean-ico:
        $(RM) $(ICONBASE).ico
@@ -280,6 +323,20 @@ clean-bin:
 clean: clean-obj clean-ico clean-bin
 
 
+# -----------------------------------------------------------------------------
+# run and test targets
+# -----------------------------------------------------------------------------
+
+run: all
+       cd .. && ./$(PROGBASE) --verbose
+
+gdb: all
+       cd .. && gdb -batch -x GDB_COMMANDS ./$(PROGBASE)
+
+valgrind: all
+       cd .. && valgrind -v --leak-check=yes ./$(PROGBASE) 2> valgrind.out
+
+
 # -----------------------------------------------------------------------------
 # development only
 # -----------------------------------------------------------------------------
@@ -287,11 +344,12 @@ clean: clean-obj clean-ico clean-bin
 dist-clean: clean-obj
 
 tags:
-       $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch]
+       $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] $(GAME_SP_DIR)/*.[ch]
 
 depend:
        $(MAKE) -C $(LIBGAME_DIR) depend
        $(MAKE) -C $(GAME_EM_DIR) depend
+       $(MAKE) -C $(GAME_SP_DIR) depend
        for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
 
 ifeq (.depend,$(wildcard .depend))