1 # vi:filetype=python:expandtab:tabstop=4:shiftwidth=4
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.
11 # This is a scons based building system for lyx, please refer
12 # to INSTALL.scons for detailed instructions.
15 import os, sys, copy, cPickle, glob, time
17 # determine where I am ...
19 from SCons.Node.FS import default_fs
20 # default_fs.SConstruct_dir is where SConstruct file is located.
21 scons_dir = default_fs.SConstruct_dir.path
22 scons_absdir = default_fs.SConstruct_dir.abspath
24 # if SConstruct is copied to the top source directory
25 if os.path.exists(os.path.join(scons_dir, 'development', 'scons', 'scons_manifest.py')):
26 scons_dir = os.path.join(scons_dir, 'development', 'scons')
27 scons_absdir = os.path.join(scons_absdir, 'development', 'scons')
28 # get the ../.. of scons_dir
29 top_src_dir = os.path.split(os.path.split(scons_absdir)[0])[0]
31 sys.path.extend([scons_absdir, os.path.join(top_src_dir, 'lib', 'doc')])
34 # scons_utils.py defines a few utility function
35 import scons_utils as utils
36 # import all file lists
37 from scons_manifest import *
39 #----------------------------------------------------------
40 # Required runtime environment
41 #----------------------------------------------------------
43 # scons asks for 1.5.2, lyx requires 2.3
44 EnsurePythonVersion(2, 3)
45 # Please use at least 0.96.92 (not 0.96.1)
46 EnsureSConsVersion(0, 96)
47 # also check for minor version number for scons 0.96
48 from SCons import __version__
49 version = map(int, __version__.split('.'))
50 if version[0] == 0 and version[1] == 96 and version[2] < 92:
51 print "Scons >= 0.96.92 is required."
55 #----------------------------------------------------------
57 #----------------------------------------------------------
59 # some global settings
61 # get version number from configure.ac so that JMarc does
62 # not have to change SConstruct during lyx release
63 package_version = utils.getVerFromConfigure(top_src_dir)
64 package_cygwin_version = '%s-1' % package_version
65 boost_version = ['1_34']
67 if 'svn' in package_version:
69 default_build_mode = 'debug'
72 default_build_mode = 'release'
75 package_bugreport = 'lyx-devel@lists.lyx.org'
77 package_tarname = 'lyx'
78 package_string = '%s %s' % (package_name, package_version)
80 # various cache/log files
81 default_log_file = 'scons_lyx.log'
82 opt_cache_file = 'opt.cache'
85 #----------------------------------------------------------
86 # platform dependent settings
87 #----------------------------------------------------------
90 platform_name = 'win32'
91 default_prefix = 'c:/program files/lyx'
92 default_with_x = False
93 default_packaging_method = 'windows'
94 elif os.name == 'posix' and sys.platform != 'cygwin':
95 platform_name = sys.platform
96 default_prefix = '/usr/local'
98 default_packaging_method = 'posix'
99 elif os.name == 'posix' and sys.platform == 'cygwin':
100 platform_name = 'cygwin'
101 default_prefix = '/usr'
102 default_with_x = True
103 default_packaging_method = 'posix'
104 elif os.name == 'darwin':
105 platform_name = 'macosx'
106 # FIXME: macOSX default prefix?
108 default_with_x = False
109 default_packaging_method = 'macosx'
110 else: # unsupported system, assume posix behavior
111 platform_name = 'others'
113 default_with_x = True
114 default_packaging_method = 'posix'
116 #---------------------------------------------------------
118 #----------------------------------------------------------
120 # You can set perminant default values in config.py
121 if os.path.isfile('config.py'):
122 print "Getting options from config.py..."
123 print open('config.py').read()
125 opts = Options(['config.py'])
128 EnumOption('frontend', 'Main GUI', 'qt4',
129 allowed_values = ('qt4',) ),
130 # debug or release build
131 EnumOption('mode', 'Building method', default_build_mode,
132 allowed_values = ('debug', 'release') ),
135 'Use included, system boost library, or try sytem boost first.',
136 'auto', allowed_values = (
137 'auto', # detect boost, if not found, use included
138 'included', # always use included boost
139 'system', # always use system boost, fail if can not find
142 EnumOption('gettext',
143 'Use included, system gettext library, or try sytem gettext first',
144 'auto', allowed_values = (
145 'auto', # detect gettext, if not found, use included
146 'included', # always use included gettext
147 'system', # always use system gettext, fail if can not find
150 EnumOption('spell', 'Choose spell checker to use.', 'auto',
151 allowed_values = ('aspell', 'pspell', 'ispell', 'auto', 'no') ),
153 EnumOption('packaging', 'Packaging method to use.', default_packaging_method,
154 allowed_values = ('windows', 'posix', 'macosx')),
156 BoolOption('fast_start', 'This option is obsolete.', False),
157 # No precompiled header support (too troublesome to make it work for msvc)
158 # BoolOption('pch', 'Whether or not use pch', False),
159 # enable assertion, (config.h has ENABLE_ASSERTIOS
160 BoolOption('assertions', 'Use assertions', True),
161 # enable warning, (config.h has WITH_WARNINGS)
162 # default to False since MSVC does not have #warning
163 BoolOption('warnings', 'Use warnings', False),
164 # config.h define _GLIBCXX_CONCEPT_CHECKS
165 # Note: for earlier version of gcc (3.3) define _GLIBCPP_CONCEPT_CHECKS
166 BoolOption('concept_checks', 'Enable concept checks', True),
168 BoolOption('nls', 'Whether or not use native language support', True),
170 BoolOption('profiling', 'Whether or not enable profiling', False),
171 # config.h define _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC
172 BoolOption('stdlib_debug', 'Whether or not turn on stdlib debug', False),
174 BoolOption('X11', 'Use x11 windows system', default_with_x),
175 # use MS VC++ to build lyx
176 BoolOption('use_vc', 'Use MS VC++ to build lyx (cl.exe will be probed)', None),
178 PathOption('qt_dir', 'Path to qt directory', None),
180 PathOption('qt_inc_path', 'Path to qt include directory', None),
182 PathOption('qt_lib_path', 'Path to qt library directory', None),
183 # extra include and libpath
184 PathOption('extra_inc_path', 'Extra include path', None),
186 PathOption('extra_lib_path', 'Extra library path', None),
188 PathOption('extra_bin_path', 'A convenient way to add a path to $PATH', None),
190 PathOption('extra_inc_path1', 'Extra include path', None),
192 PathOption('extra_lib_path1', 'Extra library path', None),
193 # rebuild only specifed, comma separated targets
194 ('rebuild', '''rebuild only specifed, comma separated targets.
195 yes or all (default): rebuild everything
196 no or none: rebuild nothing (usually used for installation)
197 comp1,comp2,...: rebuild specified targets''', None),
198 # can be set to a non-existing directory
199 ('prefix', 'install architecture-independent files in PREFIX', default_prefix),
200 # replace the default name and location of the windows installer
201 ('win_installer', 'name or full path to the windows installer', None),
202 # the deps package used to create minimal installer (qt and other libraries)
203 ('deps_dir', 'path to the development depedency packages with zlib, iconv, zlib and qt libraries', None),
204 # whether or not build bundle installer
205 BoolOption('bundle', 'Whether or not build bundle installer', False),
206 # the bundle directory, containing bundled applications
207 PathOption('bundle_dir', 'path to the bundle dependency package with miktex setup.exe etc', None),
208 # build directory, will use $mode if not set
209 ('build_dir', 'Build directory', None),
211 ('version_suffix', 'install lyx as lyx-suffix', None),
212 # how to load options
213 ('load_option', '''load option from previous scons run. option can be
214 yes (default): load all options
215 no: do not load any option
216 opt1,opt2: load specified options
217 -opt1,opt2: load all options other than specified ones''', 'yes'),
219 ('optimization', 'optimization CCFLAGS option.', None),
221 PathOption('exec_prefix', 'install architecture-independent executable files in PREFIX', None),
223 ('logfile', 'save commands (not outputs) to logfile', default_log_file),
224 # provided for backward compatibility
225 ('dest_dir', 'install to DESTDIR. (Provided for backward compatibility only)', None),
226 # environment variable can be set as options.
227 ('DESTDIR', 'install to DESTDIR', None),
228 ('CC', 'replace default $CC', None),
229 ('LINK', 'replace default $LINK', None),
230 ('CPP', 'replace default $CPP', None),
231 ('CXX', 'replace default $CXX', None),
232 ('CXXCPP', 'replace default $CXXCPP', None),
233 ('CCFLAGS', 'replace default $CCFLAGS', None),
234 ('CPPFLAGS', 'replace default $CPPFLAGS', None),
235 ('LINKFLAGS', 'replace default $LINKFLAGS', None),
239 all_options = [x.key for x in opts.options]
241 # copied from SCons/Options/BoolOption.py
242 # We need to use them before a boolean ARGUMENTS option is available
244 true_strings = ('y', 'yes', 'true', 't', '1', 'on' , 'all' )
245 false_strings = ('n', 'no', 'false', 'f', '0', 'off', 'none')
247 if ARGUMENTS.has_key('fast_start'):
248 print 'fast_start option is obsolete'
250 # if load_option=yes (default), load saved comand line options
252 # This option can take value yes/no/opt1,opt2/-opt1,opt2
253 # and tries to be clever in choosing options to load
254 if (not ARGUMENTS.has_key('load_option') or \
255 ARGUMENTS['load_option'] not in false_strings) \
256 and os.path.isfile(opt_cache_file):
257 cache_file = open(opt_cache_file)
258 opt_cache = cPickle.load(cache_file)
260 # import cached options, but we should ignore qt_dir when frontend changes
261 if ARGUMENTS.has_key('frontend') and opt_cache.has_key('frontend') \
262 and ARGUMENTS['frontend'] != opt_cache['frontend'] \
263 and opt_cache.has_key('qt_dir'):
264 opt_cache.pop('qt_dir')
265 # and we do not cache some options (dest_dir is obsolete)
266 for arg in ['load_option', 'dest_dir', 'bundle']:
267 if opt_cache.has_key(arg):
269 # remove obsolete cached keys (well, SConstruct is evolving. :-)
270 for arg in opt_cache.keys():
271 if arg not in all_options:
272 print 'Option %s is obsolete, do not load it' % arg
274 # now, if load_option=opt1,opt2 or -opt1,opt2
275 if ARGUMENTS.has_key('load_option') and \
276 ARGUMENTS['load_option'] not in true_strings + false_strings:
277 # if -opt1,opt2 is specified, do not load these options
278 if ARGUMENTS['load_option'][0] == '-':
279 for arg in ARGUMENTS['load_option'][1:].split(','):
280 if opt_cache.has_key(arg):
282 # if opt1,opt2 is specified, only load specified options
284 args = ARGUMENTS['load_option'].split(',')
285 for arg in opt_cache.keys():
288 # now restore options as if entered from command line
289 for key in opt_cache.keys():
290 if not ARGUMENTS.has_key(key):
291 ARGUMENTS[key] = opt_cache[key]
292 print "Restoring cached option %s=%s" % (key, ARGUMENTS[key])
295 # check if there is unused (or misspelled) argument
296 for arg in ARGUMENTS.keys():
297 if arg not in all_options:
299 print "Unknown option '%s'... exiting." % arg
301 print "Available options are (check 'scons -help' for details):"
302 print ' ' + '\n '.join(textwrap.wrap(', '.join(all_options)))
306 cache_file = open(opt_cache_file, 'w')
307 cPickle.dump(ARGUMENTS, cache_file)
310 #---------------------------------------------------------
311 # Setting up environment
312 #---------------------------------------------------------
314 # I do not really like ENV=os.environ, but you may add it
315 # here if you experience some environment related problem
316 env = Environment(options = opts)
318 # set individual variables since I do not really like ENV = os.environ
319 env['ENV']['PATH'] = os.environ.get('PATH')
320 env['ENV']['HOME'] = os.environ.get('HOME')
321 # these are defined for MSVC
322 env['ENV']['LIB'] = os.environ.get('LIB')
323 env['ENV']['INCLUDE'] = os.environ.get('INCLUDE')
325 # for simplicity, use var instead of env[var]
326 frontend = env['frontend']
327 prefix = env['prefix']
330 if platform_name == 'win32':
331 if env.has_key('use_vc'):
332 use_vc = env['use_vc']
333 if WhereIs('cl.exe') is None:
334 print "cl.exe is not found. Are you using the MSVC environment?"
336 elif WhereIs('cl.exe') is not None:
343 # lyx will be built to $build/build_dir so it is possible
344 # to build multiple build_dirs using the same source
345 # $mode can be debug or release
346 if env.has_key('build_dir') and env['build_dir'] is not None:
347 # create the directory if needed
348 if not os.path.isdir(env['build_dir']):
350 os.makedirs(env['build_dir'])
353 if not os.path.isdir(env['build_dir']):
354 print 'Can not create directory', env['build_dir']
356 env['BUILDDIR'] = env['build_dir']
358 # Determine the name of the build $mode
359 env['BUILDDIR'] = '#' + mode
361 # all built libraries will go to build_dir/libs
362 # (This is different from the make file approach)
363 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
364 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
367 # Here is a summary of variables defined in env
369 # 2. undefined options with a non-None default value
370 # 3. compiler commands and flags like CCFLAGS.
371 # MSGFMT used to process po files
372 # 4. Variables that will be used to replace variables in some_file.in
373 # src/support/Package.cpp.in:
374 # TOP_SRCDIR, LOCALEDIR, LYX_DIR, PROGRAM_SUFFIX
375 # lib/lyx2lyx/lyx2lyx_version.py.in
378 # PACKAGE_VERSION, LYX_DATE, VERSION_INFO
380 # full path name is used to build msvs project files
381 # and to replace TOP_SRCDIR in package.C
382 env['TOP_SRCDIR'] = Dir(top_src_dir).abspath
383 # needed by src/version.cpp.in => src/version.cpp
384 env['PACKAGE_VERSION'] = package_version
385 env['LYX_DATE'] = time.asctime()
387 # determine share_dir etc
388 packaging_method = env.get('packaging')
389 if packaging_method == 'windows':
390 share_dir = 'Resources'
391 man_dir = 'Resources/man/man1'
392 locale_dir = 'Resources/locale'
394 share_dir = 'share/lyx'
395 locale_dir = 'share/locale'
396 if platform_name == 'cygwin':
397 man_dir = 'share/man/man1'
401 # program suffix: can be yes, or a string
402 if env.has_key('version_suffix'):
403 if env['version_suffix'] in true_strings:
404 program_suffix = package_version
405 elif env['version_suffix'] in false_strings:
408 program_suffix = env['version_suffix']
411 # used by Package.cpp.in
412 env['PROGRAM_SUFFIX'] = program_suffix
414 # whether or not add suffix to file and directory names
415 add_suffix = packaging_method != 'windows'
416 # LYX_DIR are different (used in Package.cpp.in)
418 env['LYX_DIR'] = Dir(os.path.join(prefix, share_dir + program_suffix)).abspath
420 env['LYX_DIR'] = Dir(os.path.join(prefix, share_dir)).abspath
421 # we need absolute path for package.C
422 env['LOCALEDIR'] = Dir(os.path.join(prefix, locale_dir)).abspath
425 #---------------------------------------------------------
426 # Setting building environment (Tools, compiler flags etc)
427 #---------------------------------------------------------
429 # Since Tool('mingw') will reset CCFLAGS etc, this should be
430 # done before getEnvVariable
431 if platform_name == 'win32':
437 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
438 # fix a scons winres bug (there is a missing space between ${RCINCPREFIX} and ${SOURCE.dir}
440 env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
443 # we differentiate between hard-coded options and default options
444 # hard-coded options are required and will always be there
445 # default options can be replaced by enviromental variables or command line options
446 CCFLAGS_required = []
447 LINKFLAGS_required = []
450 # under windows, scons is confused by .C/.c and uses gcc instead of
451 # g++. I am forcing the use of g++ here. This is expected to change
452 # after lyx renames all .C files to .cpp
454 # save the old c compiler and CCFLAGS (used by libintl)
455 C_COMPILER = env.subst('$CC')
456 C_CCFLAGS = env.subst('$CCFLAGS').split()
457 # if we use ms vc, the commands are fine (cl.exe and link.exe)
459 # /TP treat all source code as C++
460 # C4819: The file contains a character that cannot be represented
461 # in the current code page (number)
462 # C4996: foo was decleared deprecated
463 CCFLAGS_required.extend(['/TP', '/EHsc'])
465 CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MDd'])
466 # the flags are also needed in C mode (for intl lib)
467 C_CCFLAGS.extend(['/wd4819', '/wd4996', '/nologo', '/MDd'])
469 CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MD'])
470 C_CCFLAGS.extend(['/wd4819', '/wd4996', '/nologo', '/MD'])
472 if env.has_key('CXX') and env['CXX']:
473 env['CC'] = env.subst('$CXX')
474 env['LINK'] = env.subst('$CXX')
479 # for debug/release mode
480 if env.has_key('optimization') and env['optimization'] is not None:
481 # if user supplies optimization flags, use it anyway
482 CCFLAGS_required.extend(env['optimization'].split())
483 # and do not use default
484 set_default_optimization_flags = False
486 set_default_optimization_flags = True
490 CCFLAGS_required.append('/Zi')
491 LINKFLAGS_required.extend(['/debug', '/map'])
493 CCFLAGS_required.append('-g')
494 CCFLAGS_default.append('-O')
495 elif mode == 'release' and set_default_optimization_flags:
497 CCFLAGS_default.append('/O2')
499 CCFLAGS_default.append('-O2')
501 # msvc uses separate tools for profiling
502 if env.has_key('profiling') and env['profiling']:
504 print 'Visual C++ does not use profiling options'
506 CCFLAGS_required.append('-pg')
507 LINKFLAGS_required.append('-pg')
509 if env.has_key('warnings') and env['warnings']:
511 CCFLAGS_default.append('/W2')
513 # Note: autotools detect gxx version and pass -W for 3.x
514 # and -Wextra for other versions of gcc
515 CCFLAGS_default.append('-Wall')
517 # Now, set the variables as follows:
518 # 1. if command line option exists: replace default
519 # 2. then if s envronment variable exists: replace default
520 # 3. set variable to required + default
521 def setEnvVariable(env, name, required = None, default = None, split = True):
522 ''' env: environment to set variable
524 required: hardcoded options
525 default: default options that can be replaced by command line or
526 environment variables
527 split: whether or not split obtained variable like '-02 -g'
529 # 1. ARGUMENTS is already set to env[name], override default.
530 if ARGUMENTS.has_key(name):
531 # env[name] may be rewritten when building tools are reloaded
532 # if that is the case, commandline option will override it.
533 env[name] = ARGUMENTS[name]
535 # then use environment default
536 elif os.environ.has_key(name):
537 print "Acquiring variable %s from system environment: %s" % (name, os.environ[name])
538 default = os.environ[name]
540 default = default.split()
541 # the real value should be env[name] + default + required
544 if env.has_key(name):
545 value = str(env[name]).split()
546 if required is not None:
548 if default is not None:
552 if env.has_key(name):
553 value = str(env[name])
554 if required is not None:
555 value += " " + required
556 if default is not None:
557 value += " " + default
559 # print name, env[name]
561 setEnvVariable(env, 'DESTDIR', split=False)
562 setEnvVariable(env, 'CC')
563 setEnvVariable(env, 'LINK')
564 setEnvVariable(env, 'CPP')
565 setEnvVariable(env, 'CXX')
566 setEnvVariable(env, 'CXXCPP')
567 setEnvVariable(env, 'CCFLAGS', CCFLAGS_required, CCFLAGS_default)
568 setEnvVariable(env, 'CXXFLAGS')
569 setEnvVariable(env, 'CPPFLAGS')
570 setEnvVariable(env, 'LINKFLAGS', LINKFLAGS_required)
572 # if DESTDIR is not set...
573 if env.has_key('dest_dir'):
574 print "This option is obsolete. Please use DESTDIR instead."
575 env['DESTDIR'] = env['dest_dir']
578 # extra_inc_path and extra_lib_path
581 if env.has_key('extra_inc_path') and env['extra_inc_path']:
582 extra_inc_paths.append(env['extra_inc_path'])
583 if env.has_key('extra_lib_path') and env['extra_lib_path']:
584 env.AppendUnique(LIBPATH = [env['extra_lib_path']])
585 if env.has_key('extra_inc_path1') and env['extra_inc_path1']:
586 extra_inc_paths.append(env['extra_inc_path1'])
587 if env.has_key('extra_lib_path1') and env['extra_lib_path1']:
588 env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
589 if env.has_key('extra_bin_path') and env['extra_bin_path']:
590 # only the first one is needed (a scons bug?)
591 os.environ['PATH'] += os.pathsep + env['extra_bin_path']
592 env.PrependENVPath('PATH', env['extra_bin_path'])
593 # extra_inc_paths will be used later by intlenv etc
594 env.AppendUnique(CPPPATH = extra_inc_paths)
597 #----------------------------------------------------------
599 #----------------------------------------------------------
601 conf = Configure(env,
603 'CheckPkgConfig' : utils.checkPkgConfig,
604 'CheckPackage' : utils.checkPackage,
605 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
606 'CheckSelectArgType' : utils.checkSelectArgType,
607 'CheckBoostLibraries' : utils.checkBoostLibraries,
608 'CheckCommand' : utils.checkCommand,
609 'CheckNSIS' : utils.checkNSIS,
610 'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd,
611 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
612 'CheckIconvConst' : utils.checkIconvConst,
613 'CheckSizeOfWChar' : utils.checkSizeOfWChar,
614 'CheckDeclaration' : utils.checkDeclaration,
618 # When using msvc, windows.h is required
619 if use_vc and not conf.CheckCHeader('windows.h'):
620 print 'Windows.h is not found. Please install Windows Platform SDK.'
623 # pkg-config? (if not, we use hard-coded options)
624 if conf.CheckPkgConfig('0.15.0'):
625 env['HAS_PKG_CONFIG'] = True
627 print 'pkg-config >= 0.1.50 is not found'
628 env['HAS_PKG_CONFIG'] = False
630 # zlib? This is required.
631 if (not use_vc and not conf.CheckLibWithHeader('z', 'zlib.h', 'C')) \
632 or (use_vc and not conf.CheckLibWithHeader('zdll', 'zlib.h', 'C')):
633 print 'Did not find zdll.lib or zlib.h, exiting!'
635 if conf.CheckLib('iconv'):
636 env['ICONV_LIB'] = 'iconv'
637 elif conf.CheckLib('libiconv'):
638 env['ICONV_LIB'] = 'libiconv'
639 elif conf.CheckFunc('iconv_open'):
640 env['ICONV_LIB'] = None
642 print 'Did not find iconv or libiconv, exiting!'
647 if conf.CheckLib('socket'):
648 socket_libs.append('socket')
649 # nsl is the network services library and provides a
650 # transport-level interface to networking services.
651 if conf.CheckLib('nsl'):
652 socket_libs.append('nsl')
654 # check available boost libs (since lyx1.4 does not use iostream)
656 for lib in ['signals', 'regex', 'filesystem', 'iostreams']:
657 if os.path.isdir(os.path.join(top_src_dir, 'boost', 'libs', lib)):
658 boost_libs.append(lib)
660 # check boost libraries
661 boost_opt = ARGUMENTS.get('boost', 'auto')
662 # check for system boost
663 lib_paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
664 inc_paths = env['CPPPATH'] + ['/usr/include', '/usr/local/include']
665 # default to $BUILDDIR/libs (use None since this path will be added anyway)
667 # here I assume that all libraries are in the same directory
668 if boost_opt == 'included':
669 boost_libraries = ['included_boost_%s' % x for x in boost_libs]
670 included_boost = True
671 env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
672 elif boost_opt == 'auto':
673 res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
674 # if not found, use local boost
676 boost_libraries = ['included_boost_%s' % x for x in boost_libs]
677 included_boost = True
678 env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
680 included_boost = False
681 (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
682 elif boost_opt == 'system':
683 res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
685 print "Can not find system boost libraries with version %s " % boost_version
686 print "Please supply a path through extra_lib_path and try again."
687 print "Or use boost=included to use included boost libraries."
690 included_boost = False
691 (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
694 if boost_libpath is not None:
695 env.AppendUnique(LIBPATH = [boost_libpath])
698 env['ENABLE_NLS'] = env['nls']
700 if not env['ENABLE_NLS']:
702 included_gettext = False
704 # check gettext libraries
705 gettext_opt = ARGUMENTS.get('gettext', 'auto')
706 # check for system gettext
708 if gettext_opt in ['auto', 'system']:
709 if conf.CheckFunc('gettext'):
710 included_gettext = False
713 elif conf.CheckLib('intl'):
714 included_gettext = False
718 if gettext_opt == 'system':
719 print "Can not find system gettext library"
720 print "Please supply a path through extra_lib_path and try again."
721 print "Or use gettext=included to use included gettext libraries."
723 # now, auto and succ = false, or gettext=included
725 # we do not need to set LIBPATH now.
726 included_gettext = True
727 intl_libs = ['included_intl']
731 # check for msgfmt command
732 env['MSGFMT'] = conf.CheckCommand('msgfmt')
733 env['MSGMERGE'] = conf.CheckCommand('msgmerge')
734 env['XGETTEXT'] = conf.CheckCommand('xgettext')
735 env['MSGUNIQ'] = conf.CheckCommand('msguniq')
737 # if under windows, check the nsis compiler
738 if platform_name == 'win32':
739 env['NSIS'] = conf.CheckNSIS()
741 # cygwin packaging requires the binaries to be stripped
742 if platform_name == 'cygwin':
743 env['STRIP'] = conf.CheckCommand('strip')
746 # Customized builders
748 # install customized builders
749 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
750 env['BUILDERS']['installTOC'] = Builder(action = utils.env_toc)
751 env['BUILDERS']['potfiles'] = Builder(action = utils.env_potfiles)
754 #----------------------------------------------------------
755 # Generating config.h
756 #----------------------------------------------------------
757 aspell_lib = 'aspell'
758 # assume that we use aspell, aspelld compiled for msvc
759 if platform_name == 'win32' and mode == 'debug' and use_vc:
760 aspell_lib = 'aspelld'
762 # check the existence of config.h
763 config_h = os.path.join(env.Dir('$BUILDDIR/common').path, 'config.h')
764 boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h')
766 print "Creating %s..." % boost_config_h
768 utils.createConfigFile(conf,
769 config_file = boost_config_h,
770 config_pre = '''/* boost/config.h. Generated by SCons. */
775 * This file is part of LyX, the document processor.
776 * Licence details can be found in the file COPYING.
778 * This is the compilation configuration file for LyX.
779 * It was generated by scon.
780 * You might want to change some of the defaults if something goes wrong
781 * during the compilation.
784 #ifndef _BOOST_CONFIG_H
785 #define _BOOST_CONFIG_H
788 ('ostream', 'HAVE_OSTREAM', 'cxx'),
789 ('locale', 'HAVE_LOCALE', 'cxx'),
790 ('sstream', 'HAVE_SSTREAM', 'cxx'),
791 #('newapis.h', 'HAVE_NEWAPIS_H', 'c'),
794 (env.has_key('assertions') and env['assertions'],
796 'Define if you want assertions to be enabled in the code'
800 ('wchar_t', 'HAVE_WCHAR_T', None),
804 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
805 # define USE_BOOST_FORMAT 1
807 # define USE_BOOST_FORMAT 0
810 #if !defined(ENABLE_ASSERTIONS)
811 # define BOOST_DISABLE_ASSERTS 1
813 #define BOOST_ENABLE_ASSERT_HANDLER 1
815 #define BOOST_DISABLE_THREADS 1
816 #define BOOST_NO_WSTRING 1
819 # define BOOST_POSIX 1
820 # define BOOST_POSIX_API 1
821 # define BOOST_POSIX_PATH 1
824 #define BOOST_ALL_NO_LIB 1
826 #if defined(HAVE_NEWAPIS_H)
827 # define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
831 * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
832 * support compiled in:
833 * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
834 * And we are not interested at all what libc
835 * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
836 * has the needed wchar_t support and uses UCS4. Whether it
837 * implements this with the help of libc, or whether it has own code
838 * does not matter for us, because we don't use libc directly (Georg)
840 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
848 print "\nGenerating %s..." % config_h
850 # AIKSAURUS_H_LOCATION
851 if (conf.CheckCXXHeader("Aiksaurus.h")):
852 aik_location = '<Aiksaurus.h>'
853 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
854 aik_location = '<Aiksaurus/Aiksaurus.h>'
858 # determine headers to use
859 spell_opt = ARGUMENTS.get('spell', 'auto')
860 env['USE_ASPELL'] = False
861 env['USE_PSPELL'] = False
862 env['USE_ISPELL'] = False
863 if spell_opt in ['auto', 'aspell'] and conf.CheckLib(aspell_lib):
864 spell_engine = 'USE_ASPELL'
865 elif spell_opt in ['auto', 'pspell'] and conf.CheckLib('pspell'):
866 spell_engine = 'USE_PSPELL'
867 elif spell_opt in ['auto', 'ispell'] and conf.CheckLib('ispell'):
868 spell_engine = 'USE_ISPELL'
872 if spell_engine is not None:
873 env[spell_engine] = True
875 if spell_opt == 'auto':
876 print "Warning: Can not locate any spell checker"
877 elif spell_opt != 'no':
878 print "Warning: Can not locate specified spell checker:", spell_opt
881 # check arg types of select function
882 (select_arg1, select_arg234, select_arg5) = conf.CheckSelectArgType()
884 # check the size of wchar_t
885 sizeof_wchar_t = conf.CheckSizeOfWChar()
887 if sizeof_wchar_t == 0:
888 print 'Error: Can not determine the size of wchar_t.'
893 result = utils.createConfigFile(conf,
894 config_file = config_h,
895 config_pre = '''/* config.h. Generated by SCons. */
900 * This file is part of LyX, the document processor.
901 * Licence details can be found in the file COPYING.
903 * This is the compilation configuration file for LyX.
904 * It was generated by scon.
905 * You might want to change some of the defaults if something goes wrong
906 * during the compilation.
913 ('io.h', 'HAVE_IO_H', 'c'),
914 ('limits.h', 'HAVE_LIMITS_H', 'c'),
915 ('locale.h', 'HAVE_LOCALE_H', 'c'),
916 ('process.h', 'HAVE_PROCESS_H', 'c'),
917 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
918 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
919 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
920 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
921 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
922 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
923 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
924 ('utime.h', 'HAVE_UTIME_H', 'c'),
925 ('direct.h', 'HAVE_DIRECT_H', 'c'),
926 ('istream', 'HAVE_ISTREAM', 'cxx'),
927 ('ios', 'HAVE_IOS', 'cxx'),
930 ('open', 'HAVE_OPEN', None),
931 ('chmod', 'HAVE_CHMOD', None),
932 ('close', 'HAVE_CLOSE', None),
933 ('popen', 'HAVE_POPEN', None),
934 ('pclose', 'HAVE_PCLOSE', None),
935 ('_open', 'HAVE__OPEN', None),
936 ('_close', 'HAVE__CLOSE', None),
937 ('_popen', 'HAVE__POPEN', None),
938 ('_pclose', 'HAVE__PCLOSE', None),
939 ('getpid', 'HAVE_GETPID', None),
940 ('_getpid', 'HAVE__GETPID', None),
941 ('mkdir', 'HAVE_MKDIR', None),
942 ('_mkdir', 'HAVE__MKDIR', None),
943 ('mktemp', 'HAVE_MKTEMP', None),
944 ('mkstemp', 'HAVE_MKSTEMP', None),
945 ('strerror', 'HAVE_STRERROR', None),
946 ('count', 'HAVE_STD_COUNT', '''
951 return std::count(a, a+5, 'l');
954 ('getcwd', 'HAVE_GETCWD', None),
955 ('setenv', 'HAVE_SETENV', None),
956 ('putenv', 'HAVE_PUTENV', None),
957 ('fcntl', 'HAVE_FCNTL', None),
958 ('mkfifo', 'HAVE_MKFIFO', None),
961 ('mkstemp', 'HAVE_DECL_MKSTEMP', ['unistd.h', 'stdlib.h']),
964 ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
965 '#include <streambuf>\n#include <istream>'),
966 ('wchar_t', 'HAVE_WCHAR_T', None),
967 ('mode_t', 'HAVE_MODE_T', "#include <sys/types.h>"),
970 ('gdi32', 'HAVE_LIBGDI32'),
971 (('Aiksaurus', 'libAiksaurus'), 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB'),
974 (conf.CheckType('pid_t', includes='#include <sys/types.h>'),
976 'Define is sys/types.h does not have pid_t',
980 (conf.CheckCXXGlobalCstd(),
982 'Define if your C++ compiler puts C library functions in the global namespace'
984 (conf.CheckMkdirOneArg(),
985 'MKDIR_TAKES_ONE_ARG',
986 'Define if mkdir takes only one argument.'
988 (conf.CheckIconvConst(),
990 'Define as const if the declaration of iconv() needs const.',
991 '#define ICONV_CONST const',
992 '#define ICONV_CONST',
994 (conf.CheckLC_MESSAGES(),
996 'Define if your <locale.h> file defines LC_MESSAGES.'
998 (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'),
1001 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1003 (env['nls'] and not included_gettext,
1005 'Define to 1 if using system gettext library'
1007 (env.has_key('warnings') and env['warnings'],
1009 'Define this if you want to see the warning directives put here and there by the developpers to get attention'
1011 (env.has_key('concept_checks') and env['concept_checks'],
1012 '_GLIBCXX_CONCEPT_CHECKS',
1013 'libstdc++ concept checking'
1015 (env.has_key('stdlib_debug') and env['stdlib_debug'],
1017 'libstdc++ debug mode'
1019 (env.has_key('stdlib_debug') and env['stdlib_debug'],
1020 '_GLIBCXX_DEBUG_PEDANTIC',
1021 'libstdc++ pedantic debug mode'
1023 (os.name != 'nt', 'BOOST_POSIX',
1024 'Indicates to boost < 1.34 which API to use (posix or windows).'
1026 (os.name != 'nt', 'BOOST_POSIX_API',
1027 'Indicates to boost 1.34 which API to use (posix or windows).'
1029 (os.name != 'nt', 'BOOST_POSIX_PATH',
1030 'Indicates to boost 1.34 which path style to use (posix or windows).'
1032 (spell_engine is not None, spell_engine,
1033 'Spell engine to use'
1035 # we need to know the byte order for unicode conversions
1036 (sys.byteorder == 'big', 'WORDS_BIGENDIAN',
1037 'Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX).'
1041 ('#define PACKAGE "%s%s"' % (package, program_suffix),
1043 ('#define PACKAGE_BUGREPORT "%s"' % package_bugreport,
1044 'Define to the address where bug reports for this package should be sent.'),
1045 ('#define PACKAGE_NAME "%s"' % package_name,
1046 'Define to the full name of this package.'),
1047 ('#define PACKAGE_STRING "%s"' % package_string,
1048 'Define to the full name and version of this package.'),
1049 ('#define PACKAGE_TARNAME "%s"' % package_tarname,
1050 'Define to the one symbol short name of this package.'),
1051 ('#define PACKAGE_VERSION "%s"' % package_version,
1052 'Define to the version of this package.'),
1053 ('#define BOOST_ALL_NO_LIB 1',
1054 'disable automatic linking of boost libraries.'),
1055 ('#define USE_%s_PACKAGING 1' % packaging_method.upper(),
1056 'Packaging method'),
1057 ('#define AIKSAURUS_H_LOCATION ' + aik_location,
1058 'Aiksaurus include file'),
1059 ('#define SELECT_TYPE_ARG1 %s' % select_arg1,
1060 "Define to the type of arg 1 for `select'."),
1061 ('#define SELECT_TYPE_ARG234 %s' % select_arg234,
1062 "Define to the type of arg 2, 3, 4 for `select'."),
1063 ('#define SELECT_TYPE_ARG5 %s' % select_arg5,
1064 "Define to the type of arg 5 for `select'."),
1065 ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1066 'Define to be the size of type wchar_t'),
1068 config_post = '''/************************************************************
1069 ** You should not need to change anything beyond this point */
1071 #ifndef HAVE_STRERROR
1072 #if defined(__cplusplus)
1075 char * strerror(int n);
1079 #ifndef HAVE_DECL_MKSTEMP
1080 #if defined(__cplusplus)
1087 #include <../boost/config.h>
1093 # these keys are needed in env
1094 for key in ['USE_ASPELL', 'USE_PSPELL', 'USE_ISPELL', 'HAVE_FCNTL',\
1095 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB']:
1096 # USE_ASPELL etc does not go through result
1097 if result.has_key(key):
1098 env[key] = result[key]
1101 # if nls=yes and gettext=included, create intl/config.h
1102 # intl/libintl.h etc
1104 intl_config_h = os.path.join(env.Dir('$BUILDDIR/intl').path, 'config.h')
1105 if env['nls'] and included_gettext:
1107 print "Creating %s..." % intl_config_h
1109 # create intl/config.h
1110 result = utils.createConfigFile(conf,
1111 config_file = intl_config_h,
1112 config_pre = '''/* intl/config.h. Generated by SCons. */
1117 * This file is part of LyX, the document processor.
1118 * Licence details can be found in the file COPYING.
1120 * This is the compilation configuration file for LyX.
1121 * It was generated by scon.
1122 * You might want to change some of the defaults if something goes wrong
1123 * during the compilation.
1130 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1131 ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
1132 ('string.h', 'HAVE_STRING_H', 'c'),
1133 ('strings.h', 'HAVE_STRINGS_H', 'c'),
1134 ('argz.h', 'HAVE_ARGZ_H', 'c'),
1135 ('limits.h', 'HAVE_LIMITS_H', 'c'),
1136 ('alloca.h', 'HAVE_ALLOCA_H', 'c'),
1137 ('stddef.h', 'HAVE_STDDEF_H', 'c'),
1138 ('stdint.h', 'HAVE_STDINT_H', 'c'),
1139 ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'),
1142 ('getcwd', 'HAVE_GETCWD', None),
1143 ('stpcpy', 'HAVE_STPCPY', None),
1144 ('strcasecmp', 'HAVE_STRCASECMP', None),
1145 ('strdup', 'HAVE_STRDUP', None),
1146 ('strtoul', 'HAVE_STRTOUL', None),
1147 ('alloca', 'HAVE_ALLOCA', None),
1148 ('__fsetlocking', 'HAVE___FSETLOCKING', None),
1149 ('mempcpy', 'HAVE_MEMPCPY', None),
1150 ('__argz_count', 'HAVE___ARGZ_COUNT', None),
1151 ('__argz_next', 'HAVE___ARGZ_NEXT', None),
1152 ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None),
1153 ('setlocale', 'HAVE_SETLOCALE', None),
1154 ('tsearch', 'HAVE_TSEARCH', None),
1155 ('getegid', 'HAVE_GETEGID', None),
1156 ('getgid', 'HAVE_GETGID', None),
1157 ('getuid', 'HAVE_GETUID', None),
1158 ('wcslen', 'HAVE_WCSLEN', None),
1159 ('asprintf', 'HAVE_ASPRINTF', None),
1160 ('wprintf', 'HAVE_WPRINTF', None),
1161 ('snprintf', 'HAVE_SNPRINTF', None),
1162 ('printf', 'HAVE_POSIX_PRINTF', None),
1163 ('fcntl', 'HAVE_FCNTL', None),
1166 ('intmax_t', 'HAVE_INTMAX_T', None),
1167 ('long double', 'HAVE_LONG_DOUBLE', None),
1168 ('long long', 'HAVE_LONG_LONG', None),
1169 ('wchar_t', 'HAVE_WCHAR_T', None),
1170 ('wint_t', 'HAVE_WINT_T', None),
1171 ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include <inttypes.h>'),
1172 ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include <stdint.h>'),
1178 (conf.CheckLC_MESSAGES(),
1180 'Define if your <locale.h> file defines LC_MESSAGES.'
1182 (conf.CheckIconvConst(),
1184 'Define as const if the declaration of iconv() needs const.',
1185 '#define ICONV_CONST const',
1186 '#define ICONV_CONST',
1188 (conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
1189 conf.CheckType('intmax_t', includes='#include <inttypes.h>'),
1191 "Define to 1 if you have the `intmax_t' type."
1193 (env.has_key('nls') and env['nls'],
1195 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1199 ('#define HAVE_ICONV 1', 'Define if iconv or libiconv is found'),
1200 ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1201 'Define to be the size of type wchar_t'),
1203 config_post = '#endif'
1206 # these keys are needed in env
1207 for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1208 'HAVE_POSIX_PRINTF', 'HAVE_LIBC']:
1209 # USE_ASPELL etc does not go through result
1210 if result.has_key(key):
1211 env[key] = result[key]
1214 # this looks misplaced, but intl/libintl.h is needed by src/message.C
1215 if env['nls'] and included_gettext:
1216 # libgnuintl.h.in => libintl.h
1217 env.Depends('$TOP_SRCDIR/intl/libintl.h', '$BUILDDIR/intl/config.h')
1218 env.substFile('$BUILDDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in')
1219 env.Command('$BUILDDIR/intl/libgnuintl.h', '$BUILDDIR/intl/libintl.h',
1220 [Copy('$TARGET', '$SOURCE')])
1223 # Finish auto-configuration
1226 #----------------------------------------------------------
1227 # Now set up our build process accordingly
1228 #----------------------------------------------------------
1230 if env['ICONV_LIB'] is None:
1233 system_libs = [env['ICONV_LIB']]
1234 if platform_name in ['win32', 'cygwin']:
1235 # the final link step needs stdc++ to succeed under mingw
1236 # FIXME: shouldn't g++ automatically link to stdc++?
1238 system_libs += ['ole32', 'shlwapi', 'shell32', 'advapi32', 'zdll']
1240 system_libs += ['shlwapi', 'stdc++', 'z']
1241 elif platform_name == 'cygwin' and env['X11']:
1242 system_libs += ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr',
1243 'Xcursor', 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE',
1244 'resolv', 'pthread', 'z']
1246 system_libs += ['z']
1249 ('HAVE_LIBGDI32', 'gdi32'),
1250 ('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
1251 ('USE_ASPELL', aspell_lib),
1252 ('USE_ISPELL', 'ispell'),
1253 ('USE_PSPELL', 'pspell'),
1258 system_libs.append(lib[1])
1261 # Build parameters CPPPATH etc
1264 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
1267 # boost: for boost header files
1268 # BUILDDIR/common: for config.h
1269 # TOP_SRCDIR/src: for support/* etc
1271 env['CPPPATH'] += ['$BUILDDIR/common', '$TOP_SRCDIR/src']
1273 # Separating boost directories from CPPPATH stops scons from building
1274 # the dependency tree for boost header files, and effectively reduce
1275 # the null build time of lyx from 29s to 16s. Since lyx may tweak local
1276 # boost headers, this is only done for system boost headers.
1278 env.AppendUnique(CPPPATH = ['$BOOST_INC_PATH'])
1281 env.PrependUnique(CCFLAGS = ['/I$BOOST_INC_PATH'])
1283 env.PrependUnique(CCFLAGS = ['-I$BOOST_INC_PATH'])
1285 # for intl/config.h, intl/libintl.h and intl/libgnuintl.h
1286 if env['nls'] and included_gettext:
1287 env['CPPPATH'].append('$BUILDDIR/intl')
1291 # A Link script for cygwin see
1292 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1293 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
1296 if platform_name == 'cygwin':
1297 ld_script_path = '/tmp'
1298 ld_script = utils.installCygwinLDScript(ld_script_path)
1299 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
1300 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
1303 #---------------------------------------------------------
1304 # Frontend related variables (QTDIR etc)
1305 #---------------------------------------------------------
1308 # create a separate environment so that other files do not have
1309 # to be built with all the include directories etc
1311 if frontend == 'qt4':
1312 frontend_env = env.Copy()
1314 # handle qt related user specified paths
1315 # set environment so that moc etc can be found even if its path is not set properly
1316 if frontend_env.has_key('qt_dir') and frontend_env['qt_dir']:
1317 frontend_env['QTDIR'] = frontend_env['qt_dir']
1318 if os.path.isdir(os.path.join(frontend_env['qt_dir'], 'bin')):
1319 os.environ['PATH'] += os.pathsep + os.path.join(frontend_env['qt_dir'], 'bin')
1320 frontend_env.PrependENVPath('PATH', os.path.join(frontend_env['qt_dir'], 'bin'))
1321 if os.path.isdir(os.path.join(frontend_env['qt_dir'], 'lib')):
1322 frontend_env.PrependENVPath('PKG_CONFIG_PATH', os.path.join(frontend_env['qt_dir'], 'lib'))
1324 # if separate qt_lib_path is given
1325 if frontend_env.has_key('qt_lib_path') and frontend_env['qt_lib_path']:
1326 qt_lib_path = frontend_env.subst('$qt_lib_path')
1327 frontend_env.AppendUnique(LIBPATH = [qt_lib_path])
1328 frontend_env.PrependENVPath('PKG_CONFIG_PATH', qt_lib_path)
1332 # if separate qt_inc_path is given
1333 if frontend_env.has_key('qt_inc_path') and frontend_env['qt_inc_path']:
1334 qt_inc_path = frontend_env['qt_inc_path']
1338 # local qt4 toolset from
1339 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
1341 # NOTE: I have to patch qt4.py since it does not automatically
1342 # process .C file!!! (add to cxx_suffixes )
1344 frontend_env.Tool('qt4', [scons_dir])
1345 frontend_env['QT_AUTOSCAN'] = 0
1346 frontend_env['QT4_AUTOSCAN'] = 0
1347 frontend_env['QT4_UICDECLFLAGS'] = '-tr lyx::qt_'
1349 if qt_lib_path is None:
1350 qt_lib_path = os.path.join(frontend_env.subst('$QTDIR'), 'lib')
1351 if qt_inc_path is None:
1352 qt_inc_path = os.path.join(frontend_env.subst('$QTDIR'), 'include')
1355 conf = Configure(frontend_env,
1357 'CheckPackage' : utils.checkPackage,
1358 'CheckCommand' : utils.checkCommand,
1363 # first: try pkg_config
1364 if frontend_env['HAS_PKG_CONFIG']:
1365 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
1366 # FIXME: use pkg_config information?
1367 #frontend_env['QT4_PKG_CONFIG'] = succ
1368 # second: try to link to it
1370 # Under linux, I can test the following perfectly
1371 # Under windows, lib names need to passed as libXXX4.a ...
1372 if platform_name == 'win32':
1373 succ = conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1375 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1376 # still can not find it
1378 print 'Did not find qt libraries, exiting!'
1381 # Now, determine the correct suffix:
1382 qt_libs = ['QtCore', 'QtGui']
1383 if platform_name == 'win32':
1384 if mode == 'debug' and use_vc and \
1385 conf.CheckLibWithHeader('QtCored4', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1386 qt_lib_suffix = 'd4'
1387 use_qt_debug_libs = True
1390 use_qt_debug_libs = False
1392 if mode == 'debug' and conf.CheckLibWithHeader('QtCore_debug', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1393 qt_lib_suffix = '_debug'
1394 use_qt_debug_libs = True
1397 use_qt_debug_libs = False
1398 frontend_env.EnableQt4Modules(qt_libs, debug = (mode == 'debug' and use_qt_debug_libs))
1399 frontend_libs = [x + qt_lib_suffix for x in qt_libs]
1400 qtcore_lib = ['QtCore' + qt_lib_suffix]
1402 # check uic and moc commands for qt frontends
1403 if conf.CheckCommand('uic') == None or conf.CheckCommand('moc') == None:
1404 print 'uic or moc command is not found for frontend', frontend
1407 # now, if msvc2005 is used, we will need to embed lyx.exe.manifest to lyx.exe
1408 # NOTE: previously, lyx.exe had to be linked to some qt manifest to work.
1409 # For some unknown changes in msvc or qt, this is no longer needed.
1411 frontend_env['LINKCOM'] = [frontend_env['LINKCOM'], \
1412 'mt.exe /MANIFEST %s /outputresource:$TARGET;1' % \
1413 env.File('$BUILDDIR/lyx.exe.manifest').path]
1415 frontend_env = conf.Finish()
1420 # fill in the version info
1421 env['VERSION_INFO'] = '''Configuration
1423 Special build flags: %s
1425 C Compiler flags: %s %s
1427 C++ Compiler LyX flags: %s
1428 C++ Compiler flags: %s %s
1430 Linker user flags: %s
1432 Builing directory: %s
1433 Local library directory: %s
1436 Frontend libraries: %s
1437 System libraries: %s
1438 include search path: %s
1444 ''' % (platform_name,
1445 env.subst('$CCFLAGS'), env.subst('$CC'),
1446 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
1447 env.subst('$CXX'), env.subst('$CXXFLAGS'),
1448 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
1449 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
1450 env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
1451 str(env['LIBPATH']), str(boost_libraries),
1452 str(frontend_libs), str(system_libs), str(env['CPPPATH']),
1453 frontend, packaging_method,
1454 prefix, env['LYX_DIR'])
1456 if frontend in ['qt4']:
1457 env['VERSION_INFO'] += ''' include dir: %s
1460 ''' % (qt_inc_path, qt_lib_path, env['X11'])
1462 print env['VERSION_INFO']
1465 # Mingw command line may be too short for our link usage,
1466 # Here we use a trick from scons wiki
1467 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
1469 # I also would like to add logging (commands only) capacity to the
1471 logfile = env.get('logfile', default_log_file)
1472 if logfile != '' or platform_name == 'win32':
1474 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
1475 info = '''# This is a log of commands used by scons to build lyx
1479 ''' % (time.asctime(), ' '.join(sys.argv),
1480 env['VERSION_INFO'].replace('\n','\n# ')) )
1485 # -h will print out help info
1486 Help(opts.GenerateHelpText(env))
1490 #----------------------------------------------------------
1492 #----------------------------------------------------------
1493 # this has been the source of problems on some platforms...
1494 # I find that I need to supply it with full path name
1495 env.SConsignFile(os.path.join(Dir(env['BUILDDIR']).abspath, '.sconsign'))
1496 # this usage needs further investigation.
1497 #env.CacheDir('%s/Cache/%s' % (env['BUILDDIR'], frontend))
1499 print "Building all targets recursively"
1501 if env.has_key('rebuild'):
1502 rebuild_targets = env['rebuild'].split(',')
1503 if 'none' in rebuild_targets or 'no' in rebuild_targets:
1504 rebuild_targets = []
1505 elif 'all' in rebuild_targets or 'yes' in rebuild_targets:
1506 # None: let scons decide which components to build
1507 # Forcing all components to be rebuilt is in theory not necessary
1508 rebuild_targets = None
1510 rebuild_targets = None
1512 def libExists(libname):
1513 ''' Check whether or not lib $LOCALLIBNAME/libname already exists'''
1514 return os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath)
1516 def appExists(apppath, appname):
1517 ''' Check whether or not application already exists'''
1518 return os.path.isfile(File(env.subst('$BUILDDIR/common/%s/${PROGPREFIX}%s$PROGSUFFIX' % (apppath, appname))).abspath)
1520 targets = BUILD_TARGETS
1521 build_install = 'install' in targets or 'installer' in targets
1522 build_installer = 'installer' in targets
1523 # msvc need to pass full target name, so I have to look for path/lyx etc
1524 build_lyx = build_installer or targets == [] or True in ['lyx' in x for x in targets] \
1525 or build_install or 'all' in targets
1526 build_boost = (included_boost and not libExists('boost_regex')) or 'boost' in targets
1527 build_intl = (included_gettext and not libExists('included_intl')) or 'intl' in targets
1528 build_support = build_lyx or True in [x in targets for x in ['support', 'client', 'tex2lyx']]
1529 build_mathed = build_lyx or 'mathed' in targets
1530 build_insets = build_lyx or 'insets' in targets
1531 build_frontends = build_lyx or 'frontends' in targets
1532 build_graphics = build_lyx or 'graphics' in targets
1533 build_controllers = build_lyx or 'controllers' in targets
1534 build_client = True in ['client' in x for x in targets] \
1535 or build_install or 'all' in targets or build_installer
1536 build_tex2lyx = True in ['tex2lyx' in x for x in targets] \
1537 or build_install or 'all' in targets or build_installer
1538 build_lyxbase = build_lyx or 'lyxbase' in targets
1539 update_po = 'update_po' in targets
1540 update_manifest = 'update_manifest' in targets
1541 build_po = 'po' in targets or build_install or 'all' in targets
1542 build_qt4 = (build_lyx and frontend == 'qt4') or 'qt4' in targets
1543 build_msvs_projects = use_vc and 'msvs_projects' in targets
1546 # now, if rebuild_targets is specified, do not rebuild some targets
1547 if rebuild_targets is not None:
1549 def ifBuildLib(name, libname, old_value):
1550 # explicitly asked to rebuild
1551 if name in rebuild_targets:
1553 # else if not rebuild, and if the library already exists
1554 elif libExists(libname):
1556 # do not change the original value
1559 build_boost = ifBuildLib('boost', 'included_boost_filesystem', build_boost)
1560 build_intl = ifBuildLib('intl', 'included_intl', build_intl)
1561 build_support = ifBuildLib('support', 'support', build_support)
1562 build_mathed = ifBuildLib('mathed', 'mathed', build_mathed)
1563 build_insets = ifBuildLib('insets', 'insets', build_insets)
1564 build_frontends = ifBuildLib('frontends', 'frontends', build_frontends)
1565 build_graphics = ifBuildLib('graphics', 'graphics', build_graphics)
1566 build_controllers = ifBuildLib('controllers', 'controllers', build_controllers)
1567 build_lyxbase = ifBuildLib('lyxbase', 'lyxbase_pre', build_lyxbase)
1568 build_qt4 = ifBuildLib('qt4', 'qt4', build_qt4)
1570 def ifBuildApp(name, appname, old_value):
1571 # explicitly asked to rebuild
1572 if name in rebuild_targets:
1574 # else if not rebuild, and if the library already exists
1575 elif appExists(name, appname):
1577 # do not change the original value
1580 build_tex2lyx = ifBuildApp('tex2lyx', 'tex2lyx', build_tex2lyx)
1581 build_client = ifBuildApp('client', 'lyxclient', build_client)
1583 # sync frontend and frontend (?)
1593 env.BuildDir('$BUILDDIR/boost', '$TOP_SRCDIR/boost/libs', duplicate = 0)
1595 boostenv = env.Copy()
1597 # boost use its own config.h
1598 boostenv['CPPPATH'] = ['$TOP_SRCDIR/boost', '$BUILDDIR/boost'] + extra_inc_paths
1599 boostenv.AppendUnique(CCFLAGS = ['-DBOOST_USER_CONFIG="<config.h>"'])
1601 for lib in boost_libs:
1602 print 'Processing files in boost/libs/%s/src...' % lib
1603 boostlib = boostenv.StaticLibrary(
1604 target = '$LOCALLIBPATH/included_boost_%s' % lib,
1605 source = ['$BUILDDIR/boost/%s/src/%s' % (lib, x) for x in eval('boost_libs_%s_src_files' % lib)]
1607 Alias('boost', boostlib)
1614 intlenv = env.Copy()
1616 print "Processing files in intl..."
1618 env.BuildDir('$BUILDDIR/intl', '$TOP_SRCDIR/intl', duplicate = 0)
1620 # we need the original C compiler for these files
1621 intlenv['CC'] = C_COMPILER
1622 intlenv['CCFLAGS'] = C_CCFLAGS
1624 intlenv.Append(CCFLAGS=['/Dinline#', '/D__attribute__(x)#', '/Duintmax_t=UINT_MAX'])
1625 # intl does not use global config.h
1626 intlenv['CPPPATH'] = ['$BUILDDIR/intl'] + extra_inc_paths
1628 intlenv.Append(CCFLAGS = [
1629 r'-DLOCALEDIR=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1630 r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1631 r'-DLIBDIR=\"' + env['TOP_SRCDIR'].replace('\\', '\\\\') + r'/lib\"',
1633 '-DENABLE_RELOCATABLE=1',
1635 r'-DINSTALLDIR=\"' + prefix.replace('\\', '\\\\') + r'/lib\"',
1637 '-Dset_relocation_prefix=libintl_set_relocation_prefix',
1638 '-Drelocate=libintl_relocate',
1639 '-DDEPENDS_ON_LIBICONV=1',
1644 intl = intlenv.StaticLibrary(
1645 target = '$LOCALLIBPATH/included_intl',
1647 source = ['$BUILDDIR/intl/%s' % x for x in intl_files]
1653 # Now, src code under src/
1655 env.BuildDir('$BUILDDIR/common', '$TOP_SRCDIR/src', duplicate = 0)
1662 print "Processing files in src/support..."
1664 frontend_env.Depends('$BUILDDIR/common/support/Package.cpp', '$BUILDDIR/common/config.h')
1665 Package_cpp = env.substFile('$BUILDDIR/common/support/Package.cpp', '$TOP_SRCDIR/src/support/Package.cpp.in')
1667 support = frontend_env.StaticLibrary(
1668 target = '$LOCALLIBPATH/support',
1669 source = ['$BUILDDIR/common/support/%s' % x for x in src_support_files] + Package_cpp,
1671 Alias('support', support)
1678 print "Processing files in src/mathed..."
1680 mathed = env.StaticLibrary(
1681 target = '$LOCALLIBPATH/mathed',
1682 source = ['$BUILDDIR/common/mathed/%s' % x for x in src_mathed_files]
1684 Alias('mathed', mathed)
1691 print "Processing files in src/insets..."
1693 insets = env.StaticLibrary(
1694 target = '$LOCALLIBPATH/insets',
1695 source = ['$BUILDDIR/common/insets/%s' % x for x in src_insets_files]
1697 Alias('insets', insets)
1704 print "Processing files in src/frontends..."
1706 frontends = env.StaticLibrary(
1707 target = '$LOCALLIBPATH/frontends',
1708 source = ['$BUILDDIR/common/frontends/%s' % x for x in src_frontends_files]
1710 Alias('frontends', frontends)
1717 print "Processing files in src/graphics..."
1719 graphics = env.StaticLibrary(
1720 target = '$LOCALLIBPATH/graphics',
1721 source = ['$BUILDDIR/common/graphics/%s' % x for x in src_graphics_files]
1723 Alias('graphics', graphics)
1726 if build_controllers:
1728 # src/frontends/controllers
1730 print "Processing files in src/frontends/controllers..."
1732 controllers = env.StaticLibrary(
1733 target = '$LOCALLIBPATH/controllers',
1734 source = ['$BUILDDIR/common/frontends/controllers/%s' % x for x in src_frontends_controllers_files]
1736 Alias('controllers', controllers)
1743 env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRCDIR/src/frontend/$frontend', duplicate = 0)
1745 print "Processing files in src/frontends/qt4..."
1747 qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in src_frontends_qt4_moc_files]
1752 resources = [frontend_env.Uic4(x.split('.')[0]) for x in \
1753 ["$BUILDDIR/common/frontends/qt4/ui/%s" % x for x in src_frontends_qt4_ui_files]]
1756 # moc qt4_moc_files, the moced files are included in the original files
1758 qt4_moced_files = [frontend_env.Moc4(x.replace('.cpp', '_moc.cpp'), x.replace('.cpp', '.h')) for x in qt4_moc_files]
1760 qt4 = frontend_env.StaticLibrary(
1761 target = '$LOCALLIBPATH/qt4',
1762 source = ['$BUILDDIR/common/frontends/qt4/%s' % x for x in src_frontends_qt4_files],
1766 '$BUILDDIR/common/images',
1767 '$BUILDDIR/common/frontends',
1768 '$BUILDDIR/common/frontends/qt4',
1769 '$BUILDDIR/common/frontends/controllers'
1774 '-DQT_CLEAN_NAMESPACE',
1787 frontend_env.BuildDir('$BUILDDIR/common', '$TOP_SRCDIR/src', duplicate = 0)
1789 print "Processing files in src/client..."
1791 if env['HAVE_FCNTL']:
1792 client = frontend_env.Program(
1793 target = '$BUILDDIR/common/client/lyxclient',
1794 LIBS = ['support'] + intl_libs + system_libs +
1795 socket_libs + boost_libraries + qtcore_lib,
1796 source = ['$BUILDDIR/common/client/%s' % x for x in src_client_files] + \
1797 utils.createResFromIcon(frontend_env, 'lyx_32x32.ico', '$LOCALLIBPATH/client.rc')
1799 Alias('client', frontend_env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
1800 client, [Copy('$TARGET', '$SOURCE')]))
1803 Alias('client', client)
1805 if env['HAVE_FCNTL']:
1806 # define client even if lyxclient is not built with rebuild=no
1807 client = [env.subst('$BUILDDIR/common/client/${PROGPREFIX}lyxclient$PROGSUFFIX')]
1816 print "Processing files in src/tex2lyx..."
1819 for file in src_tex2lyx_copied_files + src_tex2lyx_copied_header_files:
1820 frontend_env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
1821 [Copy('$TARGET', '$SOURCE')])
1823 tex2lyx = frontend_env.Program(
1824 target = '$BUILDDIR/common/tex2lyx/tex2lyx',
1825 LIBS = ['support'] + boost_libraries + intl_libs + system_libs + qtcore_lib,
1826 source = ['$BUILDDIR/common/tex2lyx/%s' % x for x in src_tex2lyx_files + src_tex2lyx_copied_files] + \
1827 utils.createResFromIcon(frontend_env, 'lyx_32x32.ico', '$LOCALLIBPATH/tex2lyx.rc'),
1828 CPPPATH = ['$BUILDDIR/common/tex2lyx', '$CPPPATH'],
1829 LIBPATH = ['#$LOCALLIBPATH', '$LIBPATH'],
1831 Alias('tex2lyx', frontend_env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
1832 tex2lyx, [Copy('$TARGET', '$SOURCE')]))
1833 Alias('tex2lyx', tex2lyx)
1835 # define tex2lyx even if tex2lyx is not built with rebuild=no
1836 tex2lyx = [frontend_env.subst('$BUILDDIR/common/tex2lyx/${PROGPREFIX}tex2lyx$PROGSUFFIX')]
1843 print "Processing files in src..."
1845 env.Depends('$BUILDDIR/common/version.cpp', '$BUILDDIR/common/config.h')
1846 version_cpp = env.substFile('$BUILDDIR/common/version.cpp', '$TOP_SRCDIR/src/version.cpp.in')
1848 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1849 src_post_files.append('ASpell.cpp')
1850 elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
1851 src_post_files.append('PSpell.cpp')
1852 elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
1853 src_post_files.append('ISpell.cpp')
1855 # msvc requires at least one source file with main()
1856 # so I exclude main.cpp from lyxbase
1857 lyxbase_pre = env.StaticLibrary(
1858 target = '$LOCALLIBPATH/lyxbase_pre',
1859 source = ['$BUILDDIR/common/%s' % x for x in src_pre_files] + version_cpp
1861 lyxbase_post = env.StaticLibrary(
1862 target = '$LOCALLIBPATH/lyxbase_post',
1863 source = ["$BUILDDIR/common/%s" % x for x in src_post_files]
1865 Alias('lyxbase', lyxbase_pre)
1866 Alias('lyxbase', lyxbase_post)
1871 # Build lyx with given frontend
1873 lyx = frontend_env.Program(
1874 target = '$BUILDDIR/lyx',
1875 source = ['$BUILDDIR/common/main.cpp'] + \
1876 utils.createResFromIcon(frontend_env, 'lyx_32x32.ico', '$LOCALLIBPATH/lyx.rc'),
1896 # define lyx even if lyx is not built with rebuild=no
1897 lyx = [frontend_env.subst('$BUILDDIR/${PROGPREFIX}lyx$PROGSUFFIX')]
1900 if build_msvs_projects:
1901 def build_project(target, full_target = None,
1902 src = [], inc = [], res = [], rebuildTargetOnly = True):
1903 ''' build mavs project files
1904 target: alias (correspond to directory name)
1905 full_target: full path/filename of the target
1909 rebuildTargetOnly: whether or not only rebuild this target
1911 For non-debug-able targets like static libraries, target (alias) is
1912 enough to build the target. For executable targets, msvs need to know
1913 the full path to start debug them.
1915 if rebuildTargetOnly:
1916 cmds = 'rebuild='+target
1919 if full_target is None:
1920 build_target = target
1922 build_target = full_target
1924 proj = env.MSVSProject(
1925 target = target + env['MSVSPROJECTSUFFIX'],
1926 # this allows easy access to header files (along with source)
1927 srcs = [env.subst(x) for x in src + inc],
1928 incs = [env.subst('$TOP_SRCDIR/src/config.h')],
1929 localincs = [env.subst(x) for x in inc],
1930 resources = [env.subst(x) for x in res],
1931 buildtarget = build_target,
1935 Alias('msvs_projects', proj)
1937 build_project('client', src = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_files],
1938 inc = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files],
1939 rebuildTargetOnly = False,
1940 full_target = File(env.subst('$BUILDDIR/common/client/lyxclient$PROGSUFFIX')).abspath)
1942 build_project('tex2lyx', src = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files],
1943 inc = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files],
1944 rebuildTargetOnly = False,
1945 full_target = File(env.subst('$BUILDDIR/common/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
1947 build_project('lyx',
1948 src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files + ['version.cpp']] + \
1949 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files + ['Package.cpp'] ] + \
1950 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_files] + \
1951 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files] + \
1952 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files] + \
1953 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files] + \
1954 ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_files] + \
1955 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files + src_frontends_qt4_moc_files],
1956 inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files] + \
1957 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files] + \
1958 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files] + \
1959 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files] + \
1960 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files] + \
1961 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files] + \
1962 ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_header_files] + \
1963 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
1964 res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1965 rebuildTargetOnly = False,
1966 full_target = File(env.subst('$BUILDDIR/lyx$PROGSUFFIX')).abspath)
1971 # update scons_manifest.py
1973 # When you run 'scons update_manifest', it tells you which files are missing
1974 # and which files are not in the source tree. It also generates a
1975 # scons_manifest.py.new file with all the missing files added to
1976 # XXX_extra_files. It will *not* change other sections of existing
1979 print 'Validating development/scons/scons_manifest.py...'
1981 manifest = open(env.File('$TOP_SRCDIR/development/scons/scons_manifest.py.new').abspath, 'w')
1982 print >> manifest, 'from SCons.Util import Split\n'
1984 ignore_dirs = ['boost/boost', 'm4', 'development',
1985 utils.relativePath(env.Dir('$BUILDDIR').abspath, env.Dir('$TOP_SRCDIR').abspath)]
1986 ignore_types = ['.svn', '.deps', '.cache', '.tmp', '.bak', '.gmo', '.pot',
1987 '.pyc', '.pyo', '.o', '_moc.cpp', 'Makefile.in', 'config.h.in',
1988 'LaTeXConfig.lyx', 'version.cpp', 'Package.cpp']
1989 ext_types = ['_header_files', '_files', '_pre_files', '_post_files', '_moc_files', '_inc_files',
1990 '_copied_files', '_copied_header_files', '_extra_header_files', '_extra_src_files', '_extra_files']
1991 for root,path,files in os.walk(env.Dir('$TOP_SRCDIR').abspath):
1992 if os.path.split(root)[-1][0] == '.' \
1993 or True in [x in root for x in ignore_types] \
1994 or True in [utils.isSubDir(root, x) for x in ignore_dirs]:
1996 dirname = utils.relativePath(root, env.subst('$TOP_SRCDIR')).replace(os.sep, '_')
1999 # files in the current manifest.py
2001 for ext in ext_types:
2002 if 'copied' not in ext and dirname + ext in locals():
2003 cur_files.extend(eval(dirname + ext))
2005 # compare files with cur_files
2006 files = [x for x in files if x[0] != '.' and True not in [len(x) >= len(y) and x[-len(y):] == y for y in ignore_types]]
2008 if cur_files != files:
2011 if f not in cur_files:
2017 if len(missing) > 0:
2018 print 'Missing: %s in %s' % (', '.join(missing), root)
2019 if dirname + '_extra_files' in locals():
2020 exec('%s_extra_files.extend(missing)' % dirname)
2022 exec('%s_extra_files = missing' % dirname)
2024 print 'Extra: %s in %s' % (', '.join(extra), root)
2025 # write to a new manifest file
2026 for ext in ext_types:
2027 if dirname + ext in locals():
2028 exec('%s%s.sort()' % (dirname, ext))
2029 print >> manifest, "%s%s = Split('''\n " % (dirname, ext),
2030 print >> manifest, eval(r"'\n '.join(%s%s)" % (dirname, ext))
2031 print >> manifest, "''')\n\n"
2033 Alias('update_manifest', None)
2040 print 'Updating po/*.po files...'
2042 # whether or not update po files
2043 if not env['XGETTEXT'] or not env['MSGMERGE'] or not env['MSGUNIQ']:
2044 print 'xgettext or msgmerge does not exist. Cannot merge po files'
2046 # rebuild POTFILES.in
2047 POTFILES_in = env.potfiles('$TOP_SRCDIR/po/POTFILES.in',
2048 ['$TOP_SRCDIR/src/%s' % x for x in src_header_files + src_pre_files + src_post_files + \
2049 src_extra_src_files] + \
2050 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files + src_support_files + \
2051 src_support_extra_header_files + src_support_extra_src_files] + \
2052 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files + src_mathed_files] + \
2053 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files + src_insets_files] + \
2054 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files + src_frontends_files] + \
2055 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files + src_graphics_files] + \
2056 ['$TOP_SRCDIR/src/frontends/controllers/%s' % x for x in src_frontends_controllers_header_files + src_frontends_controllers_files] + \
2057 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files + src_frontends_qt4_files + src_frontends_qt4_moc_files] + \
2058 ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files + src_client_files ] + \
2059 ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
2061 Alias('update_po', POTFILES_in)
2062 # build language_l10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n
2063 # and combine them to lyx.po
2064 env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
2065 lyx_po = env.Command('$BUILDDIR/po/lyx.po',
2066 env.Command('$BUILDDIR/po/all.po',
2067 [env.Command('$BUILDDIR/po/qt4_l10n.pot',
2068 ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
2069 '$LYX_POT -b $TOP_SRCDIR -t qt4 -o $TARGET $SOURCES'),
2070 env.Command('$BUILDDIR/po/layouts_l10n.pot',
2071 ['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files + lib_layouts_inc_files],
2072 '$LYX_POT -b $TOP_SRCDIR -t layouts -o $TARGET $SOURCES'),
2073 env.Command('$BUILDDIR/po/languages_l10n.pot', '$TOP_SRCDIR/lib/languages',
2074 '$LYX_POT -b $TOP_SRCDIR -t languages -o $TARGET $SOURCES'),
2075 env.Command('$BUILDDIR/po/ui_l10n.pot',
2076 ['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files],
2077 '$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
2078 env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
2079 '$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
2081 ['$MSGUNIQ -o $TARGET $SOURCE',
2082 '''$XGETTEXT --default-domain=${TARGET.base} \
2083 --directory=$TOP_SRCDIR --add-comments=TRANSLATORS: \
2084 --language=C++ --join-existing \
2085 --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ \
2086 --files-from=$TOP_SRCDIR/po/POTFILES.in \
2087 --copyright-holder="LyX Developers" \
2088 --msgid-bugs-address="lyx-devel@lists.lyx.org" ''']
2090 env.Depends(lyx_po, POTFILES_in)
2091 # copy lyx.po to lyx.pot
2092 lyx_pot = env.Command('$BUILDDIR/po/lyx.pot', lyx_po,
2093 Copy('$TARGET', '$SOURCE'))
2096 # files to translate
2097 transfiles = glob.glob(os.path.join(env.Dir('$TOP_SRCDIR/po').abspath, '*.po'))
2098 # possibly *only* handle these languages
2100 if env.has_key('languages'):
2101 languages = env.make_list(env['languages'])
2102 # merge. if I use lan.po as $TARGET, it will be removed
2103 # before it is merged. In this builder,
2104 # $BUILDDIR/po/lang.po is merged from po/lang.po and $BUILDDIR/po/lyx.pot
2105 # and is copied to po/lang.po
2106 env['BUILDERS']['msgmerge'] = Builder(action=[
2107 '$MSGMERGE $TOP_SRCDIR/po/${TARGET.filebase}.po $SOURCE -o $TARGET',
2108 Copy('$TOP_SRCDIR/po/${TARGET.filebase}.po', '$TARGET')]
2110 # for each po file, generate pot
2111 for po_file in transfiles:
2113 fname = os.path.split(po_file)[1]
2115 country = fname.split('.')[0]
2117 if not languages or country in languages:
2118 # merge po files, the generated lan.po_new file is copied to lan.po file.
2119 po = env.msgmerge('$BUILDDIR/po/%s.po' % country, lyx_pot)
2120 env.Depends(po, POTFILES_in)
2121 Alias('update_po', po)
2128 print 'Processing files in po...'
2133 # files to translate
2134 transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
2135 # possibly *only* handle these languages
2137 if env.has_key('languages'):
2138 languages = env.make_list(env['lanauges'])
2139 # use defulat msgfmt
2141 if not env['MSGFMT']:
2142 print 'msgfmt does not exist. Can not process po files'
2145 env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -c --statistics -o $TARGET',suffix='.gmo',src_suffix='.po')
2147 for f in transfiles:
2149 fname = os.path.split(f)[1]
2151 country = fname.split('.')[0]
2153 if not languages or country in languages:
2154 gmo_files.extend(env.Transfiles(f))
2159 # this part is a bit messy right now. Since scons will provide
2160 # --DESTDIR option soon, at least the dest_dir handling can be
2163 # how to join dest_dir and prefix
2164 def joinPaths(path1, path2):
2165 ''' join path1 and path2, do not use os.path.join because
2166 under window, c:\destdir\d:\program is invalid '''
2168 return os.path.normpath(path2)
2169 # separate drive letter
2170 (drive, path) = os.path.splitdrive(os.path.normpath(path2))
2171 # ignore drive letter, so c:\destdir + c:\program = c:\destdir\program
2172 return os.path.join(os.path.normpath(path1), path[1:])
2174 # install to dest_dir/prefix
2175 dest_dir = env.get('DESTDIR', '')
2176 dest_prefix_dir = joinPaths(dest_dir, env.Dir(prefix).abspath)
2177 # create the directory if needed
2178 if not os.path.isdir(dest_prefix_dir):
2180 os.makedirs(dest_prefix_dir)
2183 if not os.path.isdir(dest_prefix_dir):
2184 print 'Can not create directory', dest_prefix_dir
2187 if env.has_key('exec_prefix'):
2188 bin_dest_dir = joinPaths(dest_dir, Dir(env['exec_prefix']).abspath)
2190 bin_dest_dir = os.path.join(dest_prefix_dir, 'bin')
2192 share_dest_dir = os.path.join(dest_prefix_dir, share_dir + program_suffix)
2194 share_dest_dir = os.path.join(dest_prefix_dir, share_dir)
2195 man_dest_dir = os.path.join(dest_prefix_dir, man_dir)
2196 locale_dest_dir = os.path.join(dest_prefix_dir, locale_dir)
2197 env['LYX2LYX_DEST'] = os.path.join(share_dest_dir, 'lyx2lyx')
2201 # install executables (lyxclient may be None)
2204 version_suffix = program_suffix
2208 # install lyx, if in release mode, try to strip the binary
2209 if env.has_key('STRIP') and env['STRIP'] is not None and mode != 'debug':
2210 # create a builder to strip and install
2211 env['BUILDERS']['StripInstallAs'] = Builder(action='$STRIP $SOURCE -o $TARGET')
2213 # install executables
2214 for (name, obj) in (('lyx', lyx), ('tex2lyx', tex2lyx), ('client', client)):
2217 target_name = os.path.split(str(obj[0]))[1].replace(name, '%s%s' % (name, version_suffix))
2218 target = os.path.join(bin_dest_dir, target_name)
2219 if env['BUILDERS'].has_key('StripInstallAs'):
2220 env.StripInstallAs(target, obj)
2222 env.InstallAs(target, obj)
2223 Alias('install', target)
2227 for (dir,files) in [
2229 ('bind', lib_bind_files),
2230 ('bind/de', lib_bind_de_files),
2231 ('bind/fi', lib_bind_fi_files),
2232 ('bind/pt', lib_bind_pt_files),
2233 ('bind/sv', lib_bind_sv_files),
2234 ('doc', lib_doc_files),
2235 ('doc/clipart', lib_doc_clipart_files),
2236 ('doc/cs', lib_doc_cs_files),
2237 ('doc/da', lib_doc_da_files),
2238 ('doc/de', lib_doc_de_files),
2239 ('doc/de/clipart', lib_doc_de_clipart_files),
2240 ('doc/es', lib_doc_es_files),
2241 ('doc/es/clipart', lib_doc_es_clipart_files),
2242 ('doc/eu', lib_doc_eu_files),
2243 ('doc/fr', lib_doc_fr_files),
2244 ('doc/he', lib_doc_he_files),
2245 ('doc/hu', lib_doc_hu_files),
2246 ('doc/it', lib_doc_it_files),
2247 ('doc/nl', lib_doc_nl_files),
2248 ('doc/nb', lib_doc_nb_files),
2249 ('doc/pl', lib_doc_pl_files),
2250 ('doc/pt', lib_doc_pt_files),
2251 ('doc/ro', lib_doc_ro_files),
2252 ('doc/ru', lib_doc_ru_files),
2253 ('doc/sk', lib_doc_sk_files),
2254 ('doc/sl', lib_doc_sl_files),
2255 ('doc/sv', lib_doc_sv_files),
2256 ('examples', lib_examples_files),
2257 ('examples/ca', lib_examples_ca_files),
2258 ('examples/cs', lib_examples_cs_files),
2259 ('examples/da', lib_examples_da_files),
2260 ('examples/de', lib_examples_de_files),
2261 ('examples/es', lib_examples_es_files),
2262 ('examples/eu', lib_examples_eu_files),
2263 ('examples/fa', lib_examples_fa_files),
2264 ('examples/fr', lib_examples_fr_files),
2265 ('examples/he', lib_examples_he_files),
2266 ('examples/hu', lib_examples_hu_files),
2267 ('examples/it', lib_examples_it_files),
2268 ('examples/nl', lib_examples_nl_files),
2269 ('examples/pl', lib_examples_pl_files),
2270 ('examples/pt', lib_examples_pt_files),
2271 ('examples/ru', lib_examples_ru_files),
2272 ('examples/sl', lib_examples_sl_files),
2273 ('examples/ro', lib_examples_ro_files),
2274 ('fonts', lib_fonts_files),
2275 ('images', lib_images_files),
2276 ('images/math', lib_images_math_files),
2277 ('kbd', lib_kbd_files),
2278 ('layouts', lib_layouts_files + lib_layouts_inc_files),
2279 ('lyx2lyx', lib_lyx2lyx_files),
2280 ('scripts', lib_scripts_files),
2281 ('templates', lib_templates_files),
2282 ('tex', lib_tex_files),
2283 ('ui', lib_ui_files)]:
2284 dirs.append(env.Install(os.path.join(share_dest_dir, dir),
2285 [env.subst('$TOP_SRCDIR/lib/%s/%s' % (dir, file)) for file in files]))
2286 Alias('install', dirs)
2288 # subst and install lyx2lyx_version.py which is not in scons_manifest.py
2289 env.Depends(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py', '$BUILDDIR/common/config.h')
2290 env.substFile(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py',
2291 '$TOP_SRCDIR/lib/lyx2lyx/lyx2lyx_version.py.in')
2292 Alias('install', share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
2293 sys.path.append(share_dest_dir + '/lyx2lyx')
2295 # generate TOC files for each doc
2296 languages = depend.all_documents(env.Dir('$TOP_SRCDIR/lib/doc').abspath)
2298 for lang in languages.keys():
2299 if os.path.isdir(os.path.join(env.Dir('$TOP_SRCDIR/lib/doc').abspath, lang)):
2300 toc = env.installTOC(os.path.join(share_dest_dir, 'doc', lang, 'TOC.lyx'),
2303 # doc_toc.build_toc needs a installed version of lyx2lyx to execute
2304 env.Depends(toc, share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
2306 # this is for English
2307 toc = env.installTOC(os.path.join(share_dest_dir, 'doc', 'TOC.lyx'),
2310 env.Depends(toc, share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
2311 Alias('install', tocs)
2313 if platform_name == 'cygwin':
2314 # cygwin packaging requires a file /usr/share/doc/Cygwin/foot-vendor-suffix.README
2315 Cygwin_README = os.path.join(dest_prefix_dir, 'share', 'doc', 'Cygwin',
2316 '%s-%s.README' % (package, package_cygwin_version))
2317 env.InstallAs(Cygwin_README,
2318 os.path.join(env.subst('$TOP_SRCDIR'), 'README.cygwin'))
2319 Alias('install', Cygwin_README)
2320 # also a directory /usr/share/doc/lyx for README etc
2321 Cygwin_Doc = os.path.join(dest_prefix_dir, 'share', 'doc', package)
2322 env.Install(Cygwin_Doc, [os.path.join(env.subst('$TOP_SRCDIR'), x) for x in \
2323 ['INSTALL', 'README', 'README.Cygwin', 'RELEASE-NOTES', 'COPYING', 'ANNOUNCE']])
2324 Alias('install', Cygwin_Doc)
2325 # cygwin fonts also need to be installed
2326 Cygwin_fonts = os.path.join(share_dest_dir, 'fonts')
2327 env.Install(Cygwin_fonts,
2328 [env.subst('$TOP_SRCDIR/development/Win32/packaging/bakoma/%s' % file) \
2329 for file in win32_bakoma_fonts])
2330 Alias('install', Cygwin_fonts)
2331 # we also need a post installation script
2332 tmp_script = utils.installCygwinPostinstallScript('/tmp')
2333 postinstall_path = os.path.join(dest_dir, 'etc', 'postinstall')
2334 env.Install(postinstall_path, tmp_script)
2335 Alias('install', postinstall_path)
2339 env.InstallAs(os.path.join(man_dest_dir, 'lyx' + version_suffix + '.1'),
2340 env.subst('$TOP_SRCDIR/lyx.man'))
2341 env.InstallAs(os.path.join(man_dest_dir, 'tex2lyx' + version_suffix + '.1'),
2342 env.subst('$TOP_SRCDIR/src/tex2lyx/tex2lyx.man'))
2343 env.InstallAs(os.path.join(man_dest_dir, 'lyxclient' + version_suffix + '.1'),
2344 env.subst('$TOP_SRCDIR/src/client/lyxclient.man'))
2345 Alias('install', [os.path.join(man_dest_dir, x + version_suffix + '.1') for
2346 x in ['lyx', 'tex2lyx', 'lyxclient']])
2348 # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
2349 for gmo in gmo_files:
2350 lan = os.path.split(str(gmo))[1].split('.')[0]
2351 dest_file = os.path.join(locale_dest_dir, lan, 'LC_MESSAGES', 'lyx' + program_suffix + '.mo')
2352 env.InstallAs(dest_file, gmo)
2353 Alias('install', dest_file)
2358 # build windows installer using NSIS
2361 # There is a nsis builder on scons wiki but it does not work with
2362 # our lyx.nsi because it does not dig through all the include directives
2363 # and find the dependencies automatically. Also, it can not parse
2364 # OutFile in lyx.nsi since it is defined as SETUP_EXE which is in turn
2365 # something rely on date.
2366 # Because of this, I am doing a simple nsis builder here.
2367 if platform_name != 'win32':
2368 print 'installer target is only available for windows platform'
2370 if mode != 'release':
2371 print 'installer has to be built in release mode (use option mode=release)'
2373 installer_files = ['$TOP_SRCDIR/development/Win32/packaging/installer/%s' \
2374 % x for x in development_Win32_packaging_installer] + \
2375 ['$TOP_SRCDIR/development/Win32/packaging/installer/components/%s' \
2376 % x for x in development_Win32_packaging_installer_components] + \
2377 ['$TOP_SRCDIR/development/Win32/packaging/installer/dialogs/%s' \
2378 % x for x in development_Win32_packaging_installer_dialogs] + \
2379 ['$TOP_SRCDIR/development/Win32/packaging/installer/graphics/%s' \
2380 % x for x in development_Win32_packaging_installer_graphics] + \
2381 ['$TOP_SRCDIR/development/Win32/packaging/installer/include/%s' \
2382 % x for x in development_Win32_packaging_installer_include] + \
2383 ['$TOP_SRCDIR/development/Win32/packaging/installer/lang/%s' \
2384 % x for x in development_Win32_packaging_installer_lang]
2385 if env.has_key('NSIS') and env['NSIS'] is not None:
2386 # create a builder to strip and install
2387 env['BUILDERS']['installer'] = Builder(generator=utils.env_nsis)
2389 print 'No nsis compiler is found. Existing...'
2391 if not env.has_key('win_installer') or env['win_installer'] is None:
2393 env['win_installer'] = '%s-%s-%s-Installer.exe' % (package_name, package_version, time.strftime('%Y-%m-%d'))
2395 env['win_installer'] = '%s-%s-Installer.exe' % (package_name, package_version)
2396 # provide default setting
2397 if not env.has_key('deps_dir') or env['deps_dir'] is None:
2398 env['deps_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-deps-msvc-qt4')
2399 if not os.path.isdir(env.Dir('$deps_dir').abspath):
2400 print 'Development dependency package is not found.'
2403 env['deps_dir'] = env.Dir('$deps_dir').abspath
2405 if env.has_key('bundle_dir') and os.path.isdir(env.Dir('$bundle_dir').abspath):
2406 env['bundle_dir'] = env.Dir('$bundle_dir').abspath
2407 elif os.path.isdir(os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')):
2408 env['bundle_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')
2410 env['bundle_dir'] = None
2411 # if absolute path is given, use it, otherwise, write to current directory
2412 if not (':' in env['win_installer'] or '/' in env['win_installer'] or '\\' in env['win_installer']):
2413 env['win_installer'] = os.path.join(env.Dir('$BUILDDIR').abspath, env['win_installer'])
2414 env.Append(NSISDEFINES={
2415 'ExeFile':env['win_installer'],
2416 'BundleExeFile':env['win_installer'].replace('.exe', '-bundle.exe'),
2417 'FilesLyx':env.Dir(dest_prefix_dir).abspath,
2418 'FilesDeps':env['deps_dir'],
2419 'FilesBundle':env['bundle_dir'],
2421 installer = env.installer(env['win_installer'],
2422 '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2423 # since I can not use a scanner, explicit dependent is required
2424 env.Depends(installer, 'install')
2425 env.Depends(installer, installer_files)
2426 env.Alias('installer', installer)
2427 # also generate bundle?
2428 if env.has_key('bundle') and env['bundle']:
2429 if env['bundle_dir'] is None or not os.path.isdir(env['bundle_dir']):
2430 print 'Bundle directory does not exist (default to %s\lyx-windows-bundle-deps.' % env.Dir('$TOP_SRCDIR').abspath
2431 print 'Use bundle_dir option to specify'
2433 # generator of the builder will add bundle stuff depending on output name
2434 bundle_installer = env.installer(env['win_installer'].replace('.exe', '-bundle.exe'),
2435 '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2436 env.Depends(bundle_installer, 'install')
2437 env.Depends(bundle_installer, installer_files)
2438 env.Alias('installer', bundle_installer)
2441 Alias('all', ['lyx', 'client', 'tex2lyx'])