Subversion Repositories eduke32

Rev

Rev 220 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 Plagman 1
# EDuke32 Makefile for GNU Make
2
 
3
# SDK locations - adjust to match your setup
4
# DXROOT=c:/sdks/msc/dx61
5
 
6
# Engine options
7
SUPERBUILD = 1
8
POLYMOST = 1
9
USE_OPENGL = 1
10
USE_A_C = 0
11
NOASM = 0
12
 
13
# Debugging options
14
RELEASE?=1
16 Plagman 15
JFAUD?=0
5 Plagman 16
 
17
# build locations
18
 
19
SRC=source/
20
RSRC=rsrc/
21
EROOT=../build/
194 terminx 22
ESRC=$(EROOT)src/
5 Plagman 23
EINC=$(EROOT)include/
24
INC=$(SRC)
25
o=o
26
 
27
ifneq (0,$(RELEASE))
28
  # debugging disabled
222 terminx 29
  debug=-fomit-frame-pointer -O2
5 Plagman 30
else
31
  # debugging enabled
32
  debug=-ggdb -O0
33
endif
34
 
35
CC=gcc
36
CXX=g++
37
# -Werror-implicit-function-declaration
91 terminx 38
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-char-subscripts -Wunused \
5 Plagman 39
	-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -DNOCOPYPROTECT \
208 terminx 40
	-I$(INC:/=) -I$(EINC:/=) -I$(SRC)jmact -I$(SRC)jaudiolib -I../jfaud/inc
5 Plagman 41
OURCXXFLAGS=-fno-exceptions -fno-rtti
42
LIBS=-lm
11 terminx 43
ifneq (0,$(JFAUD))
96 terminx 44
	JFAUDLIBS=../jfaud/libjfaud.a ../jfaud/mpadec/libmpadec.a
220 terminx 45
	OURCFLAGS+=-DJFAUD
11 terminx 46
endif
47
 
5 Plagman 48
NASMFLAGS=-s #-g
49
EXESUFFIX=
50
 
51
include $(EROOT)Makefile.shared
52
 
53
ifeq ($(PLATFORM),LINUX)
54
	OBJ=obj.nix/
55
	EOBJ=eobj.nix/
56
	NASMFLAGS+= -f elf
57
else
58
	OBJ=obj/
59
	EOBJ=eobj/
60
endif
61
 
62
JMACTOBJ=$(OBJ)util_lib.$o \
63
	$(OBJ)file_lib.$o \
64
	$(OBJ)control.$o \
65
	$(OBJ)keyboard.$o \
66
	$(OBJ)mouse.$o \
67
	$(OBJ)mathutil.$o \
68
	$(OBJ)scriplib.$o
69
 
70
AUDIOLIB_FX_STUB=$(OBJ)audiolib_fxstub.$o
71
AUDIOLIB_MUSIC_STUB=$(OBJ)audiolib_musicstub.$o
72
AUDIOLIB_JFAUD=$(OBJ)jfaud_sounds.$o
73
AUDIOLIB_FX=$(OBJ)mv_mix.$o \
74
	  $(OBJ)mv_mix16.$o \
75
	  $(OBJ)mvreverb.$o \
76
	  $(OBJ)pitch.$o \
77
	  $(OBJ)multivoc.$o \
78
	  $(OBJ)ll_man.$o \
79
	  $(OBJ)fx_man.$o \
80
	  $(OBJ)dsoundout.$o
81
AUDIOLIB_MUSIC=$(OBJ)midi.$o \
82
	  $(OBJ)mpu401.$o \
83
	  $(OBJ)music.$o
84
 
85
GAMEOBJS=$(OBJ)game.$o \
86
	$(OBJ)actors.$o \
87
	$(OBJ)anim.$o \
88
	$(OBJ)animlib.$o \
89
	$(OBJ)config.$o \
90
	$(OBJ)gamedef.$o \
91
	$(OBJ)gameexec.$o \
