Subversion Repositories eduke32

Rev

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

Rev Author Line No. Line
996 terminx 1
#
5 Plagman 2
# EDuke32 Makefile for GNU Make
996 terminx 3
#
5 Plagman 4
 
1739 helixhorne 5
include Makefile.common
996 terminx 6
 
4543 hendricks2 7
DUKE3D_SRC=source
8
DUKE3D_INC=$(DUKE3D_SRC)
9
DUKE3D_RSRC=rsrc
10
ENGINE_ROOT=build
11
ENGINE_SRC=$(ENGINE_ROOT)/src
12
ENGINE_INC=$(ENGINE_ROOT)/include
5 Plagman 13
o=o
4543 hendricks2 14
asm=nasm
4553 hendricks2 15
obj=obj
5 Plagman 16
 
4555 hendricks2 17
COMPILERFLAGS += -I$(ENGINE_INC) -I$(DUKE3D_SRC)/jmact -I$(AUDIOLIB_ROOT)/include -I$(ENET_ROOT)/include
4543 hendricks2 18
 
4555 hendricks2 19
 
20
# EBacktrace
21
 
22
ifndef EBACKTRACEDLL
23
    EBACKTRACEDLL = ebacktrace1.dll
24
    ifeq ($(findstring x86_64,$(COMPILERTARGET)),x86_64)
25
        EBACKTRACEDLL = ebacktrace1-64.dll
26
    endif
27
endif
28
EBACKTRACEDLL_TARGET:=$(EBACKTRACEDLL)
29
 
30
 
4543 hendricks2 31
# BUILD Engine
32
 
33
ENGINE_CFLAGS=-I$(ENGINE_SRC)
34
UTIL_LIBS= -lm # -lpthread
35
 
4553 hendricks2 36
ENGINE_OBJ=$(ENGINE_ROOT)/$(obj)
4543 hendricks2 37
 
4559 hendricks2 38
ENGINE_OBJS=baselayer cache1d common compat crc32 defs engine polymost texcache dxtfilter hightile textfont smalltextfont kplib lz4 osd pragmas scriptfile mmulti_null mutex xxhash
4543 hendricks2 39
ENGINE_EDITOR_OBJS=build config defs
40
ifeq (0,$(NOASM))
41
  ENGINE_OBJS+= a
42
else
43
  ENGINE_OBJS+= a-c
44
  ifneq (0,$(USE_ASM64))
45
    ENGINE_OBJS+= a64
46
  endif
47
endif
48
ifeq (1,$(USE_OPENGL))
4639 terminx 49
    ENGINE_OBJS+= glbuild voxmodel mdsprite
4543 hendricks2 50
    ifeq (1,$(POLYMER))
51
        ENGINE_OBJS+= polymer
52
    endif
53
endif
4591 helixhorne 54
ifneq (0,$(LUNATIC))
4543 hendricks2 55
    ENGINE_OBJS+= lunatic
56
endif
57
ifeq ($(PLATFORM),DARWIN)
58
    ENGINE_OBJS += osxbits
59
    ifneq (0,$(OSX_STARTUPWINDOW))
60
        ENGINE_EDITOR_OBJS += startosx.editor
61
    endif
62
    ifeq (1,$(SDL_FRAMEWORK))
63
        ENGINE_OBJS+=SDLMain
64
    endif
65
endif
66
ifeq ($(PLATFORM),WINDOWS)
67
    ENGINE_OBJS+= winbits
68
    ENGINE_EDITOR_OBJS+= startwin.editor
69
endif
70
ifeq ($(RENDERTYPE),SDL)
71
    ENGINE_OBJS+= sdlayer
72
 
73
    ifeq (1,$(HAVE_GTK2))
74
        ENGINE_OBJS+= gtkbits
75
        ifeq ($(LINKED_GTK),0)
76
            ENGINE_OBJS+= dynamicgtk
77
        endif
78
        ENGINE_EDITOR_OBJS+= startgtk.editor
79
    endif
80
endif
81
ifeq ($(RENDERTYPE),WIN)
82
    ENGINE_OBJS+= winlayer rawinput
83
endif
84
 
85
ENGINE_OBJS_EXP:=$(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(ENGINE_OBJS)))
86
ENGINE_EDITOR_OBJS_EXP:=$(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(ENGINE_EDITOR_OBJS)))
87
 
88
 
4555 hendricks2 89
# MACT
90
 
91
MACT_OBJ=file_lib control keyboard mouse joystick mathutil scriplib animlib
92
 
93
 
4543 hendricks2 94
# AudioLib
95
 
96
AUDIOLIB_OBJS=drivers fx_man multivoc mix mixst pitch formats vorbis flac xa driver_nosound
97
 
98
AUDIOLIB_ROOT=$(DUKE3D_SRC)/jaudiolib
99
AUDIOLIB_SRC=$(AUDIOLIB_ROOT)/src
100
AUDIOLIB_INC=$(AUDIOLIB_ROOT)/include
4553 hendricks2 101
AUDIOLIB_OBJ=$(AUDIOLIB_ROOT)/$(obj)
4543 hendricks2 102
 
103
AUDIOLIB_CFLAGS=-I$(AUDIOLIB_ROOT)/third-party/common/include -DHAVE_VORBIS
104
ifneq ($(PLATFORM),WII)
105
    AUDIOLIB_CFLAGS+= -DHAVE_FLAC
