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