]> git.lyx.org Git - lyx.git/blob - development/scons/SConscript
1f0a4a7e48739354be56b5de6df06c532fef5f69
[lyx.git] / development / scons / SConscript
1 # vi:filetype=python:expandtab:tabstop=2:shiftwidth=2
2
3 # file SConscript
4 #
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7 #
8 # \author Bo Peng
9 # Full author contact details are available in file CREDITS.
10
11 import os, sys
12 sys.path.append('config')
13 from scons_utils import globSource
14
15 Import('env')
16
17 targets = env['BUILD_TARGETS']
18 build_lyx = (targets == [] or 'lyx' in targets or 'install' in targets or 'all' in targets)
19 build_boost = env['INCLUDED_BOOST'] or 'boost' in targets
20 build_intl = env['INCLUDED_GETTEXT'] or 'intl' in targets
21 build_support = build_lyx or True in [x in targets for x in ['support', 'client', 'tex2lyx']]
22 build_mathed = build_lyx or 'mathed' in targets
23 build_insets = build_lyx or 'insets' in targets
24 build_frontends = build_lyx or 'frontends' in targets
25 build_graphics = build_lyx or 'graphics' in targets
26 build_controllers = build_lyx or 'controllers' in targets
27 build_client = 'client' in targets or 'install' in targets or 'all' in targets
28 build_tex2lyx = 'tex2lyx' in targets or 'install' in targets or 'all' in targets
29 build_lyxbase = build_lyx or 'lyxbase' in targets
30 build_po = 'po' in targets or 'install' in targets or 'all' in targets
31 build_qt3 = (build_lyx and env['frontend'] == 'qt3') or 'qt3' in targets
32 build_qt4 = (build_lyx and env['frontend'] == 'qt4') or 'qt4' in targets
33 build_msvs_projects = env['USE_VC'] and 'msvs_projects' in targets
34
35
36 # now, if rebuild_targets is specified, do not rebuild some targets
37 rebuild_targets = env['REBUILD_TARGETS']
38 if rebuild_targets:
39   def ifBuildLib(name, libname, old_value):
40     # explicitly asked to rebuild
41     if name in rebuild_targets:
42       return True
43     # else if not rebuild, and if the library already exists
44     elif os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath):
45       return False
46     # do not change the original value
47     else:
48       return old_value
49   build_boost = ifBuildLib('boost', 'included_boost_filesystem', build_boost)
50   build_intl = ifBuildLib('intl', 'included_intl', build_intl)
51   build_support = ifBuildLib('support', 'support', build_support)
52   build_mathed = ifBuildLib('mathed', 'mathed', build_mathed)
53   build_insets = ifBuildLib('insets', 'insets', build_insets)
54   build_frontends = ifBuildLib('frontends', 'frontends', build_frontends)
55   build_graphics = ifBuildLib('graphics', 'graphics', build_graphics)
56   build_controllers = ifBuildLib('controllers', 'controllers', build_controllers)
57   build_lyxbase = ifBuildLib('lyxbase', 'lyxbase_pre', build_lyxbase)
58   build_qt3 = ifBuildLib('qt3', 'qt3', build_qt3)
59   build_qt4 = ifBuildLib('qt4', 'qt4', build_qt4)
60
61 # sync frontend and env['frontend'] (maybe build qt4 with frontend=qt3)
62 if build_qt3:
63   frontend = 'qt3'
64   env['frontend'] = 'qt3'
65 elif build_qt4:
66   frontend = 'qt4'
67   env['frontend'] = 'qt4'
68 else:
69   frontend = env['frontend']
70
71
72 if build_boost:
73   #
74   # boost libraries
75   #
76   # special builddir
77   env.BuildDir('$BUILDDIR/boost', '$TOP_SRC_DIR/boost/libs', duplicate = 0)
78
79   boostenv = env.Copy()
80   boostenv.AppendUnique(CCFLAGS = '-DBOOST_USER_CONFIG="<config.h>"')
81
82   print 'Processing files in boost/libs/filesystem/src...'
83
84   filesystem = boostenv.StaticLibrary(
85     target = '$LOCALLIBPATH/included_boost_filesystem',
86     source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/filesystem/src'), 
87       pattern = '*.cpp', build_dir = '$BUILDDIR/boost/filesystem/src')
88   )
89
90   print 'Processing files in boost/libs/regex/src...'
91
92   regex = boostenv.StaticLibrary(
93     target = '$LOCALLIBPATH/included_boost_regex',
94     source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/regex/src'), 
95       pattern = '*.cpp', build_dir = '$BUILDDIR/boost/regex/src')
96   )
97
98   print 'Processing files in boost/libs/signals/src...'
99
100   signals = boostenv.StaticLibrary(
101     target = '$LOCALLIBPATH/included_boost_signals',
102     source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/signals/src'), 
103       pattern = '*.cpp', build_dir = '$BUILDDIR/boost/signals/src')
104   )
105
106   print 'Processing files in boost/libs/iostreams/src...'
107
108   iostreams = boostenv.StaticLibrary(
109     target = '$LOCALLIBPATH/included_boost_iostreams',
110     source = globSource(dir = env.subst('$TOP_SRC_DIR/boost/libs/iostreams/src'), 
111       pattern = '*.cpp', build_dir = '$BUILDDIR/boost/iostreams/src')
112   )
113   Alias('boost', filesystem)
114   Alias('boost', regex)
115   Alias('boost', signals)
116   Alias('boost', iostreams)
117
118
119 if build_intl:
120   # 
121   # intl
122   # 
123   print "Processing files in intl..."
124
125   env.BuildDir('$BUILDDIR/intl', '$TOP_SRC_DIR/intl', duplicate = 0)
126
127   intlenv = env.Copy()
128   # we need the original C compiler for these files
129   intlenv['CC'] = intlenv['C_COMPILER']
130   intlenv['CCFLAGS'] = intlenv['C_CCFLAGS']
131   intlenv['CPPPATH'] += ['intl']
132   
133   intlenv.Append(CCFLAGS = [
134     r'-DLOCALEDIR=\"' + env['LOCALE_DIR'].replace('\\', '\\\\') + r'\"',
135     r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALE_DIR'].replace('\\', '\\\\') + r'\"',
136     r'-DLIBDIR=\"' + env['TOP_SRC_DIR'].replace('\\', '\\\\') + r'/lib\"',
137     '-DIN_LIBINTL',
138     '-DENABLE_RELOCATABLE=1',
139     '-DIN_LIBRARY',
140     r'-DINSTALLDIR=\"' + env['PREFIX'].replace('\\', '\\\\') + r'/lib\"',
141     '-DNO_XMALLOC',
142     '-Dset_relocation_prefix=libintl_set_relocation_prefix',
143     '-Drelocate=libintl_relocate',
144     '-DDEPENDS_ON_LIBICONV=1',
145     '-DHAVE_CONFIG_H'
146     ]
147   )
148
149   # libgnuintl.h.in => libintl.h
150   env.substFile('$TOP_SRC_DIR/intl/libintl.h', '$TOP_SRC_DIR/intl/libgnuintl.h.in')
151   env.Command('$TOP_SRC_DIR/intl/libgnuintl.h', '$TOP_SRC_DIR/intl/libintl.h',
152       [Copy('$TARGET', '$SOURCE')])
153   
154   intl = intlenv.StaticLibrary(
155     target = '$LOCALLIBPATH/included_intl',
156     LIBS = ['c'],
157     source = globSource(dir = env.subst('$TOP_SRC_DIR/intl'), pattern = '*.c',
158       exclude = ['vasnprintf.c', 'printf-parse.c', 'printf-args.c', 'os2compat.c'],
159       build_dir = '$BUILDDIR/intl')
160   )
161   Alias('intl', intl)
162
163
164 #
165 # Now, src code under src/
166 #
167 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
168
169
170 if build_support:
171   #
172   # src/support
173   #
174   print "Processing files in src/support..."
175
176   env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRC_DIR/src/support/package.C.in')
177
178   support = env.StaticLibrary(
179     target = '$LOCALLIBPATH/support',
180     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/support'), pattern = env['LYX_EXT'], 
181       exclude = ['os_win32.C', 'os_unix.C', 'os_cygwin.C', 'atexit.c'],
182       include = ['package.C'], build_dir = '$BUILDDIR/common/support')
183   )
184   Alias('support', support)
185
186
187 if build_mathed:
188   #
189   # src/mathed
190   #
191   print "Processing files in src/mathed..."
192
193   mathed = env.StaticLibrary(
194     target = '$LOCALLIBPATH/mathed',
195     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/mathed'), pattern = env['LYX_EXT'],
196       exclude = ['math_xyarrowinset.C', 'math_mboxinset.C', 'formulamacro.C'],
197       build_dir = '$BUILDDIR/common/mathed')
198   )
199   Alias('mathed', mathed)
200
201
202 if build_insets:
203   #
204   # src/insets
205   #
206   print "Processing files in src/insets..."
207
208   insets = env.StaticLibrary(
209     target = '$LOCALLIBPATH/insets',
210     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/insets'), pattern = env['LYX_EXT'],
211       exclude = ['insettheorem.C'], build_dir = '$BUILDDIR/common/insets')
212   )
213   Alias('insets', insets)
214
215
216 if build_frontends:
217   #
218   # src/frontends
219   #
220   print "Processing files in src/frontends..."
221
222   frontends = env.StaticLibrary(
223     target = '$LOCALLIBPATH/frontends',
224     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends'), pattern = env['LYX_EXT'],
225       build_dir = '$BUILDDIR/common/frontends')
226   )
227   Alias('frontends', frontends)
228
229
230 if build_graphics:
231   #
232   # src/graphics
233   #
234   print "Processing files in src/graphics..."
235
236   graphics = env.StaticLibrary(
237     target = '$LOCALLIBPATH/graphics',
238     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/graphics'), pattern = env['LYX_EXT'],
239       build_dir = '$BUILDDIR/common/graphics')
240   )
241   Alias('graphics', graphics)
242
243
244 if build_controllers:
245   #
246   # src/frontends/controllers
247   #
248   print "Processing files in src/frontends/controllers..."
249
250   controllers = env.StaticLibrary(
251     target = '$LOCALLIBPATH/controllers',
252     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/controllers'), pattern = env['LYX_EXT'],
253       build_dir = '$BUILDDIR/common/frontends/controllers')
254   )
255   Alias('controllers', controllers)
256
257
258 #
259 # src/frontend/qt3/4
260 #
261 if build_qt3 or build_qt4:
262   env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRC_DIR/src/frontend/$frontend', duplicate = 0)
263
264 if build_qt3:
265   print "Processing files in src/frontends/qt3..."
266
267   qt3env = env.Copy()
268   # disable auto scan to speed up non build time
269   qt3env['QT_AUTOSCAN'] = 0
270   qt3env['QT_MOCHPREFIX'] = ''
271
272   # load qt3 tools
273   qt3env.Tool('qt')
274
275   qt3env.AppendUnique(CPPPATH = [
276     '$BUILDDIR/common',
277     '$BUILDDIR/common/images',
278     '$BUILDDIR/common/frontends',
279     '$BUILDDIR/common/frontends/qt3',
280     '$BUILDDIR/common/frontends/controllers',
281     '$QT_INC_PATH']
282   )
283
284   qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
285     BulletsModule.C
286     emptytable.C
287     FileDialog_private.C
288     floatplacement.C
289     iconpalette.C
290     lengthcombo.C
291     panelstack.C
292     QAboutDialog.C
293     QBibitemDialog.C
294     QBibtexDialog.C
295     QBoxDialog.C
296     QBranchDialog.C
297     QBrowseBox.C
298     QChangesDialog.C
299     QCharacterDialog.C
300     QCitationDialog.C
301     QCommandBuffer.C
302     QCommandEdit.C
303     QContentPane.C
304     QDelimiterDialog.C
305     QDocumentDialog.C
306     QErrorListDialog.C
307     QERTDialog.C
308     QExternalDialog.C
309     QFloatDialog.C
310     QGraphicsDialog.C
311     QIncludeDialog.C
312     QIndexDialog.C
313     QLogDialog.C
314     QViewSourceDialog.C
315     QLPopupMenu.C
316     QLPrintDialog.C
317     QMathDialog.C
318     QMathMatrixDialog.C
319     QNoteDialog.C
320     QParagraphDialog.C
321     QPrefsDialog.C
322     QRefDialog.C
323     QSearchDialog.C
324     QSendtoDialog.C
325     qsetborder.C
326     QShowFileDialog.C
327     QSpellcheckerDialog.C
328     QDialogView.C
329     QTabularCreateDialog.C
330     QTabularDialog.C
331     QTexinfoDialog.C
332     QThesaurusDialog.C
333     QTocDialog.C
334     qttableview.C
335     QtView.C
336     QURLDialog.C
337     QVSpaceDialog.C
338     QWrapDialog.C
339     QLToolbar.C
340     socket_callback.C
341     validators.C
342   ''')]
343
344   # manually moc and uic files for better performance 
345   qt3_moced_files = [qt3env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt3_moc_files]
346
347   qt3_uiced_files = [qt3env.Uic('$BUILDDIR/common/frontends/qt3/ui/'+x) for x in \
348      globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt3/ui'), pattern = '*.ui')]
349
350   qt3_uiced_cc_files = []
351   for x in qt3_uiced_files:
352     qt3_uiced_cc_files.extend(x[1:])
353
354   qt3 = qt3env.StaticLibrary(
355     target = '$LOCALLIBPATH/qt3',
356     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt3/'), pattern = env['LYX_EXT'],
357       build_dir = '$BUILDDIR/common/frontends/qt3') + qt3_moced_files + qt3_uiced_cc_files
358   )
359   Alias('qt3', qt3)
360
361
362 if build_qt4:
363   print "Processing files in src/frontends/qt4..."
364
365   qt4env = env.Copy()
366   qt4env['QT_AUTOSCAN'] = 0
367
368   # local qt4 toolset from
369   # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
370   #
371   # NOTE: I have to patch qt4.py since it does not automatically
372   # process .C file!!! (add to cxx_suffixes )
373   #
374   qt4env.Tool('qt4', [env['SCONS_DIR']])
375   qt4env.EnableQt4Modules(env['QT_LIB'], debug = False)
376
377   qt4env.AppendUnique(CPPPATH = [
378     '$BUILDDIR/common',
379     '$BUILDDIR/common/images',
380     '$BUILDDIR/common/frontends',
381     '$BUILDDIR/common/frontends/qt4',
382     '$BUILDDIR/common/frontends/controllers' 
383     ]
384   )
385
386   # FIXME: replace by something from pkg_config
387   qt4env.Append(CCFLAGS = [
388     '-DHAVE_CONFIG_H',
389     '-DQT_CLEAN_NAMESPACE',
390     '-DQT_GENUINE_STR',
391     '-DQT_NO_STL',
392     '-DQT3_SUPPORT',
393     '-DQT_NO_STL',
394     ]
395   )
396
397
398   qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
399     BulletsModule.C
400     emptytable.C
401     FileDialog_private.C
402     floatplacement.C
403     iconpalette.C
404     lengthcombo.C
405     InsertTableWidget.C
406     panelstack.C
407     QAboutDialog.C
408     QBibitemDialog.C
409     QBibtexDialog.C
410     QBoxDialog.C
411     QBranchDialog.C
412     QBranches.C
413     QChangesDialog.C
414     QCharacterDialog.C
415     QCitationDialog.C
416     QCommandBuffer.C
417     QCommandEdit.C
418     QDelimiterDialog.C
419     QDocumentDialog.C
420     QErrorListDialog.C
421     QERTDialog.C
422     QExternalDialog.C
423     QFloatDialog.C
424     QGraphicsDialog.C
425     QIncludeDialog.C
426     QIndexDialog.C
427     QLAction.C
428     QLogDialog.C
429     QViewSourceDialog.C
430     QViewSource.C
431     QLMenubar.C
432     QLPopupMenu.C
433     QLPrintDialog.C
434     QMathDialog.C
435     QMathMatrixDialog.C
436     QNoteDialog.C
437     QParagraphDialog.C
438     QPrefsDialog.C
439     QRefDialog.C
440     QSearchDialog.C
441     QSendtoDialog.C
442     qsetborder.C
443     QShowFileDialog.C
444     QSpellcheckerDialog.C
445     QDialogView.C
446     QTabularCreateDialog.C
447     QTabularDialog.C
448     QTexinfoDialog.C
449     QThesaurusDialog.C
450     TocModel.C
451     QTocDialog.C
452     QtView.C
453     QURLDialog.C
454     QVSpaceDialog.C
455     QWorkArea.C
456     QWrapDialog.C
457     QLToolbar.C
458     socket_callback.C
459     validators.C
460   ''') ]
461
462   #
463   # Compile resources
464   #
465   resources = [qt4env.Uic4(x.split('.')[0]) for x in \
466     globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt4/ui'), pattern = '*.ui',
467       build_dir = '$BUILDDIR/common/frontends/qt4/ui')]
468
469   # 
470   # moc qt4_moc_files, the moced files are included in the original files
471   #
472   qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
473
474   qt4 = qt4env.StaticLibrary(
475     target = '$LOCALLIBPATH/qt4',
476     LIBS = qt4env['QT_LIB'],
477     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt4'), pattern = env['LYX_EXT'],
478       exclude = ['QBrowseBox.C'], build_dir = '$BUILDDIR/common/frontends/qt4')
479   )
480   Alias('qt4', qt4)
481
482
483 if build_client:
484   #
485   # src/client
486   #
487   env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
488
489   print "Processing files in src/client..."
490
491   if env['HAVE_FCNTL']:
492     client = env.Program(
493       target = '$BUILDDIR/common/client/lyxclient',
494       LIBS = ['support'] + env['INTL_LIBS'] + env['SYSTEM_LIBS'] + 
495         env['SOCKET_LIBS'] + env['BOOST_LIBRARIES'],
496       source = globSource(dir = env.subst('$TOP_SRC_DIR/src/client'), pattern = env['LYX_EXT'],
497         build_dir = '$BUILDDIR/common/client')
498     )
499     Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
500       client, [Copy('$TARGET', '$SOURCE')]))
501   else:
502     client = None
503   Alias('client', client)
504
505
506 if build_tex2lyx:
507   #
508   # tex2lyx
509   #
510   print "Processing files in src/tex2lyx..."
511
512   tex2lyx_env = env.Copy()
513   # the order is important here.
514   tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
515   tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
516
517   for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C', 
518     'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
519     env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRC_DIR/src/'+file,
520       [Copy('$TARGET', '$SOURCE')])
521
522   tex2lyx = tex2lyx_env.Program(
523     target = '$BUILDDIR/common/tex2lyx/tex2lyx',
524     LIBS = ['support'] + env['BOOST_LIBRARIES'] + env['SYSTEM_LIBS'],
525     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/tex2lyx'), pattern = env['LYX_EXT'], 
526       include = ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.C', 
527         'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C'],
528       build_dir = '$BUILDDIR/common/tex2lyx')
529   )
530   Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
531     tex2lyx, [Copy('$TARGET', '$SOURCE')]))
532   Alias('tex2lyx', tex2lyx)
533
534
535 if build_lyxbase:
536   #
537   # src/
538   #
539   print "Processing files in src..."
540
541   env.substFile('$BUILDDIR/common/version.C', '$TOP_SRC_DIR/src/version.C.in')
542
543   lyx_post_source = Split('''
544     tabular.C
545     dimension.C
546     PrinterParams.C
547     box.C
548     Thesaurus.C
549     SpellBase.C
550   ''')
551   
552   if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
553     lyx_post_source.append('aspell.C')
554   elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
555     lyx_post_source.append('pspell.C')
556   elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
557     lyx_post_source.append('ispell.C')
558
559   # temporary fix for MSVC, will remove later.
560   if not env['USE_VC']:
561     main_source = ['main.C']
562   else:
563     main_source = []
564   
565   lyxbase_pre = env.StaticLibrary(
566     target = '$LOCALLIBPATH/lyxbase_pre',
567     source = globSource(dir = env.subst('$TOP_SRC_DIR/src'), pattern = env['LYX_EXT'], 
568       exclude = lyx_post_source + ['main.C', 'aspell.C', 'pspell.C', 'ispell.C', 'Variables.C', 'Sectioning.C'],
569       include = ['version.C'] + main_source, build_dir = '$BUILDDIR/common')
570   )
571   lyxbase_post = env.StaticLibrary(
572     target = '$LOCALLIBPATH/lyxbase_post',
573     source = ["$BUILDDIR/common/%s" % x for x in lyx_post_source]
574   )
575   Alias('lyxbase', lyxbase_pre)
576   Alias('lyxbase', lyxbase_post)
577
578
579 if build_lyx:
580   #
581   # Build lyx with given frontend
582   #
583   # temporary fix for MSVC, will remove later.
584   if env['USE_VC']:
585     lyx_source = ['$BUILDDIR/common/main.C']
586   else:
587     lyx_source = []
588   lyx = env.Program(
589     target = '$BUILDDIR/$frontend/lyx',
590     source = lyx_source,
591     LIBS = [
592       'lyxbase_pre',
593       'mathed',
594       'insets',
595       'frontends',
596       env['frontend'],
597       'controllers',
598       'graphics',
599       'support',
600       'lyxbase_post',
601       ] +
602       env['BOOST_LIBRARIES'] +
603       env['EXTRA_LIBS'] +
604       env['INTL_LIBS'] + 
605       env['SOCKET_LIBS'] +
606       env['SYSTEM_LIBS']
607   )
608   # [/path/to/lyx.ext] => lyx-qt3.ext
609   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s' % frontend)
610   Alias('lyx', env.Command(os.path.join('$BUILDDIR', target_name), lyx,
611     [Copy('$TARGET', '$SOURCE')]))
612   Alias('lyx', lyx)
613  
614
615 if build_msvs_projects:
616   def build_project(target, dir, src_pattern = env['LYX_EXT'], include=[], 
617     resource=None, rebuild=True):
618     if resource is not None:
619       res = globSource(dir = env.subst('$TOP_SRC_DIR/'+resource), pattern = '*.ui', 
620         build_dir = env.subst('$TOP_SRC_DIR/'+resource))
621     else:
622       res = []
623     if rebuild:
624       cmds = 'faststart=yes rebuild='+target
625     else:
626       cmds = 'faststart=yes'
627     if type(dir) == type([]):
628       src = []
629       inc = []
630       for d in dir:
631         src.extend(globSource(dir = env.subst('$TOP_SRC_DIR/' + d), 
632           pattern = src_pattern, include = include,
633           build_dir = boostenv.subst('$TOP_SRC_DIR/' + d) ))
634         inc.extend(globSource(dir = env.subst('$TOP_SRC_DIR/' + d), 
635           pattern = '*.h', 
636           build_dir = env.subst('$TOP_SRC_DIR/' + d) ))
637     else:
638       src = globSource(dir = env.subst('$TOP_SRC_DIR/' + dir), 
639         pattern = src_pattern, include = include,
640         build_dir = boostenv.subst('$TOP_SRC_DIR/' + dir) )
641       inc = globSource(dir = env.subst('$TOP_SRC_DIR/' + dir), 
642         pattern = '*.h', 
643         build_dir = env.subst('$TOP_SRC_DIR/' + dir) )
644     # project
645     proj = boostenv.MSVSProject(
646       target = '$MSVSPATH/' + target + env['MSVSPROJECTSUFFIX'],
647       srcs = src,
648       incs = [boostenv.subst('$TOP_SRC_DIR/src/config.h')],
649       localincs = inc,
650       resources = res,
651       buildtarget = target,
652       cmdargs = cmds,
653       variant = 'Release'
654     )
655     Alias('msvs_projects', proj)
656   build_project('boost', ['boost/libs/filesystem/src',
657     'boost/libs/regex/src', 'boost/libs/signals/src',
658     'boost/libs/iostreams/src'], src_pattern = '*.cpp')
659   build_project('intl', 'intl', src_pattern = '*.c')
660   build_project('support', 'src/support', include=['package.C.in'])
661   build_project('mathed', 'src/mathed')
662   build_project('insets', 'src/insets')
663   build_project('frontends', 'src/frontends')
664   build_project('graphics', 'src/graphics')
665   build_project('controllers', 'src/frontends/controllers')
666   build_project('qt3', 'src/frontends/qt3', resource = 'src/frontends/qt3/ui')
667   build_project('qt4', 'src/frontends/qt4', resource = 'src/frontends/qt4/ui')
668   build_project('client', 'src/client', rebuild=False)
669   build_project('tex2lyx', 'src/tex2lyx', rebuild=False)
670   build_project('lyxbase', 'src')
671   if frontend == 'qt3':
672     build_project('lyx', ['src', 'src/support', 'src/mathed', 'src/insets',
673       'src/frontends', 'src/graphics', 'src/frontends/controllers', 
674       'src/frontends/qt3'], resource = 'src/frontends/qt3/ui')
675   else:
676     build_project('lyx', ['src', 'src/support', 'src/mathed', 'src/insets',
677       'src/frontends', 'src/graphics', 'src/frontends/controllers', 
678       'src/frontends/qt4'], resource = 'src/frontends/qt4/ui')
679
680
681 if build_po:
682   #
683   # po/
684   #
685   print 'Processing files in po...'
686
687   import glob
688   # handle po files
689   #
690   # files to translate
691   transfiles = glob.glob(os.path.join(env.subst('$TOP_SRC_DIR'), 'po', '*.po'))
692   # possibly *only* handle these languages
693   languages = None
694   if env.has_key('languages'):
695     languages = env.make_list(env['lanauges'])
696   # use defulat msgfmt
697   if not env['MSGFMT']:
698     print 'msgfmt does not exist. Can not process po files'
699   else:
700     # create a builder
701     env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
702     #
703     gmo_files = []
704     for f in transfiles:
705       # get filename
706       fname = os.path.split(f)[1]
707       # country code
708       country = fname.split('.')[0]
709       #
710       if not languages or country in languages:
711         gmo_files.extend(env.Transfiles(f))
712
713
714 if 'install' in targets:
715   # create the directory if needed
716   if not os.path.isdir(env['DEST_DIR']):
717     try:
718       os.makedirs(env['DEST_DIR'])
719     except:
720       pass
721     if not os.path.isdir(env['DEST_DIR']):
722       print 'Can not create directory', env['DEST_DIR']
723       Exit(3)
724   #
725   import glob
726   #
727   # do not install these files
728   exclude_list = ['Makefile.am', 'Makefile.in', 'Makefile', 
729     'lyx2lyx_version.py', 'lyx2lyx_version.py.in']
730
731   def install(dest, src):
732     ''' recusive installation of src to dest '''
733     # separate file and directory
734     files = filter(lambda x: os.path.isfile(x) and not os.path.split(x)[1] in exclude_list, src)
735     dirs = filter(os.path.isdir, src)
736     # install file
737     env.Install(dest, files)
738     # install directory
739     ins_dir = [dest]
740     for dir in dirs:
741       ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
742         glob.glob(os.path.join(dir, '*'))) )
743     return ins_dir
744   #
745   # executables (some of them may be none)
746   #
747   if env['ADD_SUFFIX_TO_EXECUTABLES']:
748     program_suffix = env['PROGRAM_SUFFIX']
749   else:
750     program_suffix = ''
751   #
752   # install lyx
753   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx%s' % program_suffix)
754   target = os.path.join(env['BIN_DEST_DIR'], target_name)
755   env.InstallAs(target, lyx)
756   Alias('install', target)
757   # install lyx as lyx-qt3
758   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s%s' % (frontend, program_suffix))
759   target = os.path.join(env['BIN_DEST_DIR'], target_name)
760   env.InstallAs(target, lyx)
761   Alias('install', target)
762   #
763   # install tex2lyx
764   target_name = os.path.split(str(tex2lyx[0]))[1].replace('tex2lyx', 'tex2lyx%s' % program_suffix)
765   target = os.path.join(env['BIN_DEST_DIR'], target_name)
766   env.InstallAs(target, tex2lyx)
767   Alias('install', target)
768   #
769   # install lyxclient, may not exist
770   if client != None:
771     target_name = os.path.split(str(client[0]))[1].replace('client', 'client%s' % program_suffix)
772     target = os.path.join(env['BIN_DEST_DIR'], target_name)
773     env.InstallAs(target, client)
774     Alias('install', target)
775   #
776   # share/lyx
777   dirs = install(env['SHARE_DEST_DIR'],
778     [env.subst('$TOP_SRC_DIR/lib/') + file for file in ['configure.py', 'encodings',
779      'chkconfig.ltx', 'CREDITS', 'external_templates', 'symbols', 'languages',
780      'lyxrc.example', 'syntax.default', 'bind', 'images', 'layouts', 'scripts', 
781      'templates', 'examples', 'kbd', 'lyx2lyx', 'tex', 'clipart', 'doc',  'ui']]
782   )
783   env.substFile('$SHARE_DEST_DIR/lyx2lyx/lyx2lyx_version.py', 
784     '$TOP_SRC_DIR/lib/lyx2lyx/lyx2lyx_version.py.in')
785   Alias('install', dirs)
786   # man
787   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyx.1'),
788     env.subst('$TOP_SRC_DIR/lyx.man'))
789   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'tex2lyx.1'),
790     env.subst('$TOP_SRC_DIR/src/tex2lyx/tex2lyx.man'))
791   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyxclient.1'),
792     env.subst('$TOP_SRC_DIR/src/client/lyxclient.man'))
793   Alias('install', [os.path.join(env['MAN_DEST_DIR'], x) for
794     x in ['lyx.1', 'tex2lyx.1', 'lyxclient.1']])
795   # locale files?
796   # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
797   for gmo in gmo_files:
798     lan = os.path.split(str(gmo))[1].split('.')[0]
799     dest_file = os.path.join(env['LOCALE_DEST_DIR'], lan, 'LC_MESSAGES', 'lyx' + env['PROGRAM_SUFFIX'] + '.mo')
800     env.InstallAs(dest_file, gmo)
801     Alias('install', dest_file)
802
803
804 Default('lyx')
805 Alias('all', ['lyx', 'client', 'tex2lyx', 'po'])