106
endif
107
 
108
ifeq ($(PLATFORM),WINDOWS)
109
    ifeq ($(MIXERTYPE),WIN)
110
        AUDIOLIB_CFLAGS+= -DHAVE_DS
111
        AUDIOLIB_OBJS+= driver_directsound
112
    endif
113
endif
114
 
115
ifeq ($(MIXERTYPE),SDL)
116
    AUDIOLIB_CFLAGS+= -DHAVE_SDL
117
    ifneq ($(PLATFORM),DARWIN)
118
        ifneq ($(PLATFORM),WINDOWS)
119
            ifneq ($(PLATFORM),WII)
120
                AUDIOLIB_CFLAGS+=`pkg-config --cflags vorbis`
121
            endif
122
        endif
123
    endif
124
    AUDIOLIB_OBJS+= driver_sdl
125
endif
126
 
127
AUDIOLIB_OBJS_EXP:=$(addprefix $(AUDIOLIB_OBJ)/,$(addsuffix .$o,$(AUDIOLIB_OBJS)))
128
 
129
 
130
# ENet
131
 
132
ENET_OBJS=callbacks host list packet peer protocol compress
133
 
134
ENET_ROOT=$(DUKE3D_SRC)/enet
135
ENET_SRC=$(ENET_ROOT)/src
136
ENET_INC=$(ENET_ROOT)/include
4553 hendricks2 137
ENET_OBJ=$(ENET_ROOT)/$(obj)
138
 
4543 hendricks2 139
ENET_CFLAGS=
140
 
141
ifeq ($(PLATFORM),WINDOWS)
142
    ENET_OBJS += win32
143
else
144
    ENET_OBJS += unix
145
    ENET_CFLAGS += -DHAS_SOCKLEN_T
146
endif
147
 
148
ENET_OBJS_EXP:=$(addprefix $(ENET_OBJ)/,$(addsuffix .$o,$(ENET_OBJS)))
149
 
4555 hendricks2 150
ifeq ($(NETCODE),0)
151
    ENET_TARGET=
152
else
153
    ENET_TARGET=$(ENET_OBJS_EXP)
154
endif
4543 hendricks2 155
 
4555 hendricks2 156
 
4543 hendricks2 157
# Tools
158
 
159
UTIL_OBJS=compat pragmas kplib cache1d compat_tools
160
UTILS=kextract kgroup transpal wad2art wad2map kmd2tool md2tool generateicon cacheinfo arttool givedepth mkpalette unpackssi bsuite
161
GAMEUTILS=ivfrate
162
DXUTILS=enumdisplay getdxdidf
163
SDLUTILS=makesdlkeytrans
164
 
165
UTIL_OBJS_EXP:=$(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(UTIL_OBJS)))
166
 
167
 
4555 hendricks2 168
# KenBuild (Test Game)
4543 hendricks2 169
 
4555 hendricks2 170
TESTGAME_ROOT=$(DUKE3D_SRC)/testgame
171
TESTGAME_SRC=$(TESTGAME_ROOT)/src
172
TESTGAME_RSRC=$(TESTGAME_ROOT)/rsrc
173
TESTGAME_OBJ=$(TESTGAME_ROOT)/$(obj)
174
 
175
TEST_CFLAGS=-I$(TESTGAME_SRC)
176
 
177
TESTGAME ?= testgame$(EXESUFFIX)
178
TESTEDITOR ?= testeditor$(EXESUFFIX)
179
 
180
TESTGAME_TARGET:=$(TESTGAME)
181
TESTEDITOR_TARGET:=$(TESTEDITOR)
182
 
183
TESTGAME_OBJS=game sound_stub common config
184
TESTEDITOR_OBJS=bstub common
185
 
186
ifeq ($(RENDERTYPE),SDL)
187
	ifeq (1,$(HAVE_GTK2))
188
		TESTGAME_OBJS+= game_banner startgtk.game
189
		TESTEDITOR_OBJS+= editor_banner
190
	endif
191
 
192
	TESTGAME_OBJS+= game_icon
193
	TESTEDITOR_OBJS+= build_icon
5 Plagman 194
endif
4555 hendricks2 195
ifeq ($(PLATFORM),WINDOWS)
196
	TESTGAME_OBJS+= gameres startwin.game
197
	TESTEDITOR_OBJS+= buildres
198
endif
5 Plagman 199
 
4555 hendricks2 200
TESTGAME_OBJS_EXP:=$(addprefix $(TESTGAME_OBJ)/,$(addsuffix .$o,$(TESTGAME_OBJS)))
201
TESTEDITOR_OBJS_EXP:=$(addprefix $(TESTGAME_OBJ)/,$(addsuffix .$o,$(TESTEDITOR_OBJS)))
1739 helixhorne 202
 
4555 hendricks2 203
 
204
# Duke Nukem 3D
205
 
206
DUKE3D_CFLAGS=-I$(DUKE3D_INC)
207
 
4543 hendricks2 208
DUKE3D_LINKERFLAGS=
209
DUKE3D_EDITOR_LINKERFLAGS=
1739 helixhorne 210
 
4553 hendricks2 211
DUKE3D_OBJ=$(DUKE3D_SRC)/$(obj)
3219 hendricks2 212
 
