darkplaces-dedicated.exe now builds
[xonotic/darkplaces.git] / makefile
index 92b73af..c6ffbf3 100644 (file)
--- a/makefile
+++ b/makefile
-#uncomment one of these according to your sound driver
-#if you use ALSA version 0.9.x
-#SND=snd_alsa_0_9.o
+##### Variables that you may want to modify #####
+
+#choose the compiler you want to use
+CC=gcc
+
+#recommended for: anyone not using ALSA 0.5
+OBJ_SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o
+SOUNDLIB=
+#recommended for: anyone using ALSA 0.5
+#OBJ_SND=snd_alsa_0_5.o snd_dma.o snd_mix.o snd_mem.o
+#SOUNDLIB=-lasound
+#recommended for: no one (this driver needs to be updated, it doesn't compile anymore)
+#OBJ_SND=snd_alsa_0_9.o snd_dma.o snd_mix.o snd_mem.o
 #SOUNDLIB=-lasound
-#if you use ALSA version 0.5.x
-SND=snd_alsa_0_5.o
-SOUNDLIB=-lasound
-#if you use the kernel sound driver or OSS
-#SND=snd_oss.o
+#recommended for: anyone who can't use the above drivers
+#OBJ_SND=snd_null.o
 #SOUNDLIB=
 
-OBJECTS= builddate.o cd_linux.o chase.o cl_demo.o cl_input.o cl_main.o cl_parse.o cl_tent.o cmd.o common.o console.o crc.o cvar.o fractalnoise.o gl_draw.o r_sky.o gl_rmain.o gl_rsurf.o gl_screen.o host.o host_cmd.o image.o keys.o mathlib.o menu.o model_alias.o model_brush.o model_shared.o model_sprite.o net_bsd.o net_udp.o net_dgrm.o net_loop.o net_main.o pr_cmds.o pr_edict.o pr_exec.o r_light.o r_particles.o r_explosion.o sbar.o snd_dma.o snd_mem.o snd_mix.o $(SND) sv_main.o sv_move.o sv_phys.o sv_user.o sv_light.o sys_linux.o transform.o view.o wad.o world.o zone.o vid_shared.o palette.o r_crosshairs.o gl_textures.o gl_models.o r_sprites.o r_modules.o r_explosion.o r_lerpanim.o r_decals.o protocol.o quakeio.o r_clip.o ui.o portals.o sys_shared.o cl_light.o gl_backend.o cl_particles.o cl_decals.o cl_screen.o cgamevm.o cgame.o
+#if you want CD sound in Linux
+OBJ_CD=cd_linux.o
+#if you want no CD audio
+#OBJ_CD=cd_null.o
 
 #K6/athlon optimizations
-CPUOPTIMIZATIONS=-march=k6
+#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 #####
+
+# Objects
+CLIENTOBJECTS= cgame.o cgamevm.o chase.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_modules.o r_sky.o \
+               r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
+               r_shadow.o
+SERVEROBJECTS= pr_cmds.o pr_edict.o pr_exec.o sv_light.o sv_main.o sv_move.o \
+               sv_phys.o sv_user.o
+SHAREDOBJECTS= builddate.o 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 \
+               net_bsd.o net_dgrm.o net_loop.o net_main.o net_master.o \
+               net_udp.o palette.o portals.o protocol.o fs.o \
+               sys_shared.o world.o wad.o zone.o
+COMMONOBJECTS= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
+
+# objects used by glx target
+OBJ_GLX= sys_linux.o vid_glx.o $(OBJ_CD) $(OBJ_SND) $(COMMONOBJECTS)
+# objects used by dedicated target
+OBJ_DED= sys_linux.o vid_null.o cd_null.o snd_null.o $(COMMONOBJECTS)
+
+
+# Compilation
+CFLAGS_COMMON=-MD -Wall -Werror
+CFLAGS_DEBUG=-ggdb
+CFLAGS_PROFILE=-g -pg -ggdb
+CFLAGS_RELEASE=
+
+OPTIM_DEBUG=
+OPTIM_RELEASE= -O9 -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_COMMON=-ldl -lm
+LDFLAGS_DEBUG=-g -ggdb
+LDFLAGS_PROFILE=-g -pg
+LDFLAGS_RELEASE=
+
+EXE_GLX=darkplaces-glx
+EXE_DED=darkplaces-dedicated
+
+GLX_LIB=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB)
+
+DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
+
 
