1 # vi:filetype=python:expandtab:tabstop=2:shiftwidth=2
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
9 # Full author contact details are available in file CREDITS.
15 targets = env['BUILD_TARGETS']
16 build_lyx = (targets == [] or 'lyx' in targets or 'install' in targets or 'all' in targets)
19 if env['INCLUDED_BOOST'] or 'boost' in targets:
24 env.BuildDir('$BUILDDIR/boost', '$TOP_SRC_DIR/boost/libs', duplicate = 0)
27 boostenv.AppendUnique(CCFLAGS = '-DBOOST_USER_CONFIG="<config.h>"')
29 print 'Processing files in boost/libs/filesystem/src...'
31 filesystem = boostenv.StaticLibrary(
32 target = '$LOCALLIBPATH/boost_filesystem',
33 source = ["$BUILDDIR/boost/filesystem/src/%s" % x for x in Split('''
36 operations_posix_windows.cpp
37 path_posix_windows.cpp
41 print 'Processing files in boost/libs/regex/src...'
43 regex = boostenv.StaticLibrary(
44 target = '$LOCALLIBPATH/boost_regex',
45 source = ["$BUILDDIR/boost/regex/src/%s" % x for x in Split('''
53 regex_traits_defaults.cpp
58 print 'Processing files in boost/libs/signals/src...'
60 signals = boostenv.StaticLibrary(
61 target = '$LOCALLIBPATH/boost_signals',
62 source = ["$BUILDDIR/boost/signals/src/%s" % x for x in Split('''
71 print 'Processing files in boost/libs/iostreams/src...'
73 iostreams = boostenv.StaticLibrary(
74 target = '$LOCALLIBPATH/boost_iostreams',
75 source = ["$BUILDDIR/boost/iostreams/src/%s" % x for x in Split('''
81 Alias('boost', filesystem)
83 Alias('boost', signals)
84 Alias('boost', iostreams)
88 # Now, src code under src/
90 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
93 if build_lyx or True in [x in targets for x in ['supports', 'client', 'tex2lyx']]:
97 print "Processing files in src/support"
99 env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRC_DIR/src/support/package.C.in')
101 supports = env.StaticLibrary(
102 target = '$LOCALLIBPATH/supports',
103 source = ['$BUILDDIR/common/support/%s' % x for x in Split('''
134 Alias('supports', supports)
137 if build_lyx or 'mathed' in targets:
141 print "Processing files in src/mathed"
143 mathed = env.StaticLibrary(
144 target = '$LOCALLIBPATH/mathed',
145 source = ["$BUILDDIR/common/mathed/%s" % x for x in Split('''
153 math_boldsymbolinset.C
162 math_decorationinset.C
220 Alias('mathed', mathed)
223 if build_lyx or 'insets' in targets:
227 print "Processing files in src/insets"
229 insets = env.StaticLibrary(
230 target = '$LOCALLIBPATH/insets',
231 source = ["$BUILDDIR/common/insets/%s" % x for x in Split('''
258 insetgraphicsParams.C
283 Alias('insets', insets)
286 if build_lyx or 'frontends' in targets:
290 print "Processing files in src/frontends"
292 frontends = env.StaticLibrary(
293 target = '$LOCALLIBPATH/frontends',
294 source = ["$BUILDDIR/common/frontends/%s" % x for x in Split('''
306 Alias('frontends', frontends)
309 if build_lyx or 'graphics' in targets:
313 print "Processing files in src/graphics"
315 graphics = env.StaticLibrary(
316 target = '$LOCALLIBPATH/graphics',
317 source = ["$BUILDDIR/common/graphics/%s" % x for x in Split('''
331 Alias('graphics', graphics)
334 if build_lyx or 'controllers' in targets:
336 # src/frontends/controllers
338 print "Processing files in src/frontends/controllers"
340 controllers = env.StaticLibrary(
341 target = '$LOCALLIBPATH/controllers',
342 source = ["$BUILDDIR/common/frontends/controllers/%s" % x for x in Split('''
360 ControlCommandBuffer.C
380 ControlSpellchecker.C
382 ControlTabularCreate.C
392 Alias('controllers', controllers)
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)
402 # frontend is qt3, but specify target qt4, OK
405 elif 'qt4' in targets:
411 if frontend == 'qt3':
412 print "Processing files in src/frontends/qt3"
415 # disable auto scan to speed up non build time
416 qt3env['QT_AUTOSCAN'] = 0
421 qt3env.AppendUnique(CPPPATH = [
423 '$BUILDDIR/common/images',
424 '$BUILDDIR/common/frontends',
425 '$BUILDDIR/common/frontends/qt3',
426 '$BUILDDIR/common/frontends/controllers',
430 qt3_ui_files = Split('''
432 BranchesModuleBase.ui
434 TextLayoutModuleBase.ui
435 LanguageModuleBase.ui
438 NumberingModuleBase.ui
440 PageLayoutModuleBase.ui
441 PreambleModuleBase.ui
444 QBibitemDialogBase.ui
446 QBibtexAddDialogBase.ui
449 QChangesDialogBase.ui
450 QCharacterDialogBase.ui
451 QCitationDialogBase.ui
452 QCitationFindDialogBase.ui
453 QDelimiterDialogBase.ui
454 QDocumentDialogBase.ui
455 QErrorListDialogBase.ui
457 QExternalDialogBase.ui
459 QGraphicsDialogBase.ui
460 QIncludeDialogBase.ui
463 QViewSourceDialogBase.ui
465 QMathMatrixDialogBase.ui
467 QParagraphDialogBase.ui
470 QPrefConvertersModule.ui
471 QPrefCopiersModule.ui
472 QPrefCygwinPathModule.ui
474 QPrefDisplayModule.ui
475 QPrefFileformatsModule.ui
476 QPrefIdentityModule.ui
477 QPrefKeyboardModule.ui
478 QPrefLanguageModule.ui
481 QPrefPrinterModule.ui
482 QPrefScreenFontsModule.ui
484 QPrefSpellcheckerModule.ui
490 QShowFileDialogBase.ui
491 QSpellcheckerDialogBase.ui
492 QTabularCreateDialogBase.ui
493 QTabularDialogBase.ui
494 QTexinfoDialogBase.ui
495 QThesaurusDialogBase.ui
502 qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
545 QSpellcheckerDialog.C
547 QTabularCreateDialog.C
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]
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:])
571 qt3 = qt3env.StaticLibrary(
572 target = '$LOCALLIBPATH/qt3',
573 source = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
635 qt3_moc_files + qt3_moced_files + qt3_uiced_cc_files
640 elif frontend == 'qt4':
641 print "Processing files in src/frontends/qt4"
644 qt4env['QT_AUTOSCAN'] = 0
646 # local qt4 toolset from
647 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
649 # NOTE: I have to patch qt4.py since it does not automatically
650 # process .C file!!! (add to cxx_suffixes )
652 qt4env.Tool('qt4', [env['SCONS_DIR']])
653 qt4env.EnableQt4Modules(env['QT_LIB'], debug = False)
655 qt4env.AppendUnique(CPPPATH = [
657 '$BUILDDIR/common/images',
658 '$BUILDDIR/common/frontends',
659 '$BUILDDIR/common/frontends/qt4',
660 '$BUILDDIR/common/frontends/controllers',
663 '$QT_INC_PATH/QtCore',
664 '$QT_INC_PATH/QtGui']
667 # FIXME: replace by something from pkg_config
668 qt4env.Append(CCFLAGS = [
670 '-DQT_CLEAN_NAMESPACE',
677 qt4_ui_files = ['$BUILDDIR/common/frontends/qt4/ui/%s' % x for x in Split('''
749 qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
794 QSpellcheckerDialog.C
796 QTabularCreateDialog.C
812 qt4_source_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
879 resources = [qt4env.Uic4(x) for x in qt4_ui_files]
884 qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
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)
896 if 'client' in targets or 'install' in targets or 'all' in targets:
900 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
902 print "Processing files in src/client"
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('''
916 Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
917 client, [Copy('$TARGET', '$SOURCE')]))
920 Alias('client', client)
923 if 'tex2lyx' in targets or 'install' in targets or 'all' in targets:
927 print "Processing files in src/tex2lyx"
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'])
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')
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('''
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)
974 if build_lyx or 'lyxbase' in targets:
978 print "Processing files in src"
980 env.substFile('$BUILDDIR/common/version.C', '$TOP_SRC_DIR/src/version.C.in')
982 lyx_source_pre = Split('''
1002 ParagraphParameters.C
1088 lyx_source_post = Split('''
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')
1104 lyxbase_pre = env.StaticLibrary(
1105 target = '$LOCALLIBPATH/lyxbase_pre',
1106 source = ["$BUILDDIR/common/%s" % x for x in lyx_source_pre]
1108 lyxbase_post = env.StaticLibrary(
1109 target = '$LOCALLIBPATH/lyxbase_post',
1110 source = ["$BUILDDIR/common/%s" % x for x in lyx_source_post]
1112 Alias('lyxbase', lyxbase_pre)
1113 Alias('lyxbase', lyxbase_post)
1116 if build_lyx or 'lyx' in targets:
1118 # Build lyx with given frontend
1121 target = '$BUILDDIR/$frontend/lyx',
1134 env['BOOST_LIBRARIES'] +
1136 env['SOCKET_LIBS'] +
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')]))
1146 if 'po' in targets or 'install' in targets or 'all' in targets:
1150 print 'Processing files in po...'
1155 # files to translate
1156 transfiles = glob.glob(os.path.join(env.subst('$TOP_SRC_DIR'), 'po', '*.po'))
1157 # possibly *only* handle these languages
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'
1166 env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
1169 for f in transfiles:
1171 fname = os.path.split(f)[1]
1173 country = fname.split('.')[0]
1175 if not languages or country in languages:
1176 gmo_files.extend(env.Transfiles(f))
1179 if 'install' in targets:
1180 # create the directory if needed
1181 if not os.path.isdir(env['PREFIX']):
1183 os.makedirs(env['PREFIX'])
1186 if not os.path.isdir(env['PREFIX']):
1187 print 'Can not create directory', env['PREFIX']
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']
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)
1211 env.Install(dest, files)
1215 ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
1216 glob.glob(os.path.join(dir, '*'))) )
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'])
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']]
1230 env.substFile('$SHARE_DIR/lyx2lyx/lyx2lyx_version.py',
1231 '$TOP_SRC_DIR/lib/lyx2lyx/lyx2lyx_version.py.in')
1232 Alias('install', dirs)
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']])
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)
1252 Alias('all', ['lyx', 'client', 'tex2lyx', 'po'])