3096 hendricks2 213
EDUKE32 ?= eduke32$(EXESUFFIX)
214
MAPSTER32 ?= mapster32$(EXESUFFIX)
215
 
216
EDUKE32_TARGET:=$(EDUKE32)
3582 hendricks2 217
MAPSTER32_TARGET:=$(MAPSTER32)
3096 hendricks2 218
 
4559 hendricks2 219
COMMON_OBJS=rev
4561 hendricks2 220
COMMON_EDITOR_OBJS=m32common m32def m32exec m32vars mathutil rev
3096 hendricks2 221
 
4559 hendricks2 222
DUKE3D_OBJS=game actors anim common config demo gamedef gameexec gamevars global input menus namesdyn net player premap savegame sector rts osdfuncs osdcmds grpscan sounds soundsdyn $(MACT_OBJ)
223
DUKE3D_EDITOR_OBJS=astub common grpscan sounds_mapster32
5 Plagman 224
 
1933 helixhorne 225
ifneq ($(USE_LIBVPX),0)
4543 hendricks2 226
    DUKE3D_OBJS+= animvpx
1933 helixhorne 227
endif
2034 helixhorne 228
 
3116 hendricks2 229
ifneq (0,$(DISABLEINLINING))
4543 hendricks2 230
    DUKE3D_OBJS+= game_inline actors_inline sector_inline
3116 hendricks2 231
endif
232
 
4543 hendricks2 233
DUKE3D_MISCDEPS=
234
DUKE3D_EDITOR_MISCDEPS=
2143 helixhorne 235
 
4591 helixhorne 236
# Lunatic object base names. These are not used in targets directly.
237
LUNATIC_COMMON_OBJS = luaJIT_BC_defs_common luaJIT_BC_engine_maptext luaJIT_BC_engine luaJIT_BC_bcarray luaJIT_BC_bcheck luaJIT_BC_bitar luaJIT_BC_xmath luaJIT_BC_v luaJIT_BC_dump luaJIT_BC_dis_x86 luaJIT_BC_dis_x64
238
LUNATIC_GAME_OBJS = luaJIT_BC_con_lang luaJIT_BC_lunacon luaJIT_BC_randgen luaJIT_BC_stat luaJIT_BC_control luaJIT_BC_defs luaJIT_BC_savegame luaJIT_BC_fs
2148 helixhorne 239
 
2143 helixhorne 240
## Lunatic devel
2034 helixhorne 241
ifneq (0,$(LUNATIC))
4237 helixhorne 242
    # TODO: remove debugging modules from release build
243
 
4543 hendricks2 244
    DUKE3D_EDITOR_OBJS+= lunatic_m32 $(LUNATIC_COMMON_OBJS)
245
    DUKE3D_OBJS+= lunatic_game $(LUNATIC_COMMON_OBJS)
2143 helixhorne 246
 
4543 hendricks2 247
    DUKE3D_EDITOR_OBJS+= luaJIT_BC_defs_m32
4237 helixhorne 248
 
3938 helixhorne 249
    ifneq ($(PLATFORM),WINDOWS)
250
        # On non-Windows, we expect to have liblpeg.a (or a symlink to it) in source/.
4319 hendricks2 251
        # On Windows, it will reside in platform/Windows/lib/32/ or lib/64/.
4553 hendricks2 252
        LIBDIRS+= -L$(DUKE3D_SRC)
4543 hendricks2 253
        ifeq ($(realpath $(DUKE3D_SRC)/liblpeg.a),)
3938 helixhorne 254
            # XXX: This cripples "make clean" etc. too, but IMO it's better than warning.
4543 hendricks2 255
            $(error "liblpeg.a not found in $(realpath $(DUKE3D_OBJ)/..)")
3938 helixhorne 256
        endif
257
    endif
258
    LIBS+= -llpeg
4591 helixhorne 259
    DUKE3D_OBJS+= $(LUNATIC_GAME_OBJS)
2650 helixhorne 260
 
2143 helixhorne 261
    # now, take care of having the necessary symbols (sector, wall, etc.) in the
262
    # executable no matter what the debugging level
263
 
2074 helixhorne 264
    ifeq ($(PLATFORM),DARWIN)
2143 helixhorne 265
        # strip on OSX says: removing global symbols from a final linked no longer supported.
266
        #                    Use -exported_symbols_list at link time when building
267
        # But, following _their_ directions does not give us the symbols! wtf?
3422 helixhorne 268
        ifneq ($(STRIP),0)
4543 hendricks2 269
            STRIP+= -s $(DUKE3D_SRC)/lunatic/dynsymlist_osx
3422 helixhorne 270
        endif
2143 helixhorne 271
 
4543 hendricks2 272
        DUKE3D_MISCDEPS+= $(DUKE3D_SRC)/lunatic/dynsymlist_osx
273
        LINKERFLAGS+= -pagezero_size 10000 -image_base 100000000 #-Wl,-alias_list -Wl,$(DUKE3D_SRC)/lunatic/aliases_list #-exported_symbols_list $(DUKE3D_SRC)/lunatic/dynsymlist_osx
2143 helixhorne 274
    endif
275
    ifeq ($(PLATFORM),WINDOWS)
3423 helixhorne 276
        override STRIP=
