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