1914415ede681514a1474ddfe145c668f43ef9e4
[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_explosion.o 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 quakeio.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 "* clean       : delete the binaries, and .o and .d files"
89         @echo "* help        : this help"
90         @echo "* debug       : make WGL and dedicated binaries (debug versions)"
91         @echo "* profile     : make WGL and dedicated binaries (profile versions)"
92         @echo "* release     : make WGL and dedicated binaries (release versions)"
93         @echo "* wgl-debug   : make WGL binary (debug version)"
94         @echo "* wgl-profile : make WGL binary (profile version)"
95         @echo "* wgl-release : make WGL binary (release version)"
96         @echo "* ded-debug   : make dedicated server (debug version)"
97         @echo "* ded-profile : make dedicated server (profile version)"
98         @echo "* 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 #       @echo Using compiler $(CC)
132 #       @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_DEBUG) \
133 #                                    $(OPTIM_DEBUG)
134 #       @echo
135         $(MAKE) -f makefile.mingwcross $(EXE) \
136                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_DEBUG) $(OPTIM_DEBUG)"\
137                 LDFLAGS="$(LDFLAGS_COMMON) $(LDFLAGS_DEBUG)"
138
139 bin-profile :
140         @echo
141         @echo "========== $(EXE) (profile) =========="
142 #       @echo Using compiler $(CC)
143 #       @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_PROFILE) \
144 #                                    $(OPTIM_RELEASE)
145 #       @echo
146         $(MAKE) -f makefile.mingwcross $(EXE) \
147                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_PROFILE) $(OPTIM_RELEASE)"\
148                 LDFLAGS="$(LDFLAGS_COMMON) $(LDFLAGS_PROFILE)"
149
150 bin-release :
151         @echo
152         @echo "========== $(EXE) (release) =========="
153 #       @echo Using compiler $(CC)
154 #       @echo Compiling with flags: $(CFLAGS_COMMON) $(CFLAGS_RELEASE) \
155 #                                    $(OPTIM_RELEASE)
156 #       @echo
157         $(MAKE) -f makefile.mingwcross $(EXE) \
158                 CFLAGS="$(CFLAGS_COMMON) $(CFLAGS_RELEASE) $(OPTIM_RELEASE)"\
159                 LDFLAGS="$(LDFLAGS_COMMON) $(LDFLAGS_RELEASE)"
160
161 builddate:
162         touch builddate.c
163
164 .c.o:
165 #       @echo "   Compiling" $<
166         $(DO_CC)
167
168 $(EXE_WGL):  $(OBJ_COMMON) $(OBJ_WGL)
169 #       @echo "   Linking  " $@
170         $(DO_LD) $(WGL_LIB)
171         strip $(EXE_WGL)
172
173 $(EXE_DED): $(OBJ_COMMON) $(OBJ_DED)
174 #       @echo "   Linking  " $@
175         $(DO_LD)
176
177 clean:
178         rm -f $(EXE_WGL) $(EXE_DED) *.o *.d
179
180 -include *.d