4543 hendricks2 277
        DUKE3D_MISCDEPS+= $(DUKE3D_SRC)/lunatic/eduke32.def
278
        DUKE3D_LINKERFLAGS+= $(DUKE3D_SRC)/lunatic/eduke32.def
279
        DUKE3D_EDITOR_MISCDEPS+= $(DUKE3D_SRC)/lunatic/mapster32.def
280
        DUKE3D_EDITOR_LINKERFLAGS+= $(DUKE3D_SRC)/lunatic/mapster32.def
2143 helixhorne 281
    endif
3272 hendricks2 282
    ifeq ($(SUBPLATFORM),LINUX)
3423 helixhorne 283
        override STRIP=
4543 hendricks2 284
        DUKE3D_LINKERFLAGS+= -Wl,--dynamic-list=$(DUKE3D_SRC)/lunatic/dynsymlist
285
        DUKE3D_EDITOR_LINKERFLAGS+= -Wl,--dynamic-list=$(DUKE3D_SRC)/lunatic/dynsymlist_m32
2074 helixhorne 286
    endif
2034 helixhorne 287
endif
288
 
3272 hendricks2 289
ifeq ($(SUBPLATFORM),LINUX)
3335 hendricks2 290
    LIBS		+= -lFLAC -lvorbisfile -lvorbis -logg
996 terminx 291
endif
292
 
293
ifeq ($(PLATFORM),DARWIN)
4646 hendricks2 294
    # LIBDIRS += -L$(AUDIOLIB_ROOT)/third-party/Apple/lib
2537 hendricks2 295
 
4543 hendricks2 296
    LIBS += -lFLAC -lvorbisfile -lvorbis -logg -lm \
297
            -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,OpenGL \
298
            -Wl,-framework,CoreMidi -Wl,-framework,AudioUnit \
4548 hendricks2 299
            -Wl,-framework,AudioToolbox -Wl,-framework,IOKit -Wl,-framework,AGL
300
    ifneq (00,$(DARWIN9)$(DARWIN10))
301
        LIBS += -Wl,-framework,QuickTime -lm
302
    endif
2537 hendricks2 303
 
2426 hendricks2 304
    ifneq (0,$(OSX_STARTUPWINDOW))
4543 hendricks2 305
        DUKE3D_OBJS += GrpFile.game GameListSource.game startosx.game
2426 hendricks2 306
    endif
996 terminx 307
endif
308
 
5 Plagman 309
ifeq ($(PLATFORM),WINDOWS)
4543 hendricks2 310
    LIBS += -lFLAC -lvorbisfile -lvorbis -logg -lcompat-from-mingw-w64
4553 hendricks2 311
    LIBDIRS += -L$(AUDIOLIB_ROOT)/third-party/Windows/lib$(WINLIB)
4543 hendricks2 312
    DUKE3D_OBJS+= gameres winbits startwin.game
313
    DUKE3D_EDITOR_OBJS+= buildres
4084 hendricks2 314
    ifeq ($(MIXERTYPE),WIN)
3219 hendricks2 315
        LIBS+= -ldsound
4543 hendricks2 316
        DUKE3D_OBJS+= music midi mpu401
3219 hendricks2 317
    endif
318
endif
4543 hendricks2 319
 
320
ifeq ($(PLATFORM),WII)
321
    LIBS += -lvorbisidec
322
endif
323
 
3219 hendricks2 324
ifeq ($(RENDERTYPE),SDL)
4084 hendricks2 325
    ifeq (1,$(HAVE_GTK2))
4543 hendricks2 326
        DUKE3D_OBJS+= game_banner startgtk.game
327
        DUKE3D_EDITOR_OBJS+= editor_banner
4084 hendricks2 328
    endif
329
 
4543 hendricks2 330
    DUKE3D_OBJS+= game_icon
331
    DUKE3D_EDITOR_OBJS+= build_icon
4084 hendricks2 332
endif
333
ifeq ($(MIXERTYPE),SDL)
4543 hendricks2 334
    DUKE3D_OBJS+= sdlmusic
5 Plagman 335
endif
336
 
4591 helixhorne 337
## Construct file names of object files
1473 terminx 338
 
4555 hendricks2 339
COMMON_OBJS_EXP:=$(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(COMMON_OBJS)))
340
COMMON_EDITOR_OBJS_EXP:=$(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(COMMON_EDITOR_OBJS)))
341
 
4543 hendricks2 342
DUKE3D_OBJS_EXP:=$(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(DUKE3D_OBJS)))
343
DUKE3D_EDITOR_OBJS_EXP:=$(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(DUKE3D_EDITOR_OBJS)))
5 Plagman 344
 
4591 helixhorne 345
LUNATIC_COMMON_OBJS_EXP := $(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(LUNATIC_COMMON_OBJS)))
346
LUNATIC_GAME_OBJS_EXP := $(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(LUNATIC_GAME_OBJS)))
347
LUNATIC_OBJS_EXP := $(LUNATIC_COMMON_OBJS_EXP) $(LUNATIC_GAME_OBJS_EXP)
1595 helixhorne 348
 
3116 hendricks2 349
 
