This is a patch from Elric greatly cleaning up the filesystem portions of the engine...
[xonotic/darkplaces.git] / makefile.mingwcross
1 ##### Variables that you may want to modify #####
2
3 #choose the compiler you want to use
4 CC=gcc
5
6 OBJ_SND=snd_win.o snd_dma.o snd_mix.o snd_mem.o
7 SOUNDLIB=
8
9 OBJ_CD=cd_win.o
10
11 #K6/athlon optimizations
12 #CPUOPTIMIZATIONS=-march=k6
13 #note: don't use -march=athlon, every gcc which has it currently (2.96-3.1)
14 #have optimizer bugs (like entities disappearing randomly - a bug with
15 #compiling BOX_ON_PLANE_SIDE in mathlib.h)
16 #CPUOPTIMIZATIONS=-march=athlon
17 #686 optimizations
18 #CPUOPTIMIZATIONS=-march=i686
19 #no specific CPU
20 CPUOPTIMIZATIONS=
21
22
23 ##### Variables that you shouldn't care about #####
24
25 # Objects
26 CLIENTOBJECTS=  cgame.o cgamevm.o chase.o cl_collision.o cl_demo.o cl_input.o \
27                 cl_main.o cl_parse.o cl_particles.o cl_screen.o cl_video.o \
28                 console.o dpvsimpledecode.o fractalnoise.o gl_backend.o \
29                 gl_draw.o gl_models.o gl_rmain.o gl_rsurf.o gl_textures.o \
30                 jpeg.o keys.o menu.o meshqueue.o r_crosshairs.o r_explosion.o \
31                 r_lerpanim.o r_light.o r_modules.o r_sky.o \
32                 r_sprites.o sbar.o ui.o vid_shared.o view.o wavefile.o \
33                 r_shadow.o conproc.o
34 SERVEROBJECTS=  pr_cmds.o pr_edict.o pr_exec.o sv_light.o sv_main.o sv_move.o \
35                 sv_phys.o sv_user.o
36 SHAREDOBJECTS=  builddate.o cmd.o collision.o common.o crc.o cvar.o \
37                 filematch.o host.o host_cmd.o image.o mathlib.o matrixlib.o \
38                 model_alias.o model_brush.o model_shared.o model_sprite.o \
39                 net_dgrm.o net_loop.o net_main.o net_master.o \
40                 palette.o portals.o protocol.o fs.o \
41                 sys_shared.o world.o wad.o zone.o
42
43
44 OBJ_COMMON= $(CLIENTOBJECTS) $(SERVEROBJECTS) $(SHAREDOBJECTS)
45 OBJ_WGL= vid_wgl.o $(OBJ_CD) $(OBJ_SND) net_win.o net_wins.o net_wipx.o sys_win.o
46 OBJ_DED= vid_null.o cd_null.o snd_null.o net_win.o net_wins.o net_wipx.o sys_win.o
47
48
49 # Compilation
50 CFLAGS_COMMON=-MD -Wall
51 CFLAGS_DEBUG=-ggdb
52 CFLAGS_PROFILE=-g -pg -ggdb
53 CFLAGS_RELEASE=
54
55 OPTIM_DEBUG=
56 # OPTIM_RELEASE=        -O6 -fno-strict-aliasing -ffast-math -funroll-loops \
57 #               -fexpensive-optimizations $(CPUOPTIMIZATIONS)
58 OPTIM_RELEASE=  -O2 -fno-strict-aliasing -ffast-math \
59                 -fexpensive-optimizations $(CPUOPTIMIZATIONS)
60
61 DO_CC=$(CC) $(CFLAGS) -c $< -o $@
62
63
64 # Link
65 LDFLAGS_COMMON=--mwindows -luser32 -lgdi32 -lwinmm -ldxguid -ldinput -lopengl32 -lcomctl32 -lwsock32
66 LDFLAGS_DEBUG=-g -ggdb
67 LDFLAGS_PROFILE=-g -pg
68 LDFLAGS_RELEASE=
69
70 EXE_WGL=darkplaces.exe
71 EXE_DED=darkplaces-dedicated.exe
72
73 WGL_LIB=
74
75 DO_LD=$(CC) -o $@ $^ $(LDFLAGS)
76
77
78 ##### Commands #####
79
80 .PHONY : clean help \
81          debug profile release \
82          wgl-debug wgl-profile wgl-release \
83          ded-debug ded-profile ded-release \
84
85 help:
86         @echo
87         @echo "===== Choose one ====="
88         @echo "* $(MAKE) clean       : delete the binaries, and .o and .d files"
89         @echo "* $(MAKE) help        : this help"
90         @echo "* $(MAKE) debug       : make WGL and dedicated binaries (debug versions)"
91         @echo "* $(MAKE) profile     : make WGL and dedicated binaries (profile versions)"
92         @echo "* $(MAKE) release     : make WGL and dedicated binaries (release versions)"
93         @echo "* $(MAKE) wgl-debug   : make WGL binary (debug version)"
94         @echo "* $(MAKE) wgl-profile : make WGL binary (profile version)"
95         @echo "* $(MAKE) wgl-release : make WGL binary (release version)"
96         @echo "* $(MAKE) ded-debug   : make dedicated server (debug version)"
97         @echo "* $(MAKE) ded-profile : make dedicated server (profile version)"
98         @echo "* $(MAKE) ded-release : make dedicated server (release version)"
99         @echo
100
101 debug :
102         $(MAKE) -f makefile.mingwcross wgl-debug ded-debug
103
104 profile :
105         $(MAKE) -f makefile.mingwcross wgl-profile ded-profile
106
107 release :
108         $(MAKE) -f makefile.mingwcross wgl-release ded-release
109
110 wgl-debug :
111         $(MAKE) -f makefile.mingwcross bin-debug EXE="$(EXE_WGL)"
112
113 wgl-profile :
114         $(MAKE) -f makefile.mingwcross bin-profile EXE="$(EXE_WGL)"
115
116 wgl-release :
117         $(MAKE) -f makefile.mingwcross bin-release EXE="$(EXE_WGL)"
118
119 ded-debug :
120         $(MAKE) -f makefile.mingwcross bin-debug EXE="$(EXE_DED)"
121
122 ded-profile :
123         $(MAKE) -f makefile.mingwcross bin-profile EXE="$(EXE_DED)"
124
125 ded-release :
126         $(MAKE) -f makefile.mingwcross bin-release EXE="$(EXE_DED)"
127
128 bin-debug :
129         @echo
130         @echo "========== $(EXE) (debug) =========="
131         $(MAKE) builddate
132         $(MAKE) -f makefile.mingwcross $(EXE) \
133                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
134                 LDFLAGS="$(LDFLAGS_DEBUG) $(LDFLAGS_COMMON)"
135
136 bin-profile :
137         @echo
138         @echo "========== $(EXE) (profile) =========="
139         $(MAKE) builddate
140         $(MAKE) -f makefile.mingwcross $(EXE) \
141                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
142                 LDFLAGS="$(LDFLAGS_PROFILE) $(LDFLAGS_COMMON)"
143
144 bin-release :
145         @echo
146         @echo "========== $(EXE) (release) =========="
147         $(MAKE) builddate
148         $(MAKE) -f makefile.mingwcross $(EXE) \
149                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
150                 LDFLAGS="$(LDFLAGS_RELEASE) $(LDFLAGS_COMMON)"
151         strip $(EXE)
152
153 builddate:
154         touch builddate.c
155
156 .c.o:
157         $(DO_CC)
158
159 $(EXE_WGL):  $(OBJ_COMMON) $(OBJ_WGL)
160         $(DO_LD) $(WGL_LIB)
161
162 $(EXE_DED): $(OBJ_COMMON) $(OBJ_DED)
163         $(DO_LD)
164
165 clean:
166         rm -f $(EXE_WGL) $(EXE_DED) *.o *.d
167
168 -include *.d