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['SUBST_KEYS'] = ['LYX_DIR', 'LOCALEDIR', 'TOP_SRCDIR', 'PROGRAM_SUFFIX']
100 env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRC_DIR/src/support/package.C.in')
102 supports = env.StaticLibrary(
103 target = '$LOCALLIBPATH/supports',
104 source = ['$BUILDDIR/common/support/%s' % x for x in Split('''
135 Alias('supports', supports)
138 if build_lyx or 'mathed' in targets:
142 print "Processing files in src/mathed"
144 mathed = env.StaticLibrary(
145 target = '$LOCALLIBPATH/mathed',
146 source = ["$BUILDDIR/common/mathed/%s" % x for x in Split('''
154 math_boldsymbolinset.C
163 math_decorationinset.C
221 Alias('mathed', mathed)
224 if build_lyx or 'insets' in targets:
228 print "Processing files in src/insets"
230 insets = env.StaticLibrary(
231 target = '$LOCALLIBPATH/insets',
232 source = ["$BUILDDIR/common/insets/%s" % x for x in Split('''
259 insetgraphicsParams.C
284 Alias('insets', insets)
287 if build_lyx or 'frontends' in targets:
291 print "Processing files in src/frontends"
293 frontends = env.StaticLibrary(
294 target = '$LOCALLIBPATH/frontends',
295 source = ["$BUILDDIR/common/frontends/%s" % x for x in Split('''
307 Alias('frontends', frontends)
310 if build_lyx or 'graphics' in targets:
314 print "Processing files in src/graphics"
316 graphics = env.StaticLibrary(
317 target = '$LOCALLIBPATH/graphics',
318 source = ["$BUILDDIR/common/graphics/%s" % x for x in Split('''
332 Alias('graphics', graphics)
335 if build_lyx or 'controllers' in targets:
337 # src/frontends/controllers
339 print "Processing files in src/frontends/controllers"
341 controllers = env.StaticLibrary(
342 target = '$LOCALLIBPATH/controllers',
343 source = ["$BUILDDIR/common/frontends/controllers/%s" % x for x in Split('''
361 ControlCommandBuffer.C
381 ControlSpellchecker.C
383 ControlTabularCreate.C
393 Alias('controllers', controllers)
399 if build_lyx or env['frontend'] in targets:
400 frontend = env['frontend']
401 env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRC_DIR/src/frontend/$frontend', duplicate = 0)
403 # frontend is qt3, but specify target qt4, OK
406 elif 'qt4' in targets:
412 if frontend == 'qt3':
413 print "Processing files in src/frontends/qt3"
416 # disable auto scan to speed up non build time
417 qt3env['QT_AUTOSCAN'] = 0
422 qt3env.AppendUnique(CPPPATH = [
424 '$BUILDDIR/common/images',
425 '$BUILDDIR/common/frontends',
426 '$BUILDDIR/common/frontends/qt3',
427 '$BUILDDIR/common/frontends/controllers',
431 qt3_ui_files = Split('''
433 BranchesModuleBase.ui
435 TextLayoutModuleBase.ui
436 LanguageModuleBase.ui
439 NumberingModuleBase.ui
441 PageLayoutModuleBase.ui
442 PreambleModuleBase.ui
445 QBibitemDialogBase.ui
447 QBibtexAddDialogBase.ui
450 QChangesDialogBase.ui
451 QCharacterDialogBase.ui
452 QCitationDialogBase.ui
453 QCitationFindDialogBase.ui
454 QDelimiterDialogBase.ui
455 QDocumentDialogBase.ui
456 QErrorListDialogBase.ui
458 QExternalDialogBase.ui
460 QGraphicsDialogBase.ui
461 QIncludeDialogBase.ui
464 QViewSourceDialogBase.ui
466 QMathMatrixDialogBase.ui
468 QParagraphDialogBase.ui
471 QPrefConvertersModule.ui
472 QPrefCopiersModule.ui
473 QPrefCygwinPathModule.ui
475 QPrefDisplayModule.ui
476 QPrefFileformatsModule.ui
477 QPrefIdentityModule.ui
478 QPrefKeyboardModule.ui
479 QPrefLanguageModule.ui
482 QPrefPrinterModule.ui
483 QPrefScreenFontsModule.ui
485 QPrefSpellcheckerModule.ui
491 QShowFileDialogBase.ui
492 QSpellcheckerDialogBase.ui
493 QTabularCreateDialogBase.ui
494 QTabularDialogBase.ui
495 QTexinfoDialogBase.ui
496 QThesaurusDialogBase.ui
503 qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
546 QSpellcheckerDialog.C
548 QTabularCreateDialog.C
563 # manually moc and uic files for better performance
564 # (stop autoscan, 13:20s->12:50s :-)
565 qt3_moced_files = [qt3env.Moc(x.replace('.C', '.h')) for x in qt3_moc_files]
567 qt3_uiced_files = [qt3env.Uic('$BUILDDIR/common/frontends/qt3/ui/'+x) for x in qt3_ui_files]
568 qt3_uiced_cc_files = []
569 for x in qt3_uiced_files:
570 qt3_uiced_cc_files.extend(x[1:])
572 qt3 = qt3env.StaticLibrary(
573 target = '$LOCALLIBPATH/qt3',
574 source = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
636 qt3_moc_files + qt3_moced_files + qt3_uiced_cc_files
641 elif frontend == 'qt4':
642 print "Processing files in src/frontends/qt4"
645 qt4env['QT_AUTOSCAN'] = 0
647 # local qt4 toolset from
648 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
650 # NOTE: I have to patch qt4.py since it does not automatically
651 # process .C file!!! (add to cxx_suffixes )
653 qt4env.Tool('qt4', [env['SCONS_DIR']])
654 qt4env.EnableQt4Modules(env['QT_LIB'], debug = False)
656 qt4env.AppendUnique(CPPPATH = [
658 '$BUILDDIR/common/images',
659 '$BUILDDIR/common/frontends',
660 '$BUILDDIR/common/frontends/qt4',
661 '$BUILDDIR/common/frontends/controllers',
664 '$QT_INC_PATH/QtCore',
665 '$QT_INC_PATH/QtGui']
668 # FIXME: replace by something from pkg_config
669 qt4env.Append(CCFLAGS = [
671 '-DQT_CLEAN_NAMESPACE',
678 qt4_ui_files = ['$BUILDDIR/common/frontends/qt4/ui/%s' % x for x in Split('''
750 qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
795 QSpellcheckerDialog.C
797 QTabularCreateDialog.C
813 qt4_source_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
880 resources = [qt4env.Uic4(x) for x in qt4_ui_files]
885 qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
887 # if the moced files are included in the .C file
888 # the Flatten(...) part will not be needed
889 qt4 = qt4env.StaticLibrary(
890 target = '$LOCALLIBPATH/qt4',
891 LIBS = qt4env['QT_LIB'],
892 source = qt4_source_files + qt4_moc_files + Flatten(qt4_moced_files)
897 if 'client' in targets or 'install' in targets or 'all' in targets:
901 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
903 print "Processing files in src/client"
905 if env['HAS_SOCKET_LIB']:
906 client = env.Program(
907 target = '$BUILDDIR/common/client/lyxclient',
908 LIBS = env['BOOST_LIBRARIES'] + env['SOCKET_LIBS'] + ['supports'],
909 source = ["$BUILDDIR/common/client/%s" % x for x in Split('''
917 Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
918 client, [Copy('$TARGET', '$SOURCE')]))
921 Alias('client', client)
924 if 'tex2lyx' in targets or 'install' in targets or 'all' in targets:
928 print "Processing files in src/tex2lyx"
930 tex2lyx_env = env.Copy()
931 # the order is important here.
932 tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
933 tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
935 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/FloatList.C', '$TOP_SRC_DIR/src/FloatList.C')
936 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/Floating.C', '$TOP_SRC_DIR/src/Floating.C')
937 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/counters.C', '$TOP_SRC_DIR/src/counters.C')
938 # for some reason I do not know, I have to copy the header files as well.
939 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlayout.h', '$TOP_SRC_DIR/src/lyxlayout.h')
940 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlayout.C', '$TOP_SRC_DIR/src/lyxlayout.C')
941 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxtextclass.h', '$TOP_SRC_DIR/src/lyxtextclass.h')
942 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxtextclass.C', '$TOP_SRC_DIR/src/lyxtextclass.C')
943 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlex.C', '$TOP_SRC_DIR/src/lyxlex.C')
944 tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlex_pimpl.C', '$TOP_SRC_DIR/src/lyxlex_pimpl.C')
946 tex2lyx = tex2lyx_env.Program(
947 target = '$BUILDDIR/common/tex2lyx/tex2lyx',
948 LIBS = ['supports'] + env['BOOST_LIBRARIES'] + env['SYSTEM_LIBS'],
949 source = ["$BUILDDIR/common/tex2lyx/%s" % x for x in Split('''
970 Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
971 tex2lyx, [Copy('$TARGET', '$SOURCE')]))
972 Alias('tex2lyx', tex2lyx)
975 if build_lyx or 'lyxbase' in targets:
979 print "Processing files in src"
981 env['SUBST_KEYS'] = ['PACKAGE_VERSION', 'VERSION_INFO']
982 env.substFile('$BUILDDIR/common/version.C', '$TOP_SRC_DIR/src/version.C.in')
984 lyx_source_pre = Split('''
1004 ParagraphParameters.C
1090 lyx_source_post = Split('''
1099 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1100 lyx_source_post.append('aspell.C')
1101 elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
1102 lyx_source_post.append('pspell.C')
1103 elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
1104 lyx_source_post.append('ispell.C')
1106 lyxbase_pre = env.StaticLibrary(
1107 target = '$LOCALLIBPATH/lyxbase_pre',
1108 source = ["$BUILDDIR/common/%s" % x for x in lyx_source_pre]
1110 lyxbase_post = env.StaticLibrary(
1111 target = '$LOCALLIBPATH/lyxbase_post',
1112 source = ["$BUILDDIR/common/%s" % x for x in lyx_source_post]
1114 Alias('lyxbase', lyxbase_pre)
1115 Alias('lyxbase', lyxbase_post)
1118 if build_lyx or 'lyx' in targets:
1120 # Build lyx with given frontend
1123 target = '$BUILDDIR/$frontend/lyx',
1136 env['BOOST_LIBRARIES'] +
1138 env['SOCKET_LIBS'] +
1141 # [/path/to/lyx.ext] => lyx-qt3.ext
1142 target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s' % frontend)
1143 Alias('lyx', env.Command(os.path.join('$BUILDDIR', target_name), lyx,
1144 [Copy('$TARGET', '$SOURCE')]))
1148 if 'po' in targets or 'install' in targets or 'all' in targets:
1152 print 'Processing files in po...'
1157 # files to translate
1158 transfiles = glob.glob(os.path.join(env.subst('$TOP_SRC_DIR'), 'po', '*.po'))
1159 # possibly *only* handle these languages
1161 if env.has_key('languages'):
1162 languages = env.make_list(env['lanauges'])
1163 # use defulat msgfmt
1164 if not env['MSGFMT']:
1165 print 'msgfmt does not exist. Can not process po files'
1168 env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
1171 for f in transfiles:
1173 fname = os.path.split(f)[1]
1175 country = fname.split('.')[0]
1177 if not languages or country in languages:
1178 gmo_files.extend(env.Transfiles(f))
1181 if 'install' in targets:
1182 # create the directory if needed
1183 if not os.path.isdir(env['PREFIX']):
1185 os.makedirs(env['PREFIX'])
1188 if not os.path.isdir(env['PREFIX']):
1189 print 'Can not create directory', env['PREFIX']
1194 # windows: $PREFIX/Resources
1195 # others: $PREDIX/share/lyx
1196 share_dir = env['SHARE_DIR']
1197 # windows: $PREFIX/Resouces/man/man1
1198 # others: $PREFIX/man/man1
1199 man_dir = env['MAN_DIR']
1200 # windows: $PREFIX/Resources/locale
1201 # others: $PREFIX/share/locale
1202 locale_dir = env['LOCALE_DIR']
1204 def install(dest, src):
1205 ''' recusive installation of src to dest '''
1206 # separate file and directory
1207 files = filter(os.path.isfile, [x for x in src])
1208 dirs = filter(os.path.isdir, [x for x in src])
1210 env.Install(dest, files)
1214 ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
1215 glob.glob(os.path.join(dir, '*'))) )
1218 # executables (some of them may be none)
1219 env.Install(env['BIN_DIR'], filter(lambda x: x != None, [lyx, tex2lyx, client]))
1220 Alias('install', env['BIN_DIR'])
1223 dirs = install(env['SHARE_DIR'],
1224 [env.subst('$TOP_SRC_DIR/lib/') + file for file in ['configure.py', 'encodings',
1225 'chkconfig.ltx', 'CREDITS', 'external_templates', 'symbols', 'languages',
1226 'lyxrc.example', 'syntax.default', 'bind', 'images', 'layouts', 'scripts',
1227 'templates', 'examples', 'kbd', 'lyx2lyx', 'tex', 'clipart', 'doc', 'ui']]
1229 Alias('install', dirs)
1231 env.InstallAs(os.path.join(env['MAN_DIR'], 'lyx.1'),
1232 env.subst('$TOP_SRC_DIR/lyx.man'))
1233 env.InstallAs(os.path.join(env['MAN_DIR'], 'tex2lyx.1'),
1234 env.subst('$TOP_SRC_DIR/src/tex2lyx/tex2lyx.man'))
1235 env.InstallAs(os.path.join(env['MAN_DIR'], 'lyxclient.1'),
1236 env.subst('$TOP_SRC_DIR/src/client/lyxclient.man'))
1237 Alias('install', [os.path.join(env['MAN_DIR'], x) for
1238 x in ['lyx.1', 'tex2lyx.1', 'lyxclient.1']])
1240 # ru.gmo ==> ru/LC_MESSAGES/lyx.mo
1241 for gmo in gmo_files:
1242 lan = os.path.split(str(gmo))[1].split('.')[0]
1243 dest_file = os.path.join(env['LOCALE_DIR'], lan, 'LC_MESSAGES', 'lyx.mo')
1244 env.InstallAs(dest_file, gmo)
1245 Alias('install', dest_file)
1249 Alias('all', ['lyx', 'client', 'tex2lyx', 'po'])