radiant may run now (only the Q3-required plugins are there yet)
[xonotic/netradiant.git] / Makefile
1 CFLAGS = -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -g3 -fPIC
2 CXXFLAGS = $(CFLAGS) -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
3 CPPFLAGS_COMMON = -DPOSIX -DXWINDOWS -D_DEBUG -D_LINUX
4 LDFLAGS_COMMON = 
5 LDFLAGS_DLL = -fPIC -Wl,-fini,fini_stub -static-libgcc -ldl
6
7 EXE = x86
8 A = a
9 DLL = so
10 NETAPI = berkley
11
12 LDD ?= ldd
13 FIND ?= find
14 RANLIB ?= ranlib
15 AR ?= ar
16
17 TEE_STDERR ?= | tee /dev/stderr
18
19 CPPFLAGS_GLIB = `pkg-config glib-2.0 --cflags`
20 LIBS_GLIB = `pkg-config glib-2.0 --libs`
21
22 CPPFLAGS_XML = `xml2-config --cflags`
23 LIBS_XML = `xml2-config --libs`
24
25 CPPFLAGS_PNG = `libpng-config --cflags`
26 LIBS_PNG = `libpng-config --libs`
27
28 CPPFLAGS_GTK = `pkg-config gtk+-2.0 --cflags`
29 LIBS_GTK = `pkg-config gtk+-2.0 --libs`
30
31 CPPFLAGS_GTKGLEXT = `pkg-config gtkglext-1.0 --cflags`
32 LIBS_GTKGLEXT = `pkg-config gtkglext-1.0 --libs`
33
34 LDFLAGS := $(LDFLAGS_COMMON)
35
36 # from qe3.cpp: const char* const EXECUTABLE_TYPE = 
37 # from qe3.cpp: #if defined(__linux__) || defined (__FreeBSD__)
38 # from qe3.cpp: "x86"
39 # from qe3.cpp: #elif defined(__APPLE__)
40 # from qe3.cpp: "ppc"
41 # from qe3.cpp: #elif defined(WIN32)
42 # from qe3.cpp: "exe"
43 # from qe3.cpp: #else
44 # from qe3.cpp: #error "unknown platform"
45 # from qe3.cpp: #endif
46 # from qe3.cpp: ;
47
48 .PHONY: all
49 all: \
50         install/q3map2.$(EXE) \
51         install/q3data.$(EXE) \
52         install/radiant.$(EXE) \
53         install/modules/archivezip.$(DLL) \
54         install/modules/entity.$(DLL) \
55         install/modules/image.$(DLL) \
56         install/modules/imagepng.$(DLL) \
57         install/modules/mapq3.$(DLL) \
58         install/modules/md3model.$(DLL) \
59         install/modules/model.$(DLL) \
60         install/modules/shaders.$(DLL) \
61         install/modules/vfspk3.$(DLL) \
62
63 .PHONY: clean
64 clean:
65         $(FIND) . \( -name \*.o -o -name \*.$(SO) -o -name \*.$(A) -o -name \*.$(EXE) \) -exec $(RM) {} \;
66
67 %.$(EXE):
68         $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS)
69         [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ 2>&1 >/dev/null $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
70
71 %.$(A):
72         $(AR) rc $@ $^
73         $(RANLIB) $@
74
75 %.$(DLL):
76         $(CXX) -shared -o $@ $^ $(LDFLAGS) $(LDFLAGS_DLL) $(LIBS)
77         [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ 2>&1 >/dev/null $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
78
79 install/q3map2.$(EXE): LIBS := -lmhash $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG)
80 install/q3map2.$(EXE): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) -Itools/quake3/common -Ilibs -Iinclude
81 install/q3map2.$(EXE): \
82         tools/quake3/common/cmdlib.o \
83         tools/quake3/common/imagelib.o \
84         tools/quake3/common/inout.o \
85         tools/quake3/common/mutex.o \
86         tools/quake3/common/polylib.o \
87         tools/quake3/common/scriplib.o \
88         tools/quake3/common/threads.o \
89         tools/quake3/common/unzip.o \
90         tools/quake3/common/vfs.o \
91         tools/quake3/q3map2/brush.o \
92         tools/quake3/q3map2/brush_primit.o \
93         tools/quake3/q3map2/bspfile_abstract.o \
94         tools/quake3/q3map2/bspfile_ibsp.o \
95         tools/quake3/q3map2/bspfile_rbsp.o \
96         tools/quake3/q3map2/bsp.o \
97         tools/quake3/q3map2/convert_ase.o \
98         tools/quake3/q3map2/convert_map.o \
99         tools/quake3/q3map2/decals.o \
100         tools/quake3/q3map2/facebsp.o \
101         tools/quake3/q3map2/fog.o \
102         tools/quake3/q3map2/image.o \
103         tools/quake3/q3map2/leakfile.o \
104         tools/quake3/q3map2/light_bounce.o \
105         tools/quake3/q3map2/lightmaps_ydnar.o \
106         tools/quake3/q3map2/light.o \
107         tools/quake3/q3map2/light_trace.o \
108         tools/quake3/q3map2/light_ydnar.o \
109         tools/quake3/q3map2/main.o \
110         tools/quake3/q3map2/map.o \
111         tools/quake3/q3map2/mesh.o \
112         tools/quake3/q3map2/model.o \
113         tools/quake3/q3map2/patch.o \
114         tools/quake3/q3map2/path_init.o \
115         tools/quake3/q3map2/portals.o \
116         tools/quake3/q3map2/prtfile.o \
117         tools/quake3/q3map2/shaders.o \
118         tools/quake3/q3map2/surface_extra.o \
119         tools/quake3/q3map2/surface_foliage.o \
120         tools/quake3/q3map2/surface_fur.o \
121         tools/quake3/q3map2/surface_meta.o \
122         tools/quake3/q3map2/surface.o \
123         tools/quake3/q3map2/tjunction.o \
124         tools/quake3/q3map2/tree.o \
125         tools/quake3/q3map2/visflow.o \
126         tools/quake3/q3map2/vis.o \
127         tools/quake3/q3map2/writebsp.o \
128         libmathlib.$(A) \
129         libl_net.$(A) \
130         libjpeg6.$(A) \
131         libpicomodel.$(A) \
132         libddslib.$(A) \
133
134 libmathlib.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs
135 libmathlib.$(A): \
136         libs/mathlib/mathlib.o \
137         libs/mathlib/bbox.o \
138         libs/mathlib/line.o \
139         libs/mathlib/m4x4.o \
140         libs/mathlib/ray.o \
141
142 libl_net.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs
143 libl_net.$(A): \
144         libs/l_net/l_net.o \
145         libs/l_net/l_net_$(NETAPI).o \
146
147 libjpeg6.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs/jpeg6 -Ilibs
148 libjpeg6.$(A): \
149         libs/jpeg6/jcomapi.o \
150         libs/jpeg6/jdcoefct.o \
151         libs/jpeg6/jdinput.o \
152         libs/jpeg6/jdpostct.o \
153         libs/jpeg6/jfdctflt.o \
154         libs/jpeg6/jpgload.o \
155         libs/jpeg6/jdapimin.o \
156         libs/jpeg6/jdcolor.o \
157         libs/jpeg6/jdmainct.o \
158         libs/jpeg6/jdsample.o \
159         libs/jpeg6/jidctflt.o \
160         libs/jpeg6/jutils.o \
161         libs/jpeg6/jdapistd.o \
162         libs/jpeg6/jddctmgr.o \
163         libs/jpeg6/jdmarker.o \
164         libs/jpeg6/jdtrans.o \
165         libs/jpeg6/jmemmgr.o \
166         libs/jpeg6/jdatasrc.o \
167         libs/jpeg6/jdhuff.o \
168         libs/jpeg6/jdmaster.o \
169         libs/jpeg6/jerror.o \
170         libs/jpeg6/jmemnobs.o \
171
172 libpicomodel.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs
173 libpicomodel.$(A): \
174         libs/picomodel/picointernal.o \
175         libs/picomodel/picomodel.o \
176         libs/picomodel/picomodules.o \
177         libs/picomodel/pm_3ds.o \
178         libs/picomodel/pm_ase.o \
179         libs/picomodel/pm_md3.o \
180         libs/picomodel/pm_obj.o \
181         libs/picomodel/pm_ms3d.o \
182         libs/picomodel/pm_mdc.o \
183         libs/picomodel/pm_fm.o \
184         libs/picomodel/pm_md2.o \
185         libs/picomodel/pm_lwo.o \
186         libs/picomodel/pm_terrain.o \
187         libs/picomodel/lwo/clip.o \
188         libs/picomodel/lwo/envelope.o \
189         libs/picomodel/lwo/list.o \
190         libs/picomodel/lwo/lwio.o \
191         libs/picomodel/lwo/lwo2.o \
192         libs/picomodel/lwo/lwob.o \
193         libs/picomodel/lwo/pntspols.o \
194         libs/picomodel/lwo/surface.o \
195         libs/picomodel/lwo/vecmath.o \
196         libs/picomodel/lwo/vmap.o \
197
198 libddslib.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs
199 libddslib.$(A): \
200         libs/ddslib/ddslib.o \
201
202 install/q3data.$(EXE): LIBS := -lmhash $(LIBS_XML) $(LIBS_GLIB)
203 install/q3data.$(EXE): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Itools/quake3/common -Ilibs -Iinclude
204 install/q3data.$(EXE): \
205         tools/quake3/common/aselib.o \
206         tools/quake3/common/bspfile.o \
207         tools/quake3/common/cmdlib.o \
208         tools/quake3/common/imagelib.o \
209         tools/quake3/common/inout.o \
210         tools/quake3/common/md4.o \
211         tools/quake3/common/scriplib.o \
212         tools/quake3/common/trilib.o \
213         tools/quake3/common/unzip.o \
214         tools/quake3/common/vfs.o \
215         tools/quake3/q3data/3dslib.o \
216         tools/quake3/q3data/compress.o \
217         tools/quake3/q3data/images.o \
218         tools/quake3/q3data/md3lib.o \
219         tools/quake3/q3data/models.o \
220         tools/quake3/q3data/p3dlib.o \
221         tools/quake3/q3data/polyset.o \
222         tools/quake3/q3data/q3data.o \
223         tools/quake3/q3data/stripper.o \
224         tools/quake3/q3data/video.o \
225         libmathlib.$(A) \
226         libl_net.$(A) \
227
228 install/radiant.$(EXE): LIBS := -lmhash -ldl -lGL -static-libgcc $(LIBS_XML) $(LIBS_GLIB) $(LIBS_GTK) $(LIBS_GTKGLEXT)
229 install/radiant.$(EXE): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
230 #install/radiant.$(EXE): LDFLAGS := -fPIC -Wl,-fini,fini_stub $(LDFLAGS_COMMON)
231 install/radiant.$(EXE): \
232         radiant/autosave.o \
233         radiant/brush.o \
234         radiant/brushmanip.o \
235         radiant/brushmodule.o \
236         radiant/brushnode.o \
237         radiant/brushtokens.o \
238         radiant/brushxml.o \
239         radiant/brush_primit.o \
240         radiant/build.o \
241         radiant/camwindow.o \
242         radiant/clippertool.o \
243         radiant/commands.o \
244         radiant/console.o \
245         radiant/csg.o \
246         radiant/dialog.o \
247         radiant/eclass.o \
248         radiant/eclass_def.o \
249         radiant/eclass_doom3.o \
250         radiant/eclass_fgd.o \
251         radiant/eclass_xml.o \
252         radiant/entity.o \
253         radiant/entityinspector.o \
254         radiant/entitylist.o \
255         radiant/environment.o \
256         radiant/error.o \
257         radiant/feedback.o \
258         radiant/filetypes.o \
259         radiant/filters.o \
260         radiant/findtexturedialog.o \
261         radiant/glwidget.o \
262         radiant/grid.o \
263         radiant/groupdialog.o \
264         radiant/gtkdlgs.o \
265         radiant/gtkmisc.o \
266         radiant/help.o \
267         radiant/image.o \
268         radiant/main.o \
269         radiant/mainframe.o \
270         radiant/map.o \
271         radiant/mru.o \
272         radiant/nullmodel.o \
273         radiant/parse.o \
274         radiant/patch.o \
275         radiant/patchdialog.o \
276         radiant/patchmanip.o \
277         radiant/patchmodule.o \
278         radiant/plugin.o \
279         radiant/pluginapi.o \
280         radiant/pluginmanager.o \
281         radiant/pluginmenu.o \
282         radiant/plugintoolbar.o \
283         radiant/points.o \
284         radiant/preferencedictionary.o \
285         radiant/preferences.o \
286         radiant/qe3.o \
287         radiant/qgl.o \
288         radiant/referencecache.o \
289         radiant/renderer.o \
290         radiant/renderstate.o \
291         radiant/scenegraph.o \
292         radiant/stacktrace.o \
293         radiant/select.o \
294         radiant/selection.o \
295         radiant/server.o \
296         radiant/shaders.o \
297         radiant/sockets.o \
298         radiant/surfacedialog.o \
299         radiant/texmanip.o \
300         radiant/textures.o \
301         radiant/texwindow.o \
302         radiant/timer.o \
303         radiant/treemodel.o \
304         radiant/undo.o \
305         radiant/url.o \
306         radiant/view.o \
307         radiant/watchbsp.o \
308         radiant/winding.o \
309         radiant/windowobservers.o \
310         radiant/xmlstuff.o \
311         radiant/xywindow.o \
312         libmathlib.$(A) \
313         libcmdlib.$(A) \
314         libl_net.$(A) \
315         libprofile.$(A) \
316         libgtkutil.$(A) \
317         libxmllib.$(A) \
318
319 libcmdlib.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs
320 libcmdlib.$(A): \
321         libs/cmdlib/cmdlib.o \
322
323 libprofile.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
324 libprofile.$(A): \
325         libs/profile/profile.o \
326         libs/profile/file.o \
327
328 libgtkutil.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
329 libgtkutil.$(A): \
330         libs/gtkutil/accelerator.o \
331         libs/gtkutil/button.o \
332         libs/gtkutil/clipboard.o \
333         libs/gtkutil/closure.o \
334         libs/gtkutil/container.o \
335         libs/gtkutil/cursor.o \
336         libs/gtkutil/dialog.o \
337         libs/gtkutil/entry.o \
338         libs/gtkutil/frame.o \
339         libs/gtkutil/filechooser.o \
340         libs/gtkutil/glfont.o \
341         libs/gtkutil/glwidget.o \
342         libs/gtkutil/image.o \
343         libs/gtkutil/idledraw.o \
344         libs/gtkutil/menu.o \
345         libs/gtkutil/messagebox.o \
346         libs/gtkutil/nonmodal.o \
347         libs/gtkutil/paned.o \
348         libs/gtkutil/pointer.o \
349         libs/gtkutil/toolbar.o \
350         libs/gtkutil/widget.o \
351         libs/gtkutil/window.o \
352         libs/gtkutil/xorrectangle.o \
353
354 libxmllib.$(A): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
355 libxmllib.$(A): \
356         libs/xml/ixml.o \
357         libs/xml/xmlparser.o \
358         libs/xml/xmlwriter.o \
359         libs/xml/xmlelement.o \
360         libs/xml/xmltextags.o \
361
362 install/modules/archivezip.$(DLL): LIBS := -lz
363 install/modules/archivezip.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
364 install/modules/archivezip.$(DLL): \
365         plugins/archivezip/plugin.o \
366         plugins/archivezip/archive.o \
367         plugins/archivezip/pkzip.o \
368         plugins/archivezip/zlibstream.o \
369
370 install/modules/entity.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
371 install/modules/entity.$(DLL): \
372         plugins/entity/plugin.o \
373         plugins/entity/entity.o \
374         plugins/entity/eclassmodel.o \
375         plugins/entity/generic.o \
376         plugins/entity/group.o \
377         plugins/entity/light.o \
378         plugins/entity/miscmodel.o \
379         plugins/entity/doom3group.o \
380         plugins/entity/skincache.o \
381         plugins/entity/angle.o \
382         plugins/entity/angles.o \
383         plugins/entity/colour.o \
384         plugins/entity/filters.o \
385         plugins/entity/model.o \
386         plugins/entity/namedentity.o \
387         plugins/entity/origin.o \
388         plugins/entity/scale.o \
389         plugins/entity/targetable.o \
390         plugins/entity/rotation.o \
391         plugins/entity/modelskinkey.o \
392
393 install/modules/image.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
394 install/modules/image.$(DLL): \
395         plugins/image/bmp.o \
396         plugins/image/jpeg.o \
397         plugins/image/image.o \
398         plugins/image/pcx.o \
399         plugins/image/tga.o \
400         plugins/image/dds.o \
401         libjpeg6.$(A) \
402         libddslib.$(A) \
403
404 install/modules/imagepng.$(DLL): LIBS := $(LIBS_PNG)
405 install/modules/imagepng.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_PNG) -Ilibs -Iinclude
406 install/modules/imagepng.$(DLL): \
407         plugins/imagepng/plugin.o \
408
409 install/modules/mapq3.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
410 install/modules/mapq3.$(DLL): \
411         plugins/mapq3/plugin.o \
412         plugins/mapq3/parse.o \
413         plugins/mapq3/write.o \
414
415 install/modules/md3model.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
416 install/modules/md3model.$(DLL): \
417         plugins/md3model/plugin.o \
418         plugins/md3model/mdl.o \
419         plugins/md3model/md3.o \
420         plugins/md3model/md2.o \
421         plugins/md3model/mdc.o \
422         plugins/md3model/mdlimage.o \
423         plugins/md3model/md5.o \
424
425 install/modules/model.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) -Ilibs -Iinclude
426 install/modules/model.$(DLL): \
427         plugins/model/plugin.o \
428         plugins/model/model.o \
429         libpicomodel.$(A) \
430
431 install/modules/shaders.$(DLL): LIBS := $(LIBS_GLIB)
432 install/modules/shaders.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
433 install/modules/shaders.$(DLL): \
434         plugins/shaders/plugin.o \
435         plugins/shaders/shaders.o \
436
437 install/modules/vfspk3.$(DLL): LIBS := $(LIBS_GLIB)
438 install/modules/vfspk3.$(DLL): CPPFLAGS := $(CPPFLAGS_COMMON) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
439 install/modules/vfspk3.$(DLL): \
440         plugins/vfspk3/archive.o \
441         plugins/vfspk3/vfs.o \
442         plugins/vfspk3/vfspk3.o \
443