make the makefile a bit more customizable
[divverent/netradiant.git] / Makefile
1 -include Makefile.conf
2
3 ## CONFIGURATION SETTINGS
4 # user customizable stuf
5 # you may override this in Makefile.conf or the environment
6 BUILD              ?= debug
7 # or: release
8 OS                 ?= $(shell uname)
9 # or: Linux, Win32, Darwin
10 CFLAGS             ?=
11 CXXFLAGS           ?=
12 CPPFLAGS           ?=
13 LIBS               ?=
14 RADIANT_ABOUTMSG   ?= Custom build
15 CC                 ?= gcc
16 CXX                ?= g++
17 LDD                ?= ldd # nothing on Win32
18 FIND               ?= find
19 RANLIB             ?= ranlib
20 AR                 ?= ar
21 MKDIR              ?= mkdir -p
22 CP                 ?= cp
23 CAT                ?= cat
24 SH                 ?= sh
25 ECHO               ?= echo
26 DIFF               ?= diff
27 CP_R               ?= $(CP) -r
28 RM_R               ?= $(RM) -r
29 PKGCONFIG          ?= pkg-config
30 TEE_STDERR         ?= | tee /dev/stderr
31 CPPFLAGS_GLIB      ?= `$(PKGCONFIG) glib-2.0 --cflags`
32 LIBS_GLIB          ?= `$(PKGCONFIG) glib-2.0 --libs-only-L` `pkg-config glib-2.0 --libs-only-l`
33 CPPFLAGS_XML       ?= `$(PKGCONFIG) libxml-2.0 --cflags`
34 LIBS_XML           ?= `$(PKGCONFIG) libxml-2.0 --libs-only-L` `pkg-config libxml-2.0 --libs-only-l`
35 CPPFLAGS_PNG       ?= `$(PKGCONFIG) libpng --cflags`
36 LIBS_PNG           ?= `$(PKGCONFIG) libpng --libs-only-L` `pkg-config libpng --libs-only-l`
37 CPPFLAGS_GTK       ?= `$(PKGCONFIG) gtk+-2.0 --cflags`
38 LIBS_GTK           ?= `$(PKGCONFIG) gtk+-2.0 --libs-only-L` `pkg-config gtk+-2.0 --libs-only-l`
39 CPPFLAGS_GTKGLEXT  ?= `$(PKGCONFIG) gtkglext-1.0 --cflags`
40 LIBS_GTKGLEXT      ?= `$(PKGCONFIG) gtkglext-1.0 --libs-only-L` `pkg-config gtkglext-1.0 --libs-only-l`
41 CPPFLAGS_GL        ?=
42 LIBS_GL            ?= -lGL # -lopengl32 on Win32
43 CPPFLAGS_DL        ?=
44 LIBS_DL            ?= -ldl # nothing on Win32
45 CPPFLAGS_ZLIB      ?=
46 LIBS_ZLIB          ?= -lz
47 DEPEND_ON_MAKEFILE ?= yes
48
49 # these are used on Win32 only
50 GTKDIR             ?= `$(PKGCONFIG) gtk+-2.0 --variable=prefix`
51 WHICHDLL           ?= which
52
53 # alias mingw32 OSes
54 ifeq ($(OS),MINGW32_NT-6.0)
55         OS = Win32
56 endif
57
58 CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter
59 CPPFLAGS_COMMON =
60 LDFLAGS_COMMON =
61 LIBS_COMMON =
62 CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
63
64 ifeq ($(BUILD),debug)
65         CFLAGS_COMMON += -g3
66         CPPFLAGS_COMMON += -D_DEBUG
67         LDFLAGS_COMMON +=
68 else ifeq ($(BUILD),release)
69         CFLAGS_COMMON += -O3
70         CPPFLAGS_COMMON +=
71         LDFLAGS_COMMON += -s
72 else
73 $(error Unsupported build type: $(BUILD))
74 endif
75
76 ifeq ($(OS),Linux)
77         CPPFLAGS_COMMON += -DPOSIX -DXWINDOWS -D_LINUX
78         CFLAGS_COMMON += -fPIC
79         LDFLAGS_DLL = -fPIC -ldl
80         LIBS_COMMON = -lpthread
81         EXE = x86
82         A = a
83         DLL = so
84         MWINDOWS =
85 else ifeq ($(OS),Win32)
86         CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline
87         CFLAGS_COMMON += -mms-bitfields
88         LDFLAGS_DLL = --dll -Wl,--add-stdcall-alias
89         LIBS_COMMON = -lws2_32 -luser32 -lgdi32
90         EXE = exe
91         A = a
92         DLL = dll
93         MWINDOWS = -mwindows
94
95         # workaround: we have no "ldd" for Win32, so...
96         LDD =
97         # workaround: OpenGL library for Win32 is called opengl32.dll
98         LIBS_GL ?= -lopengl32
99         # workaround: no -ldl on Win32
100         LIBS_DL ?= 
101 #else ifeq ($(OS),Darwin)
102 #       EXE = ppc
103 else
104 $(error Unsupported build OS: $(OS))
105 endif
106
107 .PHONY: all
108 all: \
109         makeversion \
110         install/heretic2/h2data.$(EXE) \
111         install/modules/archivepak.$(DLL) \
112         install/modules/archivewad.$(DLL) \
113         install/modules/archivezip.$(DLL) \
114         install/modules/entity.$(DLL) \
115         install/modules/image.$(DLL) \
116         install/modules/imagehl.$(DLL) \
117         install/modules/imagepng.$(DLL) \
118         install/modules/imageq2.$(DLL) \
119         install/modules/mapq3.$(DLL) \
120         install/modules/mapxml.$(DLL) \
121         install/modules/md3model.$(DLL) \
122         install/modules/model.$(DLL) \
123         install/modules/shaders.$(DLL) \
124         install/modules/vfspk3.$(DLL) \
125         install/plugins/bobtoolz.$(DLL) \
126         install/plugins/brushexport.$(DLL) \
127         install/plugins/prtview.$(DLL) \
128         install/plugins/shaderplug.$(DLL) \
129         install/plugins/sunplug.$(DLL) \
130         install/plugins/ufoaiplug.$(DLL) \
131         install/q2map.$(EXE) \
132         install/q3data.$(EXE) \
133         install/q3map2.$(EXE) \
134         install/qdata3.$(EXE) \
135         install/radiant.$(EXE) \
136         install-data \
137         install-dll \
138
139 .PHONY: clean
140 clean:
141         $(RM_R) install/
142         $(FIND) . \( -name \*.o -o -name \*.d -o -name \*.$(DLL) -o -name \*.$(A) -o -name \*.$(EXE) \) -exec $(RM) {} \;
143         $(RM) include/aboutmsg.h include/RADIANT_MAJOR include/version.h include/RADIANT_MINOR include/version
144
145 %.$(EXE):
146         file=$@; $(MKDIR) $${file%/*}
147         $(CXX) $(LDFLAGS) $(LDFLAGS_COMMON) $(LDFLAGS_EXTRA) $(LIBS) $(LIBS_COMMON) $(LIBS_EXTRA) $^ -o $@
148         [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ 2>&1 >/dev/null $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
149
150 %.$(A):
151         $(AR) rc $@ $^
152         $(RANLIB) $@
153
154 %.$(DLL):
155         file=$@; $(MKDIR) $${file%/*}
156         $(CXX) $(LDFLAGS) $(LDFLAGS_COMMON) $(LDFLAGS_EXTRA) $(LDFLAGS_DLL) $(LIBS) $(LIBS_COMMON) $(LIBS_EXTRA) -shared $^ -o $@
157         [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ 2>&1 >/dev/null $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
158
159 %.o: %.cpp $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),)
160         $(CXX) $(CFLAGS) $(CXXFLAGS) $(CFLAGS_COMMON) $(CXXFLAGS_COMMON) $(CPPFLAGS) $(CPPFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(TARGET_ARCH) -c $< -o $@
161
162 %.o: %.c $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),)
163         $(CC) $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS) $(CPPFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(TARGET_ARCH) -c $< -o $@
164
165 install/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG)
166 install/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) -Itools/quake3/common -Ilibs -Iinclude
167 install/q3map2.$(EXE): \
168         tools/quake3/common/cmdlib.o \
169         tools/quake3/common/imagelib.o \
170         tools/quake3/common/inout.o \
171         tools/quake3/common/md4.o \
172         tools/quake3/common/mutex.o \
173         tools/quake3/common/polylib.o \
174         tools/quake3/common/scriplib.o \
175         tools/quake3/common/threads.o \
176         tools/quake3/common/unzip.o \
177         tools/quake3/common/vfs.o \
178         tools/quake3/q3map2/brush.o \
179         tools/quake3/q3map2/brush_primit.o \
180         tools/quake3/q3map2/bspfile_abstract.o \
181         tools/quake3/q3map2/bspfile_ibsp.o \
182         tools/quake3/q3map2/bspfile_rbsp.o \
183         tools/quake3/q3map2/bsp.o \
184         tools/quake3/q3map2/convert_ase.o \
185         tools/quake3/q3map2/convert_map.o \
186         tools/quake3/q3map2/decals.o \
187         tools/quake3/q3map2/facebsp.o \
188         tools/quake3/q3map2/fog.o \
189         tools/quake3/q3map2/image.o \
190         tools/quake3/q3map2/leakfile.o \
191         tools/quake3/q3map2/light_bounce.o \
192         tools/quake3/q3map2/lightmaps_ydnar.o \
193         tools/quake3/q3map2/light.o \
194         tools/quake3/q3map2/light_trace.o \
195         tools/quake3/q3map2/light_ydnar.o \
196         tools/quake3/q3map2/main.o \
197         tools/quake3/q3map2/map.o \
198         tools/quake3/q3map2/mesh.o \
199         tools/quake3/q3map2/model.o \
200         tools/quake3/q3map2/patch.o \
201         tools/quake3/q3map2/path_init.o \
202         tools/quake3/q3map2/portals.o \
203         tools/quake3/q3map2/prtfile.o \
204         tools/quake3/q3map2/shaders.o \
205         tools/quake3/q3map2/surface_extra.o \
206         tools/quake3/q3map2/surface_foliage.o \
207         tools/quake3/q3map2/surface_fur.o \
208         tools/quake3/q3map2/surface_meta.o \
209         tools/quake3/q3map2/surface.o \
210         tools/quake3/q3map2/tjunction.o \
211         tools/quake3/q3map2/tree.o \
212         tools/quake3/q3map2/visflow.o \
213         tools/quake3/q3map2/vis.o \
214         tools/quake3/q3map2/writebsp.o \
215         libddslib.$(A) \
216         libjpeg6.$(A) \
217         libl_net.$(A) \
218         libmathlib.$(A) \
219         libpicomodel.$(A) \
220
221 libmathlib.$(A): CPPFLAGS_EXTRA := -Ilibs
222 libmathlib.$(A): \
223         libs/mathlib/bbox.o \
224         libs/mathlib/line.o \
225         libs/mathlib/m4x4.o \
226         libs/mathlib/mathlib.o \
227         libs/mathlib/ray.o \
228
229 libl_net.$(A): CPPFLAGS_EXTRA := -Ilibs
230 libl_net.$(A): \
231         libs/l_net/l_net.o \
232         $(if $(findstring $(OS),Win32),libs/l_net/l_net_wins.o,libs/l_net/l_net_berkley.o) \
233
234 libjpeg6.$(A): CPPFLAGS_EXTRA := -Ilibs/jpeg6 -Ilibs
235 libjpeg6.$(A): \
236         libs/jpeg6/jcomapi.o \
237         libs/jpeg6/jdapimin.o \
238         libs/jpeg6/jdapistd.o \
239         libs/jpeg6/jdatasrc.o \
240         libs/jpeg6/jdcoefct.o \
241         libs/jpeg6/jdcolor.o \
242         libs/jpeg6/jddctmgr.o \
243         libs/jpeg6/jdhuff.o \
244         libs/jpeg6/jdinput.o \
245         libs/jpeg6/jdmainct.o \
246         libs/jpeg6/jdmarker.o \
247         libs/jpeg6/jdmaster.o \
248         libs/jpeg6/jdpostct.o \
249         libs/jpeg6/jdsample.o \
250         libs/jpeg6/jdtrans.o \
251         libs/jpeg6/jerror.o \
252         libs/jpeg6/jfdctflt.o \
253         libs/jpeg6/jidctflt.o \
254         libs/jpeg6/jmemmgr.o \
255         libs/jpeg6/jmemnobs.o \
256         libs/jpeg6/jpgload.o \
257         libs/jpeg6/jutils.o \
258
259 libpicomodel.$(A): CPPFLAGS_EXTRA := -Ilibs
260 libpicomodel.$(A): \
261         libs/picomodel/lwo/clip.o \
262         libs/picomodel/lwo/envelope.o \
263         libs/picomodel/lwo/list.o \
264         libs/picomodel/lwo/lwio.o \
265         libs/picomodel/lwo/lwo2.o \
266         libs/picomodel/lwo/lwob.o \
267         libs/picomodel/lwo/pntspols.o \
268         libs/picomodel/lwo/surface.o \
269         libs/picomodel/lwo/vecmath.o \
270         libs/picomodel/lwo/vmap.o \
271         libs/picomodel/picointernal.o \
272         libs/picomodel/picomodel.o \
273         libs/picomodel/picomodules.o \
274         libs/picomodel/pm_3ds.o \
275         libs/picomodel/pm_ase.o \
276         libs/picomodel/pm_fm.o \
277         libs/picomodel/pm_lwo.o \
278         libs/picomodel/pm_md2.o \
279         libs/picomodel/pm_md3.o \
280         libs/picomodel/pm_mdc.o \
281         libs/picomodel/pm_ms3d.o \
282         libs/picomodel/pm_obj.o \
283         libs/picomodel/pm_terrain.o \
284
285 libddslib.$(A): CPPFLAGS_EXTRA := -Ilibs
286 libddslib.$(A): \
287         libs/ddslib/ddslib.o \
288
289 install/q3data.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB)
290 install/q3data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Itools/quake3/common -Ilibs -Iinclude
291 install/q3data.$(EXE): \
292         tools/quake3/common/aselib.o \
293         tools/quake3/common/bspfile.o \
294         tools/quake3/common/cmdlib.o \
295         tools/quake3/common/imagelib.o \
296         tools/quake3/common/inout.o \
297         tools/quake3/common/md4.o \
298         tools/quake3/common/scriplib.o \
299         tools/quake3/common/trilib.o \
300         tools/quake3/common/unzip.o \
301         tools/quake3/common/vfs.o \
302         tools/quake3/q3data/3dslib.o \
303         tools/quake3/q3data/compress.o \
304         tools/quake3/q3data/images.o \
305         tools/quake3/q3data/md3lib.o \
306         tools/quake3/q3data/models.o \
307         tools/quake3/q3data/p3dlib.o \
308         tools/quake3/q3data/polyset.o \
309         tools/quake3/q3data/q3data.o \
310         tools/quake3/q3data/stripper.o \
311         tools/quake3/q3data/video.o \
312         libl_net.$(A) \
313         libmathlib.$(A) \
314
315 install/radiant.$(EXE): LDFLAGS_EXTRA := $(MWINDOWS)
316 install/radiant.$(EXE): LIBS_EXTRA := $(LIBS_GL) $(LIBS_DL) $(LIBS_XML) $(LIBS_GLIB) $(LIBS_GTK) $(LIBS_GTKGLEXT)
317 install/radiant.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_GL) $(CPPFLAGS_DL) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
318 install/radiant.$(EXE): \
319         radiant/autosave.o \
320         radiant/brushmanip.o \
321         radiant/brushmodule.o \
322         radiant/brushnode.o \
323         radiant/brush.o \
324         radiant/brush_primit.o \
325         radiant/brushtokens.o \
326         radiant/brushxml.o \
327         radiant/build.o \
328         radiant/camwindow.o \
329         radiant/clippertool.o \
330         radiant/commands.o \
331         radiant/console.o \
332         radiant/csg.o \
333         radiant/dialog.o \
334         radiant/eclass_def.o \
335         radiant/eclass_doom3.o \
336         radiant/eclass_fgd.o \
337         radiant/eclass.o \
338         radiant/eclass_xml.o \
339         radiant/entityinspector.o \
340         radiant/entitylist.o \
341         radiant/entity.o \
342         radiant/environment.o \
343         radiant/error.o \
344         radiant/feedback.o \
345         radiant/filetypes.o \
346         radiant/filters.o \
347         radiant/findtexturedialog.o \
348         radiant/glwidget.o \
349         radiant/grid.o \
350         radiant/groupdialog.o \
351         radiant/gtkdlgs.o \
352         radiant/gtkmisc.o \
353         radiant/help.o \
354         radiant/image.o \
355         radiant/mainframe.o \
356         radiant/main.o \
357         radiant/map.o \
358         $(if $(findstring $(OS),Win32),radiant/multimon.o,) \
359         radiant/mru.o \
360         radiant/nullmodel.o \
361         radiant/parse.o \
362         radiant/patchdialog.o \
363         radiant/patchmanip.o \
364         radiant/patchmodule.o \
365         radiant/patch.o \
366         radiant/pluginapi.o \
367         radiant/pluginmanager.o \
368         radiant/pluginmenu.o \
369         radiant/plugin.o \
370         radiant/plugintoolbar.o \
371         radiant/points.o \
372         radiant/preferencedictionary.o \
373         radiant/preferences.o \
374         radiant/qe3.o \
375         radiant/qgl.o \
376         radiant/referencecache.o \
377         radiant/renderer.o \
378         radiant/renderstate.o \
379         radiant/scenegraph.o \
380         radiant/selection.o \
381         radiant/select.o \
382         radiant/server.o \
383         radiant/shaders.o \
384         radiant/sockets.o \
385         radiant/stacktrace.o \
386         radiant/surfacedialog.o \
387         radiant/texmanip.o \
388         radiant/textures.o \
389         radiant/texwindow.o \
390         radiant/timer.o \
391         radiant/treemodel.o \
392         radiant/undo.o \
393         radiant/url.o \
394         radiant/view.o \
395         radiant/watchbsp.o \
396         radiant/winding.o \
397         radiant/windowobservers.o \
398         radiant/xmlstuff.o \
399         radiant/xywindow.o \
400         libcmdlib.$(A) \
401         libgtkutil.$(A) \
402         libl_net.$(A) \
403         libmathlib.$(A) \
404         libprofile.$(A) \
405         libxmllib.$(A) \
406
407 libcmdlib.$(A): CPPFLAGS_EXTRA := -Ilibs
408 libcmdlib.$(A): \
409         libs/cmdlib/cmdlib.o \
410
411 libprofile.$(A): CPPFLAGS_EXTRA := -Ilibs -Iinclude
412 libprofile.$(A): \
413         libs/profile/file.o \
414         libs/profile/profile.o \
415
416 libgtkutil.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
417 libgtkutil.$(A): \
418         libs/gtkutil/accelerator.o \
419         libs/gtkutil/button.o \
420         libs/gtkutil/clipboard.o \
421         libs/gtkutil/closure.o \
422         libs/gtkutil/container.o \
423         libs/gtkutil/cursor.o \
424         libs/gtkutil/dialog.o \
425         libs/gtkutil/entry.o \
426         libs/gtkutil/filechooser.o \
427         libs/gtkutil/frame.o \
428         libs/gtkutil/glfont.o \
429         libs/gtkutil/glwidget.o \
430         libs/gtkutil/idledraw.o \
431         libs/gtkutil/image.o \
432         libs/gtkutil/menu.o \
433         libs/gtkutil/messagebox.o \
434         libs/gtkutil/nonmodal.o \
435         libs/gtkutil/paned.o \
436         libs/gtkutil/pointer.o \
437         libs/gtkutil/toolbar.o \
438         libs/gtkutil/widget.o \
439         libs/gtkutil/window.o \
440         libs/gtkutil/xorrectangle.o \
441
442 libxmllib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
443 libxmllib.$(A): \
444         libs/xml/ixml.o \
445         libs/xml/xmlelement.o \
446         libs/xml/xmlparser.o \
447         libs/xml/xmltextags.o \
448         libs/xml/xmlwriter.o \
449
450 install/modules/archivezip.$(DLL): LIBS_EXTRA := $(LIBS_ZLIB)
451 install/modules/archivezip.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_ZLIB) -Ilibs -Iinclude
452 install/modules/archivezip.$(DLL): \
453         plugins/archivezip/archive.o \
454         plugins/archivezip/pkzip.o \
455         plugins/archivezip/plugin.o \
456         plugins/archivezip/zlibstream.o \
457
458 install/modules/archivewad.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
459 install/modules/archivewad.$(DLL): \
460         plugins/archivewad/archive.o \
461         plugins/archivewad/plugin.o \
462         plugins/archivewad/wad.o \
463
464 install/modules/archivepak.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
465 install/modules/archivepak.$(DLL): \
466         plugins/archivepak/archive.o \
467         plugins/archivepak/pak.o \
468         plugins/archivepak/plugin.o \
469
470 install/modules/entity.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
471 install/modules/entity.$(DLL): \
472         plugins/entity/angle.o \
473         plugins/entity/angles.o \
474         plugins/entity/colour.o \
475         plugins/entity/doom3group.o \
476         plugins/entity/eclassmodel.o \
477         plugins/entity/entity.o \
478         plugins/entity/filters.o \
479         plugins/entity/generic.o \
480         plugins/entity/group.o \
481         plugins/entity/light.o \
482         plugins/entity/miscmodel.o \
483         plugins/entity/model.o \
484         plugins/entity/modelskinkey.o \
485         plugins/entity/namedentity.o \
486         plugins/entity/origin.o \
487         plugins/entity/plugin.o \
488         plugins/entity/rotation.o \
489         plugins/entity/scale.o \
490         plugins/entity/skincache.o \
491         plugins/entity/targetable.o \
492
493 install/modules/image.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
494 install/modules/image.$(DLL): \
495         plugins/image/bmp.o \
496         plugins/image/dds.o \
497         plugins/image/image.o \
498         plugins/image/jpeg.o \
499         plugins/image/pcx.o \
500         plugins/image/tga.o \
501         libddslib.$(A) \
502         libjpeg6.$(A) \
503
504 install/modules/imageq2.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
505 install/modules/imageq2.$(DLL): \
506         plugins/imageq2/imageq2.o \
507         plugins/imageq2/wal32.o \
508         plugins/imageq2/wal.o \
509
510 install/modules/imagehl.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
511 install/modules/imagehl.$(DLL): \
512         plugins/imagehl/hlw.o \
513         plugins/imagehl/imagehl.o \
514         plugins/imagehl/mip.o \
515         plugins/imagehl/sprite.o \
516
517 install/modules/imagepng.$(DLL): LIBS_EXTRA := $(LIBS_PNG)
518 install/modules/imagepng.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_PNG) -Ilibs -Iinclude
519 install/modules/imagepng.$(DLL): \
520         plugins/imagepng/plugin.o \
521
522 install/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
523 install/modules/mapq3.$(DLL): \
524         plugins/mapq3/parse.o \
525         plugins/mapq3/plugin.o \
526         plugins/mapq3/write.o \
527
528 install/modules/mapxml.$(DLL): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB)
529 install/modules/mapxml.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
530 install/modules/mapxml.$(DLL): \
531         plugins/mapxml/plugin.o \
532         plugins/mapxml/xmlparse.o \
533         plugins/mapxml/xmlwrite.o \
534
535 install/modules/md3model.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
536 install/modules/md3model.$(DLL): \
537         plugins/md3model/md2.o \
538         plugins/md3model/md3.o \
539         plugins/md3model/md5.o \
540         plugins/md3model/mdc.o \
541         plugins/md3model/mdlimage.o \
542         plugins/md3model/mdl.o \
543         plugins/md3model/plugin.o \
544
545 install/modules/model.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
546 install/modules/model.$(DLL): \
547         plugins/model/model.o \
548         plugins/model/plugin.o \
549         libpicomodel.$(A) \
550
551 install/modules/shaders.$(DLL): LIBS_EXTRA := $(LIBS_GLIB)
552 install/modules/shaders.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
553 install/modules/shaders.$(DLL): \
554         plugins/shaders/plugin.o \
555         plugins/shaders/shaders.o \
556
557 install/modules/vfspk3.$(DLL): LIBS_EXTRA := $(LIBS_GLIB)
558 install/modules/vfspk3.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
559 install/modules/vfspk3.$(DLL): \
560         plugins/vfspk3/archive.o \
561         plugins/vfspk3/vfs.o \
562         plugins/vfspk3/vfspk3.o \
563
564 install/plugins/bobtoolz.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
565 install/plugins/bobtoolz.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
566 install/plugins/bobtoolz.$(DLL): \
567         contrib/bobtoolz/bobToolz-GTK.o \
568         contrib/bobtoolz/bsploader.o \
569         contrib/bobtoolz/cportals.o \
570         contrib/bobtoolz/DBobView.o \
571         contrib/bobtoolz/DBrush.o \
572         contrib/bobtoolz/DEntity.o \
573         contrib/bobtoolz/DEPair.o \
574         contrib/bobtoolz/dialogs/dialogs-gtk.o \
575         contrib/bobtoolz/DMap.o \
576         contrib/bobtoolz/DPatch.o \
577         contrib/bobtoolz/DPlane.o \
578         contrib/bobtoolz/DPoint.o \
579         contrib/bobtoolz/DShape.o \
580         contrib/bobtoolz/DTrainDrawer.o \
581         contrib/bobtoolz/DTreePlanter.o \
582         contrib/bobtoolz/DVisDrawer.o \
583         contrib/bobtoolz/DWinding.o \
584         contrib/bobtoolz/funchandlers-GTK.o \
585         contrib/bobtoolz/lists.o \
586         contrib/bobtoolz/misc.o \
587         contrib/bobtoolz/ScriptParser.o \
588         contrib/bobtoolz/shapes.o \
589         contrib/bobtoolz/visfind.o \
590         libcmdlib.$(A) \
591         libmathlib.$(A) \
592         libprofile.$(A) \
593
594 install/plugins/brushexport.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
595 install/plugins/brushexport.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
596 install/plugins/brushexport.$(DLL): \
597         contrib/brushexport/callbacks.o \
598         contrib/brushexport/export.o \
599         contrib/brushexport/interface.o \
600         contrib/brushexport/plugin.o \
601         contrib/brushexport/support.o \
602
603 install/plugins/prtview.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
604 install/plugins/prtview.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
605 install/plugins/prtview.$(DLL): \
606         contrib/prtview/AboutDialog.o \
607         contrib/prtview/ConfigDialog.o \
608         contrib/prtview/LoadPortalFileDialog.o \
609         contrib/prtview/portals.o \
610         contrib/prtview/prtview.o \
611         libprofile.$(A) \
612
613 install/plugins/shaderplug.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK) $(LIBS_XML)
614 install/plugins/shaderplug.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_XML) -Ilibs -Iinclude
615 install/plugins/shaderplug.$(DLL): \
616         contrib/shaderplug/shaderplug.o \
617         libxmllib.$(A) \
618
619 install/plugins/sunplug.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
620 install/plugins/sunplug.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
621 install/plugins/sunplug.$(DLL): \
622         contrib/sunplug/sunplug.o \
623
624 install/qdata3.$(EXE): LIBS_EXTRA := $(LIBS_XML)
625 install/qdata3.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/quake2/common -Ilibs -Iinclude
626 install/qdata3.$(EXE): \
627         tools/quake2/common/bspfile.o \
628         tools/quake2/common/cmdlib.o \
629         tools/quake2/common/inout.o \
630         tools/quake2/common/l3dslib.o \
631         tools/quake2/common/lbmlib.o \
632         tools/quake2/common/mathlib.o \
633         tools/quake2/common/md4.o \
634         tools/quake2/common/path_init.o \
635         tools/quake2/common/polylib.o \
636         tools/quake2/common/scriplib.o \
637         tools/quake2/common/threads.o \
638         tools/quake2/common/trilib.o \
639         tools/quake2/qdata/images.o \
640         tools/quake2/qdata/models.o \
641         tools/quake2/qdata/qdata.o \
642         tools/quake2/qdata/sprites.o \
643         tools/quake2/qdata/tables.o \
644         tools/quake2/qdata/video.o \
645         libl_net.$(A) \
646
647 install/q2map.$(EXE): LIBS_EXTRA := $(LIBS_XML)
648 install/q2map.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/quake2/common -Ilibs -Iinclude
649 install/q2map.$(EXE): \
650         tools/quake2/common/bspfile.o \
651         tools/quake2/common/cmdlib.o \
652         tools/quake2/common/inout.o \
653         tools/quake2/common/l3dslib.o \
654         tools/quake2/common/lbmlib.o \
655         tools/quake2/common/mathlib.o \
656         tools/quake2/common/md4.o \
657         tools/quake2/common/path_init.o \
658         tools/quake2/common/polylib.o \
659         tools/quake2/common/scriplib.o \
660         tools/quake2/common/threads.o \
661         tools/quake2/common/trilib.o \
662         tools/quake2/q2map/brushbsp.o \
663         tools/quake2/q2map/csg.o \
664         tools/quake2/q2map/faces.o \
665         tools/quake2/q2map/flow.o \
666         tools/quake2/q2map/glfile.o \
667         tools/quake2/q2map/leakfile.o \
668         tools/quake2/q2map/lightmap.o \
669         tools/quake2/q2map/main.o \
670         tools/quake2/q2map/map.o \
671         tools/quake2/q2map/nodraw.o \
672         tools/quake2/q2map/patches.o \
673         tools/quake2/q2map/portals.o \
674         tools/quake2/q2map/prtfile.o \
675         tools/quake2/q2map/qbsp.o \
676         tools/quake2/q2map/qrad.o \
677         tools/quake2/q2map/qvis.o \
678         tools/quake2/q2map/textures.o \
679         tools/quake2/q2map/trace.o \
680         tools/quake2/q2map/tree.o \
681         tools/quake2/q2map/writebsp.o \
682         libl_net.$(A) \
683
684 install/plugins/ufoaiplug.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
685 install/plugins/ufoaiplug.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
686 install/plugins/ufoaiplug.$(DLL): \
687         contrib/ufoaiplug/ufoai_filters.o \
688         contrib/ufoaiplug/ufoai_gtk.o \
689         contrib/ufoaiplug/ufoai_level.o \
690         contrib/ufoaiplug/ufoai.o \
691
692 install/heretic2/h2data.$(EXE): LIBS_EXTRA := $(LIBS_XML)
693 install/heretic2/h2data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/quake2/qdata_heretic2/common -Itools/quake2/qdata_heretic2/qcommon -Itools/quake2/qdata_heretic2 -Itools/quake2/common -Ilibs -Iinclude
694 install/heretic2/h2data.$(EXE): \
695         tools/quake2/qdata_heretic2/common/bspfile.o \
696         tools/quake2/qdata_heretic2/common/cmdlib.o \
697         tools/quake2/qdata_heretic2/common/inout.o \
698         tools/quake2/qdata_heretic2/common/l3dslib.o \
699         tools/quake2/qdata_heretic2/common/lbmlib.o \
700         tools/quake2/qdata_heretic2/common/mathlib.o \
701         tools/quake2/qdata_heretic2/common/md4.o \
702         tools/quake2/qdata_heretic2/common/path_init.o \
703         tools/quake2/qdata_heretic2/common/qfiles.o \
704         tools/quake2/qdata_heretic2/common/scriplib.o \
705         tools/quake2/qdata_heretic2/common/threads.o \
706         tools/quake2/qdata_heretic2/common/token.o \
707         tools/quake2/qdata_heretic2/common/trilib.o \
708         tools/quake2/qdata_heretic2/qcommon/reference.o \
709         tools/quake2/qdata_heretic2/qcommon/resourcemanager.o \
710         tools/quake2/qdata_heretic2/qcommon/skeletons.o \
711         tools/quake2/qdata_heretic2/animcomp.o \
712         tools/quake2/qdata_heretic2/book.o \
713         tools/quake2/qdata_heretic2/fmodels.o \
714         tools/quake2/qdata_heretic2/images.o \
715         tools/quake2/qdata_heretic2/jointed.o \
716         tools/quake2/qdata_heretic2/models.o \
717         tools/quake2/qdata_heretic2/pics.o \
718         tools/quake2/qdata_heretic2/qdata.o \
719         tools/quake2/qdata_heretic2/qd_skeletons.o \
720         tools/quake2/qdata_heretic2/sprites.o \
721         tools/quake2/qdata_heretic2/svdcmp.o \
722         tools/quake2/qdata_heretic2/tables.o \
723         tools/quake2/qdata_heretic2/tmix.o \
724         tools/quake2/qdata_heretic2/video.o \
725         libl_net.$(A) \
726
727 .PHONY: makeversion
728 makeversion:
729         set -ex; \
730         ver=`$(CAT) include/version.default`; \
731         major=`$(ECHO) $$ver | cut -d . -f 2`; \
732         minor=`$(ECHO) $$ver | cut -d . -f 3 | cut -d - -f 1`; \
733         $(ECHO) "// generated header, see Makefile" > include/version.h.new; \
734         $(ECHO) "#define RADIANT_VERSION \"$$ver\"" >> include/version.h.new; \
735         $(ECHO) "#define RADIANT_MAJOR_VERSION \"$$major\"" >> include/version.h.new; \
736         $(ECHO) "#define RADIANT_MINOR_VERSION \"$$minor\"" >> include/version.h.new; \
737         $(ECHO) "$$major" > include/RADIANT_MAJOR.new; \
738         $(ECHO) "$$minor" > include/RADIANT_MINOR.new; \
739         $(ECHO) "$$ver" > include/version.new; \
740         $(ECHO) "// generated header, see Makefile" > include/aboutmsg.h.new; \
741         $(ECHO) "#define RADIANT_ABOUTMSG \"$(RADIANT_ABOUTMSG)\"" >> include/aboutmsg.h.new; \
742         mv_if_diff() \
743         { \
744                 if $(DIFF) $$1 $$2 >/dev/null 2>&1; then \
745                         rm -f $$1; \
746                 else \
747                         mv $$1 $$2; \
748                 fi; \
749         }; \
750         mv_if_diff include/version.h.new include/version.h; \
751         mv_if_diff include/RADIANT_MAJOR.new include/RADIANT_MAJOR; \
752         mv_if_diff include/RADIANT_MINOR.new include/RADIANT_MINOR; \
753         mv_if_diff include/version.new include/version; \
754         mv_if_diff include/aboutmsg.h.new include/aboutmsg.h
755
756 .PHONY: install-data
757 install-data: makeversion
758         $(MKDIR) install/games
759         $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune
760         set -ex; \
761         for GAME in games/*; do \
762                 if [ -d "$$GAME/tools" ]; then \
763                         GAME=$$GAME/tools; \
764                 fi; \
765                 for GAMEFILE in $$GAME/games/*.game; do \
766                         $(CP) "$$GAMEFILE" install/games/; \
767                 done; \
768                 for GAMEDIR in $$GAME/*.game; do \
769                         $(CP_R) "$$GAMEDIR" install/; \
770                 done; \
771         done
772         $(CP) include/RADIANT_MAJOR install/
773         $(CP) include/RADIANT_MINOR install/
774         $(CP_R) setup/data/tools/* install/
775         $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune
776
777 .PHONY: install-dll
778 ifeq ($(OS),Win32)
779 install-dll:
780         WHICHDLL="$(WHICHDLL)" GTKDIR="$(GTKDIR)" CP="$(CP)" CAT="$(CAT)" MKDIR="$(MKDIR)" $(SH) install-dlls.sh
781 else
782 install-dll:
783         echo No DLL inclusion required for this target.
784 endif
785
786 -include $(shell find . -name \*.d)