]> git.lyx.org Git - lyx.git/blob - development/scons/SConscript
Scons: dest_dir option, cache command line option, fix a intl bug
[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
13 Import('env')
14
15 targets = env['BUILD_TARGETS']
16 build_lyx = (targets == [] or 'lyx' in targets or 'install' in targets or 'all' in targets)
17
18
19 if env['INCLUDED_BOOST'] or 'boost' in targets:
20   #
21   # boost libraries
22   #
23   # special builddir
24   env.BuildDir('$BUILDDIR/boost', '$TOP_SRC_DIR/boost/libs', duplicate = 0)
25
26   boostenv = env.Copy()
27   boostenv.AppendUnique(CCFLAGS = '-DBOOST_USER_CONFIG="<config.h>"')
28
29   print 'Processing files in boost/libs/filesystem/src...'
30
31   filesystem = boostenv.StaticLibrary(
32     target = '$LOCALLIBPATH/included_boost_filesystem',
33     source = ["$BUILDDIR/boost/filesystem/src/%s" % x for x in Split('''
34       convenience.cpp
35       exception.cpp
36       operations_posix_windows.cpp
37       path_posix_windows.cpp
38     ''')]
39   )
40
41   print 'Processing files in boost/libs/regex/src...'
42
43   regex = boostenv.StaticLibrary(
44     target = '$LOCALLIBPATH/included_boost_regex',
45     source = ["$BUILDDIR/boost/regex/src/%s" % x for x in Split('''
46       cpp_regex_traits.cpp
47       c_regex_traits.cpp
48       cregex.cpp
49       fileiter.cpp
50       instances.cpp
51       regex.cpp
52       regex_raw_buffer.cpp
53       regex_traits_defaults.cpp
54       w32_regex_traits.cpp
55     ''')]
56   )
57
58   print 'Processing files in boost/libs/signals/src...'
59
60   signals = boostenv.StaticLibrary(
61     target = '$LOCALLIBPATH/included_boost_signals',
62     source = ["$BUILDDIR/boost/signals/src/%s" % x for x in Split('''
63       connection.cpp
64       named_slot_map.cpp
65       signal_base.cpp
66       slot.cpp
67       trackable.cpp
68     ''')]
69   )
70
71   print 'Processing files in boost/libs/iostreams/src...'
72
73   iostreams = boostenv.StaticLibrary(
74     target = '$LOCALLIBPATH/included_boost_iostreams',
75     source = ["$BUILDDIR/boost/iostreams/src/%s" % x for x in Split('''
76       file_descriptor.cpp
77       mapped_file.cpp
78       zlib.cpp
79     ''') ]
80   )
81   Alias('boost', filesystem)
82   Alias('boost', regex)
83   Alias('boost', signals)
84   Alias('boost', iostreams)
85
86
87 if env['INCLUDED_GETTEXT'] or 'intl' in targets:
88   # 
89   # intl
90   # 
91   print "Processing files in intl..."
92
93   env.BuildDir('$BUILDDIR/intl', '$TOP_SRC_DIR/intl', duplicate = 0)
94
95   intlenv = env.Copy()
96   # we need the original C compiler for these files
97   intlenv['CC'] = intlenv['C_COMPILER']
98   intlenv['CPPPATH'] += ['intl']
99   
100   intlenv.Append(CCFLAGS = [
101     r'-DLOCALEDIR=\"' + env['LOCALE_DIR'].replace('\\', '\\\\') + r'\"',
102     r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALE_DIR'].replace('\\', '\\\\') + r'\"',
103     r'-DLIBDIR=\"' + env['TOP_SRC_DIR'].replace('\\', '\\\\') + r'/lib\"',
104     '-DIN_LIBINTL',
105     '-DENABLE_RELOCATABLE=1',
106     '-DIN_LIBRARY',
107     r'-DINSTALLDIR=\"' + env['PREFIX'].replace('\\', '\\\\') + r'/lib\"',
108     '-DNO_XMALLOC',
109     '-Dset_relocation_prefix=libintl_set_relocation_prefix',
110     '-Drelocate=libintl_relocate',
111     '-DDEPENDS_ON_LIBICONV=1',
112     '-DHAVE_CONFIG_H'
113     ]
114   )
115
116   # libgnuintl.h.in => libintl.h
117   env.substFile('$TOP_SRC_DIR/intl/libintl.h', '$TOP_SRC_DIR/intl/libgnuintl.h.in')
118   env.Command('$TOP_SRC_DIR/intl/libgnuintl.h', '$TOP_SRC_DIR/intl/libintl.h',
119       [Copy('$TARGET', '$SOURCE')])
120   
121   intl = intlenv.StaticLibrary(
122     target = '$LOCALLIBPATH/included_intl',
123     LIBS = ['c'],
124     source = ["$BUILDDIR/intl/%s" % x for x in Split('''
125       bindtextdom.c
126       dcgettext.c
127       dgettext.c
128       gettext.c
129       finddomain.c
130       loadmsgcat.c
131       localealias.c
132       textdomain.c
133       l10nflist.c
134       explodename.c
135       dcigettext.c
136       dcngettext.c
137       dngettext.c
138       ngettext.c
139       plural.c
140       plural-exp.c
141       localcharset.c
142       relocatable.c
143       localename.c
144       log.c
145       printf.c
146       osdep.c
147       os2compat.c
148       intl-compat.c
149     ''')]
150   )
151   Alias('intl', intl)
152
153 #
154 # Now, src code under src/
155 #
156 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
157
158
159 if build_lyx or True in [x in targets for x in ['supports', 'client', 'tex2lyx']]:
160   #
161   # src/support
162   #
163   print "Processing files in src/support..."
164
165   env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRC_DIR/src/support/package.C.in')
166
167   supports = env.StaticLibrary(
168     target = '$LOCALLIBPATH/supports',
169     source = ['$BUILDDIR/common/support/%s' % x for x in Split('''
170       FileMonitor.C
171       abort.C
172       chdir.C
173       convert.C
174       copy.C
175       environment.C
176       filefilterlist.C
177       filename.C
178       filetools.C
179       forkedcall.C
180       forkedcallqueue.C
181       forkedcontr.C
182       fs_extras.C
183       getcwd.C
184       kill.C
185       lstrings.C
186       lyxtime.C
187       lyxsum.C
188       mkdir.C
189       os.C
190       path.C
191       package.C
192       rename.C
193       socktools.C
194       systemcall.C
195       tempname.C
196       userinfo.C
197       unlink.C
198     ''')]
199   )
200   Alias('supports', supports)
201
202
203 if build_lyx or 'mathed' in targets:
204   #
205   # src/mathed
206   #
207   print "Processing files in src/mathed..."
208
209   mathed = env.StaticLibrary(
210     target = '$LOCALLIBPATH/mathed',
211     source = ["$BUILDDIR/common/mathed/%s" % x for x in Split('''
212       textpainter.C
213       math_amsarrayinset.C
214       math_arrayinset.C
215       math_atom.C
216       math_autocorrect.C
217       math_biginset.C
218       math_binominset.C
219       math_boldsymbolinset.C
220       math_boxinset.C
221       math_boxedinset.C
222       math_braceinset.C
223       math_casesinset.C
224       math_charinset.C
225       math_colorinset.C
226       math_commentinset.C
227       math_data.C
228       math_decorationinset.C
229       math_deliminset.C
230       math_dfracinset.C
231       math_diffinset.C
232       math_diminset.C
233       math_dotsinset.C
234       math_envinset.C
235       math_extern.C
236       math_exfuncinset.C
237       math_exintinset.C
238       math_factory.C
239       math_fboxinset.C
240       math_frameboxinset.C
241       math_fontinset.C
242       math_fontoldinset.C
243       math_fracinset.C
244       math_fracbase.C
245       math_gridinset.C
246       math_hullinset.C
247       math_inset.C
248       math_kerninset.C
249       math_lefteqninset.C
250       math_liminset.C
251       math_macro.C
252       math_macroarg.C
253       math_macrotemplate.C
254       math_macrotable.C
255       math_makeboxinset.C
256       math_mathmlstream.C
257       math_matrixinset.C
258       math_nestinset.C
259       math_numberinset.C
260       math_oversetinset.C
261       math_parinset.C
262       math_parser.C
263       math_phantominset.C
264       math_rootinset.C
265       math_scriptinset.C
266       math_sizeinset.C
267       math_spaceinset.C
268       math_splitinset.C
269       math_sqrtinset.C
270       math_stackrelinset.C
271       math_streamstr.C
272       math_stringinset.C
273       math_substackinset.C
274       math_support.C
275       math_symbolinset.C
276       math_tabularinset.C
277       math_tfracinset.C
278       math_unknowninset.C
279       math_undersetinset.C
280       math_xarrowinset.C
281       math_xymatrixinset.C
282       command_inset.C
283       ref_inset.C
284     ''')]
285   )
286   Alias('mathed', mathed)
287
288
289 if build_lyx or 'insets' in targets:
290   #
291   # src/insets
292   #
293   print "Processing files in src/insets..."
294
295   insets = env.StaticLibrary(
296     target = '$LOCALLIBPATH/insets',
297     source = ["$BUILDDIR/common/insets/%s" % x for x in Split('''
298       mailinset.C
299       ExternalSupport.C
300       ExternalTemplate.C
301       ExternalTransforms.C
302       render_button.C
303       render_graphic.C
304       render_preview.C
305       inset.C
306       insetbase.C
307       insetbibitem.C
308       insetbibtex.C
309       insetbox.C
310       insetbranch.C
311       insetcaption.C
312       insetcharstyle.C
313       insetcite.C
314       insetcollapsable.C
315       insetcommand.C
316       insetcommandparams.C
317       insetenv.C
318       insetert.C
319       insetexternal.C
320       insetfloat.C
321       insetfloatlist.C
322       insetfoot.C
323       insetfootlike.C
324       insetgraphicsParams.C
325       insetgraphics.C
326       insethfill.C
327       insetinclude.C
328       insetindex.C
329       insetlabel.C
330       insetlatexaccent.C
331       insetline.C
332       insetmarginal.C
333       insetnewline.C
334       insetnote.C
335       insetoptarg.C
336       insetpagebreak.C
337       insetquotes.C
338       insetref.C
339       insetspace.C
340       insetspecialchar.C
341       insettabular.C
342       insettext.C
343       insettoc.C
344       inseturl.C
345       insetvspace.C
346       insetwrap.C
347     ''')]
348   )
349   Alias('insets', insets)
350
351
352 if build_lyx or 'frontends' in targets:
353   #
354   # src/frontends
355   #
356   print "Processing files in src/frontends..."
357
358   frontends = env.StaticLibrary(
359     target = '$LOCALLIBPATH/frontends',
360     source = ["$BUILDDIR/common/frontends/%s" % x for x in Split('''
361       Alert.C
362       Dialogs.C
363       LyXView.C
364       Painter.C
365       Timeout.C
366       Toolbars.C
367       guiapi.C
368       nullpainter.C
369       screen.C
370     ''')]
371   )
372   Alias('frontends', frontends)
373
374
375 if build_lyx or 'graphics' in targets:
376   #
377   # src/graphics
378   #
379   print "Processing files in src/graphics..."
380
381   graphics = env.StaticLibrary(
382     target = '$LOCALLIBPATH/graphics',
383     source = ["$BUILDDIR/common/graphics/%s" % x for x in Split('''
384       GraphicsCache.C
385       GraphicsCacheItem.C
386       GraphicsConverter.C
387       GraphicsImage.C
388       GraphicsLoader.C
389       GraphicsParams.C
390       LoaderQueue.C
391       GraphicsTypes.C
392       PreviewImage.C
393       PreviewLoader.C
394       Previews.C
395     ''')]
396   )
397   Alias('graphics', graphics)
398
399
400 if build_lyx or 'controllers' in targets:
401   #
402   # src/frontends/controllers
403   #
404   print "Processing files in src/frontends/controllers..."
405
406   controllers = env.StaticLibrary(
407     target = '$LOCALLIBPATH/controllers',
408     source = ["$BUILDDIR/common/frontends/controllers/%s" % x for x in Split('''
409       Dialog.C
410       Kernel.C
411       biblio.C
412       character.C
413       frnt_lang.C
414       tex_helpers.C
415       BCView.C
416       ButtonController.C
417       ButtonPolicies.C
418       ControlAboutlyx.C
419       ControlBibtex.C
420       ControlBox.C
421       ControlBranch.C
422       ControlCharacter.C
423       ControlChanges.C
424       ControlCitation.C
425       ControlCommand.C
426       ControlCommandBuffer.C
427       ControlDocument.C
428       ControlErrorList.C
429       ControlERT.C
430       ControlExternal.C
431       ControlFloat.C
432       ControlGraphics.C
433       ControlInclude.C
434       ControlLog.C
435       ControlViewSource.C
436       ControlMath.C
437       ControlNote.C
438       ControlParagraph.C
439       ControlPreamble.C
440       ControlPrefs.C
441       ControlPrint.C
442       ControlRef.C
443       ControlSearch.C
444       ControlSendto.C
445       ControlShowFile.C
446       ControlSpellchecker.C
447       ControlTabular.C
448       ControlTabularCreate.C
449       ControlTexinfo.C
450       ControlThesaurus.C
451       ControlToc.C
452       ControlVSpace.C
453       ControlWrap.C
454       helper_funcs.C
455       helper_funcs.h
456     ''')]
457     )
458   Alias('controllers', controllers)
459
460
461 #
462 # src/frontend/qt3/4
463 #
464 if build_lyx or env['frontend'] in targets:
465   frontend = env['frontend']
466   env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRC_DIR/src/frontend/$frontend', duplicate = 0)
467 else:
468   # frontend is qt3, but specify target qt4, OK
469   if 'qt3' in targets:
470     frontned = 'qt3'
471   elif 'qt4' in targets:
472     frontend = 'qt4'
473   else:
474     frontend = None
475
476
477 if frontend == 'qt3':
478   print "Processing files in src/frontends/qt3..."
479
480   qt3env = env.Copy()
481   # disable auto scan to speed up non build time
482   qt3env['QT_AUTOSCAN'] = 0
483   qt3env['QT_MOCHPREFIX'] = ''
484
485   # load qt3 tools
486   qt3env.Tool('qt')
487
488   qt3env.AppendUnique(CPPPATH = [
489     '$BUILDDIR/common',
490     '$BUILDDIR/common/images',
491     '$BUILDDIR/common/frontends',
492     '$BUILDDIR/common/frontends/qt3',
493     '$BUILDDIR/common/frontends/controllers',
494     '$QT_INC_PATH']
495   )
496
497   qt3_ui_files = Split('''
498     BiblioModuleBase.ui
499     BranchesModuleBase.ui
500     BulletsModuleBase.ui
501     TextLayoutModuleBase.ui
502     LanguageModuleBase.ui
503     LaTeXModuleBase.ui
504     MarginsModuleBase.ui
505     NumberingModuleBase.ui
506     MathsModuleBase.ui
507     PageLayoutModuleBase.ui
508     PreambleModuleBase.ui
509     QAboutDialogBase.ui
510     QAskForTextDialog.ui
511     QBibitemDialogBase.ui
512     QBibtexDialogBase.ui
513     QBibtexAddDialogBase.ui
514     QBoxDialogBase.ui
515     QBranchDialogBase.ui
516     QChangesDialogBase.ui
517     QCharacterDialogBase.ui
518     QCitationDialogBase.ui
519     QCitationFindDialogBase.ui
520     QDelimiterDialogBase.ui
521     QDocumentDialogBase.ui
522     QErrorListDialogBase.ui
523     QERTDialogBase.ui
524     QExternalDialogBase.ui
525     QFloatDialogBase.ui
526     QGraphicsDialogBase.ui
527     QIncludeDialogBase.ui
528     QIndexDialogBase.ui
529     QLogDialogBase.ui
530     QViewSourceDialogBase.ui
531     QMathDialogBase.ui
532     QMathMatrixDialogBase.ui
533     QNoteDialogBase.ui
534     QParagraphDialogBase.ui
535     QPrefAsciiModule.ui
536     QPrefColorsModule.ui
537     QPrefConvertersModule.ui
538     QPrefCopiersModule.ui
539     QPrefCygwinPathModule.ui
540     QPrefDateModule.ui
541     QPrefDisplayModule.ui
542     QPrefFileformatsModule.ui
543     QPrefIdentityModule.ui
544     QPrefKeyboardModule.ui
545     QPrefLanguageModule.ui
546     QPrefLatexModule.ui
547     QPrefPathsModule.ui
548     QPrefPrinterModule.ui
549     QPrefScreenFontsModule.ui
550     QPrefsDialogBase.ui
551     QPrefSpellcheckerModule.ui
552     QPrefUIModule.ui
553     QPrintDialogBase.ui
554     QRefDialogBase.ui
555     QSearchDialogBase.ui
556     QSendtoDialogBase.ui
557     QShowFileDialogBase.ui
558     QSpellcheckerDialogBase.ui
559     QTabularCreateDialogBase.ui
560     QTabularDialogBase.ui
561     QTexinfoDialogBase.ui
562     QThesaurusDialogBase.ui
563     QTocDialogBase.ui
564     QURLDialogBase.ui
565     QVSpaceDialogBase.ui
566     QWrapDialogBase.ui
567   ''')
568
569   qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
570     BulletsModule.C
571     emptytable.C
572     FileDialog_private.C
573     floatplacement.C
574     iconpalette.C
575     lengthcombo.C
576     panelstack.C
577     QAboutDialog.C
578     QBibitemDialog.C
579     QBibtexDialog.C
580     QBoxDialog.C
581     QBranchDialog.C
582     QBrowseBox.C
583     QChangesDialog.C
584     QCharacterDialog.C
585     QCitationDialog.C
586     QCommandBuffer.C
587     QCommandEdit.C
588     QContentPane.C
589     QDelimiterDialog.C
590     QDocumentDialog.C
591     QErrorListDialog.C
592     QERTDialog.C
593     QExternalDialog.C
594     QFloatDialog.C
595     QGraphicsDialog.C
596     QIncludeDialog.C
597     QIndexDialog.C
598     QLogDialog.C
599     QViewSourceDialog.C
600     QLPopupMenu.C
601     QLPrintDialog.C
602     QMathDialog.C
603     QMathMatrixDialog.C
604     QNoteDialog.C
605     QParagraphDialog.C
606     QPrefsDialog.C
607     QRefDialog.C
608     QSearchDialog.C
609     QSendtoDialog.C
610     qsetborder.C
611     QShowFileDialog.C
612     QSpellcheckerDialog.C
613     QDialogView.C
614     QTabularCreateDialog.C
615     QTabularDialog.C
616     QTexinfoDialog.C
617     QThesaurusDialog.C
618     QTocDialog.C
619     qttableview.C
620     QtView.C
621     QURLDialog.C
622     QVSpaceDialog.C
623     QWrapDialog.C
624     QLToolbar.C
625     socket_callback.C
626     validators.C
627   ''')]
628
629   # manually moc and uic files for better performance 
630   qt3_moced_files = [qt3env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt3_moc_files]
631
632   qt3_uiced_files = [qt3env.Uic('$BUILDDIR/common/frontends/qt3/ui/'+x) for x in qt3_ui_files]
633   qt3_uiced_cc_files = []
634   for x in qt3_uiced_files:
635     qt3_uiced_cc_files.extend(x[1:])
636
637   qt3 = qt3env.StaticLibrary(
638     target = '$LOCALLIBPATH/qt3',
639     source = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
640       QDialogView.C
641       Alert_pimpl.C
642       Dialogs.C
643       FileDialog.C
644       LyXKeySymFactory.C
645       LyXScreenFactory.C
646       QLMenubar.C
647       qtTimeout.C
648       QAbout.C
649       QBibitem.C
650       QBibtex.C
651       QBox.C
652       QBranch.C
653       QChanges.C
654       QCharacter.C
655       QCitation.C
656       QDocument.C
657       QErrorList.C
658       QERT.C
659       QExternal.C
660       QFloat.C
661       QGraphics.C
662       QInclude.C
663       QIndex.C
664       QLImage.C
665       QLog.C
666       QViewSource.C
667       QLPainter.C
668       QLyXKeySym.C
669       QMath.C
670       QNote.C
671       QParagraph.C
672       QPrefs.C
673       QPrint.C
674       QRef.C
675       QSearch.C
676       QSendto.C
677       QShowFile.C
678       QSpellchecker.C
679       QTabular.C
680       QTabularCreate.C
681       QTexinfo.C
682       QThesaurus.C
683       QToc.C
684       QURL.C
685       QVSpace.C
686       QWorkArea.C
687       QWrap.C
688       Qt2BC.C
689       WorkAreaFactory.C
690       checkedwidgets.C
691       lyx_gui.C
692       lcolorcache.C
693       panelstack.C
694       qcoloritem.C
695       qfontexample.C
696       qfont_loader.C
697       qfont_metrics.C
698       qscreen.C
699       qt_helpers.C
700     ''')] +
701     qt3_moc_files + qt3_moced_files + qt3_uiced_cc_files
702   )
703   Alias('qt3', qt3)
704
705
706 elif frontend == 'qt4':
707   print "Processing files in src/frontends/qt4..."
708
709   qt4env = env.Copy()
710   qt4env['QT_AUTOSCAN'] = 0
711
712   # local qt4 toolset from
713   # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
714   #
715   # NOTE: I have to patch qt4.py since it does not automatically
716   # process .C file!!! (add to cxx_suffixes )
717   #
718   qt4env.Tool('qt4', [env['SCONS_DIR']])
719   qt4env.EnableQt4Modules(env['QT_LIB'], debug = False)
720
721   qt4env.AppendUnique(CPPPATH = [
722     '$BUILDDIR/common',
723     '$BUILDDIR/common/images',
724     '$BUILDDIR/common/frontends',
725     '$BUILDDIR/common/frontends/qt4',
726     '$BUILDDIR/common/frontends/controllers' 
727     ]
728   )
729
730   # FIXME: replace by something from pkg_config
731   qt4env.Append(CCFLAGS = [
732     '-DHAVE_CONFIG_H',
733     '-DQT_CLEAN_NAMESPACE',
734     '-DQT_GENUINE_STR',
735     '-DQT_NO_STL',
736     '-DQT3_SUPPORT',
737     '-Winvalid-pch']
738   )
739
740   qt4_ui_files = ['$BUILDDIR/common/frontends/qt4/ui/%s' % x for x in Split('''
741     BiblioUi
742     BranchesUi
743     BulletsUi
744     TextLayoutUi
745     LanguageUi
746     LaTeXUi
747     MarginsUi
748     NumberingUi
749     MathsUi
750     PageLayoutUi
751     PreambleUi
752     QAboutUi
753     QAskForTextUi
754     QBibitemUi
755     QBibtexUi
756     QBibtexAddUi
757     QBoxUi
758     QBranchUi
759     QChangesUi
760     QCharacterUi
761     QCitationUi
762     QCitationFindUi
763     QDelimiterUi
764     QDocumentUi
765     QErrorListUi
766     QERTUi
767     QExternalUi
768     QFloatUi
769     QGraphicsUi
770     QIncludeUi
771     QIndexUi
772     QLogUi
773     QViewSourceUi
774     QMathUi
775     QMathMatrixUi
776     QNoteUi
777     QParagraphUi
778     QPrefAsciiUi
779     QPrefColorsUi
780     QPrefConvertersUi
781     QPrefCopiersUi
782     QPrefCygwinPathUi
783     QPrefDateUi
784     QPrefDisplayUi
785     QPrefFileformatsUi
786     QPrefIdentityUi
787     QPrefKeyboardUi
788     QPrefLanguageUi
789     QPrefLatexUi
790     QPrefPathsUi
791     QPrefPrinterUi
792     QPrefScreenFontsUi
793     QPrefsUi
794     QPrefSpellcheckerUi
795     QPrefUi
796     QPrintUi
797     QRefUi
798     QSearchUi
799     QSendtoUi
800     QShowFileUi
801     QSpellcheckerUi
802     QTabularCreateUi
803     QTabularUi
804     QTexinfoUi
805     QThesaurusUi
806     QTocUi
807     QURLUi
808     QVSpaceUi
809     QWrapUi
810   ''')]
811
812   qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
813     BulletsModule.C
814     emptytable.C
815     FileDialog_private.C
816     floatplacement.C
817     iconpalette.C
818     lengthcombo.C
819     panelstack.C
820     QAboutDialog.C
821     QBibitemDialog.C
822     QBibtexDialog.C
823     QBoxDialog.C
824     QBranchDialog.C
825     QBranches.C
826     QChangesDialog.C
827     QCharacterDialog.C
828     QCitationDialog.C
829     QCommandBuffer.C
830     QCommandEdit.C
831     QDelimiterDialog.C
832     QDocumentDialog.C
833     QErrorListDialog.C
834     QERTDialog.C
835     QExternalDialog.C
836     QFloatDialog.C
837     QGraphicsDialog.C
838     QIncludeDialog.C
839     QIndexDialog.C
840     QLAction.C
841     QLogDialog.C
842     QViewSourceDialog.C
843     QViewSource.C
844     QLMenubar.C
845     QLPopupMenu.C
846     QLPrintDialog.C
847     QMathDialog.C
848     QMathMatrixDialog.C
849     QNoteDialog.C
850     QParagraphDialog.C
851     QPrefsDialog.C
852     QRefDialog.C
853     QSearchDialog.C
854     QSendtoDialog.C
855     qsetborder.C
856     QShowFileDialog.C
857     QSpellcheckerDialog.C
858     QDialogView.C
859     QTabularCreateDialog.C
860     QTabularDialog.C
861     QTexinfoDialog.C
862     QThesaurusDialog.C
863     TocModel.C
864     QTocDialog.C
865     QtView.C
866     QURLDialog.C
867     QVSpaceDialog.C
868     QWorkArea.C
869     QWrapDialog.C
870     QLToolbar.C
871     socket_callback.C
872     validators.C
873   ''') ]
874
875   qt4_source_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
876     QDialogView.C
877     Alert_pimpl.C
878     Dialogs.C
879     FileDialog.C
880     LyXKeySymFactory.C
881     LyXScreenFactory.C
882     QLMenubar.C
883     qtTimeout.C
884     QAbout.C
885     QBibitem.C
886     QBibtex.C
887     QBox.C
888     QBranch.C
889     QBranches.C
890     QChanges.C
891     QCharacter.C
892     QCitation.C
893     QDocument.C
894     QErrorList.C
895     QERT.C
896     QExternal.C
897     QFloat.C
898     QGraphics.C
899     QInclude.C
900     QIndex.C
901     QLAction.C
902     QLImage.C
903     QLog.C
904     QViewSource.C
905     QLPainter.C
906     QLyXKeySym.C
907     QMath.C
908     QNote.C
909     QParagraph.C
910     QPrefs.C
911     QPrint.C
912     QRef.C
913     QSearch.C
914     QSendto.C
915     QShowFile.C
916     QSpellchecker.C
917     QTabular.C
918     QTabularCreate.C
919     QTexinfo.C
920     QThesaurus.C
921     QToc.C
922     QURL.C
923     QVSpace.C
924     QWorkArea.C
925     QWrap.C
926     Qt2BC.C
927     WorkAreaFactory.C
928     checkedwidgets.C
929     lyx_gui.C
930     lcolorcache.C
931     panelstack.C
932     qfontexample.C
933     qfont_loader.C
934     qfont_metrics.C
935     qscreen.C
936     qt_helpers.C
937   ''')]
938
939   #
940   # Compile resources
941   #
942   resources = [qt4env.Uic4(x) for x in qt4_ui_files]
943
944   # 
945   # moc qt4_moc_files, the moced files are included in the original files
946   #
947   qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
948
949   qt4 = qt4env.StaticLibrary(
950     target = '$LOCALLIBPATH/qt4',
951     LIBS = qt4env['QT_LIB'],
952     source = qt4_source_files + qt4_moc_files
953   )
954   Alias('qt4', qt4)
955
956
957 if 'client' in targets or 'install' in targets or 'all' in targets:
958   #
959   # src/client
960   #
961   env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
962
963   print "Processing files in src/client..."
964
965   if env['HAVE_FCNTL']:
966     client = env.Program(
967       target = '$BUILDDIR/common/client/lyxclient',
968       LIBS = ['supports'] + env['INTL_LIBS'] + env['SYSTEM_LIBS'] + 
969         env['SOCKET_LIBS'] + env['BOOST_LIBRARIES'],
970       source = ["$BUILDDIR/common/client/%s" % x for x in Split('''
971         boost.C
972         client.C
973         debug.C
974         gettext.C
975         messages.C
976       ''')]
977     )
978     Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
979       client, [Copy('$TARGET', '$SOURCE')]))
980   else:
981     client = None
982   Alias('client', client)
983
984
985 if 'tex2lyx' in targets or 'install' in targets or 'all' in targets:
986   #
987   # tex2lyx
988   #
989   print "Processing files in src/tex2lyx..."
990
991   tex2lyx_env = env.Copy()
992   # the order is important here.
993   tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
994   tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
995
996   for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C', 
997     'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
998     env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRC_DIR/src/'+file,
999       [Copy('$TARGET', '$SOURCE')])
1000
1001   tex2lyx = tex2lyx_env.Program(
1002     target = '$BUILDDIR/common/tex2lyx/tex2lyx',
1003     LIBS = ['supports'] + env['BOOST_LIBRARIES'] + env['SYSTEM_LIBS'],
1004     source = ["$BUILDDIR/common/tex2lyx/%s" % x for x in Split('''
1005       FloatList.C
1006       Floating.C
1007       counters.C
1008       lyxlayout.C
1009       lyxtextclass.C
1010       lyxlex.C
1011       lyxlex_pimpl.C
1012       boost.C
1013       context.C
1014       gettext.C
1015       lengthcommon.C
1016       lyxfont.C
1017       texparser.C
1018       tex2lyx.C
1019       preamble.C
1020       math.C
1021       table.C
1022       text.C
1023     ''')]
1024   )
1025   Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
1026     tex2lyx, [Copy('$TARGET', '$SOURCE')]))
1027   Alias('tex2lyx', tex2lyx)
1028
1029
1030 if build_lyx or 'lyxbase' in targets:
1031   #
1032   # src/
1033   #
1034   print "Processing files in src..."
1035
1036   env.substFile('$BUILDDIR/common/version.C', '$TOP_SRC_DIR/src/version.C.in')
1037
1038   lyx_source_pre = Split('''
1039     Bidi.C
1040     BufferView.C
1041     BufferView_pimpl.C
1042     Bullet.C
1043     BranchList.C
1044     Chktex.C
1045     Color.C
1046     CutAndPaste.C
1047     DepTable.C
1048     FloatList.C
1049     Floating.C
1050     FontIterator.C
1051     FuncStatus.C
1052     InsetList.C
1053     LColor.C
1054     LaTeX.C
1055     LaTeXFeatures.C
1056     LyXAction.C
1057     MenuBackend.C
1058     ParagraphParameters.C
1059     Spacing.C
1060     ToolbarBackend.C
1061     author.C
1062     boost.C
1063     buffer.C
1064     buffer_funcs.C
1065     bufferlist.C
1066     bufferparams.C
1067     bufferview_funcs.C
1068     changes.C
1069     chset.C
1070     converter.C
1071     counters.C
1072     coordcache.C
1073     cursor.C
1074     cursor_slice.C
1075     debug.C
1076     dociterator.C
1077     encoding.C
1078     errorlist.C
1079     exporter.C
1080     gettext.C
1081     factory.C
1082     format.C
1083     funcrequest.C
1084     graph.C
1085     importer.C
1086     intl.C
1087     insetiterator.C
1088     kbmap.C
1089     kbsequence.C
1090     language.C
1091     session.C
1092     lengthcommon.C
1093     lyx_cb.C
1094     lyx_main.C
1095     lyx_sty.C
1096     lyxfont.C
1097     lyxfind.C
1098     lyxfunc.C
1099     lyxgluelength.C
1100     lyxlayout.C
1101     lyxlength.C
1102     lyxlex.C
1103     lyxlex_pimpl.C
1104     lyxrc.C
1105     lyxrow.C
1106     lyxrow_funcs.C
1107     lyxserver.C
1108     lyxsocket.C
1109     lyxtextclass.C
1110     lyxtextclasslist.C
1111     lyxvc.C
1112     messages.C
1113     metricsinfo.C
1114     mover.C
1115     output.C
1116     outputparams.C
1117     output_docbook.C
1118     output_latex.C
1119     output_linuxdoc.C
1120     output_plaintext.C
1121     paragraph.C
1122     paragraph_funcs.C
1123     paragraph_pimpl.C
1124     pariterator.C
1125     rowpainter.C
1126     sgml.C
1127     tex-accent.C
1128     tex-strings.C
1129     texrow.C
1130     text.C
1131     text2.C
1132     text3.C
1133     TocBackend.C
1134     toc.C
1135     trans.C
1136     trans_mgr.C
1137     undo.C
1138     vc-backend.C
1139     version.C
1140     vspace.C
1141     main.C
1142   ''')
1143
1144   lyx_source_post = Split('''
1145     tabular.C
1146     dimension.C
1147     PrinterParams.C
1148     box.C
1149     Thesaurus.C
1150     SpellBase.C
1151   ''')
1152
1153   if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1154     lyx_source_post.append('aspell.C')
1155   elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
1156     lyx_source_post.append('pspell.C')
1157   elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
1158     lyx_source_post.append('ispell.C')
1159
1160   lyxbase_pre = env.StaticLibrary(
1161     target = '$LOCALLIBPATH/lyxbase_pre',
1162     source = ["$BUILDDIR/common/%s" % x for x in lyx_source_pre]
1163   )
1164   lyxbase_post = env.StaticLibrary(
1165     target = '$LOCALLIBPATH/lyxbase_post',
1166     source = ["$BUILDDIR/common/%s" % x for x in lyx_source_post]
1167   )
1168   Alias('lyxbase', lyxbase_pre)
1169   Alias('lyxbase', lyxbase_post)
1170
1171
1172 if build_lyx or 'lyx' in targets:
1173   #
1174   # Build lyx with given frontend
1175   #
1176   lyx = env.Program(
1177     target = '$BUILDDIR/$frontend/lyx',
1178     source = [],
1179     LIBS = [
1180       'lyxbase_pre',
1181       'mathed',
1182       'insets',
1183       'frontends',
1184       env['frontend'],
1185       'controllers',
1186       'graphics',
1187       'supports',
1188       'lyxbase_post',
1189       ] +
1190       env['BOOST_LIBRARIES'] +
1191       env['EXTRA_LIBS'] +
1192       env['INTL_LIBS'] + 
1193       env['SOCKET_LIBS'] +
1194       env['SYSTEM_LIBS']
1195   )
1196   # [/path/to/lyx.ext] => lyx-qt3.ext
1197   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s' % frontend)
1198   Alias('lyx', env.Command(os.path.join('$BUILDDIR', target_name), lyx,
1199     [Copy('$TARGET', '$SOURCE')]))
1200   Alias('lyx', lyx)
1201
1202
1203 if 'po' in targets or 'install' in targets or 'all' in targets:
1204   #
1205   # po/
1206   #
1207   print 'Processing files in po...'
1208
1209   import glob
1210   # handle po files
1211   #
1212   # files to translate
1213   transfiles = glob.glob(os.path.join(env.subst('$TOP_SRC_DIR'), 'po', '*.po'))
1214   # possibly *only* handle these languages
1215   languages = None
1216   if env.has_key('languages'):
1217     languages = env.make_list(env['lanauges'])
1218   # use defulat msgfmt
1219   if not env['MSGFMT']:
1220     print 'msgfmt does not exist. Can not process po files'
1221   else:
1222     # create a builder
1223     env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
1224     #
1225     gmo_files = []
1226     for f in transfiles:
1227       # get filename
1228       fname = os.path.split(f)[1]
1229       # country code
1230       country = fname.split('.')[0]
1231       #
1232       if not languages or country in languages:
1233         gmo_files.extend(env.Transfiles(f))
1234
1235
1236 if 'install' in targets:
1237   # create the directory if needed
1238   if not os.path.isdir(env['DEST_DIR']):
1239     try:
1240       os.makedirs(env['DEST_DIR'])
1241     except:
1242       pass
1243     if not os.path.isdir(env['DEST_DIR']):
1244       print 'Can not create directory', env['DEST_DIR']
1245       Exit(3)
1246   #
1247   import glob
1248   #
1249   # do not install these files
1250   exclude_list = ['Makefile.am', 'Makefile.in', 'Makefile', 
1251     'lyx2lyx_version.py', 'lyx2lyx_version.py.in']
1252
1253   def install(dest, src):
1254     ''' recusive installation of src to dest '''
1255     # separate file and directory
1256     files = filter(lambda x: os.path.isfile(x) and not os.path.split(x)[1] in exclude_list, src)
1257     dirs = filter(os.path.isdir, src)
1258     # install file
1259     env.Install(dest, files)
1260     # install directory
1261     ins_dir = [dest]
1262     for dir in dirs:
1263       ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
1264         glob.glob(os.path.join(dir, '*'))) )
1265     return ins_dir
1266   #
1267   # executables (some of them may be none)
1268   #
1269   if env['ADD_SUFFIX_TO_EXECUTABLES']:
1270     program_suffix = env['PROGRAM_SUFFIX']
1271   else:
1272     program_suffix = ''
1273   #
1274   # install lyx
1275   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx%s' % program_suffix)
1276   target = os.path.join(env['BIN_DEST_DIR'], target_name)
1277   env.InstallAs(target, lyx)
1278   Alias('install', target)
1279   # install lyx as lyx-qt3
1280   target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s%s' % (frontend, program_suffix))
1281   target = os.path.join(env['BIN_DEST_DIR'], target_name)
1282   env.InstallAs(target, lyx)
1283   Alias('install', target)
1284   #
1285   # install tex2lyx
1286   target_name = os.path.split(str(tex2lyx[0]))[1].replace('tex2lyx', 'tex2lyx%s' % program_suffix)
1287   target = os.path.join(env['BIN_DEST_DIR'], target_name)
1288   env.InstallAs(target, tex2lyx)
1289   Alias('install', target)
1290   #
1291   # install lyxclient, may not exist
1292   if client != None:
1293     target_name = os.path.split(str(client[0]))[1].replace('client', 'client%s' % program_suffix)
1294     target = os.path.join(env['BIN_DEST_DIR'], target_name)
1295     env.InstallAs(target, client)
1296     Alias('install', target)
1297   #
1298   # share/lyx
1299   dirs = install(env['SHARE_DEST_DIR'],
1300     [env.subst('$TOP_SRC_DIR/lib/') + file for file in ['configure.py', 'encodings',
1301      'chkconfig.ltx', 'CREDITS', 'external_templates', 'symbols', 'languages',
1302      'lyxrc.example', 'syntax.default', 'bind', 'images', 'layouts', 'scripts', 
1303      'templates', 'examples', 'kbd', 'lyx2lyx', 'tex', 'clipart', 'doc',  'ui']]
1304   )
1305   env.substFile('$SHARE_DEST_DIR/lyx2lyx/lyx2lyx_version.py', 
1306     '$TOP_SRC_DIR/lib/lyx2lyx/lyx2lyx_version.py.in')
1307   Alias('install', dirs)
1308   # man
1309   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyx.1'),
1310     env.subst('$TOP_SRC_DIR/lyx.man'))
1311   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'tex2lyx.1'),
1312     env.subst('$TOP_SRC_DIR/src/tex2lyx/tex2lyx.man'))
1313   env.InstallAs(os.path.join(env['MAN_DEST_DIR'], 'lyxclient.1'),
1314     env.subst('$TOP_SRC_DIR/src/client/lyxclient.man'))
1315   Alias('install', [os.path.join(env['MAN_DEST_DIR'], x) for
1316     x in ['lyx.1', 'tex2lyx.1', 'lyxclient.1']])
1317   # locale files?
1318   # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
1319   for gmo in gmo_files:
1320     lan = os.path.split(str(gmo))[1].split('.')[0]
1321     dest_file = os.path.join(env['LOCALE_DEST_DIR'], lan, 'LC_MESSAGES', 'lyx' + env['PROGRAM_SUFFIX'] + '.mo')
1322     env.InstallAs(dest_file, gmo)
1323     Alias('install', dest_file)
1324
1325
1326 Default('lyx')
1327 Alias('all', ['lyx', 'client', 'tex2lyx', 'po'])