1103 terminx 350
ifeq ($(PRETTY_OUTPUT),1)
1101 terminx 351
.SILENT:
1103 terminx 352
endif
4565 hendricks2 353
.PHONY: veryclean clean all test cleanutils utils dxutils sdlutils printutils printsdlutils printdxutils rev $(DUKE3D_OBJ)/rev.$o
5 Plagman 354
 
355
# TARGETS
356
 
4565 hendricks2 357
all: start $(EDUKE32_TARGET) $(MAPSTER32_TARGET) finish
2685 hendricks2 358
ifneq (,$(EDUKE32_TARGET))
3096 hendricks2 359
	@ls -l $(EDUKE32)
2685 hendricks2 360
endif
361
ifneq (,$(MAPSTER32_TARGET))
3096 hendricks2 362
	@ls -l $(MAPSTER32)
2685 hendricks2 363
endif
3236 hendricks2 364
 
4555 hendricks2 365
test: start $(TESTGAME_TARGET) $(TESTEDITOR_TARGET) finish
366
ifneq (,$(TESTGAME_TARGET))
367
	@ls -l $(TESTGAME)
368
endif
369
ifneq (,$(TESTEDITOR_TARGET))
370
	@ls -l $(TESTEDITOR)
371
endif
372
 
3236 hendricks2 373
ebacktrace: start $(EBACKTRACEDLL_TARGET) finish
3163 hendricks2 374
ifneq (,$(EBACKTRACEDLL_TARGET))
375
	@ls -l $(EBACKTRACEDLL)
376
endif
1101 terminx 377
 
3163 hendricks2 378
start:
1102 terminx 379
	$(BUILD_STARTED)
1595 helixhorne 380
 
3163 hendricks2 381
finish:
382
	$(BUILD_FINISHED)
3096 hendricks2 383
 
4543 hendricks2 384
utils: $(addsuffix $(EXESUFFIX),$(UTILS) $(GAMEUTILS))
385
	@ls -l $^
3163 hendricks2 386
 
4543 hendricks2 387
dxutils: $(addsuffix $(EXESUFFIX),$(DXUTILS))
388
	@ls -l $^
389
 
390
sdlutils: $(addsuffix $(EXESUFFIX),$(SDLUTILS))
391
	@ls -l $^
392
 
4555 hendricks2 393
$(TESTGAME): $(TESTGAME_OBJS_EXP) $(COMMON_OBJS_EXP) $(ENGINE_OBJS_EXP)
1102 terminx 394
	$(LINK_STATUS)
4555 hendricks2 395
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(RECIPE_RESULT_LINK)
396
ifneq ($(STRIP),)
397
	$(STRIP) $(TESTGAME)
398
endif
399
 
400
$(TESTEDITOR): $(TESTEDITOR_OBJS_EXP) $(COMMON_EDITOR_OBJS_EXP) $(ENGINE_EDITOR_OBJS_EXP) $(ENGINE_OBJS_EXP)
401
	$(LINK_STATUS)
402
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(RECIPE_RESULT_LINK)
403
ifneq ($(STRIP),)
404
	$(STRIP) $(TESTEDITOR)
405
endif
406
 
407
$(EDUKE32): $(DUKE3D_OBJS_EXP) $(COMMON_OBJS_EXP) $(ENGINE_OBJS_EXP) $(AUDIOLIB_OBJS_EXP) $(ENET_TARGET) $(DUKE3D_MISCDEPS)
408
	$(LINK_STATUS)
4543 hendricks2 409
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(DUKE3D_LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(RECIPE_RESULT_LINK)
3422 helixhorne 410
ifneq ($(STRIP),)
411
	$(STRIP) $(EDUKE32)
1101 terminx 412
endif
2385 hendricks2 413
ifeq ($(PLATFORM),DARWIN)
3551 terminx 414
	cp -RPf "platform/Apple/bundles/EDuke32.app" "./"
2388 helixhorne 415
	mkdir -p "EDuke32.app/Contents/MacOS"
3096 hendricks2 416
	cp -f "$(EDUKE32)" "EDuke32.app/Contents/MacOS/"
2385 hendricks2 417
endif
1595 helixhorne 418
 
4555 hendricks2 419
$(MAPSTER32): $(DUKE3D_EDITOR_OBJS_EXP) $(COMMON_EDITOR_OBJS_EXP) $(ENGINE_EDITOR_OBJS_EXP) $(ENGINE_OBJS_EXP) $(AUDIOLIB_OBJS_EXP) $(DUKE3D_EDITOR_MISCDEPS)
1102 terminx 420
	$(LINK_STATUS)
4543 hendricks2 421
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(DUKE3D_EDITOR_LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(RECIPE_RESULT_LINK)
3422 helixhorne 422
ifneq ($(STRIP),)
423
	$(STRIP) $(MAPSTER32)
1693 helixhorne 424
endif
2385 hendricks2 425
ifeq ($(PLATFORM),DARWIN)
3551 terminx 426
	cp -RPf "platform/Apple/bundles/Mapster32.app" "./"
2388 helixhorne 427
	mkdir -p "Mapster32.app/Contents/MacOS"
3096 hendricks2 428
	cp -f "$(MAPSTER32)" "Mapster32.app/Contents/MacOS/"
2385 hendricks2 429
endif
5 Plagman 430
 
4555 hendricks2 431
 
5 Plagman 432
include Makefile.deps
4543 hendricks2 433
include $(ENGINE_ROOT)/Makefile.deps
5 Plagman 434
 
435
# RULES
3057 helixhorne 436
 
3551 terminx 437
$(EBACKTRACEDLL): platform/Windows/src/backtrace.c
3163 hendricks2 438
	$(COMPILE_STATUS)
4543 hendricks2 439
	$(RECIPE_IF) $(CC) $(CONLYFLAGS) -O2 -ggdb -shared -Wall -Wextra -static-libgcc -I$(ENGINE_INC) -o $@ $^ -lbfd -liberty -limagehlp $(RECIPE_RESULT_COMPILE)
2037 helixhorne 440
 
4543 hendricks2 441
libcache1d$(DLLSUFFIX): $(ENGINE_SRC)/cache1d.c
1102 terminx 442
	$(COMPILE_STATUS)
4543 hendricks2 443
	$(RECIPE_IF) $(COMPILER) -Wall -Wextra -DCACHE1D_COMPRESS_ONLY -shared -fPIC $< -o $@ $(RECIPE_RESULT_COMPILE)
1693 helixhorne 444
 
4543 hendricks2 445
%$(EXESUFFIX): $(ENGINE_OBJ)/%.$o $(UTIL_OBJS_EXP)
446
	$(ONESTEP_STATUS)
447
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) $(RECIPE_RESULT_ONESTEP)
1101 terminx 448
 
4543 hendricks2 449
%$(EXESUFFIX): $(DUKE3D_OBJ)/%.$o
450
	$(ONESTEP_STATUS)
451
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) $(RECIPE_RESULT_ONESTEP)
4194 helixhorne 452
 