92
	$(OBJ)global.$o \
93
	$(OBJ)menus.$o \
94
	$(OBJ)namesdyn.$o \
95
	$(OBJ)player.$o \
96
	$(OBJ)premap.$o \
97
	$(OBJ)savegame.$o \
98
	$(OBJ)sector.$o \
99
	$(OBJ)rts.$o \
100
	$(OBJ)testcd.$o \
101
	$(OBJ)osdfuncs.$o \
102
	$(OBJ)osdcmds.$o \
103
	$(JMACTOBJ)
104
 
105
EDITOROBJS=$(OBJ)astub.$o
106
 
107
ifeq ($(PLATFORM),WINDOWS)
108
	OURCFLAGS+= -DUNDERSCORES -I$(DXROOT)/include
109
	NASMFLAGS+= -DUNDERSCORES -f win32
214 terminx 110
	GAMEOBJS+= $(OBJ)gameres.$o $(OBJ)winbits.$o $(OBJ)startwin.game.$o $(OBJ)startdlg.$o
5 Plagman 111
	EDITOROBJS+= $(OBJ)buildres.$o
112
endif
113
 
114
ifeq ($(RENDERTYPE),SDL)
115
 	OURCFLAGS+= $(subst -Dmain=SDL_main,,$(shell sdl-config --cflags))
116
 
11 terminx 117
	ifneq (0,$(JFAUD))
118
		AUDIOLIBOBJ=$(AUDIOLIB_JFAUD)
119
	else
120
		AUDIOLIBOBJ=$(AUDIOLIB_MUSIC_STUB) $(AUDIOLIB_FX_STUB) $(OBJ)sounds.$o
121
	endif
122
 
5 Plagman 123
	ifeq (1,$(HAVE_GTK2))
124
		OURCFLAGS+= -DHAVE_GTK2 $(shell pkg-config --cflags gtk+-2.0)
214 terminx 125
		GAMEOBJS+= $(OBJ)game_banner.$o $(OBJ)startgtk.game.$o $(OBJ)startdlg.$o
5 Plagman 126
		EDITOROBJS+= $(OBJ)editor_banner.$o
127
	endif
128
 
129
	GAMEOBJS+= $(OBJ)game_icon.$o
130
	EDITOROBJS+= $(OBJ)build_icon.$o
131
endif
132
 
133
ifeq ($(RENDERTYPE),WIN)
11 terminx 134
	ifneq (0,$(JFAUD))
135
		AUDIOLIBOBJ=$(AUDIOLIB_JFAUD)
136
	else
137
		AUDIOLIBOBJ=$(AUDIOLIB_MUSIC) $(AUDIOLIB_FX) $(OBJ)sounds.$o
138
	endif
5 Plagman 139
endif
140
 
141
GAMEOBJS+= $(AUDIOLIBOBJ)
142
OURCFLAGS+= $(BUILDCFLAGS)
143
OURCXXFLAGS+= $(BUILDCFLAGS)
144
 
145
.PHONY: clean all engine $(EOBJ)$(ENGINELIB) $(EOBJ)$(EDITORLIB)
146
 
147
# TARGETS
148
 
149
# Invoking Make from the terminal in OSX just chains the build on to xcode
150
ifeq ($(PLATFORM),DARWIN)
151
ifeq ($(RELEASE),0)
152
style=Development
153
else
154
style=Deployment
155
endif
156
.PHONY: alldarwin
157
alldarwin:
158
	cd osx && xcodebuild -target All -buildstyle $(style)
159
endif
160
 
135 terminx 161
ifeq ($(PLATFORM),WINDOWS)
162
all: eduke32$(EXESUFFIX) mapster32$(EXESUFFIX) duke3d_w32$(EXESUFFIX)
163
else
5 Plagman 164
all: eduke32$(EXESUFFIX) mapster32$(EXESUFFIX)
135 terminx 165
endif
5 Plagman 166
 
