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