4543 hendricks2 453
enumdisplay$(EXESUFFIX): $(ENGINE_OBJ)/enumdisplay.$o
454
	$(ONESTEP_STATUS)
455
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) -lgdi32 $(RECIPE_RESULT_ONESTEP)
456
getdxdidf$(EXESUFFIX): $(ENGINE_OBJ)/getdxdidf.$o
457
	$(ONESTEP_STATUS)
458
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) -ldinput $(RECIPE_RESULT_ONESTEP)
459
makesdlkeytrans$(EXESUFFIX): $(ENGINE_OBJ)/makesdlkeytrans.$o
460
	$(ONESTEP_STATUS)
461
	$(RECIPE_IF) $(LINKER) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(UTIL_LIBS) $(SDL_INCLUDES) $(RECIPE_RESULT_ONESTEP)
462
arttool$(EXESUFFIX): $(ENGINE_OBJ)/arttool.$o
463
	$(ONESTEP_STATUS)
4547 hendricks2 464
	$(RECIPE_IF) $(L_CXX) $(CPPONLYFLAGS) -o $@ $^ $(COMMONFLAGS) $(LINKERFLAGS) $(LIBDIRS) $(LIBS) $(STATICSTDCPP) $(STDCPPLIB) $(UTIL_LIBS) $(RECIPE_RESULT_ONESTEP)
4194 helixhorne 465
 
3057 helixhorne 466
#### Lunatic
467
 
2650 helixhorne 468
# Create object files directly with luajit
4543 hendricks2 469
$(DUKE3D_OBJ)/luaJIT_BC_%.$o: source/lunatic/%.lua
2650 helixhorne 470
	$(COMPILE_STATUS)
4543 hendricks2 471
	$(RECIPE_IF) $(LUAJIT) -bg $(LUAJIT_BCOPTS) $< $@ $(RECIPE_RESULT_COMPILE)
2650 helixhorne 472
 
4238 helixhorne 473
# Same thing for defs*.ilua which I'm too reluctant to rename now:
4000 helixhorne 474
# NOTE: The target path must match EXACTLY with that of the DEFS_BC_SIZE
475
# determination in Makefile.common, because it is embedded into the bytecode as
476
# debugging information.
4543 hendricks2 477
$(DUKE3D_OBJ)/luaJIT_BC_%.$o: source/lunatic/%.ilua
478
	$(RECIPE_IF) $(LUAJIT) -bg $(LUAJIT_BCOPTS) $< $@ $(RECIPE_RESULT_COMPILE)
3517 helixhorne 479
 
4543 hendricks2 480
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/lunatic/%.c
2034 helixhorne 481
	$(COMPILE_STATUS)
4555 hendricks2 482
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
2034 helixhorne 483
 
3057 helixhorne 484
# TODO: _m32
485
# List of exported symbols, OS X
4543 hendricks2 486
$(DUKE3D_SRC)/lunatic/dynsymlist_osx: $(DUKE3D_SRC)/lunatic/dynsymlist
2074 helixhorne 487
	sed 's/[{};]//g;s/[A-Za-z_][A-Za-z_0-9]*/_&/g' $< > $@
488
 
4543 hendricks2 489
#$(DUKE3D_SRC)/lunatic/aliases_list: $(DUKE3D_SRC)/lunatic/dynsymlist_osx
3057 helixhorne 490
#	sed 's/_\([A-Za-z_][A-Za-z_0-9]*\)/_\1 \1/g' $< > $@
2074 helixhorne 491
 
3057 helixhorne 492
# List of exported symbols, Windows
4543 hendricks2 493
$(DUKE3D_SRC)/lunatic/eduke32.def: $(DUKE3D_SRC)/lunatic/dynsymlist
2143 helixhorne 494
	echo EXPORTS > $@
