rnd-20001204-3-src
[rocksndiamonds.git] / src / Makefile
index a6ce59b487a6c77f8fd12c48c964f374be2445e5..18efb9d99ddb5aca2cc28450dfceba27afba9d21 100644 (file)
-#
-# Makefile fuer "Rocks'n'Diamonds -- McDuffin Strikes Back"
-#
+#=============================================================================#
+# Makefile for Rocks'n'Diamonds                                               #
+# (c) 1995-2000 Holger Schemel, info@artsoft.org                              #
+#=============================================================================#
+
+.EXPORT_ALL_VARIABLES:
+
+ifndef PLATFORM                        # platform not specified -- try auto detection
+ifdef COMSPEC
+PLATFORM = msdos
+else
+PLATFORM = unix
+endif
+endif
+
+ifdef X11_PATH                 # path to X11 specified by top level Makefile
+XINC_PATH = $(X11_PATH)/include
+XLIB_PATH = $(X11_PATH)/lib
+X11_INCL = -I$(XINC_PATH)
+X11_LIBS = -L$(XLIB_PATH)
+endif
+
+AR = ar
+RANLIB = ranlib
+
+ifeq ($(PLATFORM),msdos)       # MS-DOS native compiling
+
+RM = del
+PROGNAME = ../rocks.exe
+
+SYS_CFLAGS = -DTARGET_X11
+SYS_LDFLAGS = -s -lalleg
 
-PROGNAME = rocksndiamonds
-SERVNAME = rnd_server
+else                           # Unix or cross-compiling for MS-DOS and Win32
 
 RM = rm -f
-CC = gcc
-CPP = $(CC) -E
-# CC = cc                              # for HP-UX and others
+PROGNAME = ../rocksndiamonds
+
+ifeq ($(PLATFORM),solaris)
+EXTRA_LDFLAGS = -lnsl -lsocket -R$(XLIB_PATH)
+PLATFORM = unix
+endif
+
+ifeq ($(PLATFORM),unix)
+PROFILING = -pg
+endif
+
+ifeq ($(PLATFORM),cross-msdos)
+PROGNAME = ../rocks.exe
+TARGET = allegro
+endif
+
+ifeq ($(PLATFORM),cross-win32)
+PROGNAME = ../rocksndiamonds.exe
+TARGET = sdl
+endif
+
+ifeq ($(TARGET),x11)
+SYS_CFLAGS  = -DTARGET_X11 $(X11_INCL)
+SYS_LDFLAGS = $(X11_LIBS) -lX11
+endif
 
-GAME_DIR = -DGAME_DIR=\".\"            # path of the game and its data
-# JOYSTICK = -DNO_JOYSTICK             # no joystick
-# SOUNDS = -DNO_SOUNDS                 # no sounds
-# SCORE_ENTRIES = -DONE_PER_NAME       # only one score entry per name
-SCORE_ENTRIES = -DMANY_PER_NAME                # many score entries per name
+ifeq ($(TARGET),sdl)
+SYS_CFLAGS  = -DTARGET_SDL $(shell sdl-config --cflags)
+SYS_LDFLAGS = -lSDL_image -lSDL_mixer $(shell sdl-config --libs)
+endif
 
-# The XPM-Library is no longer needed to build this program,
-# but is used to load graphics if XPM_INCLUDE_FILE is defined,
-# because the GIF loading routines are still a bit beta.
-# If you use the Xpm library, convert the GIF files to Xpm
-# files (and the mask files ('*Maske.gif') to xbm files).
+ifeq ($(TARGET),allegro)
+SYS_CFLAGS = -DTARGET_ALLEGRO -I$(CROSS_PATH_MSDOS)/include
+SYS_LDFLAGS = -lalleg
+endif
 
-# XPM_INCLUDE_FILE = -DXPM_INCLUDE_FILE="<X11/xpm.h>"
-# EXTRA_X11_LIBS = -lXpm
+endif                          # (PLATFORM != msdos)
 
-CONFIG = $(GAME_DIR) $(SOUNDS) $(JOYSTICK)     \
-        $(SCORE_ENTRIES) $(XPM_INCLUDE_FILE)
 
-# DEBUG = -DDEBUG -g -ansi -pedantic -Wall
-DEBUG = -DDEBUG -g -Wall
-# DEBUG = -O6
+ifdef RO_GAME_DIR              # path to read-only game data specified
+CONFIG_RO_GAME_DIR = -DRO_GAME_DIR="\"$(RO_GAME_DIR)\""
+endif
 
