c025189f2b03fad405c1c8a231850518daf83d29
[xonotic/netradiant.git] / SConscript
1 import os, sys, commands, string
2 from makeversion import get_version
3 # OS Detection:
4 OS = commands.getoutput('uname')
5
6 Import('GLOBALS')
7 Import(GLOBALS)
8
9 def build_list(s_prefix, s_string):
10   s_list = Split(s_string)
11   for i in range(len(s_list)):
12     s_list[i] = s_prefix + '/' + s_list[i]
13   return s_list
14
15 # common code ------------------------------------------------------
16
17 cmdlib_lib = g_env.StaticLibrary(target='libs/cmdlib', source='libs/cmdlib/cmdlib.cpp')
18
19 mathlib_src = 'mathlib.c bbox.c line.c m4x4.c ray.c'
20 mathlib_lib = g_env.StaticLibrary(target='libs/mathlib', source=build_list('libs/mathlib', mathlib_src))
21
22 md5lib_lib = g_env.StaticLibrary(target='libs/md5lib', source='libs/md5lib/md5lib.c')
23
24 ddslib_lib = g_env.StaticLibrary(target='libs/ddslib', source='libs/ddslib/ddslib.c')
25
26 jpeg_env = g_env.Copy()
27 jpeg_env.Prepend(CPPPATH = 'libs/jpeg6')
28 jpeg_src = 'jcomapi.cpp jdcoefct.cpp jdinput.cpp jdpostct.cpp jfdctflt.cpp jpgload.cpp jdapimin.cpp jdcolor.cpp jdmainct.cpp jdsample.cpp jidctflt.cpp jutils.cpp jdapistd.cpp jddctmgr.cpp jdmarker.cpp jdtrans.cpp jmemmgr.cpp jdatasrc.cpp jdhuff.cpp jdmaster.cpp jerror.cpp jmemnobs.cpp'
29 jpeg_lib = jpeg_env.StaticLibrary(target='libs/jpeg6', source=build_list('libs/jpeg6', jpeg_src))
30
31 l_net_lib = g_env.StaticLibrary(target='libs/l_net', source=['libs/l_net/l_net.c', 'libs/l_net/l_net_berkley.c'])
32
33 picomodel_src = 'picointernal.c picomodel.c picomodules.c pm_3ds.c pm_ase.c pm_md3.c pm_obj.c\
34   pm_ms3d.c pm_mdc.c pm_fm.c pm_md2.c pm_lwo.c pm_terrain.c lwo/clip.c lwo/envelope.c lwo/list.c lwo/lwio.c\
35   lwo/lwo2.c lwo/lwob.c lwo/pntspols.c lwo/surface.c lwo/vecmath.c lwo/vmap.c'
36 picomodel_lib = g_env.StaticLibrary(target='libs/picomodel', source=build_list('libs/picomodel', picomodel_src))
37
38 #splines_env = g_env.Copy()
39 #splines_src = build_list('libs/splines', 'math_angles.cpp math_matrix.cpp math_quaternion.cpp math_vector.cpp q_parse.cpp q_shared.cpp splines.cpp util_str.cpp')
40 #splines_env['CPPPATH'].append('include')
41 #splines_lib = splines_env.StaticLibrary(target='libs/splines', source=splines_src)
42
43 profile_env = g_env.Copy();
44 profile_env['CPPPATH'].append('include')
45 profile_src = 'profile.cpp file.cpp'
46 profile_lib = profile_env.StaticLibrary(target='libs/profile', source=build_list('libs/profile', profile_src))
47
48 gtkutil_env = g_env.Copy();
49 gtkutil_env['CPPPATH'].append('include')
50 gtkutil_env.useGlib2()
51 gtkutil_env.useGtk2()
52 gtkutil_env.useGtkGLExt()
53
54 gtkutil_src = '\
55   accelerator.cpp\
56   button.cpp\
57   clipboard.cpp\
58   closure.cpp\
59   container.cpp\
60   cursor.cpp\
61   dialog.cpp\
62   entry.cpp\
63   frame.cpp\
64   filechooser.cpp\
65   glfont.cpp\
66   glwidget.cpp\
67   image.cpp\
68   idledraw.cpp\
69   menu.cpp\
70   messagebox.cpp\
71   nonmodal.cpp\
72   paned.cpp\
73   pointer.cpp\
74   toolbar.cpp\
75   widget.cpp\
76   window.cpp\
77   xorrectangle.cpp\
78 '
79
80 gtkutil_lib = gtkutil_env.StaticLibrary(target='libs/gtkutil', source=build_list('libs/gtkutil', gtkutil_src))
81
82 # end static / common libraries ---------------------------------------------------
83
84 # q3map ---------------------------------------------------------------------------
85
86 q3map_env = g_env.Copy()
87 q3map_env['CPPPATH'].append('include')
88 q3map_env.useXML2()
89 q3map_env.useGlib2()
90 q3map_env.usePNG()
91 q3map_env.useMHash()
92 q3map_env.usePThread()
93 q3map_env.Prepend(CPPPATH='tools/quake3/common')
94
95 q3map_common_src = [
96   'common/cmdlib.c',
97   'common/imagelib.c',
98   'common/inout.c',
99   'common/mutex.c',
100   'common/polylib.c',
101   'common/scriplib.c',
102   'common/threads.c',
103   'common/unzip.c',
104   'common/vfs.c' ]
105
106 q3map_src = [
107   'q3map2/brush.c',
108   'q3map2/brush_primit.c',
109   'q3map2/bsp.c',
110   'q3map2/facebsp.c',
111   'q3map2/fog.c',
112   'q3map2/leakfile.c',
113   'q3map2/map.c',
114   'q3map2/model.c',
115   'q3map2/patch.c',
116   'q3map2/portals.c',
117   'q3map2/prtfile.c',
118   'q3map2/surface.c',
119   'q3map2/surface_fur.c',
120   'q3map2/surface_meta.c',
121   'q3map2/tjunction.c',
122   'q3map2/tree.c',
123   'q3map2/writebsp.c',
124   'q3map2/image.c',
125   'q3map2/light.c',
126   'q3map2/light_bounce.c',
127   'q3map2/light_trace.c',
128   'q3map2/light_ydnar.c',
129   'q3map2/lightmaps_ydnar.c',
130   'q3map2/vis.c',
131   'q3map2/visflow.c',
132   'q3map2/bspfile_abstract.c',
133   'q3map2/bspfile_ibsp.c',
134   'q3map2/bspfile_rbsp.c',
135   'q3map2/decals.c',
136   'q3map2/main.c',
137   'q3map2/mesh.c',
138   'q3map2/path_init.c',
139   'q3map2/shaders.c',
140   'q3map2/surface_extra.c',
141   'q3map2/surface_foliage.c',
142   'q3map2/convert_ase.c',
143   'q3map2/convert_map.c' ]
144
145 q3map_full_src = [ ]
146 for i in q3map_common_src + q3map_src:
147   q3map_full_src.append('tools/quake3/' + i)
148
149 q3map_libs = ['mathlib', 'l_net', 'jpeg6', 'picomodel', 'ddslib']
150
151 q3map_prog = q3map_env.Program(target='q3map2.' + g_cpu, source=q3map_full_src, LIBS=q3map_libs, LIBPATH='libs')
152 q3map_env.Depends(q3map_prog, mathlib_lib)
153 q3map_env.Depends(q3map_prog, l_net_lib)
154 q3map_env.Depends(q3map_prog, jpeg_lib)
155 q3map_env.Depends(q3map_prog, picomodel_lib)
156 q3map_env.Depends(q3map_prog, ddslib_lib)
157 q3map_env.Install(INSTALL, q3map_prog)
158
159 # end q3map2 ----------------------------------------------------------------------
160
161 # q3data ---------------------------------------------------------------------------
162
163 q3data_env = q3map_env.Copy()
164
165 q3data_common_src = [
166   'common/aselib.c',
167   'common/bspfile.c',
168   'common/cmdlib.c',
169   'common/imagelib.c',
170   'common/inout.c',
171   'common/md4.c',
172   'common/scriplib.c',
173   'common/trilib.c',
174   'common/unzip.c',
175   'common/vfs.c'
176   ]
177
178 q3data_src = [
179   'q3data/3dslib.c',
180   'q3data/compress.c',
181   'q3data/images.c',
182   'q3data/md3lib.c',
183   'q3data/models.c',
184   'q3data/p3dlib.c',
185   'q3data/polyset.c',
186   'q3data/q3data.c',
187   'q3data/stripper.c',
188   'q3data/video.c' ]
189
190 q3data_full_src = [ ]
191 for i in q3data_common_src + q3data_src:
192   q3data_full_src.append('tools/quake3/' + i)
193
194 q3data_prog = q3data_env.Program( target = 'q3data.' + g_cpu, source = q3data_full_src, LIBS=['mathlib', 'l_net'], LIBPATH='libs' )
195 q3data_env.Depends(q3data_prog, mathlib_lib)
196 q3data_env.Depends(q3data_prog, l_net_lib)
197 q3data_env.Install( INSTALL, q3data_prog )
198
199 # end q3data ----------------------------------------------------------------------
200
201 # q2_tools ---------------------------------------------------------------------------
202
203 q2_tools_env = g_env.Copy()
204 q2_tools_env['CPPPATH'].append('include')
205 q2_tools_env.useXML2()
206 q2_tools_env.usePThread()
207 q2_tools_env.Prepend(CPPPATH='tools/quake2/common')
208
209 q2_tools_common_src = [
210   'common/bspfile.c',
211   'common/cmdlib.c',
212   'common/inout.c',
213   'common/l3dslib.c',
214   'common/lbmlib.c',
215   'common/mathlib.c',
216   'common/md4.c',
217   'common/path_init.c',
218   'common/polylib.c',
219   'common/scriplib.c',
220   'common/threads.c',
221   'common/trilib.c'
222 ]
223
224
225 q2_tools_q2map_src = [
226   'q2map/brushbsp.c',
227   'q2map/csg.c',
228   'q2map/faces.c',
229   'q2map/flow.c',
230   'q2map/glfile.c',
231   'q2map/leakfile.c',
232   'q2map/lightmap.c',
233   'q2map/main.c',
234   'q2map/map.c',
235   'q2map/nodraw.c',
236   'q2map/patches.c',
237   'q2map/portals.c',
238   'q2map/prtfile.c',
239   'q2map/qbsp.c',
240   'q2map/qrad.c',
241   'q2map/qvis.c',
242   'q2map/textures.c',
243   'q2map/trace.c',
244   'q2map/tree.c',
245   'q2map/writebsp.c'
246 ]
247
248 q2_tools_qdata3_common_src = [
249   'common/bspfile.c',
250   'common/cmdlib.c',
251   'common/inout.c',
252   'common/l3dslib.c',
253   'common/lbmlib.c',
254   'common/mathlib.c',
255   'common/md4.c',
256   'common/path_init.c',
257   'common/scriplib.c',
258   'common/threads.c',
259   'common/trilib.c'
260 ]
261
262 q2_tools_qdata3_src = [
263   'qdata/images.c',
264   'qdata/models.c',
265   'qdata/qdata.c',
266   'qdata/sprites.c',
267   'qdata/tables.c',
268   'qdata/video.c'
269 ]
270
271 q2_tools_q2map_full_src = [ ]
272 for i in q2_tools_common_src + q2_tools_q2map_src:
273   q2_tools_q2map_full_src.append('tools/quake2/' + i)
274
275 q2_tools_qdata3_full_src = [ ]
276 for i in q2_tools_common_src + q2_tools_qdata3_src:
277   q2_tools_qdata3_full_src.append('tools/quake2/' + i)
278
279 if ( OS != 'Darwin' ):
280   q2_tools_q2map_prog = q2_tools_env.Program(target='quake2_tools/q2map', source=q2_tools_q2map_full_src, LIBS='l_net', LIBPATH='libs')
281   q2_tools_env.Depends(q2_tools_q2map_prog, l_net_lib)
282   q2_tools_env.Install(INSTALL, q2_tools_q2map_prog )
283
284   q2_tools_qdata3_prog = q2_tools_env.Program(target='quake2_tools/qdata3', source=q2_tools_qdata3_full_src, LIBS='l_net', LIBPATH='libs')
285   q2_tools_env.Depends(q2_tools_qdata3_prog, l_net_lib)
286   q2_tools_env.Install(INSTALL, q2_tools_qdata3_prog )
287
288
289 # end q2_tools ----------------------------------------------------------------------
290
291 # qdata3_heretic2 ---------------------------------------------------------------------------
292
293 heretic2_tools_env = g_env.Copy()
294 heretic2_tools_env['CPPPATH'].append('include')
295 heretic2_tools_env.useXML2()
296 heretic2_tools_env.usePThread()
297 heretic2_tools_env.Prepend(CPPPATH='tools/quake2/qdata_heretic2')
298 heretic2_tools_env.Prepend(CPPPATH='tools/quake2/qdata_heretic2/qcommon')
299 heretic2_tools_env.Prepend(CPPPATH='tools/quake2/qdata_heretic2/common')
300
301 heretic2_tools_qdata3_common_src = [
302   'qdata_heretic2/common/bspfile.c',
303   'qdata_heretic2/common/cmdlib.c',
304   'qdata_heretic2/common/inout.c',
305   'qdata_heretic2/common/l3dslib.c',
306   'qdata_heretic2/common/lbmlib.c',
307   'qdata_heretic2/common/mathlib.c',
308   'qdata_heretic2/common/md4.c',
309   'qdata_heretic2/common/path_init.c',
310   'qdata_heretic2/common/qfiles.c',
311   'qdata_heretic2/common/scriplib.c',
312   'qdata_heretic2/common/threads.c',
313   'qdata_heretic2/common/token.c',
314   'qdata_heretic2/common/trilib.c'
315 ]
316
317 heretic2_tools_qdata3_qcommon_src = [
318   'qdata_heretic2/qcommon/reference.c',
319   'qdata_heretic2/qcommon/resourcemanager.c',
320   'qdata_heretic2/qcommon/skeletons.c'
321 ]
322
323 heretic2_tools_qdata3_src = [
324   'qdata_heretic2/animcomp.c',
325   'qdata_heretic2/book.c',
326   'qdata_heretic2/fmodels.c',
327   'qdata_heretic2/images.c',
328   'qdata_heretic2/jointed.c',
329   'qdata_heretic2/models.c',
330   'qdata_heretic2/pics.c',
331   'qdata_heretic2/qdata.c',
332   'qdata_heretic2/qd_skeletons.c',
333   'qdata_heretic2/sprites.c',
334   'qdata_heretic2/svdcmp.c',
335   'qdata_heretic2/tables.c',
336   'qdata_heretic2/tmix.c',
337   'qdata_heretic2/video.c'
338 ]
339
340 heretic2_tools_qdata3_full_src = [ ]
341 for i in heretic2_tools_qdata3_common_src + heretic2_tools_qdata3_qcommon_src + heretic2_tools_qdata3_src:
342   heretic2_tools_qdata3_full_src.append('tools/quake2/' + i)
343
344
345 heretic2_tools_env['CCFLAGS'] += '-D_LINUX '
346
347 if ( OS != 'Darwin' ):
348   heretic2_tools_prog = heretic2_tools_env.Program(target='h2data', source=heretic2_tools_qdata3_full_src, LIBS='l_net', LIBPATH='libs')
349   heretic2_tools_env.Depends(heretic2_tools_prog, l_net_lib)
350   heretic2_tools_env.Install(INSTALL + '/heretic2', heretic2_tools_prog )
351
352 # end heretic2_tools ----------------------------------------------------------------------
353
354
355
356 # radiant, modules and plugins ----------------------------------------------------
357
358 module_env = g_env.Copy()
359 module_env['CPPPATH'].append('include')
360 if ( OS == 'Darwin' ):
361   module_env['LINKFLAGS'] += '-dynamiclib -ldl '
362 else:
363   module_env['LINKFLAGS'] += '-ldl '
364 module_env['LIBPREFIX'] = ''
365
366
367 vfspk3_env = module_env.Copy()
368 vfspk3_lst = build_list('plugins/vfspk3', 'vfspk3.cpp vfs.cpp archive.cpp')
369 vfspk3_env.useGlib2()
370 vfspk3_lib = vfspk3_env.SharedLibrarySafe(target='vfspk3', source=vfspk3_lst)
371 vfspk3_env.Install(INSTALL + '/modules', vfspk3_lib)
372
373 archivepak_env = module_env.Copy()
374 archivepak_lst = build_list('plugins/archivepak', 'plugin.cpp archive.cpp pak.cpp')
375 archivepak_lib = archivepak_env.SharedLibrarySafe(target='archivepak', source=archivepak_lst, LIBS='cmdlib', LIBPATH='libs')
376 archivepak_env.Depends(archivepak_lib, cmdlib_lib)
377 archivepak_env.Install(INSTALL + '/modules', archivepak_lib)
378
379 archivewad_env = module_env.Copy()
380 archivewad_lst = build_list('plugins/archivewad', 'plugin.cpp archive.cpp wad.cpp')
381 archivewad_lib = archivewad_env.SharedLibrarySafe(target='archivewad', source=archivewad_lst, LIBS='cmdlib', LIBPATH='libs')
382 archivewad_env.Depends(archivewad_lib, cmdlib_lib)
383 archivewad_env.Install(INSTALL + '/modules', archivewad_lib)
384
385 archivezip_env = module_env.Copy()
386 archivezip_lst = build_list('plugins/archivezip', 'plugin.cpp archive.cpp pkzip.cpp zlibstream.cpp')
387 archivezip_env.useZLib()
388 archivezip_lib = archivezip_env.SharedLibrarySafe(target='archivezip', source=archivezip_lst, LIBS='cmdlib', LIBPATH='libs')
389 archivezip_env.Depends(archivezip_lib, cmdlib_lib)
390 archivezip_env.Install(INSTALL + '/modules', archivezip_lib)
391
392 shaders_env = module_env.Copy()
393 shaders_lst = build_list('plugins/shaders', 'shaders.cpp plugin.cpp')
394 shaders_env.useGlib2()
395 shaders_lib = shaders_env.SharedLibrarySafe(target='shaders', source=shaders_lst, LIBS='cmdlib', LIBPATH='libs')
396 shaders_env.Depends(shaders_lib, cmdlib_lib)
397 shaders_env.Install(INSTALL + '/modules', shaders_lib)
398
399 image_env = module_env.Copy()
400 image_lst = build_list('plugins/image', 'bmp.cpp jpeg.cpp image.cpp pcx.cpp tga.cpp dds.cpp')
401 image_lib = image_env.SharedLibrarySafe(target='image', source=image_lst, LIBS=['jpeg6', 'ddslib'], LIBPATH='libs')
402 image_env.Depends(image_lib, jpeg_lib)
403 image_env.Depends(image_lib, ddslib_lib)
404 image_env.Install(INSTALL + '/modules', image_lib)
405
406 imagehl_lst=build_list('plugins/imagehl', 'imagehl.cpp hlw.cpp mip.cpp sprite.cpp')
407 imagehl_lib = module_env.SharedLibrarySafe(target='imagehl', source=imagehl_lst)
408 module_env.Install(INSTALL + '/modules', imagehl_lib)
409
410 imageq2_lst = build_list('plugins/imageq2', 'imageq2.cpp wal.cpp wal32.cpp')
411 imageq2_lib = module_env.SharedLibrarySafe(target='imageq2', source=imageq2_lst)
412 module_env.Install(INSTALL + '/modules', imageq2_lib)
413
414 mapq3_env = module_env.Copy()
415 mapq3_lst=build_list('plugins/mapq3', 'plugin.cpp parse.cpp write.cpp')
416 mapq3_lib = mapq3_env.SharedLibrarySafe(target='mapq3', source=mapq3_lst, LIBS='cmdlib', LIBPATH='libs')
417 mapq3_env.Depends(mapq3_lib, cmdlib_lib)
418 mapq3_env.Install(INSTALL + '/modules', mapq3_lib)
419
420 imagepng_env = module_env.Copy()
421 imagepng_lst = build_list('plugins/imagepng', 'plugin.cpp')
422 imagepng_env.usePNG()
423 imagepng_lib = imagepng_env.SharedLibrarySafe(target='imagepng', source=imagepng_lst)
424 imagepng_env.Install(INSTALL + '/modules', imagepng_lib)
425
426 mapxml_env = module_env.Copy()
427 mapxml_lst = build_list('plugins/mapxml', 'plugin.cpp xmlparse.cpp xmlwrite.cpp')
428 mapxml_lib = mapxml_env.SharedLibrarySafe(target='mapxml', source=mapxml_lst)
429 mapxml_env.useXML2()
430 mapxml_env.useGlib2()
431 mapxml_env.Install(INSTALL + '/modules', mapxml_lib)
432
433 model_env = module_env.Copy()
434 model_lst = build_list('plugins/model', 'plugin.cpp model.cpp')
435 model_lib = model_env.SharedLibrarySafe(target='model', source=model_lst, LIBS=['mathlib', 'picomodel'], LIBPATH='libs')
436 model_env.Depends(model_lib, mathlib_lib)
437 model_env.Depends(model_lib, picomodel_lib)
438 model_env.Install(INSTALL + '/modules', model_lib)
439
440 md3model_lst=build_list('plugins/md3model', 'plugin.cpp mdl.cpp md3.cpp md2.cpp mdc.cpp mdlimage.cpp md5.cpp')
441 md3model_lib = module_env.SharedLibrarySafe(target='md3model', source=md3model_lst)
442 module_env.Install(INSTALL + '/modules', md3model_lib)
443
444 entity_lst = build_list('plugins/entity', 'plugin.cpp entity.cpp eclassmodel.cpp generic.cpp group.cpp light.cpp miscmodel.cpp doom3group.cpp skincache.cpp angle.cpp angles.cpp colour.cpp filters.cpp model.cpp namedentity.cpp origin.cpp scale.cpp targetable.cpp rotation.cpp modelskinkey.cpp')
445 entity_lib = module_env.SharedLibrarySafe(target='entity', source=entity_lst)
446 module_env.Install(INSTALL + '/modules', entity_lib)
447
448 bob_env = module_env.Copy()
449 bob_lst = build_list('contrib/bobtoolz/',
450 'dialogs/dialogs-gtk.cpp bobToolz-GTK.cpp bsploader.cpp cportals.cpp DBobView.cpp \
451 DBrush.cpp DEntity.cpp DEPair.cpp DMap.cpp DPatch.cpp DPlane.cpp DPoint.cpp \
452 DShape.cpp DTrainDrawer.cpp DTreePlanter.cpp DVisDrawer.cpp DWinding.cpp funchandlers-GTK.cpp \
453 lists.cpp misc.cpp ScriptParser.cpp shapes.cpp visfind.cpp')
454 bob_lib = bob_env.SharedLibrarySafe(target='bobtoolz', source=bob_lst, LIBS=['mathlib', 'cmdlib', 'profile'], LIBPATH='libs')
455 bob_env.Depends(bob_lib, mathlib_lib)
456 bob_env.Depends(bob_lib, cmdlib_lib)
457 bob_env.Depends(bob_lib, profile_lib)
458 bob_env.useGlib2()
459 bob_env.useGtk2()
460 bob_env.Install(INSTALL + '/plugins', bob_lib)
461
462 #camera_lst = build_list('contrib/camera', 
463 #'camera.cpp dialogs.cpp dialogs_common.cpp funchandlers.cpp listener.cpp misc.cpp renderer.cpp')
464 #camera_lst.append('libs/libsplines.a')
465 #bob_env.SharedLibrarySafe(target='camera', source=camera_lst)
466 #bob_env.Install(INSTALL + '/plugins', 'camera.so')
467
468 prtview_env = module_env.Copy()
469 prtview_lst = build_list('contrib/prtview', 'AboutDialog.cpp ConfigDialog.cpp LoadPortalFileDialog.cpp portals.cpp prtview.cpp')
470 prtview_env.useGlib2()
471 prtview_env.useGtk2()
472 prtview_lib = prtview_env.SharedLibrarySafe(target='prtview', source=prtview_lst, LIBS='profile', LIBPATH='libs')
473 prtview_env.Depends(prtview_lib, profile_lib)
474 prtview_env.Install(INSTALL + '/plugins', prtview_lib)
475
476 #gensurf_lst = build_list('contrib/gtkgensurf',
477 #'bitmap.cpp dec.cpp face.cpp font.cpp gendlgs.cpp genmap.cpp gensurf.cpp heretic.cpp plugin.cpp view.cpp triangle.c')
478 #bob_env.SharedLibrarySafe(target='gensurf', source=gensurf_lst)
479 #bob_env.Install(INSTALL + '/plugins', 'gensurf.so')
480
481 #bkgrnd2d_list = build_list( 'contrib/bkgrnd2d', 'bkgrnd2d.cpp plugin.cpp dialog.cpp' )
482 #bkgrnd2d_list.append( 'libs/libsynapse.a' )
483 #bkgrnd2d_env = module_env.Copy()
484 #bkgrnd2d_env.useGtk2()
485 #bkgrnd2d_env.SharedLibrarySafe( target='bkgrnd2d', source=bkgrnd2d_list )
486 #bkgrnd2d_env.Install( INSTALL + '/plugins', 'bkgrnd2d.so' )
487
488 radiant_env = g_env.Copy()
489 radiant_env['CPPPATH'].append('include')
490 radiant_env['LINKFLAGS'] += '-ldl -lGL '
491 if ( OS == 'Darwin' ):
492   radiant_env['CXXFLAGS'] += '-fno-common '
493   radiant_env['CCFLAGS'] += '-fno-common '
494   radiant_env['LINKFLAGS'] += '-lX11 -lGL -lGLU '
495 radiant_env['LIBPREFIX'] = ''
496 radiant_env.useGlib2()
497 radiant_env.useXML2()
498 radiant_env.useGtk2()
499 radiant_env.useGtkGLExt()
500
501 radiant_src = [
502 'autosave.cpp',
503 'brush.cpp',
504 'brushmanip.cpp',
505 'brushmodule.cpp',
506 'brushnode.cpp',
507 'brushtokens.cpp',
508 'brushxml.cpp',
509 'brush_primit.cpp',
510 'build.cpp',
511 'camwindow.cpp',
512 'clippertool.cpp',
513 'commands.cpp',
514 'console.cpp',
515 'csg.cpp',
516 'dialog.cpp',
517 'eclass.cpp',
518 'eclass_def.cpp',
519 'eclass_doom3.cpp',
520 'eclass_fgd.cpp',
521 'eclass_xml.cpp',
522 'entity.cpp',
523 'entityinspector.cpp',
524 'entitylist.cpp',
525 'environment.cpp',
526 'error.cpp',
527 'feedback.cpp',
528 'filetypes.cpp',
529 'filters.cpp',
530 'findtexturedialog.cpp',
531 'glwidget.cpp',
532 'grid.cpp',
533 'groupdialog.cpp',
534 'gtkdlgs.cpp',
535 'gtkmisc.cpp',
536 'help.cpp',
537 'image.cpp',
538 'main.cpp',
539 'mainframe.cpp',
540 'map.cpp',
541 'mru.cpp',
542 'nullmodel.cpp',
543 'parse.cpp',
544 'patch.cpp',
545 'patchdialog.cpp',
546 'patchmanip.cpp',
547 'patchmodule.cpp',
548 'plugin.cpp',
549 'pluginapi.cpp',
550 'pluginmanager.cpp',
551 'pluginmenu.cpp',
552 'plugintoolbar.cpp',
553 'points.cpp',
554 'preferencedictionary.cpp',
555 'preferences.cpp',
556 'qe3.cpp',
557 'qgl.cpp',
558 'referencecache.cpp',
559 'renderer.cpp',
560 'renderstate.cpp',
561 'scenegraph.cpp',
562 'select.cpp',
563 'selection.cpp',
564 'server.cpp',
565 'shaders.cpp',
566 'surfacedialog.cpp',
567 'texmanip.cpp',
568 'textures.cpp',
569 'texwindow.cpp',
570 'timer.cpp',
571 'treemodel.cpp',
572 'undo.cpp',
573 'url.cpp',
574 'view.cpp',
575 'watchbsp.cpp',
576 'winding.cpp',
577 'windowobservers.cpp',
578 'xmlstuff.cpp',
579 'xywindow.cpp',
580 ]
581
582 for i in range(len(radiant_src)):
583   radiant_src[i] = 'radiant/' + radiant_src[i]
584
585 radiant_libs = ['mathlib', 'cmdlib', 'l_net', 'profile', 'gtkutil']
586 radiant_prog = radiant_env.Program(target='radiant.' + g_cpu, source=radiant_src, LIBS=radiant_libs, LIBPATH='libs')
587 radiant_env.Depends(radiant_prog, mathlib_lib)
588 radiant_env.Depends(radiant_prog, cmdlib_lib)
589 radiant_env.Depends(radiant_prog, l_net_lib)
590 radiant_env.Depends(radiant_prog, profile_lib)
591 radiant_env.Depends(radiant_prog, gtkutil_lib)
592 radiant_env.Install(INSTALL, radiant_prog)
593
594 # setup -------------------------------------------------------------------------------------------
595
596 class setup_builder:
597
598   g_dryrun = 0
599   
600   def system(self, cmd):
601     if (self.g_dryrun):
602       print cmd
603     else:
604       sys.stdout.write(cmd)
605       ret = commands.getstatusoutput(cmd)
606       print ret[1]
607       if (ret[0] != 0):
608         raise 'command failed'
609
610   def copy_core(self):
611     # binaries and misc
612     self.system('mkdir -p %s/modules' % self.SETUP_BIN_DIR)
613     self.system('mkdir -p %s/plugins' % self.SETUP_BIN_DIR)
614     self.system('cp install/%s %s' % (self.EDITOR_BIN, self.SETUP_BIN_DIR))
615     self.system('cp install/modules/*.so %s/modules' % self.SETUP_BIN_DIR )
616 #    self.system('cp install/plugins/*.so %s/plugins' % self.SETUP_BIN_DIR )
617     self.system('cp install/q3map2.%s %s' % ( g_cpu, self.SETUP_BIN_DIR ) )
618     self.M4_STDC = ''
619     if (not self.g_darwin):    
620       # fugly
621       # copy libgcc_s and stdc++ over to distribute it and reduce potential ABI fuckups
622       ret = commands.getstatusoutput('ldd -r install/' + self.EDITOR_BIN + ' 2>/dev/null | grep libgcc_s | sed -e \'s/.* => \\([^ ]*\\) .*/\\1/\'')
623       if (ret[0] != 0):
624         raise 'ldd command failed'
625       self.system('cp ' + ret[1] + ' ' + self.SETUP_BIN_DIR)
626       ret = commands.getstatusoutput('ldd -r install/' + self.EDITOR_BIN + ' 2>/dev/null | grep libstdc++ | sed -e \'s/.* => \\([^ ]*\\) .*/\\1/\'')
627       if (ret[0] != 0):
628         raise 'ldd command failed'
629       lines = string.split(ret[1], '\n')
630       self.M4_STDC = '"' 
631       for i in lines:
632         self.system('cp ' + i + ' ' + self.SETUP_BIN_DIR)
633         self.M4_STDC += os.path.basename(i) + ' \n'
634       self.M4_STDC += '"'
635     # hack for symlink
636     # setup process generates the wrapper at install time
637     # but we need a dummy executable for symlink in loki_setup
638     self.system('echo -n "#!/bin/sh\necho If you read this then there was a bug during setup. Report the bug and try running %s directly from it\'s installation directory.\n" > %s/radiant' % (self.EDITOR_BIN, self.SETUP_BIN_DIR));
639     self.system('echo -n "#!/bin/sh\necho If you read this then there was a bug during setup. Report the bug and try running %s directly from it\'s installation directory.\n" > %s/q3map2' % (self.EDITOR_BIN, self.SETUP_BIN_DIR));
640     ## this goes to the core install directory
641     DEST = self.SETUP_DIR + '/core'
642     self.system('mkdir -p ' + DEST + '/modules/bitmaps')
643     # general content stuff
644     self.system('cp -R plugins/model/bitmaps/* ' + DEST + '/modules/bitmaps')
645     self.system('cp setup/data/tools/credits.html ' + DEST)
646     self.system('cp setup/data/tools/links.htm ' + DEST)
647     self.system('cp setup/data/tools/q3data.qdt ' + DEST)
648     self.system('cp setup/data/tools/global.xlink ' + DEST)
649     self.system('cp -R radiant/bitmaps ' + DEST)
650     self.system('cp setup/changelog.txt ' + DEST)
651     self.system('cp setup/openurl.sh ' + DEST)
652     self.system('cp tools/quake3/q3map2/changelog.q3map2.txt ' + DEST)
653     # documentation
654     self.system('cp -R docs/manual/Q3Rad_Manual ' + DEST)
655     self.system('cp -R docs/manual/quake3/Compile_Manual ' + DEST)
656     self.system('cp -R docs/manual/quake3/Model_Manual ' + DEST)
657     self.system('cp -R docs/manual/quake3/Terrain_Manual ' + DEST)
658     # copy plugins media
659     #self.system('mkdir -p ' + DEST + '/plugins/bitmaps')
660     #self.system('cp -R contrib/bobtoolz/bitmaps/* ' + DEST + '/plugins/bitmaps')
661     #self.system('cp -R contrib/bobtoolz/bt ' + DEST + '/plugins')
662     #self.system('cp -R contrib/camera/bitmaps/* ' + DEST + '/plugins/bitmaps' )
663     #self.system('cp -R contrib/bkgrnd2d/bitmaps/* ' + DEST + '/plugins/bitmaps' )
664     # games files
665     self.system('mkdir -p ' + self.SETUP_DIR + '/games')
666   
667   def copy_q3(self):
668     # binaries
669     self.system('mkdir -p ' + self.SETUP_BIN_DIR + '/q3')
670     if ( self.g_darwin == 0 ):
671       self.system('cp setup/linux/bspc ' + self.SETUP_BIN_DIR + '/q3')
672
673     # goes in core
674     DEST = self.SETUP_DIR + '/core/q3.game'
675     self.system('mkdir -p ' + DEST)
676     self.system('cp -R games/Q3Pack/tools/q3.game/* ' + DEST)
677     self.system('cp -R docs/manual/quake3/Team_Arena_Mapping_Help ' + DEST)
678     self.system('cp -R docs/manual/quake3/New_Teams_For_Q3TA ' + DEST)
679     self.system('cp -R docs/manual/quake3/Q3AShader_Manual ' + DEST)
680   
681     # goes in the game install path
682     DEST = self.SETUP_DIR + '/q3'
683     self.system('mkdir -p ' + DEST)
684     self.system('cp -R games/Q3Pack/baseq3 ' + DEST)
685     self.system('cp -R games/Q3Pack/missionpack ' + DEST)
686
687     # game file
688     self.system('cp -R games/Q3Pack/tools/games/q3.game ' + self.SETUP_DIR + '/games')
689
690   def copy_wolf(self):
691     # binaries
692     self.system('mkdir -p ' + self.SETUP_BIN_DIR + '/wolf')
693     if ( self.g_darwin == 0 ):
694       self.system('cp games/WolfPack/bin/wolf.game/bspc ' + self.SETUP_BIN_DIR + '/wolf')
695   
696     # goes in core
697     DEST = self.SETUP_DIR + '/core/wolf.game'
698     self.system('mkdir -p ' + DEST)
699     self.system('cp -R games/WolfPack/docs ' + DEST)
700     self.system('cp -R games/WolfPack/bin/wolf.game/* ' + DEST)
701
702     # goes in the game install path
703     DEST = self.SETUP_DIR + '/wolf/main'
704     self.system('mkdir -p ' + DEST)
705     self.system('cp games/WolfPack/astro-skies.pk3 ' + DEST)
706     self.system('cp games/WolfPack/common-astro-spog.pk3 ' + DEST)
707     self.system('cp games/WolfPack/lights.pk3 ' + DEST)      
708     self.system('cp -R games/WolfPack/scripts ' + DEST)
709     self.system('cp -R games/WolfPack/maps ' + DEST)
710     self.system('cp -R games/WolfPack/models ' + DEST)
711   
712     # game file
713     self.system('cp -R games/WolfPack/bin/games/wolf.game ' + self.SETUP_DIR + '/games')
714
715   def copy_et(self):
716     # goes in core
717     DEST = self.SETUP_DIR + '/core/et.game'
718     self.system('mkdir -p ' + DEST)    
719     self.system('cp -R games/ETPack/docs ' + DEST)
720     self.system('cp -R games/ETPack/et.game/* ' + DEST)
721     
722     # goes in game install path
723     DEST = self.SETUP_DIR + '/et/etmain'
724     self.system('mkdir -p ' + DEST)
725     self.system('cp games/ETPack/astro-skies.pk3 ' + DEST)
726     self.system('cp games/ETPack/common.pk3 ' + DEST)
727     self.system('cp games/ETPack/goldrush.pcx ' + DEST)    
728     self.system('cp games/ETPack/lights.pk3 ' + DEST)
729     self.system('cp games/ETPack/mapmedia.pk3 ' + DEST)
730     self.system('cp -R games/ETPack/scripts ' + DEST)
731     self.system('cp -R games/ETPack/maps ' + DEST)
732     self.system('cp -R games/ETPack/models ' + DEST)
733   
734     # game file
735     self.system('cp -R games/ETPack/games/et.game ' + self.SETUP_DIR + '/games')
736
737   def copy_doom3(self):
738     # goes in core
739     DEST = self.SETUP_DIR + '/core/doom3.game'
740     self.system('mkdir -p ' + DEST)
741     self.system('cp -R games/Doom3Pack/tools/doom3.game/* ' + DEST)
742   
743     # game file
744     self.system('cp -R games/Doom3Pack/tools/games/doom3.game ' + self.SETUP_DIR + '/games')
745
746   def copy_q2(self):
747     # binaries
748     self.system('cp -R install/q2 %s' % (self.SETUP_BIN_DIR))
749
750     # goes in core
751     DEST = self.SETUP_DIR + '/core/q2.game'
752     self.system('mkdir -p ' + DEST + '/modules')
753     self.system('cp -R games/Q2Pack/q2.game/* ' + DEST)
754     self.system('cp install/q2/q2map install/q2/qdata3 ' + DEST) 
755 #    self.system('cp -R install/q2/modules ' + DEST )
756
757     # goes in game install path
758     DEST = self.SETUP_DIR + '/q2'
759     self.system('mkdir -p ' + DEST +  '/baseq2')
760     self.system('cp -R games/Q2Pack/baseq2/* ' + DEST + '/baseq2')
761   
762     # game file
763     self.system('cp -R games/Q2Pack/games/q2.game ' + self.SETUP_DIR + '/games')
764
765   def copy_her2(self):
766     # binaries
767     self.system('cp -R install/heretic2 %s' % (self.SETUP_BIN_DIR))
768
769     # goes in core
770     DEST = self.SETUP_DIR + '/core/heretic2.game'
771     self.system('mkdir -p ' + DEST + '/modules')
772     self.system('cp -R games/Her2Pack/heretic2.game/* ' + DEST)
773     self.system('cp install/q2/q2map install/heretic2/qdata3 ' + DEST)
774 #    self.system('cp -R install/heretic2/modules ' + DEST )
775
776     # goes in game install path
777     DEST = self.SETUP_DIR + '/heretic2'
778     self.system('mkdir -p ' + DEST +  '/base')
779     self.system('cp -R games/Her2Pack/base/* ' + DEST + '/base')
780   
781     # game file
782     self.system('cp -R games/Her2Pack/games/heretic2.game ' + self.SETUP_DIR + '/games')
783
784   def build_setup(self):
785     self.system( 'cp -R ' + self.SETUP_IMAGE_OS + '/* ' + self.SETUP_DIR )
786     self.system( 'cp -fR ' + self.SETUP_IMAGE + '/* ' + self.SETUP_DIR )
787     self.system('cp setup/license.txt ' + self.SETUP_DIR)
788     self.system('cp setup/linux/README ' + self.SETUP_DIR)
789     OS_DEFS=''
790     if (self.g_darwin):
791       OS_DEFS='--define=M4_OSX'
792     M4_LINE = OS_DEFS + ' --define=M4_VER_MAJOR=' + self.major + ' --define=M4_VER_MINOR=' + self.minor + ' --define=M4_VER=' + self.line 
793     M4_LINE += ' --define=M4_GAME_ET=%d' % self.DO_GAME_ET
794     M4_LINE += ' --define=M4_GAME_DOOM3=%d' % self.DO_GAME_DOOM3
795     M4_LINE += ' --define=M4_GAME_Q2=%d' % self.DO_GAME_Q2
796     if ( self.M4_STDC != '' ):
797       M4_LINE += ' --define=M4_STDC=' + self.M4_STDC 
798     # setup.xml
799     self.system('m4 ' + M4_LINE + ' ' + self.SETUP_DIR + '/setup.data/setup.xml.in > ' + self.SETUP_DIR + '/setup.data/setup.xml')
800     # postinstall.sh
801     self.system('m4 ' + M4_LINE + ' ' + self.SETUP_DIR + '/setup.data/postinstall.sh.in > ' + self.SETUP_DIR + '/setup.data/postinstall.sh')
802     # config.sh
803     self.system('m4 ' + M4_LINE + ' ' + self.SETUP_DIR + '/setup.data/config.sh.in > ' + self.SETUP_DIR + '/setup.data/config.sh')
804     # setup.sh
805     self.system('m4 ' + M4_LINE + ' ' + self.SETUP_DIR + '/setup.sh.in > ' + self.SETUP_DIR + '/setup.sh')
806     self.system('chmod +x ' +self.SETUP_DIR + '/setup.sh')
807     self.system('find ' + self.SETUP_DIR + ' -name .svn | while read i ; do rm -r "$i" ; done')
808     # pack it up
809     self.system('setup/linux/makeself/makeself.sh ' + self.SETUP_DIR + ' ' + self.SETUP_TARGET + ' "GtkRadiant ' + self.line + ' setup" ./setup.sh')
810     if (self.g_darwin):
811       def build_fink_deb(self):
812         print "Building installer .deb\n"
813         self.F_REV = '1'
814         self.FINKINFO_DIR = '/sw/fink/10.2/unstable/main/finkinfo/games'
815         self.TARBALL_DIR='radiant-' + self.F_REV + '.' + self.major 
816         self.TARBALL_NAME='radiant-' + self.F_REV + '.' + self.major + '.tar.gz'
817         self.TARBALL_DEST='/sw/src'
818
819         # prepare package description
820         self.system('mkdir -p ' + self.FINKINFO_DIR)
821         self.system('m4 ' + M4_LINE + ' --define=M4_SETUP_TARGET=' + self.SETUP_TARGET + '  --define=M4_F_REV=' + self.F_REV + ' ' + 'setup/osx/radiant.info.m4 > ' + self.FINKINFO_DIR + '/radiant-' + self.TARBALL_DIR + '.info')
822
823         # build the tarball
824         self.system('if [ -r /tmp/' + self.TARBALL_DIR + ' ] ; then rm -r ' '/tmp/' + self.TARBALL_DIR + ' ; fi')
825         self.system('mkdir -p ' '/tmp/' + self.TARBALL_DIR)
826         self.system('cp ' + self.SETUP_TARGET + ' ' + '/tmp/' + self.TARBALL_DIR)
827         self.system('cd /tmp ; tar -cvzf ' + self.TARBALL_NAME + ' ' + self.TARBALL_DIR + ' ; cp ' + self.TARBALL_NAME + ' ' + self.TARBALL_DEST + '/')
828         self.system('/sw/bin/fink rebuild radiant')
829
830         build_fink_deb(self)
831       
832   def spawn_setup(self, env, target, source):
833     if ( OS == 'Darwin' ):
834       self.g_darwin = 1
835     else:
836       self.g_darwin = 0
837     (self.line, self.major, self.minor) = get_version()
838     print 'Setup: GtkRadiant %s' % self.line  
839     if ( self.g_darwin ):
840       self.SETUP_IMAGE_OS = '../loki_setup/image'
841     else:
842       self.SETUP_IMAGE_OS = 'setup/linux/setup_image.Linux'
843     self.SETUP_IMAGE = 'setup/linux/setup_image'
844     self.SETUP_DIR = '/tmp/radiant-setup.%d' % os.getpid()
845     self.EDITOR_BIN='radiant.' + g_cpu
846     if ( self.g_darwin ):
847       self.SETUP_BIN_DIR = self.SETUP_DIR + '/bin/Darwin/ppc'
848       self.SETUP_TARGET = 'osx-radiant-%s.run' % self.line
849     else:
850       self.SETUP_BIN_DIR = self.SETUP_DIR + '/bin/Linux/x86'
851       self.SETUP_TARGET = 'linux-radiant-%s.run' % self.line
852     # TODO: eval a conf file instead
853     self.DO_CORE=1
854     self.DO_GAME_Q3=1
855     self.DO_GAME_WOLF=1
856     self.DO_GAME_ET=1
857     self.DO_GAME_DOOM3=1
858     self.DO_GAME_Q2=1
859     self.DO_GAME_HER2=1
860     if ( self.g_darwin ):
861       self.DO_GAME_Q2=0
862       self.DO_GAME_ET=0
863       self.DO_GAME_HER2=0
864     # verbose a bit
865     print 'version: %s major: %s minor: %s\neditor core: %d\nq3: %d\nwolf: %d\net: %d\ndoom3: %d\nq2: %d\nher2: %d' % (self.line, self.major, self.minor, self.DO_CORE, self.DO_GAME_Q3, self.DO_GAME_WOLF, self.DO_GAME_ET, self.DO_GAME_DOOM3, self.DO_GAME_Q2, self.DO_GAME_HER2)
866     if (self.DO_CORE):
867       self.copy_core()
868     if (self.DO_GAME_Q3):
869       self.copy_q3()
870     if (self.DO_GAME_WOLF):
871       self.copy_wolf()
872     if (self.DO_GAME_ET):
873       self.copy_et()
874     if (self.DO_GAME_DOOM3):
875       self.copy_doom3()
876     if ( OS != 'Darwin' ):
877       if (self.DO_GAME_Q2):
878         self.copy_q2()
879       if (self.DO_GAME_HER2):
880         self.copy_her2()
881     self.build_setup()
882     return 0
883     
884 def spawn_setup(env, target, source):
885   setup = setup_builder()
886   setup.spawn_setup(env, target, source)
887
888 # NOTE: could modify g_env to add the deps auto when calling SharedLibrarySafe ..
889 if (SETUP == '1'):
890   g_env.Command('foo', INSTALL + '/radiant.' + g_cpu, [ spawn_setup ] )
891   depends_list = [ 
892     INSTALL + '/modules/archivepak.so',
893     INSTALL + '/modules/archivewad.so',
894     INSTALL + '/modules/archivezip.so',
895     INSTALL + '/modules/entity.so',
896 #    INSTALL + '/modules/fgd.so',
897     INSTALL + '/modules/imagehl.so',
898     INSTALL + '/modules/imageq2.so',
899     INSTALL + '/modules/image.so',
900     INSTALL + '/modules/imagepng.so',
901     INSTALL + '/modules/mapq3.so',
902     INSTALL + '/modules/mapxml.so',
903     INSTALL + '/modules/model.so',
904     INSTALL + '/modules/md3model.so',
905     INSTALL + '/modules/shaders.so',
906     INSTALL + '/modules/vfspk3.so',
907 #    INSTALL + '/modules/vfswad.so',
908 #    INSTALL + '/plugins/bobtoolz.so',
909 #    INSTALL + '/plugins/camera.so',
910 #    INSTALL + '/plugins/prtview.so',
911 #    INSTALL + '/plugins/gensurf.so',
912 #    INSTALL + '/plugins/bkgrnd2d.so',
913     INSTALL + '/q3map2.' + g_cpu,
914     INSTALL + '/radiant.' + g_cpu,
915     INSTALL + '/q3data.' + g_cpu ]
916   if ( OS != 'Darwin' ):
917     depends_list += [
918       INSTALL + '/q2/q2map',
919       INSTALL + '/q2/qdata3',
920       INSTALL + '/heretic2/qdata3',
921       INSTALL + '/heretic2/q2map' ]
922   g_env.Depends( 'foo', depends_list )
923
924 # end setup ---------------------------------------------------------------------------------------