495
	sed 's/[{};]//g' $< >> $@
496
 
4543 hendricks2 497
$(DUKE3D_SRC)/lunatic/mapster32.def: $(DUKE3D_SRC)/lunatic/dynsymlist_m32
3248 helixhorne 498
	echo EXPORTS > $@
499
	sed 's/[{};]//g' $< >> $@
500
 
3057 helixhorne 501
####
502
 
4553 hendricks2 503
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.nasm | $(ENGINE_OBJ)
1905 helixhorne 504
	$(COMPILE_STATUS)
4543 hendricks2 505
	$(RECIPE_IF) $(AS) $(ASFLAGS) $< -o $@ $(RECIPE_RESULT_COMPILE)
1905 helixhorne 506
 
4553 hendricks2 507
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.yasm | $(ENGINE_OBJ)
3334 hendricks2 508
	$(COMPILE_STATUS)
4543 hendricks2 509
	$(RECIPE_IF) $(AS) $(ASFLAGS) $< -o $@ $(RECIPE_RESULT_COMPILE)
3334 hendricks2 510
 
4543 hendricks2 511
# Comment out the following rule to debug a-c.o
4553 hendricks2 512
$(ENGINE_OBJ)/a-c.$o: $(ENGINE_SRC)/a-c.c | $(ENGINE_OBJ)
2458 hendricks2 513
	$(COMPILE_STATUS)
4543 hendricks2 514
	$(RECIPE_IF) $(COMPILER) $(subst -O$(OPTLEVEL),-O2,$(subst $(CLANG_DEBUG_FLAGS),,$(COMMONFLAGS) $(COMPILERFLAGS))) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
2458 hendricks2 515
 
4553 hendricks2 516
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.c | $(ENGINE_OBJ)
1102 terminx 517
	$(COMPILE_STATUS)
4543 hendricks2 518
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
1101 terminx 519
 
4553 hendricks2 520
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.m | $(ENGINE_OBJ)
1102 terminx 521
	$(COMPILE_STATUS)
4644 hendricks2 522
	$(RECIPE_IF) $(COMPILER_OBJC) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
220 terminx 523
 
4553 hendricks2 524
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/%.cpp | $(ENGINE_OBJ)
1102 terminx 525
	$(COMPILE_STATUS)
4547 hendricks2 526
	$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
220 terminx 527
 
4553 hendricks2 528
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/misc/%.c | $(ENGINE_OBJ)
1102 terminx 529
	$(COMPILE_STATUS)
4543 hendricks2 530
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
1595 helixhorne 531
 
4553 hendricks2 532
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.c | $(ENGINE_OBJ)
1765 plagman 533
	$(COMPILE_STATUS)
4543 hendricks2 534
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
1765 plagman 535
 
4553 hendricks2 536
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.cpp | $(ENGINE_OBJ)
4543 hendricks2 537
	$(COMPILE_STATUS)
4547 hendricks2 538
	$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 539
 
4553 hendricks2 540
$(ENGINE_OBJ)/%.$o: $(ENGINE_SRC)/util/%.cc | $(ENGINE_OBJ)
4543 hendricks2 541
	$(COMPILE_STATUS)
4547 hendricks2 542
	$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENGINE_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 543
 
4553 hendricks2 544
$(ENGINE_OBJ)/%.$o: $(DUKE3D_RSRC)/%.c | $(ENGINE_OBJ)
4543 hendricks2 545
	$(COMPILE_STATUS)
546
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
547
 
548
$(AUDIOLIB_OBJ)/%.o: $(AUDIOLIB_SRC)/%.c | $(AUDIOLIB_OBJ)
549
	$(COMPILE_STATUS)
