]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - makefile
Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem)
[xonotic/darkplaces.git] / makefile
index 09a468c93be45c827c5dc609c32b1a9002b0f712..e959e4e4636c9c2300d553d43c775f8a03130a85 100644 (file)
--- a/makefile
+++ b/makefile
+#####  DP_MAKE_TARGET autodetection and arch specific variables ##### 
 
+ifndef DP_MAKE_TARGET
 
-#uncomment these according to your sound driver
+# Win32
+ifdef windir
+       DP_MAKE_TARGET=mingw
+else
 
-#recommended for: anyone not using ALSA 0.5
-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
-#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
-#SOUNDLIB=-lasound
-#recommended for: anyone who can't use the above drivers
-#SND=snd_null.o
-#SOUNDLIB=
+# UNIXes
+DP_ARCH:=$(shell uname)
+ifneq ($(filter %BSD,$(DP_ARCH)),)
+       DP_MAKE_TARGET=bsd
+else
+       DP_MAKE_TARGET=linux
+endif
 
+endif
 
-#uncomment your preference
-#if you want CD sound in Linux
-#CD=cd_linux.o
-#if you want no CD audio
-CD=cd_null.o
+endif
 
-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
-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)
+# If we're not on compiling for Win32, we need additional information
+ifneq ($(DP_MAKE_TARGET), mingw)
+       DP_ARCH:=$(shell uname)
+       DP_MACHINE:=$(shell uname -m)
+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=
+# Command used to delete files
+ifdef windir
+       CMD_RM=del
+else
+       CMD_RM=$(CMD_UNIXRM)
+endif
 
-#use this line for profiling
-#PROFILEOPTION=-pg -g
-#use this line for no profiling
-PROFILEOPTION=
+# 64bits AMD CPUs use another lib directory
+ifeq ($(DP_MACHINE),x86_64)
+       UNIX_X11LIBPATH:=-L/usr/X11R6/lib64
+else
+       UNIX_X11LIBPATH:=-L/usr/X11R6/lib
+endif
 
-#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)
+# Linux configuration
+ifeq ($(DP_MAKE_TARGET), linux)
+       OBJ_SOUND=$(OBJ_LINUXSOUND)
+       LIB_SOUND=$(LIB_LINUXSOUND)
+       OBJ_CD=$(OBJ_LINUXCD)
 
-LDFLAGS= $(PROFILEOPTION) -lm -ldl
+       OBJ_CL=$(OBJ_GLX)
 
-all: builddate darkplaces-dedicated darkplaces-glx
+       LDFLAGS_CL=$(LDFLAGS_LINUXCL)
+       LDFLAGS_SV=$(LDFLAGS_LINUXSV)
+       LDFLAGS_SDL=$(LDFLAGS_LINUXSDL)
 
-builddate:
-       touch builddate.c
+       EXE_CL=$(EXE_UNIXCL)
+       EXE_SV=$(EXE_UNIXSV)
+       EXE_SDL=$(EXE_UNIXSDL)
+endif
 
-vid_glx.o: vid_glx.c
-       gcc $(CFLAGS) -c vid_glx.c -I/usr/X11R6/include
+# BSD configuration
+ifeq ($(DP_MAKE_TARGET), bsd)
+ifeq ($(DP_ARCH),FreeBSD)
+       OBJ_SOUND=$(OBJ_OSSSOUND)
+       LIB_SOUND=$(LIB_OSSSOUND)
+else
+       OBJ_SOUND=$(OBJ_BSDSOUND)
+       LIB_SOUND=$(LIB_BSDSOUND)
+endif
+       OBJ_CD=$(OBJ_BSDCD)
 
-.c.o:
-       gcc $(CFLAGS) -c $*.c
+       OBJ_CL=$(OBJ_GLX)
 
-darkplaces-glx:  $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_glx.o $(CD) $(SND)
-       gcc -o $@ $^ $(LDFLAGS) -L/usr/X11R6/lib -lX11 -lXext -lXxf86dga -lXxf86vm $(SOUNDLIB)
+       LDFLAGS_CL=$(LDFLAGS_BSDCL)
+       LDFLAGS_SV=$(LDFLAGS_BSDSV)
+       LDFLAGS_SDL=$(LDFLAGS_BSDSDL)
 
-darkplaces-dedicated: $(SHAREDOBJECTS) $(CLIENTOBJECTS) $(SERVEROBJECTS) vid_null.o cd_null.o snd_null.o
-       gcc -o $@ $^ $(LDFLAGS)
+       EXE_CL=$(EXE_UNIXCL)
+       EXE_SV=$(EXE_UNIXSV)
+       EXE_SDL=$(EXE_UNIXSDL)
+endif
 
-clean:
-       -rm -f darkplaces-glx darkplaces-dedicated *.o *.d
+# Win32 configuration
+ifeq ($(DP_MAKE_TARGET), mingw)
+       OBJ_SOUND=$(OBJ_WINSOUND)
+       LIB_SOUND=$(LIB_WINSOUND)
+       OBJ_CD=$(OBJ_WINCD)
 
-.PHONY: clean builddate
+       OBJ_CL=$(OBJ_WGL)
 
--include *.d
+       LDFLAGS_CL=$(LDFLAGS_WINCL)
+       LDFLAGS_SV=$(LDFLAGS_WINSV)
+       LDFLAGS_SDL=$(LDFLAGS_WINSDL)
+
+       EXE_CL=$(EXE_WINCL)
+       EXE_SV=$(EXE_WINSV)
+       EXE_SDL=$(EXE_WINSDL)
+endif
+
+
+##### GNU Make specific definitions #####
+
+DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
 
+
+##### Definitions shared by all makefiles #####
+include makefile.inc
+
+
+##### Dependency files #####
+
+-include *.d