]> git.lyx.org Git - lyx.git/blob - development/scons/SConscript
Scons: msvc command line support.
[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_supports = build_lyx or True in [x in targets for x in ['supports', '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_msvc_projects = env['USE_VC'] and 'msvc_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_supports = ifBuildLib('supports', 'supports', build_supports)
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'), pattern = '*.cpp',
95       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'), pattern = '*.cpp',
103       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'), pattern = '*.cpp',
111       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 # Now, src code under src/
165 #
166 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
167
168
169 if build_supports:
170   #
171   # src/support
172   #
173   print "Processing files in src/support..."
174
175   env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRC_DIR/src/support/package.C.in')
176
177   supports = env.StaticLibrary(
178     target = '$LOCALLIBPATH/supports',
179     source =  globSource(dir = env.subst('$TOP_SRC_DIR/src/support'), pattern = env['LYX_EXT'], 
180       exclude = ['os_win32.C', 'os_unix.C', 'os_cygwin.C', 'atexit.c'],
181       include = ['package.C'], build_dir = '$BUILDDIR/common/support')
182   )
183   Alias('supports', supports)
184
185
186 if build_mathed:
187   #
188   # src/mathed
189   #
190   print "Processing files in src/mathed..."
191
192   mathed = env.StaticLibrary(
193     target = '$LOCALLIBPATH/mathed',
194     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/mathed'), pattern = env['LYX_EXT'],
195       exclude = ['math_xyarrowinset.C', 'math_mboxinset.C', 'formulamacro.C'],
196       build_dir = '$BUILDDIR/common/mathed')
197   )
198   Alias('mathed', mathed)
199
200
201 if build_insets:
202   #
203   # src/insets
204   #
205   print "Processing files in src/insets..."
206
207   insets = env.StaticLibrary(
208     target = '$LOCALLIBPATH/insets',
209     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/insets'), pattern = env['LYX_EXT'],
210       exclude = ['insettheorem.C'], build_dir = '$BUILDDIR/common/insets')
211   )
212   Alias('insets', insets)
213
214
215 if build_frontends:
216   #
217   # src/frontends
218   #
219   print "Processing files in src/frontends..."
220
221   frontends = env.StaticLibrary(
222     target = '$LOCALLIBPATH/frontends',
223     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends'), pattern = env['LYX_EXT'],
224       build_dir = '$BUILDDIR/common/frontends')
225   )
226   Alias('frontends', frontends)
227
228
229 if build_graphics:
230   #
231   # src/graphics
232   #
233   print "Processing files in src/graphics..."
234
235   graphics = env.StaticLibrary(
236     target = '$LOCALLIBPATH/graphics',
237     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/graphics'), pattern = env['LYX_EXT'],
238       build_dir = '$BUILDDIR/common/graphics')
239   )
240   Alias('graphics', graphics)
241
242
243 if build_controllers:
244   #
245   # src/frontends/controllers
246   #
247   print "Processing files in src/frontends/controllers..."
248
249   controllers = env.StaticLibrary(
250     target = '$LOCALLIBPATH/controllers',
251     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/controllers'), pattern = env['LYX_EXT'],
252       build_dir = '$BUILDDIR/common/frontends/controllers')
253   )
254   Alias('controllers', controllers)
255
256
257 #
258 # src/frontend/qt3/4
259 #
260 if build_qt3 or build_qt4:
261   env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRC_DIR/src/frontend/$frontend', duplicate = 0)
262
263 if build_qt3:
264   print "Processing files in src/frontends/qt3..."
265
266   qt3env = env.Copy()
267   # disable auto scan to speed up non build time
268   qt3env['QT_AUTOSCAN'] = 0
269   qt3env['QT_MOCHPREFIX'] = ''
270
271   # load qt3 tools
272   qt3env.Tool('qt')
273
274   qt3env.AppendUnique(CPPPATH = [
275     '$BUILDDIR/common',
276     '$BUILDDIR/common/images',
277     '$BUILDDIR/common/frontends',
278     '$BUILDDIR/common/frontends/qt3',
279     '$BUILDDIR/common/frontends/controllers',
280     '$QT_INC_PATH']
281   )
282
283   qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
284     BulletsModule.C
285     emptytable.C
286     FileDialog_private.C
287     floatplacement.C
288     iconpalette.C
289     lengthcombo.C
290     panelstack.C
291     QAboutDialog.C
292     QBibitemDialog.C
293     QBibtexDialog.C
294     QBoxDialog.C
295     QBranchDialog.C
296     QBrowseBox.C
297     QChangesDialog.C
298     QCharacterDialog.C
299     QCitationDialog.C
300     QCommandBuffer.C
301     QCommandEdit.C
302     QContentPane.C
303     QDelimiterDialog.C
304     QDocumentDialog.C
305     QErrorListDialog.C
306     QERTDialog.C
307     QExternalDialog.C
308     QFloatDialog.C
309     QGraphicsDialog.C
310     QIncludeDialog.C
311     QIndexDialog.C
312     QLogDialog.C
313     QViewSourceDialog.C
314     QLPopupMenu.C
315     QLPrintDialog.C
316     QMathDialog.C
317     QMathMatrixDialog.C
318     QNoteDialog.C
319     QParagraphDialog.C
320     QPrefsDialog.C
321     QRefDialog.C
322     QSearchDialog.C
323     QSendtoDialog.C
324     qsetborder.C
325     QShowFileDialog.C
326     QSpellcheckerDialog.C
327     QDialogView.C
328     QTabularCreateDialog.C
329     QTabularDialog.C
330     QTexinfoDialog.C
331     QThesaurusDialog.C
332     QTocDialog.C
333     qttableview.C
334     QtView.C
335     QURLDialog.C
336     QVSpaceDialog.C
337     QWrapDialog.C
338     QLToolbar.C
339     socket_callback.C
340     validators.C
341   ''')]
342
343   # manually moc and uic files for better performance 
344   qt3_moced_files = [qt3env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt3_moc_files]
345
346   qt3_uiced_files = [qt3env.Uic('$BUILDDIR/common/frontends/qt3/ui/'+x) for x in \
347      globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt3/ui'), pattern = '*.ui')]
348
349   qt3_uiced_cc_files = []
350   for x in qt3_uiced_files:
351     qt3_uiced_cc_files.extend(x[1:])
352
353   qt3 = qt3env.StaticLibrary(
354     target = '$LOCALLIBPATH/qt3',
355     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt3/'), pattern = env['LYX_EXT'],
356       build_dir = '$BUILDDIR/common/frontends/qt3') + qt3_moced_files + qt3_uiced_cc_files
357   )
358   Alias('qt3', qt3)
359
360
361 if build_qt4:
362   print "Processing files in src/frontends/qt4..."
363
364   qt4env = env.Copy()
365   qt4env['QT_AUTOSCAN'] = 0
366
367   # local qt4 toolset from
368   # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
369   #
370   # NOTE: I have to patch qt4.py since it does not automatically
371   # process .C file!!! (add to cxx_suffixes )
372   #
373   qt4env.Tool('qt4', [env['SCONS_DIR']])
374   qt4env.EnableQt4Modules(env['QT_LIB'], debug = False)
375
376   qt4env.AppendUnique(CPPPATH = [
377     '$BUILDDIR/common',
378     '$BUILDDIR/common/images',
379     '$BUILDDIR/common/frontends',
380     '$BUILDDIR/common/frontends/qt4',
381     '$BUILDDIR/common/frontends/controllers' 
382     ]
383   )
384
385   # FIXME: replace by something from pkg_config
386   qt4env.Append(CCFLAGS = [
387     '-DHAVE_CONFIG_H',
388     '-DQT_CLEAN_NAMESPACE',
389     '-DQT_GENUINE_STR',
390     '-DQT_NO_STL',
391     '-DQT3_SUPPORT',
392     ]
393   )
394
395
396   qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
397     BulletsModule.C
398     emptytable.C
399     FileDialog_private.C
400     floatplacement.C
401     iconpalette.C
402     lengthcombo.C
403     InsertTableWidget.C
404     panelstack.C
405     QAboutDialog.C
406     QBibitemDialog.C
407     QBibtexDialog.C
408     QBoxDialog.C
409     QBranchDialog.C
410     QBranches.C
411     QChangesDialog.C
412     QCharacterDialog.C
413     QCitationDialog.C
414     QCommandBuffer.C
415     QCommandEdit.C
416     QDelimiterDialog.C
417     QDocumentDialog.C
418     QErrorListDialog.C
419     QERTDialog.C
420     QExternalDialog.C
421     QFloatDialog.C
422     QGraphicsDialog.C
423     QIncludeDialog.C
424     QIndexDialog.C
425     QLAction.C
426     QLogDialog.C
427     QViewSourceDialog.C
428     QViewSource.C
429     QLMenubar.C
430     QLPopupMenu.C
431     QLPrintDialog.C
432     QMathDialog.C
433     QMathMatrixDialog.C
434     QNoteDialog.C
435     QParagraphDialog.C
436     QPrefsDialog.C
437     QRefDialog.C
438     QSearchDialog.C
439     QSendtoDialog.C
440     qsetborder.C
441     QShowFileDialog.C
442     QSpellcheckerDialog.C
443     QDialogView.C
444     QTabularCreateDialog.C
445     QTabularDialog.C
446     QTexinfoDialog.C
447     QThesaurusDialog.C
448     TocModel.C
449     QTocDialog.C
450     QtView.C
451     QURLDialog.C
452     QVSpaceDialog.C
453     QWorkArea.C
454     QWrapDialog.C
455     QLToolbar.C
456     socket_callback.C
457     validators.C
458   ''') ]
459
460   #
461   # Compile resources
462   #
463   resources = [qt4env.Uic4(x.split('.')[0]) for x in \
464     globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt4/ui'), pattern = '*.ui',
465       build_dir = '$BUILDDIR/common/frontends/qt4/ui')]
466
467   # 
468   # moc qt4_moc_files, the moced files are included in the original files
469   #
470   qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
471
472   qt4 = qt4env.StaticLibrary(
473     target = '$LOCALLIBPATH/qt4',
474     LIBS = qt4env['QT_LIB'],
475     source =  globSource(dir = env.subst('$TOP_SRC_DIR/src/frontends/qt4'), pattern = env['LYX_EXT'],
476       exclude = ['QBrowseBox.C'], build_dir = '$BUILDDIR/common/frontends/qt4')
477   )
478   Alias('qt4', qt4)
479
480
481 if build_client:
482   #
483   # src/client
484   #
485   env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
486
487   print "Processing files in src/client..."
488
489   if env['HAVE_FCNTL']:
490     client = env.Program(
491       target = '$BUILDDIR/common/client/lyxclient',
492       LIBS = ['supports'] + env['INTL_LIBS'] + env['SYSTEM_LIBS'] + 
493         env['SOCKET_LIBS'] + env['BOOST_LIBRARIES'],
494       source = globSource(dir = env.subst('$TOP_SRC_DIR/src/client'), pattern = env['LYX_EXT'],
495         build_dir = '$BUILDDIR/common/client')
496     )
497     Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
498       client, [Copy('$TARGET', '$SOURCE')]))
499   else:
500     client = None
501   Alias('client', client)
502
503
504 if build_tex2lyx:
505   #
506   # tex2lyx
507   #
508   print "Processing files in src/tex2lyx..."
509
510   tex2lyx_env = env.Copy()
511   # the order is important here.
512   tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
513   tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
514
515   for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C', 
516     'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
517     env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRC_DIR/src/'+file,
518       [Copy('$TARGET', '$SOURCE')])
519
520   tex2lyx = tex2lyx_env.Program(
521     target = '$BUILDDIR/common/tex2lyx/tex2lyx',
522     LIBS = ['supports'] + env['BOOST_LIBRARIES'] + env['SYSTEM_LIBS'],
523     source = globSource(dir = env.subst('$TOP_SRC_DIR/src/tex2lyx'), pattern = env['LYX_EXT'], 
524       include = ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.C', 
525         'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C'],
526       build_dir = '$BUILDDIR/common/tex2lyx')
527   )
528   Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
529     tex2lyx, [Copy('$TARGET', '$SOURCE')]))
530   Alias('tex2lyx', tex2lyx)
531
532
533 if build_lyxbase:
534   #
535   # src/
536   #
537   print "Processing files in src..."
538
539   env.substFile('$BUILDDIR/common/version.C', '$TOP_SRC_DIR/src/version.C.in')
540
541   lyx_post_source = Split('''
542     tabular.C
543     dimension.C
544     PrinterParams.C
545     box.C
546     Thesaurus.C
547     SpellBase.C
548   ''')
549   
550   if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
551     lyx_post_source.append('aspell.C')
552   elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
553     lyx_post_source.append('pspell.C')
554   elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
555     lyx_post_source.append('ispell.C')
556
557   # temporary fix for MSVC, will remove later.
558   if not env['USE_VC']:
559     main_source = ['main.C']
560   else:
561     main_source = []
562   
563   lyxbase_pre = env.StaticLibrary(
564     target = '$LOCALLIBPATH/lyxbase_pre',
565     source =  globSource(dir = env.subst('$TOP_SRC_DIR/src'), pattern = env['LYX_EXT'], 
566       exclude = lyx_post_source + ['main.C', 'aspell.C', 'pspell.C', 'ispell.C', 'Variables.C', 'Sectioning.C'],
567       include = ['version.C'] + main_source, build_dir = '$BUILDDIR/common')
568   )
569   lyxbase_post = env.StaticLibrary(
570     target = '$LOCALLIBPATH/lyxbase_post',
571     source = ["$BUILDDIR/common/%s" % x for x in lyx_post_source]
572   )
573   Alias('lyxbase', lyxbase_pre)
574   Alias('lyxbase', lyxbase_post)
575
576
577 if build_lyx:
578   #
579   # Build lyx with given frontend
580   #
581   # temporary fix for MSVC, will remove later.
582   if env['USE_VC']:
583     lyx_source = ['$BUILDDIR/common/main.C']
584   else:
585     lyx_source = []
586   lyx = env.Program(
587     target = '$BUILDDIR/$frontend/lyx',
588     source = lyx_source,
589     LIBS = [
590       'lyxbase_pre',
591       'mathed',
592       'insets',
593       'frontends',
594       env['frontend'],
595       'controllers',
596       'graphics',
597       'supports',
598       'lyxbase_post',
599       ] +
600       env['BOOST_LIBRARIES'] +
601       env['EXTRA_LIBS'] +
602       env['INTL_LIBS'] + 
603       env['SOCKET_LIBS'] +
604       env['SYSTEM_LIBS']
605   )
606   # [/path/to/lyx.ext] => lyx-qt3.ext
607   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s' % frontend)
608   Alias('lyx', env.Command(os.path.join('$BUILDDIR', target_name), lyx,
609     [Copy('$TARGET', '$SOURCE')]))
610   Alias('lyx', lyx)
611
612
613
614 if build_po:
615   #
616   # po/
617   #
618   print 'Processing files in po...'
619
620   import glob
621   # handle po files
622   #
623   # files to translate
624   transfiles = glob.glob(os.path.join(env.subst('$TOP_SRC_DIR'), 'po', '*.po'))
625   # possibly *only* handle these languages
626   languages = None
627   if env.has_key('languages'):
628     languages = env.make_list(env['lanauges'])
629   # use defulat msgfmt
630   if not env['MSGFMT']:
631     print 'msgfmt does not exist. Can not process po files'
632   else:
633     # create a builder
634     env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
635     #
636     gmo_files = []
637     for f in transfiles:
638       # get filename
639       fname = os.path.split(f)[1]
640       # country code
641       country = fname.split('.')[0]
642       #
643       if not languages or country in languages:
644         gmo_files.extend(env.Transfiles(f))
645
646
647 if 'install' in targets:
648   # create the directory if needed
649   if not os.path.isdir(env['DEST_DIR']):
650     try:
651       os.makedirs(env['DEST_DIR'])
652     except:
653       pass
654     if not os.path.isdir(env['DEST_DIR']):
655       print 'Can not create directory', env['DEST_DIR']
656       Exit(3)
657   #
658   import glob
659   #
660   # do not install these files
661   exclude_list = ['Makefile.am', 'Makefile.in', 'Makefile', 
662     'lyx2lyx_version.py', 'lyx2lyx_version.py.in']
663
664   def install(dest, src):
665     ''' recusive installation of src to dest '''
666     # separate file and directory
667     files = filter(lambda x: os.path.isfile(x) and not os.path.split(x)[1] in exclude_list, src)
668     dirs = filter(os.path.isdir, src)
669     # install file
670     env.Install(dest, files)
671     # install directory
672     ins_dir = [dest]
673     for dir in dirs:
674       ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
675         glob.glob(os.path.join(dir, '*'))) )
676     return ins_dir
677   #
678   # executables (some of them may be none)
679   #
680   if env['ADD_SUFFIX_TO_EXECUTABLES']:
681     program_suffix = env['PROGRAM_SUFFIX']
682   else:
683     program_suffix = ''
684   #
685   # install lyx
686   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx%s' % program_suffix)
687   target = os.path.join(env['BIN_DEST_DIR'], target_name)
688   env.InstallAs(target, lyx)
689   Alias('install', target)
690   # install lyx as lyx-qt3
691   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s%s' % (frontend, program_suffix))
692   target = os.path.join(env['BIN_DEST_DIR'], target_name)
693   env.InstallAs(target, lyx)
694   Alias('install', target)
695   #
696   # install tex2lyx
697   target_name = os.path.split(str(tex2lyx[0]))[1].replace('tex2lyx', 'tex2lyx%s' % program_suffix)
698   target = os.path.join(env['BIN_DEST_DIR'], target_name)
699   env.InstallAs(target, tex2lyx)
700   Alias('install', target)
701   #
702   # install lyxclient, may not exist
703   if client != None:
704     target_name = os.path.split(str(client[0]))[1].replace('client', 'client%s' % program_suffix)
705     target = os.path.join(env['BIN_DEST_DIR'], target_name)
706     env.InstallAs(target, client)
707     Alias('install', target)
708   #
709   # share/lyx
710   dirs = install(env['SHARE_DEST_DIR'],
711     [env.subst('$TOP_SRC_DIR/lib/') + file for file in ['configure.py', 'encodings',
712      'chkconfig.ltx', 'CREDITS', 'external_templates', 'symbols', 'languages',
713      'lyxrc.example', 'syntax.default', 'bind', 'images', 'layouts', 'scripts', 
714      'templates', 'examples', 'kbd', 'lyx2lyx', 'tex', 'clipart', 'doc',  'ui']]
715   )
716   env.substFile('$SHARE_DEST_DIR/lyx2lyx/lyx2lyx_version.py', 
717     '$TOP_SRC_DIR/lib/lyx2lyx/lyx2lyx_version.py.in')
718   Alias('install', dirs)
719   # man
720   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyx.1'),
721     env.subst('$TOP_SRC_DIR/lyx.man'))
722   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'tex2lyx.1'),
723     env.subst('$TOP_SRC_DIR/src/tex2lyx/tex2lyx.man'))
724   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyxclient.1'),
725     env.subst('$TOP_SRC_DIR/src/client/lyxclient.man'))
726   Alias('install', [os.path.join(env['MAN_DEST_DIR'], x) for
727     x in ['lyx.1', 'tex2lyx.1', 'lyxclient.1']])
728   # locale files?
729   # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
730   for gmo in gmo_files:
731     lan = os.path.split(str(gmo))[1].split('.')[0]
732     dest_file = os.path.join(env['LOCALE_DEST_DIR'], lan, 'LC_MESSAGES', 'lyx' + env['PROGRAM_SUFFIX'] + '.mo')
733     env.InstallAs(dest_file, gmo)
734     Alias('install', dest_file)
735
736
737 Default('lyx')
738 Alias('all', ['lyx', 'client', 'tex2lyx', 'po'])