-# SYSTEM = -Aa -D_HPUX_SOURCE -Dhpux   # for HP-UX (obsolete)
-# SYSTEM = -DSYSV -Ae                  # for HP-UX
-# INCL = -I/usr/include/X11R5          # for HP-UX and others
-# INCL = -I/usr/local/X11/include      # for SunOS and others
-# LIBS = -L/usr/lib/X11R5 -lXpm -lX11 -lm
-#                                      # for HP-UX and others
-# LIBS = -L/usr/local/X11/lib -lXpm -lX11 -lm -lsocket -R/usr/local/X11/lib
-#                                      # for SunOS and others
+ifdef RW_GAME_DIR              # path to writable game data specified
+CONFIG_RW_GAME_DIR = -DRW_GAME_DIR="\"$(RW_GAME_DIR)\""
+endif
 
-# LIBS = -L/usr/X11R6/lib -lXpm -lX11 -lm
-# LIBS = -L/usr/X11R6/lib -lX11 -lm
+ifdef SCORE_ENTRIES            # number of score entries per player specified
+CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES)
+endif
 
-LIBS = -L/usr/X11R6/lib $(EXTRA_X11_LIBS) -lX11 -lm
+CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
+
+
+CONFIG = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(JOYSTICK)
+DEBUG = -DDEBUG -g
+
+OPTIONS = $(DEBUG) -Wall                       # only for debugging purposes
+# OPTIONS = $(DEBUG) -O3 -Wall                 # only for debugging purposes
+# OPTIONS = $(DEBUG) -Wall -ansi -pedantic     # only for debugging purposes
+# OPTIONS = -O3 -Wall -ansi -pedantic
+# OPTIONS = -O3 -Wall
+# OPTIONS = -O3
+# OPTIONS = -DSYSV -Ae                         # may be needed for HP-UX
+
+CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(CONFIG)
+LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm
 
-# CFLAGS = -O2 $(CONFIG) $(SYSTEM)
-CFLAGS = $(DEBUG) $(CONFIG) $(SYSTEM) $(INCL)
 
 SRCS = main.c          \
        init.c          \
        events.c        \
        tools.c         \
        screens.c       \
-       misc.c          \
        game.c          \
        editor.c        \
-       buttons.c       \
        files.c         \
        tape.c          \
-       sound.c         \
        joystick.c      \
        cartoons.c      \
-       random.c        \
-       gifload.c       \
-       gif.c           \
-       send.c          \
-       new.c           \
-       network.c
+       network.c       \
+       netserv.c
 
 OBJS = main.o          \
        init.o          \
        events.o        \
        tools.o         \
        screens.o       \
-       misc.o          \
        game.o          \
        editor.o        \
-       buttons.o       \
        files.o         \
        tape.o          \
-       sound.o         \
        joystick.o      \
        cartoons.o      \
-       random.o        \
-       gifload.o       \
-       gif.o           \
-       send.o          \
-       new.o           \
-       network.o
+       network.o       \
+       netserv.o
 
-all:   $(PROGNAME) $(SERVNAME)
+LIBDIR = libgame
+LIBGAME = $(LIBDIR)/libgame.a
 
-$(PROGNAME):   $(OBJS)
-       $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(PROGNAME)
 
-$(SERVNAME):   $(SERVNAME).c
-       $(CC) $(CFLAGS) $(SERVNAME).c $(LIBS) -o $(SERVNAME)
+all: $(PROGNAME)
+
+$(PROGNAME): $(LIBGAME) $(OBJS)
+       $(CC) $(PROFILING) $(OBJS) $(LIBGAME) $(LDFLAGS) -o $(PROGNAME)
+
+$(LIBGAME):
+       $(MAKE) -C $(LIBDIR)
 
 .c.o:
-       $(CC) $(CFLAGS) -c $*.c
+       $(CC) $(PROFILING) $(CFLAGS) -c $*.c
 
 clean:
-       $(RM) $(PROGNAME) $(SERVNAME) $(OBJS)
+       $(MAKE) -C $(LIBDIR) clean
+       $(RM) $(OBJS)
+       $(RM) $(LIBGAME)
+       $(RM) $(PROGNAME)
+       $(RM) ../*.exe
+
 
-backup:
-       ./make_backup.sh
+#-----------------------------------------------------------------------------#
+# development only stuff                                                      #
+#-----------------------------------------------------------------------------#
 
 depend:
+       $(MAKE) -C $(LIBDIR) depend
        for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend
 
 ifeq (.depend,$(wildcard .depend))