550
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(AUDIOLIB_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
551
 
552
$(ENET_OBJ)/%.o: $(ENET_SRC)/%.c $(ENET_INC)/enet/*.h | $(ENET_OBJ)
553
	$(COMPILE_STATUS)
554
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(ENET_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
555
 
4555 hendricks2 556
$(TESTGAME_OBJ)/%.$o: $(TESTGAME_SRC)/%.c | $(TESTGAME_OBJ)
557
	$(COMPILE_STATUS)
558
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(TESTGAME_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
559
 
560
$(TESTGAME_OBJ)/%.$o: $(TESTGAME_RSRC)/%.rc | $(TESTGAME_OBJ)
561
	$(COMPILE_STATUS)
562
	$(RECIPE_IF) $(RC) -i $< -o $@ --include-dir=$(ENGINE_INC) --include-dir=$(TESTGAME_SRC) --include-dir=$(TESTGAME_RSRC) $(RECIPE_RESULT_COMPILE)
563
 
564
$(TESTGAME_OBJ)/%.$o: $(TESTGAME_RSRC)/%.c | $(TESTGAME_OBJ)
565
	$(COMPILE_STATUS)
4558 hendricks2 566
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(TESTGAME_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4555 hendricks2 567
 
568
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.c | $(DUKE3D_OBJ)
569
	$(COMPILE_STATUS)
570
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
571
 
4565 hendricks2 572
$(DUKE3D_OBJ)/rev.$o: $(DUKE3D_SRC)/rev.c | $(DUKE3D_OBJ)
573
	$(COMPILE_STATUS)
574
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) $(REVFLAG) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
575
 
4555 hendricks2 576
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/util/%.c | $(DUKE3D_OBJ)
577
	$(COMPILE_STATUS)
578
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
579
 
4553 hendricks2 580
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.m | $(DUKE3D_OBJ)
4543 hendricks2 581
	$(COMPILE_STATUS)
4644 hendricks2 582
	$(RECIPE_IF) $(COMPILER_OBJC) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 583
 
4553 hendricks2 584
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/%.cpp | $(DUKE3D_OBJ)
4543 hendricks2 585
	$(COMPILE_STATUS)
4555 hendricks2 586
	$(RECIPE_IF) $(CXX) $(CPPONLYFLAGS) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 587
 
4553 hendricks2 588
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/jmact/%.c | $(DUKE3D_OBJ)
4543 hendricks2 589
	$(COMPILE_STATUS)
4555 hendricks2 590
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 591
 
4553 hendricks2 592
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_SRC)/misc/%.rc | $(DUKE3D_OBJ)
4543 hendricks2 593
	$(COMPILE_STATUS)
4555 hendricks2 594
	$(RECIPE_IF) $(RC) -i $< -o $@ --include-dir=$(ENGINE_INC) --include-dir=$(DUKE3D_SRC) --include-dir=$(DUKE3D_RSRC) -DPOLYMER=$(POLYMER) $(RECIPE_RESULT_COMPILE)
4543 hendricks2 595
 
4553 hendricks2 596
$(DUKE3D_OBJ)/%.$o: $(DUKE3D_RSRC)/%.c | $(DUKE3D_OBJ)
4543 hendricks2 597
	$(COMPILE_STATUS)
4558 hendricks2 598
	$(RECIPE_IF) $(COMPILER) $(COMMONFLAGS) $(COMPILERFLAGS) $(DUKE3D_CFLAGS) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
4543 hendricks2 599
 
600
$(DUKE3D_RSRC)/game_banner.c: $(DUKE3D_RSRC)/game.bmp
5 Plagman 601
	echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
3137 Plagman 602
	echo "extern const GdkPixdata startbanner_pixdata;" >> $@
5 Plagman 603
	gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
4543 hendricks2 604
$(DUKE3D_RSRC)/editor_banner.c: $(DUKE3D_RSRC)/build.bmp
5 Plagman 605
	echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $@
3137 Plagman 606
	echo "extern const GdkPixdata startbanner_pixdata;" >> $@
5 Plagman 607
	gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
608
 
4555 hendricks2 609
$(ENGINE_OBJ) $(AUDIOLIB_OBJ) $(ENET_OBJ) $(DUKE3D_OBJ) $(TESTGAME_OBJ):
4553 hendricks2 610
	mkdir $@
611
 
3163 hendricks2 612
# PHONIES
996 terminx 613
 
4565 hendricks2 614
clean:
4591 helixhorne 615
	-rm -f $(EDUKE32) $(MAPSTER32) $(LUNATIC_OBJS_EXP) $(COMMON_OBJS_EXP) $(DUKE3D_OBJS_EXP) $(COMMON_EDITOR_OBJS_EXP) $(DUKE3D_EDITOR_OBJS_EXP) $(DUKE3D_MISCDEPS) $(DUKE3D_EDITOR_MISCDEPS) core*
2388 helixhorne 616
ifeq ($(PLATFORM),DARWIN)
617
	-rm -rf EDuke32.app Mapster32.app
618
endif
5 Plagman 619
 
4555 hendricks2 620
cleantest:
621
	-rm -f $(TESTGAME) $(TESTEDITOR) $(TESTGAME_OBJS_EXP) $(TESTEDITOR_OBJS_EXP)
622
 
3163 hendricks2 623
cleanutils:
4543 hendricks2 624
	-rm -f $(addsuffix $(EXESUFFIX),$(UTILS) $(GAMEUTILS)) $(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(UTILS))) $(addprefix $(DUKE3D_OBJ)/,$(addsuffix .$o,$(GAMEUTILS))) $(addsuffix $(EXESUFFIX),$(DXUTILS)) $(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(DXUTILS))) $(addsuffix $(EXESUFFIX),$(SDLUTILS)) $(addprefix $(ENGINE_OBJ)/,$(addsuffix .$o,$(SDLUTILS))) $(UTIL_OBJS_EXP)
3163 hendricks2 625
 
626
veryclean: clean cleanutils
4543 hendricks2 627
	-rm -f $(ENGINE_EDITOR_OBJS_EXP) $(ENGINE_OBJS_EXP) $(AUDIOLIB_OBJS_EXP) $(ENET_OBJS_EXP) $(DUKE3D_RSRC)/*banner* $(EBACKTRACEDLL)
3163 hendricks2 628
 
629
printutils:
4543 hendricks2 630
	echo "$(addsuffix $(EXESUFFIX),$(UTILS) $(GAMEUTILS))"
4343 hendricks2 631
 
4543 hendricks2 632
printdxutils:
633
	echo "$(addsuffix $(EXESUFFIX),$(DXUTILS))"
634
 
635
printsdlutils:
636
	echo "$(addsuffix $(EXESUFFIX),$(SDLUTILS))"
637
 
4565 hendricks2 638
rev: $(DUKE3D_OBJ)/rev.$o