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