167
eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)$(ENGINELIB)
132 terminx 168
	$(CC) -o $@ $^ $(JFAUDLIBS) $(LIBS) $(STDCPPLIB) -Wl,-Map=$@.map
5 Plagman 169
	-rm eduke32.sym$(EXESUFFIX)
170
	cp eduke32$(EXESUFFIX) eduke32.sym$(EXESUFFIX)
171
	strip eduke32$(EXESUFFIX)
172
 
173
mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)$(EDITORLIB) $(EOBJ)$(ENGINELIB)
174
	$(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) -Wl,-Map=$@.map
175
	-rm mapster32.sym$(EXESUFFIX)
176
	cp mapster32$(EXESUFFIX) mapster32.sym$(EXESUFFIX)
177
	strip mapster32$(EXESUFFIX)
178
 
132 terminx 179
duke3d_w32$(EXESUFFIX): $(OBJ)wrapper.$o
180
	$(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ -Wl
181
	strip duke3d_w32$(EXESUFFIX)
182
 
5 Plagman 183
include Makefile.deps
184
 
185
.PHONY: enginelib editorlib
186
enginelib editorlib:
187
	-mkdir $(EOBJ)
188
	$(MAKE) -C $(EROOT) "OBJ=$(CURDIR)/$(EOBJ)" \
189
		SUPERBUILD=$(SUPERBUILD) POLYMOST=$(POLYMOST) \
163 terminx 190
		USE_OPENGL=$(USE_OPENGL) USE_A_C=$(USE_A_C) \
191
		NOASM=$(NOASM) RELEASE=$(RELEASE) $@
5 Plagman 192
 
193
$(EOBJ)$(ENGINELIB): enginelib
194
$(EOBJ)$(EDITORLIB): editorlib
195
 
196
# RULES
197
$(OBJ)%.$o: $(SRC)%.nasm
198
	nasm $(NASMFLAGS) $< -o $@
199
$(OBJ)%.$o: $(SRC)jaudiolib/%.nasm
200
	nasm $(NASMFLAGS) $< -o $@
201
 
202
$(OBJ)%.$o: $(SRC)%.c
203
	$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
204
$(OBJ)%.$o: $(SRC)%.cpp
205
	$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
206
$(OBJ)%.$o: $(SRC)jmact/%.c
207
	$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
208
$(OBJ)%.$o: $(SRC)jaudiolib/%.c
209
	$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
220 terminx 210
 
211
ifeq (1,$(JFAUD))
5 Plagman 212
$(OBJ)%.$o: $(SRC)misc/%.rc
220 terminx 213
	windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC) -DJFAUD
214
else
215
$(OBJ)%.$o: $(SRC)misc/%.rc
194 terminx 216
	windres -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC)
220 terminx 217
endif
218
 
5 Plagman 219
$(OBJ)%.$o: $(SRC)util/%.c
220
	$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
221
 
222
$(OBJ)%.$o: $(RSRC)%.c
223
	$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@ 2>&1
224
 
225
$(OBJ)game_banner.$o: $(RSRC)game_banner.c
226
$(OBJ)editor_banner.$o: $(RSRC)editor_banner.c
227
$(RSRC)game_banner.c: $(RSRC)game.bmp
228
	echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
229
	gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
230
$(RSRC)editor_banner.c: $(RSRC)build.bmp
231
	echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
232
	gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
233
 
234
# PHONIES
235
clean:
236
ifeq ($(PLATFORM),DARWIN)
237
	cd osx && xcodebuild -target All clean
238
else
132 terminx 239
	-rm -f $(OBJ)* eduke32$(EXESUFFIX) eduke32.sym$(EXESUFFIX) mapster32$(EXESUFFIX) mapster32.sym$(EXESUFFIX) core* duke3d_w32$(EXESUFFIX)
5 Plagman 240
endif
241
 
242
veryclean: clean
243
ifeq ($(PLATFORM),DARWIN)
244
else
245
	-rm -f $(EOBJ)*
246
endif