+#
+# src/frontend/qt4
+#
+if build_qt4:
+ env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRCDIR/src/frontend/$frontend', duplicate = 0)
+
+
+if build_qt4:
+ print "Processing files in src/frontends/qt4..."
+
+ qt4env = env.Copy()
+ qt4env['QT_AUTOSCAN'] = 0
+
+ # local qt4 toolset from
+ # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
+ #
+ # NOTE: I have to patch qt4.py since it does not automatically
+ # process .C file!!! (add to cxx_suffixes )
+ #
+ qt4env.Tool('qt4', [scons_dir])
+ qt4env.EnableQt4Modules(qt_libs, debug = (mode == 'debug'))
+
+ qt4env.AppendUnique(CPPPATH = [
+ '$BUILDDIR/common',
+ '$BUILDDIR/common/images',
+ '$BUILDDIR/common/frontends',
+ '$BUILDDIR/common/frontends/qt4',
+ '$BUILDDIR/common/frontends/controllers',
+ qt_inc_path
+ ]
+ )
+
+ # FIXME: replace by something from pkg_config
+ qt4env.Append(CCFLAGS = [
+ '-DHAVE_CONFIG_H',
+ '-DQT_CLEAN_NAMESPACE',
+ '-DQT_GENUINE_STR',
+ '-DQT_NO_STL',
+ '-DQT_NO_KEYWORDS',
+ ]
+ )
+
+
+ qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in src_frontends_qt4_moc_files]
+
+ #
+ # Compile resources
+ #
+ resources = [qt4env.Uic4(x.split('.')[0]) for x in \
+ ["$BUILDDIR/common/frontends/qt4/ui/%s" % x for x in src_frontends_qt4_ui_files]]
+
+ #
+ # moc qt4_moc_files, the moced files are included in the original files
+ #
+ qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
+
+ qt4 = qt4env.StaticLibrary(
+ target = '$LOCALLIBPATH/qt4',
+ source = ['$BUILDDIR/common/frontends/qt4/%s' % x for x in src_frontends_qt4_files]
+ )
+ Alias('qt4', qt4)
+
+
+if build_client:
+ #
+ # src/client
+ #
+ env.BuildDir('$BUILDDIR/common', '$TOP_SRCDIR/src', duplicate = 0)
+
+ print "Processing files in src/client..."
+
+ if env['HAVE_FCNTL']:
+ client = env.Program(
+ target = '$BUILDDIR/common/client/lyxclient',
+ LIBS = ['support'] + intl_libs + system_libs +
+ socket_libs + boost_libraries,
+ source = ['$BUILDDIR/common/client/%s' % x for x in src_client_files]
+ )
+ Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
+ client, [Copy('$TARGET', '$SOURCE')]))
+ else:
+ client = None
+ Alias('client', client)
+else:
+ if env['HAVE_FCNTL']:
+ # define client even if lyxclient is not built with rebuild=no
+ client = [env.subst('$BUILDDIR/common/client/${PROGPREFIX}lyxclient$PROGSUFFIX')]
+ else:
+ client = None
+
+
+if build_tex2lyx:
+ #
+ # tex2lyx
+ #
+ print "Processing files in src/tex2lyx..."
+
+ tex2lyx_env = env.Copy()
+ #
+ tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
+ tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
+
+ for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C',
+ 'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
+ env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
+ [Copy('$TARGET', '$SOURCE')])
+
+ tex2lyx = tex2lyx_env.Program(
+ target = '$BUILDDIR/common/tex2lyx/tex2lyx',
+ LIBS = ['support'] + boost_libraries + intl_libs + system_libs,
+ source = ['$BUILDDIR/common/tex2lyx/%s' % x for x in src_tex2lyx_files]
+ )
+ Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
+ tex2lyx, [Copy('$TARGET', '$SOURCE')]))
+ Alias('tex2lyx', tex2lyx)
+else:
+ # define tex2lyx even if tex2lyx is not built with rebuild=no
+ tex2lyx = [env.subst('$BUILDDIR/common/tex2lyx/${PROGPREFIX}tex2lyx$PROGSUFFIX')]
+
+
+if build_lyxbase:
+ #
+ # src/
+ #
+ print "Processing files in src..."
+
+ env.Depends('$BUILDDIR/common/version.C', '$BUILDDIR/common/config.h')
+ env.substFile('$BUILDDIR/common/version.C', '$TOP_SRCDIR/src/version.C.in')
+
+ if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
+ src_post_files.append('aspell.C')
+ elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
+ src_post_files.append('pspell.C')
+ elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
+ src_post_files.append('ispell.C')
+
+ # msvc requires at least one source file with main()
+ # so I exclude main.C from lyxbase
+ lyxbase_pre = env.StaticLibrary(
+ target = '$LOCALLIBPATH/lyxbase_pre',
+ source = ['$BUILDDIR/common/%s' % x for x in src_pre_files]
+ )
+ lyxbase_post = env.StaticLibrary(
+ target = '$LOCALLIBPATH/lyxbase_post',
+ source = ["$BUILDDIR/common/%s" % x for x in src_post_files]
+ )
+ Alias('lyxbase', lyxbase_pre)
+ Alias('lyxbase', lyxbase_post)
+
+
+if build_lyx:
+ #
+ # Build lyx with given frontend
+ #
+ lyx = env.Program(
+ target = '$BUILDDIR/$frontend/lyx',
+ source = ['$BUILDDIR/common/main.C'],
+ LIBS = [
+ 'lyxbase_pre',
+ 'mathed',
+ 'insets',
+ 'frontends',
+ frontend,
+ 'controllers',
+ 'graphics',
+ 'support',
+ 'lyxbase_post',
+ ] +
+ boost_libraries +
+ frontend_libs +
+ intl_libs +
+ socket_libs +
+ system_libs
+ )
+ Alias('lyx', lyx)
+else:
+ # define lyx even if lyx is not built with rebuild=no
+ lyx = [env.subst('$BUILDDIR/$frontend/${PROGPREFIX}lyx$PROGSUFFIX')]
+
+
+if build_msvs_projects:
+ def build_project(target, full_target = None,
+ src = [], inc = [], res = [], rebuildTargetOnly = True):
+ ''' build mavs project files
+ target: alias (correspond to directory name)
+ full_target: full path/filename of the target
+ src: source files
+ inc: include files
+ res: resource files
+ rebuildTargetOnly: whether or not only rebuild this target
+
+ For non-debug-able targets like static libraries, target (alias) is
+ enough to build the target. For executable targets, msvs need to know
+ the full path to start debug them.
+ '''
+ if rebuildTargetOnly:
+ cmds = 'rebuild='+target
+ else:
+ cmds = ''
+ if full_target is None:
+ build_target = target
+ else:
+ build_target = full_target
+ # project
+ proj = env.MSVSProject(
+ target = target + env['MSVSPROJECTSUFFIX'],
+ # this allows easy access to header files (along with source)
+ srcs = [env.subst(x) for x in src + inc],
+ incs = [env.subst('$TOP_SRCDIR/src/config.h')],
+ localincs = [env.subst(x) for x in inc],
+ resources = [env.subst(x) for x in res],
+ buildtarget = build_target,
+ cmdargs = cmds,
+ variant = 'Debug'
+ )
+ Alias('msvs_projects', proj)
+ #
+ boost_src = []
+ for lib in boost_libs:
+ boost_src += ['$TOP_SRCDIR/boost/libs/%s/src/%s' % (lib, x) for x in eval('boost_libs_%s_src_files' % lib)]
+ build_project('boost', src = boost_src)
+ #
+ build_project('intl', src = ['$TOP_SRCDIR/intl/%s' % x for x in intl_files],
+ inc = ['$TOP_SRCDIR/intl/%s' % x for x in intl_header_files])
+ #
+ build_project('support', src = ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files],
+ inc = ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files])
+ #
+ build_project('mathed', src = ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files],
+ inc = ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files])
+ #
+ build_project('insets', src = ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files],
+ inc = ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files])
+ #
+ build_project('frontends', src = ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files],
+ inc = ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files])
+ #
+ build_project('graphics', src = ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files],
+ inc = ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files])
+ #
+ build_project('controllers', src = ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_files],
+ inc = ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_header_files])
+ #
+ build_project('qt4', src = ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files + src_frontends_qt4_moc_files],
+ inc = ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
+ res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files])
+ #
+ build_project('client', src = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_files],
+ inc = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files],
+ rebuildTargetOnly = False,
+ full_target = File(env.subst('$BUILDDIR/common/client/lyxclient$PROGSUFFIX')).abspath)
+ #
+ build_project('tex2lyx', src = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files],
+ inc = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files],
+ rebuildTargetOnly = False,
+ full_target = File(env.subst('$BUILDDIR/common/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
+ #
+ build_project('lyxbase', src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files],
+ inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files])
+ build_project('lyx',
+ src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files] + \
+ ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files] + \
+ ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_files] + \
+ ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files] + \
+ ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files] + \
+ ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files] + \
+ ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_files] + \
+ ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files + src_frontends_qt4_moc_files],
+ inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files] + \
+ ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files] + \
+ ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files] + \
+ ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files] + \
+ ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files] + \
+ ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files] + \
+ ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_header_files] + \
+ ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
+ res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
+ rebuildTargetOnly = False,
+ full_target = File(env.subst('$BUILDDIR/$frontend/lyx$PROGSUFFIX')).abspath)
+
+
+if build_po:
+ #
+ # po/
+ #
+ print 'Processing files in po...'
+
+ import glob
+ # handle po files
+ #
+ # files to translate
+ transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
+ # possibly *only* handle these languages
+ languages = None
+ if env.has_key('languages'):
+ languages = env.make_list(env['lanauges'])
+ # use defulat msgfmt
+ gmo_files = []
+ if not env['MSGFMT']:
+ print 'msgfmt does not exist. Can not process po files'
+ else:
+ # create a builder
+ env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
+ #
+ for f in transfiles:
+ # get filename
+ fname = os.path.split(f)[1]
+ # country code
+ country = fname.split('.')[0]
+ #
+ if not languages or country in languages:
+ gmo_files.extend(env.Transfiles(f))
+
+
+if 'install' in targets:
+ #
+ # this part is a bit messy right now. Since scons will provide
+ # --DESTDIR option soon, at least the dest_dir handling can be
+ # removed later.
+ #
+ # how to join dest_dir and prefix
+ def joinPaths(path1, path2):
+ ''' join path1 and path2, do not use os.path.join because
+ under window, c:\destdir\d:\program is invalid '''
+ if path1 == '':
+ return os.path.normpath(path2)
+ # separate drive letter
+ (drive, path) = os.path.splitdrive(os.path.normpath(path2))
+ # ignore drive letter, so c:\destdir + c:\program = c:\destdir\program
+ return os.path.join(os.path.normpath(path1), path[1:])
+ #
+ # install to dest_dir/prefix
+ dest_dir = env.get('DESTDIR', '')
+ dest_prefix_dir = joinPaths(dest_dir, env.Dir(prefix).abspath)
+ # create the directory if needed
+ if not os.path.isdir(dest_prefix_dir):
+ try:
+ os.makedirs(dest_prefix_dir)
+ except:
+ pass
+ if not os.path.isdir(dest_prefix_dir):
+ print 'Can not create directory', dest_prefix_dir
+ Exit(3)
+ #
+ if env.has_key('exec_prefix'):
+ bin_dest_dir = joinPaths(dest_dir, Dir(env['exec_prefix']).abspath)
+ else:
+ bin_dest_dir = os.path.join(dest_prefix_dir, 'bin')
+ if add_suffix:
+ share_dest_dir = os.path.join(dest_prefix_dir, share_dir + program_suffix)
+ else:
+ share_dest_dir = os.path.join(dest_prefix_dir, share_dir)
+ man_dest_dir = os.path.join(dest_prefix_dir, man_dir)
+ locale_dest_dir = os.path.join(dest_prefix_dir, locale_dir)
+ #
+ import glob
+ #
+ # install executables (lyxclient may be None)
+ #
+ if add_suffix:
+ version_suffix = program_suffix
+ else:
+ version_suffix = ''
+ #
+ # install lyx, if in release mode, try to strip the binary
+ if env.has_key('STRIP') and env['STRIP'] is not None and mode != 'debug':
+ # create a builder to strip and install
+ env['BUILDERS']['StripInstallAs'] = Builder(action='$STRIP $SOURCE -o $TARGET')
+
+ # install executables
+ for (name, obj) in (('lyx', lyx), ('tex2lyx', tex2lyx), ('client', client)):
+ if obj is None:
+ continue
+ target_name = os.path.split(str(obj[0]))[1].replace(name, '%s%s' % (name, version_suffix))
+ target = os.path.join(bin_dest_dir, target_name)
+ if env['BUILDERS'].has_key('StripInstallAs'):
+ env.StripInstallAs(target, obj)
+ else:
+ env.InstallAs(target, obj)
+ Alias('install', target)
+
+ # share/lyx
+ dirs = []
+ for (dir,files) in [
+ ('.', lib_files),
+ ('clipart', lib_clipart_files),
+ ('examples', lib_examples_files),
+ ('images', lib_images_files),
+ ('images/math', lib_images_math_files),
+ ('bind', lib_bind_files),
+ ('kbd', lib_kbd_files),
+ ('layouts', lib_layouts_files),
+ ('scripts', lib_scripts_files),
+ ('templates', lib_templates_files),
+ ('tex', lib_tex_files),
+ ('ui', lib_ui_files),
+ ('doc', lib_doc_files),
+ ('lyx2lyx', lib_lyx2lyx_files)]:
+ dirs.append(env.Install(os.path.join(share_dest_dir, dir),
+ [env.subst('$TOP_SRCDIR/lib/%s/%s' % (dir, file)) for file in files]))
+ Alias('install', dirs)
+
+ if platform_name == 'cygwin':
+ # cygwin packaging requires a file /usr/share/doc/Cygwin/foot-vendor-suffix.README
+ Cygwin_README = os.path.join(dest_prefix_dir, 'share', 'doc', 'Cygwin',
+ '%s-%s.README' % (package, package_cygwin_version))
+ env.InstallAs(Cygwin_README,
+ os.path.join(env.subst('$TOP_SRCDIR'), 'README.cygwin'))
+ Alias('install', Cygwin_README)
+ # also a directory /usr/share/doc/lyx for README etc
+ Cygwin_Doc = os.path.join(dest_prefix_dir, 'share', 'doc', package)
+ env.Install(Cygwin_Doc, [os.path.join(env.subst('$TOP_SRCDIR'), x) for x in \
+ ['INSTALL', 'README', 'README.Cygwin', 'RELEASE-NOTES', 'COPYING', 'ANNOUNCE']])
+ Alias('install', Cygwin_Doc)
+ # cygwin fonts also need to be installed
+ Cygwin_fonts = os.path.join(share_dest_dir, 'fonts')
+ env.Install(Cygwin_fonts,
+ [env.subst('$TOP_SRCDIR/development/Win32/packaging/bakoma/%s' % file) \
+ for file in win32_bakoma_fonts])
+ Alias('install', Cygwin_fonts)
+ # we also need a post installation script
+ tmp_script = utils.installCygwinPostinstallScript('/tmp')
+ postinstall_path = os.path.join(dest_dir, 'etc', 'postinstall')
+ env.Install(postinstall_path, tmp_script)
+ Alias('install', postinstall_path)
+
+ # subst and install lyx2lyx_version.py which is not in scons_manifest.py
+ env.Depends(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py', '$BUILDDIR/common/config.h')
+ env.substFile(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py',
+ '$TOP_SRCDIR/lib/lyx2lyx/lyx2lyx_version.py.in')
+ Alias('install', share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
+
+ # man
+ env.InstallAs(os.path.join(man_dest_dir, 'lyx' + version_suffix + '.1'),
+ env.subst('$TOP_SRCDIR/lyx.man'))
+ env.InstallAs(os.path.join(man_dest_dir, 'tex2lyx' + version_suffix + '.1'),
+ env.subst('$TOP_SRCDIR/src/tex2lyx/tex2lyx.man'))
+ env.InstallAs(os.path.join(man_dest_dir, 'lyxclient' + version_suffix + '.1'),
+ env.subst('$TOP_SRCDIR/src/client/lyxclient.man'))
+ Alias('install', [os.path.join(man_dest_dir, x + version_suffix + '.1') for
+ x in ['lyx', 'tex2lyx', 'lyxclient']])
+ # locale files?
+ # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
+ for gmo in gmo_files:
+ lan = os.path.split(str(gmo))[1].split('.')[0]
+ dest_file = os.path.join(locale_dest_dir, lan, 'LC_MESSAGES', 'lyx' + program_suffix + '.mo')
+ env.InstallAs(dest_file, gmo)
+ Alias('install', dest_file)
+
+
+Default('lyx')
+Alias('all', ['lyx', 'client', 'tex2lyx'])