-#use this line for profiling
-#PROFILEOPTION=-pg -g
-#NOPROFILEOPTIMIZATIONS=
-#use this line for no profiling
-#PROFILEOPTION=
-#NOPROFILEOPTIMIZATIONS=-fomit-frame-pointer
-#use these lines for debugging without profiling
-PROFILEOPTION=
-NOPROFILEOPTIMIZATIONS=
-
-#note:
-#the -Werror can be removed to compile even if there are warnings,
-#this is used to ensure that all released versions are free of warnings.
-
-#normal compile
-#OPTIMIZATIONS= -O6 -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -I/usr/include/glide $(OPTIMIZATIONS) $(PROFILEOPTION)
-#debug compile
-OPTIMIZATIONS=
-CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
-
-LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXIE -lXxf86dga -lXxf86vm -lGL -ldl $(SOUNDLIB) $(PROFILEOPTION)
-
-#if you don't need the -3dfx version, use this line
-all: builddate darkplaces-glx
-#all: builddate darkplaces-glx darkplaces-3dfx
+##### 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 binary (debug version)"
+       @echo "* $(MAKE) glx-profile : make GLX binary (profile version)"
+       @echo "* $(MAKE) glx-release : make GLX binary (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)"
+
+glx-profile :
+       $(MAKE) bin-profile EXE="$(EXE_GLX)"
+
+glx-release :
+       $(MAKE) bin-release EXE="$(EXE_GLX)"
+
+ded-debug :
+       $(MAKE) bin-debug EXE="$(EXE_DED)"
+
+ded-profile :
+       $(MAKE) bin-profile EXE="$(EXE_DED)"
+
+ded-release :
+       $(MAKE) bin-release EXE="$(EXE_DED)"
+
+bin-debug :
+       @echo
+       @echo "========== $(EXE) (debug) =========="
+       $(MAKE) builddate
+       $(MAKE) $(EXE) \
+               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
+               LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
+
+bin-profile :
+       @echo
+       @echo "========== $(EXE) (profile) =========="
+       $(MAKE) builddate
+       $(MAKE) $(EXE) \
+               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
+               LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
+
+bin-release :
+       @echo
+       @echo "========== $(EXE) (release) =========="
+       $(MAKE) builddate
+       $(MAKE) $(EXE) \
+               CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
+               LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
+       strip $(EXE)
 
 builddate:
        touch builddate.c
 
-.c.o:
-       gcc $(CFLAGS) -c $*.c
+vid_glx.o: vid_glx.c
+       $(DO_CC) -I/usr/X11R6/include
 
-darkplaces-glx: $(OBJECTS) vid_glx.o
-       gcc -o $@ $^ $(LDFLAGS)
+.c.o:
+       $(DO_CC)
 
-darkplaces-3dfx: $(OBJECTS) in_svgalib.o vid_3dfxsvga.o
-       gcc -o $@ $^ $(LDFLAGS)
+$(EXE_GLX):  $(OBJ_GLX)
+       $(DO_LD) $(GLX_LIB)
 
+$(EXE_DED): $(OBJ_DED)
+       $(DO_LD)
 
 clean:
-       -rm -f darkplaces-glx darkplaces-3dfx vid_glx.o in_svgalib.o vid_3dfxsvga.o $(OBJECTS) *.d
-
-.PHONY: clean builddate
+       rm -f $(EXE_GLX) $(EXE_DED) *.o *.d
 
 -include *.d