From 2b308c9a74460d52fa1ea81307164b500bad3c03 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 7 Oct 2002 18:43:12 +0000 Subject: [PATCH] Elric rewrote the makefile, it is quite self explanatory when run. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2515 d7cf8633-e32d-0410-b094-e92efae38249 --- makefile | 188 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 146 insertions(+), 42 deletions(-) diff --git a/makefile b/makefile index 4693c102..5c1bc588 100644 --- a/makefile +++ b/makefile @@ -1,32 +1,25 @@ -#choose the compiler you want here -CC=gcc +##### Variables that you may want to modify ##### -#uncomment these according to your sound driver +#choose the compiler you want to use +CC=gcc #recommended for: anyone not using ALSA 0.5 -SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o +OBJ_SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o SOUNDLIB= #recommended for: anyone using ALSA 0.5 -#SND=snd_alsa_0_5.o snd_dma.o snd_mix.o snd_mem.o +#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) -#SND=snd_alsa_0_9.o snd_dma.o snd_mix.o snd_mem.o +#OBJ_SND=snd_alsa_0_9.o snd_dma.o snd_mix.o snd_mem.o #SOUNDLIB=-lasound #recommended for: anyone who can't use the above drivers -#SND=snd_null.o +#OBJ_SND=snd_null.o #SOUNDLIB= - -#uncomment your preference #if you want CD sound in Linux -#CD=cd_linux.o +OBJ_CD=cd_linux.o #if you want no CD audio -CD=cd_null.o - -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 keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.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.c -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 quakeio.o sys_linux.o sys_shared.o transform.o world.o wad.o zone.o $(NETOBJECTS) $(SERVEROBJECTS) - +#OBJ_CD=cd_null.o #K6/athlon optimizations #CPUOPTIMIZATIONS=-march=k6 @@ -39,45 +32,156 @@ SHAREDOBJECTS= builddate.o cmd.o collision.o common.o crc.o cvar.o filematch.o h #no specific CPU CPUOPTIMIZATIONS= -#use this line for profiling -PROFILEOPTION=-pg -g -#use this line for no profiling -#PROFILEOPTION= - -#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 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS) -CFLAGS= -MD -Wall -Werror $(OPTIMIZATIONS) $(PROFILEOPTION) -#debug compile -#OPTIMIZATIONS= -#CFLAGS= -MD -Wall -Werror -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION) +##### Variables that you shouldn't care about ##### -LDFLAGS= $(PROFILEOPTION) -lm -ldl +# 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 \ + keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.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.c +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 quakeio.o sys_linux.o \ + sys_shared.o transform.o world.o wad.o zone.o + +OBJ_COMMON= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS) +OBJ_GLX= vid_glx.c $(OBJ_CD) $(OBJ_SND) +OBJ_DED= vid_null.o cd_null.o snd_null.o + + +# Compilation +CFLAGS_COMMON=-MD -Wall -Werror +CFLAGS_DEBUG=-ggdb +CFLAGS_PROFILE=-pg +CFLAGS_RELEASE= + +OPTIM_DEBUG= +OPTIM_RELEASE= -O6 -fno-strict-aliasing -ffast-math -funroll-loops \ + -fexpensive-optimizations $(CPUOPTIMIZATIONS) + +DO_CC=$(CC) $(CFLAGS) -c $< -o $@ + + +# Link +LDFLAGS=-lm -ldl + +EXE_GLX=darkplaces-glx +EXE_DED=darkplaces-dedicated + +GLX_LIB=-L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB) + +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 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) ==========" + @echo Using compiler $(CC) + @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_DEBUG) \ + $(OPTIM_DEBUG) + @echo + @$(MAKE) $(EXE) \ + CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)" + +bin-profile : + @echo + @echo "========== $(EXE) (profile) ==========" + @echo Using compiler $(CC) + @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_PROFILE) \ + $(OPTIM_RELEASE) + @echo + @$(MAKE) $(EXE) \ + CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)" -all: builddate darkplaces-dedicated darkplaces-glx +bin-release : + @echo + @echo "========== $(EXE) (release) ==========" + @echo Using compiler $(CC) + @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_RELEASE) \ + $(OPTIM_RELEASE) + @echo + @$(MAKE) $(EXE) \ + CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)" builddate: touch builddate.c vid_glx.o: vid_glx.c - $(CC) $(CFLAGS) -c vid_glx.c -I/usr/X11R6/include + @echo " Compiling" $< + @$(DO_CC) -I/usr/X11R6/include .c.o: - $(CC) $(CFLAGS) -c $*.c + @echo " Compiling" $< + @$(DO_CC) -darkplaces-glx: $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_glx.o $(CD) $(SND) - $(CC) -o $@ $^ $(LDFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB) +$(EXE_GLX): $(OBJ_COMMON) $(OBJ_GLX) + @echo " Linking " $@ + @$(DO_LD) $(GLX_LIB) -darkplaces-dedicated: $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_null.o cd_null.o snd_null.o - $(CC) -o $@ $^ $(LDFLAGS) +$(EXE_DED): $(OBJ_COMMON) $(OBJ_DED) + @echo " Linking " $@ + @$(DO_LD) clean: - -rm -f darkplaces-glx darkplaces-dedicated *.o *.d - -.PHONY: clean builddate + @rm -f $(EXE_GLX) $(EXE_DED) *.o *.d -include *.d - -- 2.39.2