-##### Variables that you may want to modify #####
+##### DP_MAKE_TARGET autodetection and arch specific variables #####
-#choose the compiler you want to use
-CC=gcc
+ifndef DP_MAKE_TARGET
-#recommended for: anyone not using ALSA 0.5
-OBJ_LINUXSOUND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o ogg.o
-LINUXSOUNDLIB=
-#recommended for: anyone using ALSA 0.5
-#OBJ_LINUXSOUND=snd_alsa_0_5.o snd_dma.o snd_mix.o snd_mem.o ogg.o
-#LINUXSOUNDLIB=-lasound
-#recommended for: no one (this driver needs to be updated, it doesn't compile anymore)
-#OBJ_LINUXSOUND=snd_alsa_0_9.o snd_dma.o snd_mix.o snd_mem.o ogg.o
-#LINUXSOUNDLIB=-lasound
-#recommended for: anyone who can't use the above drivers
-#OBJ_LINUXSOUND=snd_null.o
-#LINUXSOUNDLIB=
+# Win32
+ifdef windir
+ DP_MAKE_TARGET=mingw
+else
-#if you want CD sound in Linux
-OBJ_LINUXCD=cd_shared.o cd_linux.o
-#if you want no CD audio
-#OBJ_LINUXCD=cd_null.o
+# UNIXes
+DP_ARCH:=$(shell uname)
+ifeq ($(DP_ARCH),NetBSD)
+ DP_MAKE_TARGET=bsd
+else
+ DP_MAKE_TARGET=linux
+endif
-#K6/athlon optimizations
-#CPUOPTIMIZATIONS=-march=k6
-#note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
-#have optimizer bugs (like entities disappearing randomly - a bug with
-#compiling BOX_ON_PLANE_SIDE in mathlib.h)
-#CPUOPTIMIZATIONS=-march=athlon
-#686 optimizations
-#CPUOPTIMIZATIONS=-march=i686
-#no specific CPU
-CPUOPTIMIZATIONS=
+endif
+endif
-##### Variables that you shouldn't care about #####
+# Command used to delete files
ifdef windir
-CMD_RM=del
+ CMD_RM=del
else
-CMD_RM=rm -f
+ CMD_RM=$(CMD_UNIXRM)
endif
-# Objects
-CLIENTOBJECTS= cgame.o cgamevm.o cl_collision.o cl_demo.o cl_input.o \
- cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_video.o \
- console.o dpvsimpledecode.o fractalnoise.o gl_backend.o \
- gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o \
- jpeg.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o \
- r_lerpanim.o r_light.o r_lightning.o r_modules.o r_sky.o \
- r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
- r_shadow.o prvm_exec.o prvm_edict.o prvm_cmds.o
-SERVEROBJECTS= pr_cmds.o pr_edict.o pr_exec.o sv_main.o sv_move.o \
- sv_phys.o sv_user.o
-SHAREDOBJECTS= cmd.o collision.o common.o crc.o cvar.o \
- filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o \
- model_alias.o model_brush.o model_shared.o model_sprite.o \
- netconn.o lhnet.o palette.o portals.o protocol.o fs.o \
- sys_shared.o winding.o world.o wad.o zone.o curves.o
-COMMONOBJECTS= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
-
-# note that builddate.c is very intentionally not compiled to a .o before
-# being linked, because it should be recompiled every time an executable is
-# built to give the executable a proper date string
-OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_LINUXCD) $(OBJ_LINUXSOUND) $(COMMONOBJECTS)
-OBJ_DED= builddate.c sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
-OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o cd_null.o snd_null.o $(COMMONOBJECTS)
-OBJ_WGL_EXE= builddate.c sys_win.o vid_wgl.o conproc.o cd_shared.o cd_win.o snd_win.o snd_dma.o snd_mix.o snd_mem.o ogg.o $(COMMONOBJECTS)
-OBJ_DED_EXE= builddate.c sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
-
-
-# Compilation
-# CFLAGS_NONEXECOMMON=-MD -Wall -Werror
-CFLAGS_NONEXECOMMON=-MD -Wall
-CFLAGS_EXECOMMON=-MD -Wall
-CFLAGS_DEBUG=-ggdb
-CFLAGS_PROFILE=-g -pg -ggdb
-CFLAGS_RELEASE=
-
-OPTIM_DEBUG=
-OPTIM_RELEASE= -O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-
-DO_CC=$(CC) $(CFLAGS) -c $< -o $@
-
-
-# Link
-# LordHavoc note: I have been informed that system libraries must come last
-# on the linker line, and that -lm must always be last
-LDFLAGS_GLX=-ldl -lm
-LDFLAGS_DED=-ldl -lm
-LDFLAGS_SDL=-ldl -lm
-LDFLAGS_WGL_EXE=-mwindows -lwinmm -lwsock32 -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
-LDFLAGS_DED_EXE=-mconsole -lwinmm -lwsock32
-LDFLAGS_DEBUG=-g -ggdb
-LDFLAGS_PROFILE=-g -pg
-LDFLAGS_RELEASE=
-
-EXE_GLX=darkplaces-glx
-EXE_DED=darkplaces-dedicated
-EXE_SDL=darkplaces-sdl
-EXE_WGL_EXE=darkplaces.exe
-EXE_DED_EXE=darkplaces-dedicated.exe
-
-DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
-
-
-##### Commands #####
-
-.PHONY : clean help \
- debug profile release \
- glx-debug glx-profile glx-release \
- ded-debug ded-profile ded-release \
- exedebug exeprofile exerelease \
- exewgl-debug exewgl-profile exewgl-release \
- exeded-debug exeded-profile exeded-release \
-
-help:
- @echo
- @echo "===== Choose one ====="
- @echo "* $(MAKE) clean : delete the binaries, and .o and .d files"
- @echo "* $(MAKE) help : this help"
- @echo "* $(MAKE) debug : make GLX and dedicated binaries (debug versions)"
- @echo "* $(MAKE) profile : make GLX and dedicated binaries (profile versions)"
- @echo "* $(MAKE) release : make GLX and dedicated binaries (release versions)"
- @echo "* $(MAKE) glx-debug : make GLX client (debug version)"
- @echo "* $(MAKE) glx-profile : make GLX client (profile version)"
- @echo "* $(MAKE) glx-release : make GLX client (release version)"
- @echo "* $(MAKE) ded-debug : make dedicated server (debug version)"
- @echo "* $(MAKE) ded-profile : make dedicated server (profile version)"
- @echo "* $(MAKE) ded-release : make dedicated server (release version)"
- @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
- @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
- @echo "* $(MAKE) sdl-release : make SDL client (release version)"
- @echo "* $(MAKE) exedebug : make WGL and dedicated binaries (debug versions)"
- @echo "* $(MAKE) exeprofile : make WGL and dedicated binaries (profile versions)"
- @echo "* $(MAKE) exerelease : make WGL and dedicated binaries (release versions)"
- @echo "* $(MAKE) exewgl-debug : make WGL client (debug version)"
- @echo "* $(MAKE) exewgl-profile : make WGL client (profile version)"
- @echo "* $(MAKE) exewgl-release : make WGL client (release version)"
- @echo "* $(MAKE) exeded-debug : make dedicated server (debug version)"
- @echo "* $(MAKE) exeded-profile : make dedicated server (profile version)"
- @echo "* $(MAKE) exeded-release : make dedicated server (release version)"
- @echo
-debug :
- $(MAKE) glx-debug ded-debug
+# Linux configuration
+ifeq ($(DP_MAKE_TARGET), linux)
+ OBJ_SOUND=$(OBJ_LINUXSOUND)
+ LIB_SOUND=$(LIB_LINUXSOUND)
+ OBJ_CD=$(OBJ_LINUXCD)
-profile :
- $(MAKE) glx-profile ded-profile
+ OBJ_CL=$(OBJ_GLX)
-release :
- $(MAKE) glx-release ded-release
+ LDFLAGS_CL=$(LDFLAGS_LINUXCL)
+ LDFLAGS_SV=$(LDFLAGS_LINUXSV)
+ LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
-exedebug :
- $(MAKE) wglexe-debug dedexe-debug
-
-exeprofile :
- $(MAKE) wglexe-profile dedexe-profile
-
-exerelease :
- $(MAKE) wglexe-release dedexe-release
-
-glx-debug :
- $(MAKE) bin-debug EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-glx-profile :
- $(MAKE) bin-profile EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-glx-release :
- $(MAKE) bin-release EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-debug :
- $(MAKE) bin-debug EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-profile :
- $(MAKE) bin-profile EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-release :
- $(MAKE) bin-release EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-sdl-debug :
- $(MAKE) bin-debug EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-sdl-profile :
- $(MAKE) bin-profile EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-sdl-release :
- $(MAKE) bin-release EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-wglexe-debug :
- $(MAKE) bin-debug EXE="$(EXE_WGL_EXE)" LDFLAGS_COMMON="$(LDFLAGS_WGL_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
-
-wglexe-profile :
- $(MAKE) bin-profile EXE="$(EXE_WGL_EXE)" LDFLAGS_COMMON="$(LDFLAGS_WGL_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
-
-wglexe-release :
- $(MAKE) bin-release EXE="$(EXE_WGL_EXE)" LDFLAGS_COMMON="$(LDFLAGS_WGL_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
-
-dedexe-debug :
- $(MAKE) bin-debug EXE="$(EXE_DED_EXE)" LDFLAGS_COMMON="$(LDFLAGS_DED_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
-
-dedexe-profile :
- $(MAKE) bin-profile EXE="$(EXE_DED_EXE)" LDFLAGS_COMMON="$(LDFLAGS_DED_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
+ EXE_CL=$(EXE_UNIXCL)
+ EXE_SV=$(EXE_UNIXSV)
+ EXE_SDL=$(EXE_UNIXSDL)
+endif
-dedexe-release :
- $(MAKE) bin-release EXE="$(EXE_DED_EXE)" LDFLAGS_COMMON="$(LDFLAGS_DED_EXE)" CFLAGS_COMMON="$(CFLAGS_EXECOMMON)"
+# BSD configuration
+ifeq ($(DP_MAKE_TARGET), bsd)
+ OBJ_SOUND=$(OBJ_BSDSOUND)
+ LIB_SOUND=$(LIB_BSDSOUND)
+ OBJ_CD=$(OBJ_BSDCD)
-bin-debug :
- @echo
- @echo "========== $(EXE) (debug) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
- LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
+ OBJ_CL=$(OBJ_GLX)
-bin-profile :
- @echo
- @echo "========== $(EXE) (profile) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
- LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
+ LDFLAGS_CL=$(LDFLAGS_BSDCL)
+ LDFLAGS_SV=$(LDFLAGS_BSDSV)
+ LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
-bin-release :
- @echo
- @echo "========== $(EXE) (release) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
- LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
- strip $(EXE)
+ EXE_CL=$(EXE_UNIXCL)
+ EXE_SV=$(EXE_UNIXSV)
+ EXE_SDL=$(EXE_UNIXSDL)
+endif
-vid_glx.o: vid_glx.c
- $(DO_CC) -I/usr/X11R6/include
+# Win32 configuration
+ifeq ($(DP_MAKE_TARGET), mingw)
+ OBJ_SOUND=$(OBJ_WINSOUND)
+ LIB_SOUND=$(LIB_WINSOUND)
+ OBJ_CD=$(OBJ_WINCD)
-vid_sdl.o: vid_sdl.c
- $(DO_CC) `sdl-config --cflags`
+ OBJ_CL=$(OBJ_WGL)
-sys_sdl.o: sys_sdl.c
- $(DO_CC) `sdl-config --cflags`
+ LDFLAGS_CL=$(LDFLAGS_WINCL)
+ LDFLAGS_SV=$(LDFLAGS_WINSV)
+ LDFLAGS_SDL=$(LDFLAGS_WINSDL)
-.c.o:
- $(DO_CC)
+ EXE_CL=$(EXE_WINCL)
+ EXE_SV=$(EXE_WINSV)
+ EXE_SDL=$(EXE_WINSDL)
+endif
-$(EXE_SDL): $(OBJ_SDL)
- $(DO_LD) `sdl-config --libs`
-$(EXE_GLX): $(OBJ_GLX)
- $(DO_LD) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LINUXSOUNDLIB)
+##### GNU Make specific definitions #####
-$(EXE_DED): $(OBJ_DED)
- $(DO_LD)
+DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
-$(EXE_WGL_EXE): $(OBJ_WGL_EXE)
- $(DO_LD)
-$(EXE_DED_EXE): $(OBJ_DED_EXE)
- $(DO_LD)
+##### Definitions shared by all makefiles #####
+include makefile.inc
-clean:
- -$(CMD_RM) $(EXE_GLX)
- -$(CMD_RM) $(EXE_DED)
- -$(CMD_RM) $(EXE_WGL_EXE)
- -$(CMD_RM) $(EXE_DED_EXE)
- -$(CMD_RM) *.o
- -$(CMD_RM) *.d
+##### Dependency files #####
-include *.d
-
-##### Variables that you may want to modify #####
+##### DP_MAKE_TARGET autodetection and arch specific variables #####
-#choose the compiler you want to use
-CC=gcc
+.ifndef DP_MAKE_TARGET
-MAKE:=$(MAKE) -f makefile.bsd
+DP_MAKE_TARGET=bsd
+
+.endif
+
+
+# Command used to delete files
+CMD_RM=$(CMD_UNIXRM)
+
+
+# BSD configuration
+.if $(DP_MAKE_TARGET) == "bsd"
+
+OBJ_SOUND=$(OBJ_BSDSOUND)
+LIB_SOUND=$(LIB_BSDSOUND)
+OBJ_CD=$(OBJ_BSDCD)
-OBJ_BSDSOUND=snd_bsd.o snd_dma.o snd_mix.o snd_mem.o ogg.o
-#OBJ_BSDSOUND=snd_null.o
-BSDSOUNDLIB=
-
-#if you want CD sound in BSD
-OBJ_BSDCD=cd_shared.o cd_bsd.o
-#if you want no CD audio
-#OBJ_BSDCD=cd_null.o
-
-#K6/athlon optimizations
-#CPUOPTIMIZATIONS=-march=k6
-#note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
-#have optimizer bugs (like entities disappearing randomly - a bug with
-#compiling BOX_ON_PLANE_SIDE in mathlib.h)
-#CPUOPTIMIZATIONS=-march=athlon
-#686 optimizations
-#CPUOPTIMIZATIONS=-march=i686
-#no specific CPU
-CPUOPTIMIZATIONS=
-
-
-##### Variables that you shouldn't care about #####
-
-CMD_RM=rm -f
-
-# Objects
-CLIENTOBJECTS= cgame.o cgamevm.o cl_collision.o cl_demo.o cl_input.o \
- cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_video.o \
- console.o dpvsimpledecode.o fractalnoise.o gl_backend.o \
- gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o \
- jpeg.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o \
- r_lerpanim.o r_light.o r_lightning.o r_modules.o r_sky.o \
- r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
- r_shadow.o prvm_exec.o prvm_edict.o prvm_cmds.o
-SERVEROBJECTS= pr_cmds.o pr_edict.o pr_exec.o sv_main.o sv_move.o \
- sv_phys.o sv_user.o
-SHAREDOBJECTS= cmd.o collision.o common.o crc.o cvar.o \
- filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o \
- model_alias.o model_brush.o model_shared.o model_sprite.o \
- netconn.o lhnet.o palette.o portals.o protocol.o fs.o \
- sys_shared.o winding.o world.o wad.o zone.o curves.o
-COMMONOBJECTS= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
-
-# note that builddate.c is very intentionally not compiled to a .o before
-# being linked, because it should be recompiled every time an executable is
-# built to give the executable a proper date string
-OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_BSDCD) $(OBJ_BSDSOUND) $(COMMONOBJECTS)
-OBJ_DED= builddate.c sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
-
-
-# Compilation
-# CFLAGS_NONEXECOMMON=-MD -Wall -Werror
-CFLAGS_NONEXECOMMON=-MD -Wall
-CFLAGS_DEBUG=-ggdb
-CFLAGS_PROFILE=-g -pg -ggdb
-CFLAGS_RELEASE=
-
-OPTIM_DEBUG=
-OPTIM_RELEASE= -O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-
-DO_CC=$(CC) $(CFLAGS) -c $< -o $@
-
-
-# Link
-# LordHavoc note: I have been informed that system libraries must come last
-# on the linker line, and that -lm must always be last
-LDFLAGS_GLX=-lm -lutil
-LDFLAGS_DED=-lm
-LDFLAGS_DEBUG=-g -ggdb
-LDFLAGS_PROFILE=-g -pg
-LDFLAGS_RELEASE=
-
-EXE_GLX=darkplaces-glx
-EXE_DED=darkplaces-dedicated
+OBJ_CL=$(OBJ_GLX)
+
+LDFLAGS_CL=$(LDFLAGS_BSDCL)
+LDFLAGS_SV=$(LDFLAGS_BSDSV)
+
+EXE_CL=$(EXE_UNIXCL)
+EXE_SV=$(EXE_UNIXSV)
+EXE_SDL=$(EXE_UNIXSDL)
+
+.endif
+
+
+##### BSD Make specific definitions #####
+
+MAKE:=$(MAKE) -f makefile.bsd
DO_LD=$(CC) -o $@ $> $(LDFLAGS)
-##### Commands #####
-
-.PHONY : clean help \
- debug profile release \
- glx-debug glx-profile glx-release \
- ded-debug ded-profile ded-release
-
-help:
- @echo
- @echo "===== Choose one ====="
- @echo "* $(MAKE) clean : delete the binaries, and .o and .d files"
- @echo "* $(MAKE) help : this help"
- @echo "* $(MAKE) debug : make GLX and dedicated binaries (debug versions)"
- @echo "* $(MAKE) profile : make GLX and dedicated binaries (profile versions)"
- @echo "* $(MAKE) release : make GLX and dedicated binaries (release versions)"
- @echo "* $(MAKE) glx-debug : make GLX client (debug version)"
- @echo "* $(MAKE) glx-profile : make GLX client (profile version)"
- @echo "* $(MAKE) glx-release : make GLX client (release version)"
- @echo "* $(MAKE) ded-debug : make dedicated server (debug version)"
- @echo "* $(MAKE) ded-profile : make dedicated server (profile version)"
- @echo "* $(MAKE) ded-release : make dedicated server (release version)"
- @echo
-
-debug :
- $(MAKE) glx-debug ded-debug
-
-profile :
- $(MAKE) glx-profile ded-profile
-
-release :
- $(MAKE) glx-release ded-release
-
-glx-debug :
- $(MAKE) bin-debug EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-glx-profile :
- $(MAKE) bin-profile EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-glx-release :
- $(MAKE) bin-release EXE="$(EXE_GLX)" LDFLAGS_COMMON="$(LDFLAGS_GLX)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-debug :
- $(MAKE) bin-debug EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-profile :
- $(MAKE) bin-profile EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-ded-release :
- $(MAKE) bin-release EXE="$(EXE_DED)" LDFLAGS_COMMON="$(LDFLAGS_DED)" CFLAGS_COMMON="$(CFLAGS_NONEXECOMMON)"
-
-bin-debug :
- @echo
- @echo "========== $(EXE) (debug) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
- LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
-
-bin-profile :
- @echo
- @echo "========== $(EXE) (profile) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
- LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
-
-bin-release :
- @echo
- @echo "========== $(EXE) (release) =========="
- $(MAKE) $(EXE) \
- CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
- LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
- strip $(EXE)
-
-vid_glx.o: vid_glx.c
- $(DO_CC) -I/usr/X11R6/include
-
-.c.o:
- $(DO_CC)
-
-$(EXE_GLX): $(OBJ_GLX)
- $(DO_LD) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LINUXSOUNDLIB)
-
-$(EXE_DED): $(OBJ_DED)
- $(DO_LD)
-
-clean:
- -$(CMD_RM) $(EXE_GLX)
- -$(CMD_RM) $(EXE_DED)
- -$(CMD_RM) *.o
- -$(CMD_RM) *.d
+##### Definitions shared by all makefiles #####
+.include "makefile.inc"
##### Dependency files #####
--- /dev/null
+##### Variables that you may want to modify #####
+
+# Choose the compiler you want to use
+CC=gcc
+
+# K6/athlon optimizations
+#CPUOPTIMIZATIONS=-march=k6
+# Note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
+# have optimizer bugs (like entities disappearing randomly - a bug with
+# compiling BOX_ON_PLANE_SIDE in mathlib.h)
+#CPUOPTIMIZATIONS=-march=athlon
+# 686 optimizations
+#CPUOPTIMIZATIONS=-march=i686
+# No specific CPU
+CPUOPTIMIZATIONS=
+
+
+##### Variables that you shouldn't care about #####
+
+# Sound objects
+OBJ_COMMONSOUND=ogg.o snd_dma.o snd_mem.o snd_mix.o
+OBJ_NOSOUND=snd_null.o
+
+# CD objects
+OBJ_COMMONCD=cd_shared.o
+OBJ_NOCD=cd_null.o
+
+# Common objects
+OBJ_COMMON= \
+ cgame.o \
+ cgamevm.o \
+ cl_collision.o \
+ cl_demo.o \
+ cl_input.o \
+ cl_main.o \
+ cl_parse.o \
+ cl_particles.o \
+ cl_screen.o \
+ cl_video.o \
+ cmd.o \
+ collision.o \
+ common.o \
+ console.o \
+ crc.o \
+ curves.o \
+ cvar.o \
+ dpvsimpledecode.o \
+ filematch.o \
+ fractalnoise.o \
+ fs.o \
+ gl_backend.o \
+ gl_draw.o \
+ gl_models.o \
+ gl_rmain.o \
+ gl_rsurf.o \
+ gl_textures.o \
+ host.o \
+ host_cmd.o \
+ image.o \
+ jpeg.o \
+ keys.o \
+ lhnet.o \
+ mathlib.o \
+ matrixlib.o \
+ menu.o \
+ meshqueue.o \
+ model_alias.o \
+ model_brush.o \
+ model_shared.o \
+ model_sprite.o \
+ netconn.o \
+ palette.o \
+ portals.o \
+ pr_cmds.o \
+ pr_edict.o \
+ pr_exec.o \
+ protocol.o \
+ prvm_cmds.o \
+ prvm_edict.o \
+ prvm_exec.o \
+ r_crosshairs.o \
+ r_explosion.o \
+ r_lerpanim.o \
+ r_light.o \
+ r_lightning.o \
+ r_modules.o \
+ r_shadow.o \
+ r_sky.o \
+ r_sprites.o \
+ sbar.o \
+ sv_main.o \
+ sv_move.o \
+ sv_phys.o \
+ sv_user.o \
+ sys_shared.o \
+ ui.o \
+ vid_shared.o \
+ view.o \
+ wad.o \
+ wavefile.o \
+ winding.o \
+ world.o \
+ zone.o
+
+# note that builddate.c is very intentionally not compiled to a .o before
+# being linked, because it should be recompiled every time an executable is
+# built to give the executable a proper date string
+OBJ_SV= builddate.c sys_linux.o vid_null.o $(OBJ_NOSOUND) $(OBJ_NOCD) $(OBJ_COMMON)
+OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_NOSOUND) $(OBJ_NOCD) $(OBJ_COMMON)
+
+
+# Compilation
+# CFLAGS_COMMON=-MD -Wall -Werror
+CFLAGS_COMMON=-MD -Wall
+CFLAGS_DEBUG=-ggdb
+CFLAGS_PROFILE=-g -pg -ggdb
+CFLAGS_RELEASE=
+
+OPTIM_DEBUG=
+OPTIM_RELEASE=-O2 -fno-strict-aliasing -ffast-math -fexpensive-optimizations $(CPUOPTIMIZATIONS)
+
+DO_CC=$(CC) $(CFLAGS) -c $< -o $@
+
+
+# Link
+LDFLAGS_DEBUG=-g -ggdb
+LDFLAGS_PROFILE=-g -pg
+LDFLAGS_RELEASE=
+
+
+##### UNIX specific variables #####
+
+OBJ_GLX= builddate.c sys_linux.o vid_glx.o $(OBJ_SOUND) $(OBJ_CD) $(OBJ_COMMON)
+
+LDFLAGS_UNIXCOMMON=-lm
+LDFLAGS_UNIXCL=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(LIB_SOUND)
+LDFLAGS_UNIXSDL=`sdl-config --libs`
+EXE_UNIXCL=darkplaces-glx
+EXE_UNIXSV=darkplaces-dedicated
+EXE_UNIXSDL=darkplaces-sdl
+
+CMD_UNIXRM=rm -rf
+
+
+##### Linux specific variables #####
+
+# Recommended for: anyone not using ALSA 0.5
+OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_oss.o
+LIB_LINUXSOUND=
+# Recommended for: anyone using ALSA 0.5
+#OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_alsa_0_5.o
+#LIB_LINUXSOUND=-lasound
+# Recommended for: no one (this driver needs to be updated, it doesn't compile anymore)
+#OBJ_LINUXSOUND=$(OBJ_COMMONSOUND) snd_alsa_0_9.o
+#LIB_LINUXSOUND=-lasound
+# Recommended for: anyone who can't use the above drivers
+#OBJ_LINUXSOUND=$(OBJ_NOSOUND)
+#LIB_LINUXSOUND=
+
+# If you want CD sound in Linux
+OBJ_LINUXCD=$(OBJ_COMMONCD) cd_linux.o
+# If you want no CD audio
+#OBJ_LINUXCD=$(OBJ_NOCD)
+
+# Link
+LDFLAGS_LINUXCL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXCL)
+LDFLAGS_LINUXSV=$(LDFLAGS_UNIXCOMMON) -ldl
+LDFLAGS_LINUXSDL=$(LDFLAGS_UNIXCOMMON) -ldl $(LDFLAGS_UNIXSDL)
+
+
+##### BSD specific variables #####
+
+OBJ_BSDSOUND=$(OBJ_COMMONSOUND) snd_bsd.o
+#OBJ_BSDSOUND=$(OBJ_NOSOUND)
+LIB_BSDSOUND=
+
+#if you want CD sound in BSD
+OBJ_BSDCD=$(OBJ_COMMONCD) cd_bsd.o
+#if you want no CD audio
+#OBJ_BSDCD=$(OBJ_NOCD)
+
+# Link
+LDFLAGS_BSDCL=$(LDFLAGS_UNIXCOMMON) -lutil $(LDFLAGS_UNIXCL)
+LDFLAGS_BSDSV=$(LDFLAGS_UNIXCOMMON)
+LDFLAGS_BSDSDL=$(LDFLAGS_UNIXCOMMON) $(LDFLAGS_UNIXSDL)
+
+
+##### Win32 specific variables #####
+
+OBJ_WINSOUND=$(OBJ_COMMONSOUND) snd_win.o
+#OBJ_WINSOUND=$(OBJ_NOSOUND)
+LIB_WINSOUND=
+
+#if you want CD sound in Win32
+OBJ_WINCD=$(OBJ_COMMONCD) cd_win.o
+#if you want no CD audio
+#OBJ_WINCD=$(OBJ_NOCD)
+
+OBJ_WGL= builddate.c sys_win.o vid_wgl.o conproc.o $(OBJ_WINSOUND) $(OBJ_WINCD) $(OBJ_COMMON)
+
+# Link
+LDFLAGS_WINCOMMON=-lwinmm -lwsock32
+LDFLAGS_WINCL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
+LDFLAGS_WINSV=$(LDFLAGS_WINCOMMON) -mconsole -lwinmm -lwsock32
+LDFLAGS_WINSDL=$(LDFLAGS_WINCOMMON) -mwindows -luser32 -lgdi32 -ldxguid -ldinput -lcomctl32
+EXE_WINCL=darkplaces.exe
+EXE_WINSV=darkplaces-dedicated.exe
+EXE_WINSDL=darkplaces-sdl.exe
+
+
+##### Commands #####
+
+.PHONY : clean help \
+ debug profile release \
+ cl-debug cl-profile cl-release \
+ sv-debug sv-profile sv-release \
+ sdl-debug sdl-profile sdl-release
+
+help:
+ @echo
+ @echo "===== Choose one ====="
+ @echo "* $(MAKE) clean : delete all files produced by the build"
+ @echo "* $(MAKE) help : this help"
+ @echo "* $(MAKE) debug : make client and server binaries (debug versions)"
+ @echo "* $(MAKE) profile : make client and server binaries (profile versions)"
+ @echo "* $(MAKE) release : make client and server binaries (release versions)"
+ @echo "* $(MAKE) cl-debug : make client (debug version)"
+ @echo "* $(MAKE) cl-profile : make client (profile version)"
+ @echo "* $(MAKE) cl-release : make client (release version)"
+ @echo "* $(MAKE) sv-debug : make dedicated server (debug version)"
+ @echo "* $(MAKE) sv-profile : make dedicated server (profile version)"
+ @echo "* $(MAKE) sv-release : make dedicated server (release version)"
+ @echo "* $(MAKE) sdl-debug : make SDL client (debug version)"
+ @echo "* $(MAKE) sdl-profile : make SDL client (profile version)"
+ @echo "* $(MAKE) sdl-release : make SDL client (release version)"
+ @echo
+
+debug :
+ $(MAKE) cl-debug sv-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET)
+
+profile :
+ $(MAKE) cl-profile sv-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET)
+
+release :
+ $(MAKE) cl-release sv-release DP_MAKE_TARGET=$(DP_MAKE_TARGET)
+
+cl-debug :
+ $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
+
+cl-profile :
+ $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
+
+cl-release :
+ $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_CL)" LDFLAGS_COMMON="$(LDFLAGS_CL)"
+
+sv-debug :
+ $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
+
+sv-profile :
+ $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
+
+sv-release :
+ $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SV)" LDFLAGS_COMMON="$(LDFLAGS_SV)"
+
+sdl-debug :
+ $(MAKE) bin-debug DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
+
+sdl-profile :
+ $(MAKE) bin-profile DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
+
+sdl-release :
+ $(MAKE) bin-release DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ EXE="$(EXE_SDL)" LDFLAGS_COMMON="$(LDFLAGS_SDL)"
+
+bin-debug :
+ @echo
+ @echo "========== $(EXE) (debug) =========="
+ $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
+ LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
+
+bin-profile :
+ @echo
+ @echo "========== $(EXE) (profile) =========="
+ $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
+ LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
+
+bin-release :
+ @echo
+ @echo "========== $(EXE) (release) =========="
+ $(MAKE) $(EXE) DP_MAKE_TARGET=$(DP_MAKE_TARGET) \
+ CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
+ LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
+ strip $(EXE)
+
+vid_glx.o: vid_glx.c
+ $(DO_CC) -I/usr/X11R6/include
+
+vid_sdl.o: vid_sdl.c
+ $(DO_CC) `sdl-config --cflags`
+
+sys_sdl.o: sys_sdl.c
+ $(DO_CC) `sdl-config --cflags`
+
+.c.o:
+ $(DO_CC)
+
+$(EXE_CL): $(OBJ_CL)
+ $(DO_LD)
+
+$(EXE_SV): $(OBJ_SV)
+ $(DO_LD)
+
+$(EXE_SDL): $(OBJ_SDL)
+ $(DO_LD)
+
+clean:
+ -$(CMD_RM) $(EXE_CL)
+ -$(CMD_RM) $(EXE_SV)
+ -$(CMD_RM) $(EXE_SDL)
+ -$(CMD_RM) *.o
+ -$(CMD_RM) *.d