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')])
33 # scons_utils.py defines a few utility function
34 import scons_utils as utils
35 # import all file lists
36 from scons_manifest import *
38 # scons asks for 1.5.2, lyx requires 2.3
39 EnsurePythonVersion(2, 3)
40 # Please use at least version 0.97
41 EnsureSConsVersion(0, 97)
43 #----------------------------------------------------------
45 #----------------------------------------------------------
47 # some global settings
49 # get version number from configure.ac so that JMarc does
50 # not have to change SConstruct during lyx release
51 package_version, majmin_ver, lyx_date = utils.getVerFromConfigure(top_src_dir)
53 lyx_major_version = package_version.split('.')[0]
54 lyx_minor_version = package_version.split('.')[1]
56 lyx_major_version = majmin_ver[0]
57 lyx_minor_version = majmin_ver[1]
59 package_cygwin_version = '%s-1' % package_version
60 boost_version = ['1_34']
62 if 'svn' in package_version:
64 default_build_mode = 'debug'
67 default_build_mode = 'release'
70 package_bugreport = 'lyx-devel@lists.lyx.org'
72 package_tarname = 'lyx'
73 package_string = '%s %s' % (package_name, package_version)
75 # various cache/log files
76 default_log_file = 'scons_lyx.log'
77 opt_cache_file = 'opt.cache'
80 #----------------------------------------------------------
81 # platform dependent settings
82 #----------------------------------------------------------
85 platform_name = 'win32'
86 default_prefix = 'c:/program files/lyx'
87 default_with_x = False
88 default_packaging_method = 'windows'
89 elif os.name == 'posix' and sys.platform != 'cygwin':
90 platform_name = sys.platform
91 default_prefix = '/usr/local'
93 default_packaging_method = 'posix'
94 elif os.name == 'posix' and sys.platform == 'cygwin':
95 platform_name = 'cygwin'
96 default_prefix = '/usr'
98 default_packaging_method = 'posix'
99 elif os.name == 'darwin':
100 platform_name = 'macosx'
101 # FIXME: macOSX default prefix?
103 default_with_x = False
104 default_packaging_method = 'macosx'
105 else: # unsupported system, assume posix behavior
106 platform_name = 'others'
108 default_with_x = True
109 default_packaging_method = 'posix'
111 #---------------------------------------------------------
113 #----------------------------------------------------------
115 # You can set perminant default values in config.py
116 if os.path.isfile('config.py'):
117 print "Getting options from config.py..."
118 print open('config.py').read()
120 opts = Variables(['config.py'])
123 EnumVariable('frontend', 'Main GUI', 'qt4',
124 allowed_values = ('qt4',) ),
125 # debug or release build
126 EnumVariable('mode', 'Building method', default_build_mode,
127 allowed_values = ('debug', 'release') ),
129 EnumVariable('boost',
130 'Use included, system boost library, or try sytem boost first.',
131 'auto', allowed_values = (
132 'auto', # detect boost, if not found, use included
133 'included', # always use included boost
134 'system', # always use system boost, fail if can not find
137 EnumVariable('gettext',
138 'Use included, system gettext library, or try sytem gettext first',
139 'auto', allowed_values = (
140 'auto', # detect gettext, if not found, use included
141 'included', # always use included gettext
142 'system', # always use system gettext, fail if can not find
145 EnumVariable('spell', 'Choose spell checker to use.', 'auto',
146 allowed_values = ('aspell', 'enchant', 'hunspell', 'auto', 'no') ),
148 EnumVariable('packaging', 'Packaging method to use.', default_packaging_method,
149 allowed_values = ('windows', 'posix', 'macosx')),
151 BoolVariable('fast_start', 'This option is obsolete.', False),
152 # No precompiled header support (too troublesome to make it work for msvc)
153 # BoolVariable('pch', 'Whether or not use pch', False),
154 # enable assertion, (config.h has ENABLE_ASSERTIOS
155 BoolVariable('assertions', 'Use assertions', True),
156 # config.h define _GLIBCXX_CONCEPT_CHECKS
157 # Note: for earlier version of gcc (3.3) define _GLIBCPP_CONCEPT_CHECKS
158 BoolVariable('concept_checks', 'Enable concept checks', True),
160 BoolVariable('nls', 'Whether or not use native language support', True),
162 BoolVariable('profiling', 'Whether or not enable profiling', False),
163 # config.h define _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC
164 BoolVariable('stdlib_debug', 'Whether or not turn on stdlib debug', False),
166 BoolVariable('X11', 'Use x11 windows system', default_with_x),
167 # use MS VC++ to build lyx
168 BoolVariable('use_vc', 'Use MS VC++ to build lyx (cl.exe will be probed)', None),
170 PathVariable('qt_dir', 'Path to qt directory', None),
172 PathVariable('qt_inc_path', 'Path to qt include directory', None),
174 PathVariable('qt_lib_path', 'Path to qt library directory', None),
175 # extra include and libpath
176 PathVariable('extra_inc_path', 'Extra include path', None),
178 PathVariable('extra_lib_path', 'Extra library path', None),
180 PathVariable('extra_bin_path', 'A convenient way to add a path to $PATH', None),
182 PathVariable('extra_inc_path1', 'Extra include path', None),
184 PathVariable('extra_lib_path1', 'Extra library path', None),
186 ('rebuild', 'Obsolete option', None),
187 # can be set to a non-existing directory
188 ('prefix', 'install architecture-independent files in PREFIX', default_prefix),
189 # replace the default name and location of the windows installer
190 ('win_installer', 'name or full path to the windows installer', None),
191 # the deps package used to create minimal installer (qt and other libraries)
192 ('deps_dir', 'path to the development depedency packages with zlib, iconv and qt libraries', None),
193 # whether or not build bundle installer
194 BoolVariable('bundle', 'Whether or not build bundle installer', False),
195 # the bundle directory, containing bundled applications
196 PathVariable('bundle_dir', 'path to the bundle dependency package with miktex setup.exe etc', None),
197 # build directory, will use $mode if not set
198 ('build_dir', 'Build directory', None),
200 ('version_suffix', 'install lyx as lyx-suffix', None),
201 # how to load options
202 ('load_option', '''load option from previous scons run. option can be
203 yes (default): load all options
204 no: do not load any option
205 opt1,opt2: load specified options
206 -opt1,opt2: load all options other than specified ones''', 'yes'),
208 ('optimization', 'optimization CCFLAGS option.', None),
210 PathVariable('exec_prefix', 'install architecture-independent executable files in PREFIX', None),
212 ('logfile', 'save commands (not outputs) to logfile', default_log_file),
213 # provided for backward compatibility
214 ('dest_dir', 'install to DESTDIR. (Provided for backward compatibility only)', None),
215 # environment variable can be set as options.
216 ('DESTDIR', 'install to DESTDIR', None),
217 ('CC', 'replace default $CC', None),
218 ('LINK', 'replace default $LINK', None),
219 ('CPP', 'replace default $CPP', None),
220 ('CXX', 'replace default $CXX', None),
221 ('CXXCPP', 'replace default $CXXCPP', None),
222 ('CCFLAGS', 'replace default $CCFLAGS', None),
223 ('CPPFLAGS', 'replace default $CPPFLAGS', None),
224 ('LINKFLAGS', 'replace default $LINKFLAGS', None),
228 all_options = [x.key for x in opts.options]
230 # copied from SCons/Variables/BoolVariable.py
231 # We need to use them before a boolean ARGUMENTS option is available
233 true_strings = ('y', 'yes', 'true', 't', '1', 'on' , 'all' )
234 false_strings = ('n', 'no', 'false', 'f', '0', 'off', 'none')
236 if ARGUMENTS.has_key('fast_start'):
237 print 'fast_start option is obsolete'
239 # if load_option=yes (default), load saved comand line options
241 # This option can take value yes/no/opt1,opt2/-opt1,opt2
242 # and tries to be clever in choosing options to load
243 if (not ARGUMENTS.has_key('load_option') or \
244 ARGUMENTS['load_option'] not in false_strings) \
245 and os.path.isfile(opt_cache_file):
246 cache_file = open(opt_cache_file)
247 opt_cache = cPickle.load(cache_file)
249 # import cached options, but we should ignore qt_dir when frontend changes
250 if ARGUMENTS.has_key('frontend') and opt_cache.has_key('frontend') \
251 and ARGUMENTS['frontend'] != opt_cache['frontend'] \
252 and opt_cache.has_key('qt_dir'):
253 opt_cache.pop('qt_dir')
254 # and we do not cache some options (dest_dir is obsolete)
255 for arg in ['load_option', 'dest_dir', 'bundle']:
256 if opt_cache.has_key(arg):
258 # remove obsolete cached keys (well, SConstruct is evolving. :-)
259 for arg in opt_cache.keys():
260 if arg not in all_options:
261 print 'Option %s is obsolete, do not load it' % arg
263 # now, if load_option=opt1,opt2 or -opt1,opt2
264 if ARGUMENTS.has_key('load_option') and \
265 ARGUMENTS['load_option'] not in true_strings + false_strings:
266 # if -opt1,opt2 is specified, do not load these options
267 if ARGUMENTS['load_option'][0] == '-':
268 for arg in ARGUMENTS['load_option'][1:].split(','):
269 if opt_cache.has_key(arg):
271 # if opt1,opt2 is specified, only load specified options
273 args = ARGUMENTS['load_option'].split(',')
274 for arg in opt_cache.keys():
277 # now restore options as if entered from command line
278 for key in opt_cache.keys():
279 if not ARGUMENTS.has_key(key):
280 ARGUMENTS[key] = opt_cache[key]
281 print "Restoring cached option %s=%s" % (key, ARGUMENTS[key])
284 # check if there is unused (or misspelled) argument
285 for arg in ARGUMENTS.keys():
286 if arg not in all_options:
288 print "Unknown option '%s'... exiting." % arg
290 print "Available options are (check 'scons -help' for details):"
291 print ' ' + '\n '.join(textwrap.wrap(', '.join(all_options)))
295 cache_file = open(opt_cache_file, 'w')
296 cPickle.dump(ARGUMENTS, cache_file)
299 #---------------------------------------------------------
300 # Setting up environment
301 #---------------------------------------------------------
303 # I do not really like ENV=os.environ, but you may add it
304 # here if you experience some environment related problem
305 env = Environment(options = opts)
307 # set individual variables since I do not really like ENV = os.environ
308 env['ENV']['PATH'] = os.environ.get('PATH')
309 env['ENV']['HOME'] = os.environ.get('HOME')
310 # these are defined for MSVC
311 env['ENV']['LIB'] = os.environ.get('LIB')
312 env['ENV']['INCLUDE'] = os.environ.get('INCLUDE')
314 # for simplicity, use var instead of env[var]
315 frontend = env['frontend']
316 prefix = env['prefix']
319 if platform_name == 'win32':
320 if env.has_key('use_vc'):
321 use_vc = env['use_vc']
322 if WhereIs('cl.exe') is None:
323 print "cl.exe is not found. Are you using the MSVC environment?"
325 elif WhereIs('cl.exe') is not None:
332 if env.has_key('build_dir') and env['build_dir'] is not None:
333 env['BUILDDIR'] = env['build_dir']
335 # Determine the name of the build $mode
336 env['BUILDDIR'] = '#' + mode
338 # all built libraries will go to build_dir/libs
339 # (This is different from the make file approach)
340 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
341 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
344 # Here is a summary of variables defined in env
346 # 2. undefined options with a non-None default value
347 # 3. compiler commands and flags like CCFLAGS.
348 # MSGFMT used to process po files
349 # 4. Variables that will be used to replace variables in some_file.in
350 # lib/lyx2lyx/lyx2lyx_version.py.in
353 # full path name is used to build msvs project files
354 # and to replace TOP_SRCDIR in package.C
355 env['TOP_SRCDIR'] = Dir(top_src_dir).abspath
357 # determine share_dir etc
358 packaging_method = env.get('packaging')
359 if packaging_method == 'windows':
360 share_dir = 'Resources'
361 man_dir = 'Resources/man/man1'
362 locale_dir = 'Resources/locale'
364 share_dir = 'share/lyx'
365 locale_dir = 'share/locale'
366 if platform_name == 'cygwin':
367 man_dir = 'share/man/man1'
371 # program suffix: can be yes, or a string
372 if env.has_key('version_suffix'):
373 if env['version_suffix'] in true_strings:
374 program_suffix = package_version
375 elif env['version_suffix'] in false_strings:
378 program_suffix = env['version_suffix']
383 # whether or not add suffix to file and directory names
384 add_suffix = packaging_method != 'windows'
385 # Absolute data directory
386 if mode == 'release':
388 env['LYX_DATA_DIR'] = Dir(os.path.join(prefix, share_dir + program_suffix)).abspath
390 env['LYX_DATA_DIR'] = Dir(os.path.join(prefix, share_dir)).abspath
392 # in the debug mode, use $TOP_SRCDIR/lib to make sure lyx can be started from anyway
393 # by using this directory as data directory
394 env['LYX_DATA_DIR'] = os.path.join(env.subst('$TOP_SRCDIR'), 'lib')
395 # we need absolute path for package.C
396 env['LOCALEDIR'] = Dir(os.path.join(prefix, locale_dir)).abspath
399 #---------------------------------------------------------
400 # Setting building environment (Tools, compiler flags etc)
401 #---------------------------------------------------------
403 # Since Tool('mingw') will reset CCFLAGS etc, this should be
404 # done before getEnvVariable
405 if platform_name == 'win32':
411 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
412 # fix a scons winres bug (there is a missing space between ${RCINCPREFIX} and ${SOURCE.dir}
414 env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
417 # we differentiate between hard-coded options and default options
418 # hard-coded options are required and will always be there
419 # default options can be replaced by enviromental variables or command line options
420 CCFLAGS_required = []
421 CXXFLAGS_required = []
422 LINKFLAGS_required = []
425 # if we use ms vc, the commands are fine (cl.exe and link.exe)
427 # C4819: The file contains a character that cannot be represented
428 # in the current code page (number)
429 # C4996: foo was decleared deprecated
430 CCFLAGS_required.append('/EHsc')
431 CXXFLAGS_required.append('/Zc:wchar_t-')
433 CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MDd'])
435 CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MD'])
437 # for debug/release mode
438 if env.has_key('optimization') and env['optimization'] is not None:
439 # if user supplies optimization flags, use it anyway
440 CCFLAGS_required.extend(env['optimization'].split())
441 # and do not use default
442 set_default_optimization_flags = False
444 set_default_optimization_flags = True
448 CCFLAGS_required.append('/Zi')
449 LINKFLAGS_required.extend(['/debug', '/map'])
451 CCFLAGS_required.append('-g')
452 CCFLAGS_default.append('-O')
453 elif mode == 'release' and set_default_optimization_flags:
455 CCFLAGS_default.append('/O2')
457 CCFLAGS_default.append('-O2')
459 # msvc uses separate tools for profiling
460 if env.has_key('profiling') and env['profiling']:
462 print 'Visual C++ does not use profiling options'
464 CCFLAGS_required.append('-pg')
465 LINKFLAGS_required.append('-pg')
467 if env.has_key('warnings') and env['warnings']:
469 CCFLAGS_default.append('/W2')
471 # Note: autotools detect gxx version and pass -W for 3.x
472 # and -Wextra for other versions of gcc
473 CCFLAGS_default.append('-Wall')
475 # Now, set the variables as follows:
476 # 1. if command line option exists: replace default
477 # 2. then if s envronment variable exists: replace default
478 # 3. set variable to required + default
479 def setEnvVariable(env, name, required = None, default = None, split = True):
480 ''' env: environment to set variable
482 required: hardcoded options
483 default: default options that can be replaced by command line or
484 environment variables
485 split: whether or not split obtained variable like '-02 -g'
487 # 1. ARGUMENTS is already set to env[name], override default.
488 if ARGUMENTS.has_key(name):
489 # env[name] may be rewritten when building tools are reloaded
490 # if that is the case, commandline option will override it.
491 env[name] = ARGUMENTS[name]
493 # then use environment default
494 elif os.environ.has_key(name):
495 print "Acquiring variable %s from system environment: %s" % (name, os.environ[name])
496 default = os.environ[name]
498 default = default.split()
499 # the real value should be env[name] + default + required
502 if env.has_key(name):
503 value = str(env[name]).split()
504 if required is not None:
506 if default is not None:
510 if env.has_key(name):
511 value = str(env[name])
512 if required is not None:
513 value += " " + required
514 if default is not None:
515 value += " " + default
517 # print name, env[name]
519 setEnvVariable(env, 'DESTDIR', split=False)
520 setEnvVariable(env, 'CC')
521 setEnvVariable(env, 'LINK')
522 setEnvVariable(env, 'CPP')
523 setEnvVariable(env, 'CXX')
524 setEnvVariable(env, 'CXXCPP')
525 setEnvVariable(env, 'CCFLAGS', CCFLAGS_required, CCFLAGS_default)
526 setEnvVariable(env, 'CXXFLAGS', CXXFLAGS_required)
527 setEnvVariable(env, 'CPPFLAGS')
528 setEnvVariable(env, 'LINKFLAGS', LINKFLAGS_required)
530 # if DESTDIR is not set...
531 if env.has_key('dest_dir'):
532 print "This option is obsolete. Please use DESTDIR instead."
533 env['DESTDIR'] = env['dest_dir']
536 # extra_inc_path and extra_lib_path
539 if env.has_key('extra_inc_path') and env['extra_inc_path']:
540 extra_inc_paths.append(env['extra_inc_path'])
541 if env.has_key('extra_lib_path') and env['extra_lib_path']:
542 env.AppendUnique(LIBPATH = [env['extra_lib_path']])
543 if env.has_key('extra_inc_path1') and env['extra_inc_path1']:
544 extra_inc_paths.append(env['extra_inc_path1'])
545 if env.has_key('extra_lib_path1') and env['extra_lib_path1']:
546 env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
547 if env.has_key('extra_bin_path') and env['extra_bin_path']:
548 # only the first one is needed (a scons bug?)
549 os.environ['PATH'] += os.pathsep + env['extra_bin_path']
550 env.PrependENVPath('PATH', env['extra_bin_path'])
551 # extra_inc_paths will be used later by intlenv etc
552 env.AppendUnique(CPPPATH = extra_inc_paths)
555 #----------------------------------------------------------
557 #----------------------------------------------------------
559 conf = Configure(env,
561 'CheckPkgConfig' : utils.checkPkgConfig,
562 'CheckPackage' : utils.checkPackage,
563 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
564 'CheckSelectArgType' : utils.checkSelectArgType,
565 'CheckBoostLibraries' : utils.checkBoostLibraries,
566 'CheckCommand' : utils.checkCommand,
567 'CheckNSIS' : utils.checkNSIS,
568 'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd,
569 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
570 'CheckIconvConst' : utils.checkIconvConst,
571 'CheckSizeOfWChar' : utils.checkSizeOfWChar,
572 'CheckDeclaration' : utils.checkDeclaration,
576 # When using msvc, windows.h is required
577 if use_vc and not conf.CheckCHeader('windows.h'):
578 print 'Windows.h is not found. Please install Windows Platform SDK.'
579 print 'Please check config.log for more information.'
582 # pkg-config? (if not, we use hard-coded options)
583 if conf.CheckPkgConfig('0.15.0'):
584 env['HAS_PKG_CONFIG'] = True
586 print 'pkg-config >= 0.1.50 is not found'
587 env['HAS_PKG_CONFIG'] = False
589 # zlib? zdll is required for MSVC 2005 and 2008, for 2010 only zlib is required
590 if (not use_vc and not conf.CheckLibWithHeader('z', 'zlib.h', 'C')) \
591 or (use_vc and not conf.CheckLibWithHeader('zlib', 'zlib.h', 'C')):
592 print 'Did not find zlib.lib or zlib.h, exiting!'
593 print 'Please check config.log for more information.'
595 if conf.CheckLib('iconv'):
596 env['ICONV_LIB'] = 'iconv'
597 elif conf.CheckLib('libiconv'):
598 env['ICONV_LIB'] = 'libiconv'
599 elif conf.CheckFunc('iconv_open'):
600 env['ICONV_LIB'] = None
602 print 'Did not find iconv or libiconv, exiting!'
603 print 'Please check config.log for more information.'
608 if conf.CheckLib('socket'):
609 socket_libs.append('socket')
610 # nsl is the network services library and provides a
611 # transport-level interface to networking services.
612 if conf.CheckLib('nsl'):
613 socket_libs.append('nsl')
615 # check available boost libs (since lyx1.4 does not use iostream)
617 for lib in ['signals', 'regex']:
618 if os.path.isdir(os.path.join(top_src_dir, 'boost', 'libs', lib)):
619 boost_libs.append(lib)
621 # check boost libraries
622 boost_opt = ARGUMENTS.get('boost', 'auto')
623 # check for system boost
624 lib_paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
625 inc_paths = env['CPPPATH'] + ['/usr/include', '/usr/local/include']
626 # default to $BUILDDIR/libs (use None since this path will be added anyway)
628 # here I assume that all libraries are in the same directory
629 if boost_opt == 'included':
630 boost_libraries = ['included_boost_%s' % x for x in boost_libs]
631 included_boost = True
632 env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
633 elif boost_opt == 'auto':
634 res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
635 # if not found, use local boost
637 boost_libraries = ['included_boost_%s' % x for x in boost_libs]
638 included_boost = True
639 env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
641 included_boost = False
642 (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
643 elif boost_opt == 'system':
644 res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
646 print "Can not find system boost libraries with version %s " % boost_version
647 print "Please supply a path through extra_lib_path and try again."
648 print "Or use boost=included to use included boost libraries."
651 included_boost = False
652 (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
655 if boost_libpath is not None:
656 env.AppendUnique(LIBPATH = [boost_libpath])
659 env['ENABLE_NLS'] = env['nls']
661 if not env['ENABLE_NLS']:
663 included_gettext = False
665 # check gettext libraries
666 gettext_opt = ARGUMENTS.get('gettext', 'auto')
667 # check for system gettext
669 if gettext_opt in ['auto', 'system']:
670 if conf.CheckFunc('gettext'):
671 included_gettext = False
674 elif conf.CheckLib('intl'):
675 included_gettext = False
679 if gettext_opt == 'system':
680 print "Can not find system gettext library"
681 print "Please supply a path through extra_lib_path and try again."
682 print "Or use gettext=included to use included gettext libraries."
684 # now, auto and succ = false, or gettext=included
686 # we do not need to set LIBPATH now.
687 included_gettext = True
688 intl_libs = ['included_intl']
692 # check for msgfmt command
693 env['MSGFMT'] = conf.CheckCommand('msgfmt')
694 env['MSGMERGE'] = conf.CheckCommand('msgmerge')
695 env['XGETTEXT'] = conf.CheckCommand('xgettext')
696 env['MSGUNIQ'] = conf.CheckCommand('msguniq')
698 # if under windows, check the nsis compiler
699 if platform_name == 'win32':
700 env['NSIS'] = conf.CheckNSIS()
702 # cygwin packaging requires the binaries to be stripped
703 if platform_name == 'cygwin':
704 env['STRIP'] = conf.CheckCommand('strip')
707 # Customized builders
709 # install customized builders
710 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
711 #env['BUILDERS']['installTOC'] = Builder(action = utils.env_toc)
712 env['BUILDERS']['potfiles'] = Builder(action = utils.env_potfiles)
715 #----------------------------------------------------------
716 # Generating config.h
717 #----------------------------------------------------------
718 aspell_lib = 'aspell'
719 # assume that we use aspell, aspelld compiled for msvc
720 if platform_name == 'win32' and mode == 'debug' and use_vc:
721 aspell_lib = 'aspelld'
723 hunspell_lib = 'libhunspell'
725 # check the existence of config.h
726 config_h = os.path.join(env.Dir('$BUILDDIR/src').path, 'config.h')
727 boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h')
729 print "Creating %s..." % boost_config_h
731 utils.createConfigFile(conf,
732 config_file = boost_config_h,
733 config_pre = r'''/* boost/config.h. Generated by SCons. */
738 * This file is part of LyX, the document processor.
739 * Licence details can be found in the file COPYING.
741 * This is the compilation configuration file for LyX.
742 * It was generated by scon.
743 * You might want to change some of the defaults if something goes wrong
744 * during the compilation.
747 #ifndef _BOOST_CONFIG_H
748 #define _BOOST_CONFIG_H
751 ('ostream', 'HAVE_OSTREAM', 'cxx'),
752 ('locale', 'HAVE_LOCALE', 'cxx'),
753 ('sstream', 'HAVE_SSTREAM', 'cxx'),
756 (env.has_key('assertions') and env['assertions'] and mode == 'debug',
758 'Define if you want assertions to be enabled in the code'
762 ('wchar_t', 'HAVE_WCHAR_T', None),
766 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
767 # define USE_BOOST_FORMAT 1
769 # define USE_BOOST_FORMAT 0
772 #if !defined(ENABLE_ASSERTIONS)
773 # define BOOST_DISABLE_ASSERTS 1
775 #define BOOST_ENABLE_ASSERT_HANDLER 1
777 #define BOOST_DISABLE_THREADS 1
778 #define BOOST_NO_WSTRING 1
781 # define BOOST_POSIX 1
782 # define BOOST_POSIX_API 1
783 # define BOOST_POSIX_PATH 1
786 #define BOOST_ALL_NO_LIB 1
789 * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
790 * support compiled in:
791 * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
792 * And we are not interested at all what libc
793 * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
794 * has the needed wchar_t support and uses UCS4. Whether it
795 * implements this with the help of libc, or whether it has own code
796 * does not matter for us, because we don't use libc directly (Georg)
798 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
806 print "\nGenerating %s..." % config_h
808 # AIKSAURUS_H_LOCATION
809 if (conf.CheckCXXHeader("Aiksaurus.h")):
810 aik_location = '<Aiksaurus.h>'
811 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
812 aik_location = '<Aiksaurus/Aiksaurus.h>'
816 # determine headers to use
817 spell_opt = ARGUMENTS.get('spell', 'auto')
818 env['USE_ASPELL'] = False
819 env['USE_ENCHANT'] = False
820 env['USE_HUNSPELL'] = False
821 if spell_opt in ['auto', 'aspell'] and conf.CheckLib(aspell_lib):
822 spell_engine = 'USE_ASPELL'
823 elif spell_opt in ['auto', 'enchant'] and conf.CheckLib('enchant'):
824 spell_engine = 'USE_ENCHANT'
825 elif spell_opt in ['auto', 'hunspell'] and conf.CheckLib(hunspell_lib):
826 spell_engine = 'USE_HUNSPELL'
830 if spell_engine is not None:
831 env[spell_engine] = True
833 if spell_opt == 'auto':
834 print "Warning: Can not locate any spell checker"
835 elif spell_opt != 'no':
836 print "Warning: Can not locate specified spell checker:", spell_opt
837 print 'Please check config.log for more information.'
840 # check arg types of select function
841 (select_arg1, select_arg234, select_arg5) = conf.CheckSelectArgType()
843 # check the size of wchar_t
844 sizeof_wchar_t = conf.CheckSizeOfWChar()
846 if sizeof_wchar_t == 0:
847 print 'Error: Can not determine the size of wchar_t.'
848 print 'Please check config.log for more information.'
852 # fill in the version info
853 env['VERSION_INFO'] = '''Configuration
855 Special build flags: %s
857 C Compiler flags: %s %s
859 C++ Compiler LyX flags: %s
860 C++ Compiler flags: %s %s
862 Linker user flags: %s
864 Builing directory: %s
867 include search path: %s
873 ''' % (platform_name,
874 env.subst('$CCFLAGS'), env.subst('$CC'),
875 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
876 env.subst('$CXX'), env.subst('$CXXFLAGS'),
877 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
878 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
879 env.subst('$LOCALLIBPATH'),
880 env.subst('$LIBPATH'), str(boost_libraries),
881 env.subst('$CPPPATH'),
882 frontend, packaging_method,
883 prefix, env['LYX_DATA_DIR'])
887 result = utils.createConfigFile(conf,
888 config_file = config_h,
889 config_pre = r'''/* config.h. Generated by SCons. */
894 * This file is part of LyX, the document processor.
895 * Licence details can be found in the file COPYING.
897 * This is the compilation configuration file for LyX.
898 * It was generated by scon.
899 * You might want to change some of the defaults if something goes wrong
900 * during the compilation.
907 ('io.h', 'HAVE_IO_H', 'c'),
908 ('limits.h', 'HAVE_LIMITS_H', 'c'),
909 ('locale.h', 'HAVE_LOCALE_H', 'c'),
910 ('process.h', 'HAVE_PROCESS_H', 'c'),
911 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
912 ('string.h', 'HAVE_STRING_H', 'c'),
913 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
914 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
915 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
916 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
917 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
918 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
919 ('utime.h', 'HAVE_UTIME_H', 'c'),
920 ('direct.h', 'HAVE_DIRECT_H', 'c'),
921 ('istream', 'HAVE_ISTREAM', 'cxx'),
922 ('ios', 'HAVE_IOS', 'cxx'),
925 ('open', 'HAVE_OPEN', None),
926 ('chmod', 'HAVE_CHMOD', None),
927 ('close', 'HAVE_CLOSE', None),
928 ('popen', 'HAVE_POPEN', None),
929 ('pclose', 'HAVE_PCLOSE', None),
930 ('_open', 'HAVE__OPEN', None),
931 ('_close', 'HAVE__CLOSE', None),
932 ('_popen', 'HAVE__POPEN', None),
933 ('_pclose', 'HAVE__PCLOSE', None),
934 ('getpid', 'HAVE_GETPID', None),
935 ('_getpid', 'HAVE__GETPID', None),
936 ('mkdir', 'HAVE_MKDIR', None),
937 ('_mkdir', 'HAVE__MKDIR', None),
938 ('mktemp', 'HAVE_MKTEMP', None),
939 ('mkstemp', 'HAVE_MKSTEMP', None),
940 ('strerror', 'HAVE_STRERROR', None),
941 ('getcwd', 'HAVE_GETCWD', None),
942 ('setenv', 'HAVE_SETENV', None),
943 ('putenv', 'HAVE_PUTENV', None),
944 ('fcntl', 'HAVE_FCNTL', None),
945 ('mkfifo', 'HAVE_MKFIFO', None),
948 ('mkstemp', 'HAVE_DECL_MKSTEMP', ['unistd.h', 'stdlib.h']),
951 ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
952 '#include <streambuf>\n#include <istream>'),
953 ('wchar_t', 'HAVE_WCHAR_T', None),
954 ('mode_t', 'HAVE_MODE_T', "#include <sys/types.h>"),
957 ('gdi32', 'HAVE_LIBGDI32'),
958 (('Aiksaurus', 'libAiksaurus'), 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB'),
961 (conf.CheckType('pid_t', includes='#include <sys/types.h>'),
963 'Define is sys/types.h does not have pid_t',
967 (conf.CheckCXXGlobalCstd(),
969 'Define if your C++ compiler puts C library functions in the global namespace'
971 (conf.CheckMkdirOneArg(),
972 'MKDIR_TAKES_ONE_ARG',
973 'Define if mkdir takes only one argument.'
975 (conf.CheckIconvConst(),
977 'Define as const if the declaration of iconv() needs const.',
978 '#define ICONV_CONST const',
979 '#define ICONV_CONST',
981 (conf.CheckLC_MESSAGES(),
983 'Define if your <locale.h> file defines LC_MESSAGES.'
985 (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'),
988 "Define to 1 if translation of program messages to the user's native anguage is requested.",
990 (env['nls'] and not included_gettext,
992 'Define to 1 if using system gettext library'
994 (env.has_key('concept_checks') and env['concept_checks'],
995 '_GLIBCXX_CONCEPT_CHECKS',
996 'libstdc++ concept checking'
998 (env.has_key('stdlib_debug') and env['stdlib_debug'],
1000 'libstdc++ debug mode'
1002 (env.has_key('stdlib_debug') and env['stdlib_debug'],
1003 '_GLIBCXX_DEBUG_PEDANTIC',
1004 'libstdc++ pedantic debug mode'
1006 (os.name != 'nt', 'BOOST_POSIX',
1007 'Indicates to boost < 1.34 which API to use (posix or windows).'
1009 (os.name != 'nt', 'BOOST_POSIX_API',
1010 'Indicates to boost 1.34 which API to use (posix or windows).'
1012 (os.name != 'nt', 'BOOST_POSIX_PATH',
1013 'Indicates to boost 1.34 which path style to use (posix or windows).'
1015 (spell_engine is not None, spell_engine,
1016 'Spell engine to use'
1018 # we need to know the byte order for unicode conversions
1019 (sys.byteorder == 'big', 'WORDS_BIGENDIAN',
1020 'Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX).'
1024 ('#define PACKAGE "%s%s"' % (package, program_suffix),
1026 ('#define PACKAGE_BUGREPORT "%s"' % package_bugreport,
1027 'Define to the address where bug reports for this package should be sent.'),
1028 ('#define PACKAGE_NAME "%s"' % package_name,
1029 'Define to the full name of this package.'),
1030 ('#define PACKAGE_STRING "%s"' % package_string,
1031 'Define to the full name and version of this package.'),
1032 ('#define PACKAGE_TARNAME "%s"' % package_tarname,
1033 'Define to the one symbol short name of this package.'),
1034 ('#define PACKAGE_VERSION "%s"' % package_version,
1035 'Define to the version of this package.'),
1036 ('#define LYX_MAJOR_VERSION %d' % int(lyx_major_version),
1037 'Define to the major version of this package.'),
1038 ('#define LYX_MINOR_VERSION %d' % int(lyx_minor_version),
1039 'Define to the minor version of this package.'),
1040 ('#define VERSION_INFO "%s"' % env['VERSION_INFO'].replace('\n', '\\n'),
1041 'Full version info'),
1042 ('#define LYX_DIR_VER "LYX_DIR_%sx"' % majmin_ver,
1043 'Versioned env var for system dir'),
1044 ('#define LYX_USERDIR_VER "LYX_USERDIR_%sx"' % majmin_ver,
1045 'Versioned env var for user dir'),
1046 ('#define LYX_DATE "%s"' % lyx_date,
1048 ('#define PROGRAM_SUFFIX "%s"' % program_suffix,
1049 'Program version suffix'),
1050 ('#define LYX_ABS_INSTALLED_DATADIR "%s"' % env.subst('$LYX_DATA_DIR').replace('\\', '/'),
1051 'Hard coded system support directory'),
1052 ('#define LYX_ABS_INSTALLED_LOCALEDIR "%s"' % env.subst('$LOCALEDIR').replace('\\', '/'),
1053 'Hard coded locale directory'),
1054 ('#define LYX_ABS_TOP_SRCDIR "%s"' % env.subst('$TOP_SRCDIR').replace('\\', '/'),
1055 'Top source directory'),
1056 ('#define BOOST_ALL_NO_LIB 1',
1057 'disable automatic linking of boost libraries.'),
1058 ('#define LYX_USE_TR1 1',
1060 ('#define USE_%s_PACKAGING 1' % packaging_method.upper(),
1061 'Packaging method'),
1062 ('#define AIKSAURUS_H_LOCATION ' + aik_location,
1063 'Aiksaurus include file'),
1064 ('#define SELECT_TYPE_ARG1 %s' % select_arg1,
1065 "Define to the type of arg 1 for `select'."),
1066 ('#define SELECT_TYPE_ARG234 %s' % select_arg234,
1067 "Define to the type of arg 2, 3, 4 for `select'."),
1068 ('#define SELECT_TYPE_ARG5 %s' % select_arg5,
1069 "Define to the type of arg 5 for `select'."),
1070 ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1071 'Define to be the size of type wchar_t'),
1073 config_post = '''/************************************************************
1074 ** You should not need to change anything beyond this point */
1076 #ifndef HAVE_STRERROR
1077 #if defined(__cplusplus)
1080 char * strerror(int n);
1083 #include <../boost/config.h>
1089 # these keys are needed in env
1090 for key in ['USE_ASPELL', 'USE_ENCHANT', 'USE_HUNSPELL', 'HAVE_FCNTL',\
1091 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB']:
1092 # USE_ASPELL etc does not go through result
1093 if result.has_key(key):
1094 env[key] = result[key]
1097 # if nls=yes and gettext=included, create intl/config.h
1098 # intl/libintl.h etc
1100 intl_config_h = os.path.join(env.Dir('$BUILDDIR/intl').path, 'config.h')
1101 if env['nls'] and included_gettext:
1103 print "Creating %s..." % intl_config_h
1105 # create intl/config.h
1106 result = utils.createConfigFile(conf,
1107 config_file = intl_config_h,
1108 config_pre = r'''/* intl/config.h. Generated by SCons. */
1113 * This file is part of LyX, the document processor.
1114 * Licence details can be found in the file COPYING.
1116 * This is the compilation configuration file for LyX.
1117 * It was generated by scon.
1118 * You might want to change some of the defaults if something goes wrong
1119 * during the compilation.
1122 #ifndef _INTL_CONFIG_H
1123 #define _INTL_CONFIG_H
1126 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1127 ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
1128 ('string.h', 'HAVE_STRING_H', 'c'),
1129 ('strings.h', 'HAVE_STRINGS_H', 'c'),
1130 ('argz.h', 'HAVE_ARGZ_H', 'c'),
1131 ('limits.h', 'HAVE_LIMITS_H', 'c'),
1132 ('alloca.h', 'HAVE_ALLOCA_H', 'c'),
1133 ('stddef.h', 'HAVE_STDDEF_H', 'c'),
1134 ('stdint.h', 'HAVE_STDINT_H', 'c'),
1135 ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'),
1138 ('getcwd', 'HAVE_GETCWD', None),
1139 ('stpcpy', 'HAVE_STPCPY', None),
1140 ('strcasecmp', 'HAVE_STRCASECMP', None),
1141 ('strdup', 'HAVE_STRDUP', None),
1142 ('strtoul', 'HAVE_STRTOUL', None),
1143 ('alloca', 'HAVE_ALLOCA', None),
1144 ('__fsetlocking', 'HAVE___FSETLOCKING', None),
1145 ('mempcpy', 'HAVE_MEMPCPY', None),
1146 ('__argz_count', 'HAVE___ARGZ_COUNT', None),
1147 ('__argz_next', 'HAVE___ARGZ_NEXT', None),
1148 ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None),
1149 ('setlocale', 'HAVE_SETLOCALE', None),
1150 ('tsearch', 'HAVE_TSEARCH', None),
1151 ('getegid', 'HAVE_GETEGID', None),
1152 ('getgid', 'HAVE_GETGID', None),
1153 ('getuid', 'HAVE_GETUID', None),
1154 ('wcslen', 'HAVE_WCSLEN', None),
1155 ('asprintf', 'HAVE_ASPRINTF', None),
1156 ('wprintf', 'HAVE_WPRINTF', None),
1157 ('snprintf', 'HAVE_SNPRINTF', None),
1158 ('printf', 'HAVE_POSIX_PRINTF', None),
1159 ('fcntl', 'HAVE_FCNTL', None),
1162 ('intmax_t', 'HAVE_INTMAX_T', None),
1163 ('long double', 'HAVE_LONG_DOUBLE', None),
1164 ('long long', 'HAVE_LONG_LONG', None),
1165 ('wchar_t', 'HAVE_WCHAR_T', None),
1166 ('wint_t', 'HAVE_WINT_T', None),
1167 ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include <inttypes.h>'),
1168 ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include <stdint.h>'),
1174 (conf.CheckLC_MESSAGES(),
1176 'Define if your <locale.h> file defines LC_MESSAGES.'
1178 (conf.CheckIconvConst(),
1180 'Define as const if the declaration of iconv() needs const.',
1181 '#define ICONV_CONST const',
1182 '#define ICONV_CONST',
1184 (conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
1185 conf.CheckType('intmax_t', includes='#include <inttypes.h>'),
1187 "Define to 1 if you have the `intmax_t' type."
1189 (env.has_key('nls') and env['nls'],
1191 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1195 ('#define HAVE_ICONV 1', 'Define if iconv or libiconv is found'),
1196 ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1197 'Define to be the size of type wchar_t'),
1199 config_post = '#endif'
1202 # these keys are needed in env
1203 for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1204 'HAVE_POSIX_PRINTF', 'HAVE_LIBC']:
1205 # USE_ASPELL etc does not go through result
1206 if result.has_key(key):
1207 env[key] = result[key]
1210 # this looks misplaced, but intl/libintl.h is needed by src/message.C
1211 if env['nls'] and included_gettext:
1212 # libgnuintl.h.in => libintl.h
1213 env.Depends('$TOP_SRCDIR/intl/libintl.h', '$BUILDDIR/intl/config.h')
1214 env.substFile('$BUILDDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in')
1215 env.Command('$BUILDDIR/intl/libgnuintl.h', '$BUILDDIR/intl/libintl.h',
1216 [Copy('$TARGET', '$SOURCE')])
1219 # Finish auto-configuration
1222 #----------------------------------------------------------
1223 # Now set up our build process accordingly
1224 #----------------------------------------------------------
1226 if env['ICONV_LIB'] is None:
1229 system_libs = [env['ICONV_LIB']]
1230 if platform_name in ['win32', 'cygwin']:
1231 # the final link step needs stdc++ to succeed under mingw
1232 # FIXME: shouldn't g++ automatically link to stdc++?
1234 system_libs += ['ole32', 'shlwapi', 'psapi', 'shell32', 'advapi32']
1236 system_libs += ['shlwapi', 'psapi', 'stdc++', 'z']
1237 elif platform_name == 'cygwin' and env['X11']:
1238 system_libs += ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr',
1239 'Xcursor', 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE',
1240 'resolv', 'pthread', 'z']
1242 system_libs += ['z']
1245 ('HAVE_LIBGDI32', 'gdi32'),
1246 ('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
1247 ('USE_ASPELL', aspell_lib),
1248 ('USE_ENCHANT', 'enchant'),
1249 ('USE_HUNSPELL', hunspell_lib)
1254 system_libs.append(lib[1])
1257 # Build parameters CPPPATH etc
1260 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
1263 # boost: for boost header files
1264 # BUILDDIR/src: for config.h
1265 # TOP_SRCDIR/src: for support/* etc
1267 env['CPPPATH'] += ['$BUILDDIR/src', '$TOP_SRCDIR/src']
1269 # Separating boost directories from CPPPATH stops scons from building
1270 # the dependency tree for boost header files, and effectively reduce
1271 # the null build time of lyx from 29s to 16s. Since lyx may tweak local
1272 # boost headers, the following is not 100% safe.
1273 # env.AppendUnique(CPPPATH = ['$BOOST_INC_PATH'])
1274 env.PrependUnique(CCFLAGS = ['$INCPREFIX$BOOST_INC_PATH'])
1276 # for intl/config.h, intl/libintl.h and intl/libgnuintl.h
1277 if env['nls'] and included_gettext:
1278 env['CPPPATH'].append('$BUILDDIR/intl')
1282 # A Link script for cygwin see
1283 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1284 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
1287 if platform_name == 'cygwin':
1288 ld_script_path = '/tmp'
1289 ld_script = utils.installCygwinLDScript(ld_script_path)
1290 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
1291 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
1294 #---------------------------------------------------------
1295 # Frontend related variables (QTDIR etc)
1296 #---------------------------------------------------------
1299 # create a separate environment so that other files do not have
1300 # to be built with all the include directories etc
1302 if frontend == 'qt4':
1303 env['BUILDERS']['qtResource'] = Builder(action = utils.env_qtResource)
1305 # handle qt related user specified paths
1306 # set environment so that moc etc can be found even if its path is not set properly
1307 if env.has_key('qt_dir') and env['qt_dir']:
1308 env['QTDIR'] = env['qt_dir']
1309 if os.path.isdir(os.path.join(env['qt_dir'], 'bin')):
1310 os.environ['PATH'] += os.pathsep + os.path.join(env['qt_dir'], 'bin')
1311 env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
1312 if os.path.isdir(os.path.join(env['qt_dir'], 'lib')):
1313 env.PrependENVPath('PKG_CONFIG_PATH', os.path.join(env['qt_dir'], 'lib'))
1315 # if separate qt_lib_path is given
1316 if env.has_key('qt_lib_path') and env['qt_lib_path']:
1317 qt_lib_path = env.subst('$qt_lib_path')
1318 env.AppendUnique(LIBPATH = [qt_lib_path])
1319 env.PrependENVPath('PKG_CONFIG_PATH', qt_lib_path)
1323 # if separate qt_inc_path is given
1324 if env.has_key('qt_inc_path') and env['qt_inc_path']:
1325 qt_inc_path = env['qt_inc_path']
1329 # local qt4 toolset from
1330 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
1332 # NOTE: I have to patch qt4.py since it does not automatically
1333 # process .C file!!! (add to cxx_suffixes )
1335 env.Tool('qt4', [scons_dir])
1336 env['QT_AUTOSCAN'] = 0
1337 env['QT4_AUTOSCAN'] = 0
1338 env['QT4_UICDECLFLAGS'] = '-tr lyx::qt_'
1339 if platform_name == 'win32':
1340 env['QT4_MOCFROMHFLAGS'] = '-D_WIN32'
1342 if qt_lib_path is None:
1343 qt_lib_path = os.path.join(env.subst('$QTDIR'), 'lib')
1344 if qt_inc_path is None:
1345 qt_inc_path = os.path.join(env.subst('$QTDIR'), 'include')
1348 conf = Configure(env,
1350 'CheckPackage' : utils.checkPackage,
1351 'CheckCommand' : utils.checkCommand,
1356 # first: try pkg_config
1357 if env['HAS_PKG_CONFIG']:
1358 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
1359 # FIXME: use pkg_config information?
1360 #env['QT4_PKG_CONFIG'] = succ
1361 # second: try to link to it
1363 # Under linux, I can test the following perfectly
1364 # Under windows, lib names need to passed as libXXX4.a ...
1365 if platform_name == 'win32':
1366 succ = conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1368 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1369 # still can not find it
1371 print 'Did not find qt libraries, exiting!'
1372 print 'Please check config.log for more information.'
1375 # Now, determine the correct suffix:
1376 qt_libs = ['QtCore', 'QtGui']
1377 if platform_name == 'win32':
1378 if mode == 'debug' and use_vc and \
1379 conf.CheckLibWithHeader('QtCored4', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1380 qt_lib_suffix = 'd4'
1381 use_qt_debug_libs = True
1384 use_qt_debug_libs = False
1386 if mode == 'debug' and conf.CheckLibWithHeader('QtCore_debug', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1387 qt_lib_suffix = '_debug'
1388 use_qt_debug_libs = True
1391 use_qt_debug_libs = False
1392 env.EnableQt4Modules(qt_libs, debug = (mode == 'debug' and use_qt_debug_libs))
1393 frontend_libs = [x + qt_lib_suffix for x in qt_libs]
1394 qtcore_lib = ['QtCore' + qt_lib_suffix]
1396 # check uic and moc commands for qt frontends
1397 if conf.CheckCommand('uic') == None or conf.CheckCommand('moc') == None:
1398 print 'uic or moc command is not found for frontend', frontend
1401 # if MSVC 2005 and 2008 is used, we will need to embed lyx.exe.manifest to lyx.exe
1402 # for MSVC 2010 this is not necessary
1404 # env['LINKCOM'] = [env['LINKCOM'], \
1405 # 'mt.exe /MANIFEST %s /outputresource:$TARGET;1' % \
1406 # env.File('$BUILDDIR/lyx.exe.manifest').path]
1413 print env['VERSION_INFO']
1416 # Mingw command line may be too short for our link usage,
1417 # Here we use a trick from scons wiki
1418 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
1420 # I also would like to add logging (commands only) capacity to the
1422 logfile = env.get('logfile', default_log_file)
1423 if logfile != '' or platform_name == 'win32':
1425 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
1426 info = '''# This is a log of commands used by scons to build lyx
1430 ''' % (time.asctime(), ' '.join(sys.argv),
1431 env['VERSION_INFO'].replace('\n','\n# ')) )
1436 # -h will print out help info
1437 Help(opts.GenerateHelpText(env))
1440 #----------------------------------------------------------
1442 #----------------------------------------------------------
1443 # this has been the source of problems on some platforms...
1444 # I find that I need to supply it with full path name
1445 env.SConsignFile(os.path.join(Dir(env['BUILDDIR']).abspath, '.sconsign'))
1446 # this usage needs further investigation.
1447 #env.CacheDir('%s/Cache/%s' % (env['BUILDDIR'], frontend))
1448 env.VariantDir('$BUILDDIR/boost', '$TOP_SRCDIR/boost/libs', duplicate = 0)
1449 env.VariantDir('$BUILDDIR/intl', '$TOP_SRCDIR/intl', duplicate = 0)
1450 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1451 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1453 print "Building all targets recursively"
1455 def libExists(libname):
1456 ''' Check whether or not lib $LOCALLIBNAME/libname already exists'''
1457 return os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath)
1460 if (included_boost and not libExists('included_boost_regex')) or 'boost' in BUILD_TARGETS:
1464 for lib in boost_libs:
1465 boostlib = env.StaticLibrary(
1466 target = '$LOCALLIBPATH/included_boost_%s' % lib,
1467 source = ['$BUILDDIR/boost/%s/src/%s' % (lib, x) for x in eval('boost_libs_%s_src_files' % lib)],
1468 # do not use global CPPPATH because src/config.h will mess up with boost/config.h
1469 CPPPATH = ['$BUILDDIR/boost'] + extra_inc_paths,
1470 CCFLAGS = ['$CCFLAGS', '$INCPREFIX$TOP_SRCDIR/boost', '-DBOOST_USER_CONFIG="<config.h>"']
1472 Alias('boost', boostlib)
1475 if (included_gettext and not libExists('included_intl')) or 'intl' in BUILD_TARGETS:
1480 r'-DLOCALEDIR=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1481 r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1482 r'-DLIBDIR=\"' + env['TOP_SRCDIR'].replace('\\', '\\\\') + r'/lib\"',
1484 '-DENABLE_RELOCATABLE=1',
1486 r'-DINSTALLDIR=\"' + prefix.replace('\\', '\\\\') + r'/lib\"',
1488 '-Dset_relocation_prefix=libintl_set_relocation_prefix',
1489 '-Drelocate=libintl_relocate',
1490 '-DDEPENDS_ON_LIBICONV=1',
1494 INTL_CCFLAGS.extend(['/Dinline#', '/D__attribute__(x)#', '/Duintmax_t=UINT_MAX'])
1496 intl = env.StaticLibrary(
1497 target = '$LOCALLIBPATH/included_intl',
1499 CCFLAGS = INTL_CCFLAGS,
1500 # do not use global CPPPATH because src/config.h will mess up with intl/config.h
1501 CPPPATH = ['$BUILDDIR/intl'] + extra_inc_paths,
1502 source = ['$BUILDDIR/intl/%s' % x for x in intl_files]
1509 env['QT4_MOCHPREFIX'] = 'moc_'
1510 env['QT4_MOCHSUFFIX'] = '.cpp'
1512 support_moced_files = [env.Moc4('$BUILDDIR/src/support/%s' % x)
1513 for x in src_support_header_files ]
1514 support = env.StaticLibrary(
1515 target = '$LOCALLIBPATH/support',
1516 source = ['$BUILDDIR/src/support/%s' % x for x in src_support_files],
1523 CPPPATH = ['$CPPPATH', '$BUILDDIR/src/support']
1525 Alias('support', support)
1528 if env['HAVE_FCNTL']:
1529 client = env.Program(
1530 target = '$BUILDDIR/src/client/lyxclient',
1531 LIBS = ['support'] + intl_libs + system_libs +
1532 socket_libs + boost_libraries + qtcore_lib,
1533 source = ['$BUILDDIR/src/client/%s' % x for x in src_client_files] + \
1534 utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/client.rc')
1536 Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
1537 client, [Copy('$TARGET', '$SOURCE')]))
1540 Alias('client', client)
1546 for file in src_tex2lyx_copied_files + src_tex2lyx_copied_header_files:
1547 env.Command('$BUILDDIR/src/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
1548 [Copy('$TARGET', '$SOURCE')])
1550 tex2lyx = env.Program(
1551 target = '$BUILDDIR/src/tex2lyx/tex2lyx',
1552 LIBS = ['support'] + boost_libraries + intl_libs + system_libs + qtcore_lib,
1553 source = ['$BUILDDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files + src_tex2lyx_copied_files] + \
1554 utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/tex2lyx.rc'),
1555 CPPPATH = ['$BUILDDIR/src/tex2lyx', '$BUILDDIR/src', '$CPPPATH'],
1556 LIBPATH = ['#$LOCALLIBPATH', '$LIBPATH'],
1557 CCFLAGS = ['$CCFLAGS', '-DTEX2LYX'],
1559 Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
1560 tex2lyx, [Copy('$TARGET', '$SOURCE')]))
1561 Alias('tex2lyx', tex2lyx)
1565 # Build lyx with given frontend
1567 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1568 src_post_files.append('AspellChecker.cpp')
1569 src_post_files.append('PersonalWordList.cpp')
1570 elif env.has_key('USE_ENCHANT') and env['USE_ENCHANT']:
1571 src_post_files.append('EnchantChecker.cpp')
1572 src_post_files.append('PersonalWordList.cpp')
1573 elif env.has_key('USE_HUNSPELL') and env['USE_HUNSPELL']:
1574 src_post_files.append('HunspellChecker.cpp')
1575 src_post_files.append('PersonalWordList.cpp')
1577 # tells scons how to get these moced files, although not all moced files are needed
1578 # (or are actually generated).
1579 qt4_moced_files = [env.Moc4('$BUILDDIR/src/frontends/qt4/%s' % x)
1580 for x in src_frontends_qt4_header_files ]
1581 src_moced_files = [env.Moc4('$BUILDDIR/src/%s' % x)
1582 for x in src_header_files ]
1583 ui_files = [env.Uic4('$BUILDDIR/src/frontends/qt4/ui/%s' % x.split('.')[0])
1584 for x in src_frontends_qt4_ui_files]
1585 resource = env.Qrc(env.qtResource(
1586 '$BUILDDIR/src/frontends/qt4/Resource.qrc',
1587 ['$TOP_SRCDIR/lib/images/%s' % x for x in lib_images_files] +
1588 ['$TOP_SRCDIR/lib/images/math/%s' % x for x in lib_images_math_files] +
1589 ['$TOP_SRCDIR/lib/images/commands/%s' % x for x in lib_images_commands_files]))
1592 target = '$BUILDDIR/lyx',
1593 source = ['$BUILDDIR/src/main.cpp'] +
1594 ['$BUILDDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files] +
1596 ['$BUILDDIR/src/graphics/%s' % x for x in src_graphics_files] +
1597 ['$BUILDDIR/src/mathed/%s' % x for x in src_mathed_files] +
1598 ['$BUILDDIR/src/insets/%s' % x for x in src_insets_files] +
1599 ['$BUILDDIR/src/frontends/%s' % x for x in src_frontends_files] +
1600 ['$BUILDDIR/src/%s' % x for x in src_pre_files] +
1601 ["$BUILDDIR/src/%s" % x for x in src_post_files] +
1602 utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/lyx.rc'),
1606 '$BUILDDIR/src/images',
1607 '$BUILDDIR/src/frontends',
1608 '$BUILDDIR/src/frontends/qt4',
1609 '$BUILDDIR/src/frontends/qt4/ui',
1629 if use_vc and 'msvs_projects' in BUILD_TARGETS:
1630 def build_project(target, full_target = None, src = [], inc = [], res = []):
1631 ''' build mavs project files
1632 target: alias (correspond to directory name)
1633 full_target: full path/filename of the target
1638 For non-debug-able targets like static libraries, target (alias) is
1639 enough to build the target. For executable targets, msvs need to know
1640 the full path to start debug them.
1643 proj = env.MSVSProject(
1644 target = target + env['MSVSPROJECTSUFFIX'],
1645 # this allows easy access to header files (along with source)
1646 srcs = [env.subst(x) for x in src + inc],
1647 incs = [env.subst('$TOP_SRCDIR/src/config.h')],
1648 localincs = [env.subst(x) for x in inc],
1649 resources = [env.subst(x) for x in res],
1650 buildtarget = full_target,
1653 Alias('msvs_projects', proj)
1655 build_project('client', src = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_files],
1656 inc = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files],
1657 full_target = File(env.subst('$BUILDDIR/src/client/lyxclient$PROGSUFFIX')).abspath)
1659 build_project('tex2lyx', src = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files],
1660 inc = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files],
1661 full_target = File(env.subst('$BUILDDIR/src/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
1663 build_project('lyx',
1664 src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files + ['version.cpp']] + \
1665 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files + ['Package.cpp'] ] + \
1666 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_files] + \
1667 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files] + \
1668 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files] + \
1669 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files] + \
1670 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files],
1671 inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files] + \
1672 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files] + \
1673 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files] + \
1674 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files] + \
1675 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files] + \
1676 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files] + \
1677 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
1678 res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1679 full_target = File(env.subst('$BUILDDIR/lyx$PROGSUFFIX')).abspath)
1682 if 'update_po' in BUILD_TARGETS:
1686 print 'Updating po/*.po files...'
1688 # whether or not update po files
1689 if not env['XGETTEXT'] or not env['MSGMERGE'] or not env['MSGUNIQ']:
1690 print 'xgettext or msgmerge does not exist. Cannot merge po files'
1692 # rebuild POTFILES.in
1693 POTFILES_in = env.potfiles('$TOP_SRCDIR/po/POTFILES.in',
1694 ['$TOP_SRCDIR/src/%s' % x for x in src_header_files + src_pre_files + src_post_files + \
1695 src_extra_src_files] + \
1696 ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files + src_support_files + \
1697 src_support_extra_header_files + src_support_extra_src_files] + \
1698 ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files + src_mathed_files] + \
1699 ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files + src_insets_files] + \
1700 ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files + src_frontends_files] + \
1701 ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files + src_graphics_files] + \
1702 ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files + src_frontends_qt4_files] + \
1703 ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files + src_client_files ] + \
1704 ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
1706 Alias('update_po', POTFILES_in)
1707 # build language_l10n.pot, encodings_10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n
1708 # and combine them to lyx.po
1709 env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
1710 lyx_po = env.Command('$BUILDDIR/po/lyx.po',
1711 env.Command('$BUILDDIR/po/all.po',
1712 [env.Command('$BUILDDIR/po/qt4_l10n.pot',
1713 ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1714 '$LYX_POT -b $TOP_SRCDIR -t qt4 -o $TARGET $SOURCES'),
1715 env.Command('$BUILDDIR/po/layouts_l10n.pot',
1716 ['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files + lib_layouts_inc_files + lib_layouts_module_files],
1717 '$LYX_POT -b $TOP_SRCDIR -t layouts -o $TARGET $SOURCES'),
1718 env.Command('$BUILDDIR/po/languages_l10n.pot', '$TOP_SRCDIR/lib/languages',
1719 '$LYX_POT -b $TOP_SRCDIR -t languages -o $TARGET $SOURCES'),
1720 env.Command('$BUILDDIR/po/encodings_l10n.pot', '$TOP_SRCDIR/lib/encodings',
1721 '$LYX_POT -b $TOP_SRCDIR -t encodings -o $TARGET $SOURCES'),
1722 env.Command('$BUILDDIR/po/ui_l10n.pot',
1723 ['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files],
1724 '$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
1725 env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
1726 '$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
1727 env.Command('$BUILDDIR/po/formats_l10n.pot', '$TOP_SRCDIR/lib/configure.py',
1728 '$LYX_POT -b $TOP_SRCDIR -t formats -o $TARGET $SOURCES'),
1730 ['$MSGUNIQ -o $TARGET $SOURCE',
1731 '''$XGETTEXT --default-domain=${TARGET.base} \
1732 --directory=$TOP_SRCDIR --add-comments=TRANSLATORS: \
1733 --language=C++ --join-existing \
1734 --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ \
1735 --files-from=$TOP_SRCDIR/po/POTFILES.in \
1736 --copyright-holder="LyX Developers" \
1737 --msgid-bugs-address="lyx-devel@lists.lyx.org" ''']
1739 env.Depends(lyx_po, POTFILES_in)
1740 # copy lyx.po to lyx.pot
1741 lyx_pot = env.Command('$BUILDDIR/po/lyx.pot', lyx_po,
1742 Copy('$TARGET', '$SOURCE'))
1745 # files to translate
1746 transfiles = glob.glob(os.path.join(env.Dir('$TOP_SRCDIR/po').abspath, '*.po'))
1747 # possibly *only* handle these languages
1749 if env.has_key('languages'):
1750 languages = env.make_list(env['languages'])
1751 # merge. if I use lan.po as $TARGET, it will be removed
1752 # before it is merged. In this builder,
1753 # $BUILDDIR/po/lang.po is merged from po/lang.po and $BUILDDIR/po/lyx.pot
1754 # and is copied to po/lang.po
1755 env['BUILDERS']['msgmerge'] = Builder(action=[
1756 '$MSGMERGE $TOP_SRCDIR/po/${TARGET.filebase}.po $SOURCE -o $TARGET',
1757 Copy('$TOP_SRCDIR/po/${TARGET.filebase}.po', '$TARGET')]
1759 # for each po file, generate pot
1760 for po_file in transfiles:
1762 fname = os.path.split(po_file)[1]
1764 country = fname.split('.')[0]
1766 if not languages or country in languages:
1767 # merge po files, the generated lan.po_new file is copied to lan.po file.
1768 po = env.msgmerge('$BUILDDIR/po/%s.po' % country, lyx_pot)
1769 env.Depends(po, POTFILES_in)
1770 Alias('update_po', po)
1773 # if 'install' is not in the target, do not process this
1774 if 'install' in BUILD_TARGETS or 'installer' in BUILD_TARGETS:
1776 # this part is a bit messy right now. Since scons will provide
1777 # --DESTDIR option soon, at least the dest_dir handling can be
1786 # files to translate
1787 transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
1788 # possibly *only* handle these languages
1790 if env.has_key('languages'):
1791 languages = env.make_list(env['lanauges'])
1792 # use default msgfmt
1794 if not env['MSGFMT']:
1795 print 'msgfmt does not exist. Can not process po files'
1798 env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -c --statistics -o $TARGET',suffix='.gmo',src_suffix='.po')
1800 for f in transfiles:
1802 fname = os.path.split(f)[1]
1804 country = fname.split('.')[0]
1806 if not languages or country in languages:
1807 gmo_files.extend(env.Transfiles(f))
1808 # how to join dest_dir and prefix
1809 def joinPaths(path1, path2):
1810 ''' join path1 and path2, do not use os.path.join because
1811 under window, c:\destdir\d:\program is invalid '''
1813 return os.path.normpath(path2)
1814 # separate drive letter
1815 (drive, path) = os.path.splitdrive(os.path.normpath(path2))
1816 # ignore drive letter, so c:\destdir + c:\program = c:\destdir\program
1817 return os.path.join(os.path.normpath(path1), path[1:])
1819 # install to dest_dir/prefix
1820 dest_dir = env.get('DESTDIR', '')
1821 dest_prefix_dir = joinPaths(dest_dir, env.Dir(prefix).abspath)
1822 # create the directory if needed
1823 if not os.path.isdir(dest_prefix_dir):
1825 os.makedirs(dest_prefix_dir)
1828 if not os.path.isdir(dest_prefix_dir):
1829 print 'Can not create directory', dest_prefix_dir
1832 if env.has_key('exec_prefix'):
1833 bin_dest_dir = joinPaths(dest_dir, Dir(env['exec_prefix']).abspath)
1835 bin_dest_dir = os.path.join(dest_prefix_dir, 'bin')
1837 share_dest_dir = os.path.join(dest_prefix_dir, share_dir + program_suffix)
1839 share_dest_dir = os.path.join(dest_prefix_dir, share_dir)
1840 man_dest_dir = os.path.join(dest_prefix_dir, man_dir)
1841 locale_dest_dir = os.path.join(dest_prefix_dir, locale_dir)
1842 env['LYX2LYX_DEST'] = os.path.join(share_dest_dir, 'lyx2lyx')
1846 # install executables (lyxclient may be None)
1849 version_suffix = program_suffix
1853 # install lyx, if in release mode, try to strip the binary
1854 if env.has_key('STRIP') and env['STRIP'] is not None and mode != 'debug':
1855 # create a builder to strip and install
1856 env['BUILDERS']['StripInstallAs'] = Builder(action='$STRIP $SOURCE -o $TARGET')
1858 # install executables
1859 for (name, obj) in (('lyx', lyx), ('tex2lyx', tex2lyx), ('client', client)):
1862 target_name = os.path.split(str(obj[0]))[1].replace(name, '%s%s' % (name, version_suffix))
1863 target = os.path.join(bin_dest_dir, target_name)
1864 if env['BUILDERS'].has_key('StripInstallAs'):
1865 env.StripInstallAs(target, obj)
1867 env.InstallAs(target, obj)
1868 Alias('install', target)
1872 for (dir,files) in [
1874 ('bind', lib_bind_files),
1875 ('bind/de', lib_bind_de_files),
1876 ('commands', lib_commands_files),
1877 ('doc', lib_doc_files),
1878 ('doc/biblio', lib_doc_biblio_files),
1879 ('doc/clipart', lib_doc_clipart_files),
1880 ('doc/ca', lib_doc_ca_files),
1881 ('doc/cs', lib_doc_cs_files),
1882 ('doc/da', lib_doc_da_files),
1883 ('doc/de', lib_doc_de_files),
1884 ('doc/de/clipart', lib_doc_de_clipart_files),
1885 ('doc/el', lib_doc_el_files),
1886 ('doc/es', lib_doc_es_files),
1887 ('doc/es/clipart', lib_doc_es_clipart_files),
1888 ('doc/eu', lib_doc_eu_files),
1889 ('doc/fr', lib_doc_fr_files),
1890 ('doc/fr/clipart', lib_doc_fr_clipart_files),
1891 ('doc/gl', lib_doc_gl_files),
1892 ('doc/he', lib_doc_he_files),
1893 ('doc/hu', lib_doc_hu_files),
1894 ('doc/id', lib_doc_id_files),
1895 ('doc/id/clipart', lib_doc_id_clipart_files),
1896 ('doc/it', lib_doc_it_files),
1897 ('doc/it/clipart', lib_doc_it_clipart_files),
1898 ('doc/ja', lib_doc_ja_files),
1899 ('doc/ja/clipart', lib_doc_ja_clipart_files),
1900 ('doc/nl', lib_doc_nl_files),
1901 ('doc/nb', lib_doc_nb_files),
1902 ('doc/pl', lib_doc_pl_files),
1903 ('doc/pt', lib_doc_pt_files),
1904 ('doc/ro', lib_doc_ro_files),
1905 ('doc/ru', lib_doc_ru_files),
1906 ('doc/sk', lib_doc_sk_files),
1907 ('doc/sl', lib_doc_sl_files),
1908 ('doc/sv', lib_doc_sv_files),
1909 ('doc/uk', lib_doc_uk_files),
1910 ('doc/uk/clipart', lib_doc_uk_clipart_files),
1911 ('doc/zh_CN', lib_doc_zhCN_files),
1912 ('examples', lib_examples_files),
1913 ('examples/ca', lib_examples_ca_files),
1914 ('examples/cs', lib_examples_cs_files),
1915 ('examples/da', lib_examples_da_files),
1916 ('examples/de', lib_examples_de_files),
1917 ('examples/el', lib_examples_el_files),
1918 ('examples/es', lib_examples_es_files),
1919 ('examples/eu', lib_examples_eu_files),
1920 ('examples/fa', lib_examples_fa_files),
1921 ('examples/fr', lib_examples_fr_files),
1922 ('examples/gl', lib_examples_gl_files),
1923 ('examples/he', lib_examples_he_files),
1924 ('examples/hu', lib_examples_hu_files),
1925 ('examples/id', lib_examples_id_files),
1926 ('examples/it', lib_examples_it_files),
1927 ('examples/ja', lib_examples_ja_files),
1928 ('examples/nl', lib_examples_nl_files),
1929 ('examples/pl', lib_examples_pl_files),
1930 ('examples/pt', lib_examples_pt_files),
1931 ('examples/ro', lib_examples_ro_files),
1932 ('examples/ru', lib_examples_ru_files),
1933 ('examples/sk', lib_examples_sk_files),
1934 ('examples/sl', lib_examples_sl_files),
1935 ('examples/sr', lib_examples_sr_files),
1936 ('examples/sv', lib_examples_sv_files),
1937 ('examples/uk', lib_examples_uk_files),
1938 ('fonts', lib_fonts_files),
1939 ('images', lib_images_files),
1940 ('images/math', lib_images_math_files),
1941 ('images/commands', lib_images_commands_files),
1942 ('kbd', lib_kbd_files),
1943 ('layouts', lib_layouts_files + lib_layouts_inc_files + lib_layouts_module_files),
1944 ('lyx2lyx', lib_lyx2lyx_files),
1945 ('scripts', lib_scripts_files),
1946 ('templates', lib_templates_files),
1947 ('templates/thesis', lib_templates_thesis_files),
1948 ('tex', lib_tex_files),
1949 ('ui', lib_ui_files)]:
1950 dirs.append(env.Install(os.path.join(share_dest_dir, dir),
1951 [env.subst('$TOP_SRCDIR/lib/%s/%s' % (dir, file)) for file in files]))
1952 Alias('install', dirs)
1954 # subst and install lyx2lyx_version.py which is not in scons_manifest.py
1955 env.Depends(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py', '$BUILDDIR/src/config.h')
1956 env.substFile(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py',
1957 '$TOP_SRCDIR/lib/lyx2lyx/lyx2lyx_version.py.in')
1958 Alias('install', share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
1959 sys.path.append(share_dest_dir + '/lyx2lyx')
1961 if platform_name == 'cygwin':
1962 # cygwin packaging requires a file /usr/share/doc/Cygwin/foot-vendor-suffix.README
1963 Cygwin_README = os.path.join(dest_prefix_dir, 'share', 'doc', 'Cygwin',
1964 '%s-%s.README' % (package, package_cygwin_version))
1965 env.InstallAs(Cygwin_README,
1966 os.path.join(env.subst('$TOP_SRCDIR'), 'README.cygwin'))
1967 Alias('install', Cygwin_README)
1968 # also a directory /usr/share/doc/lyx for README etc
1969 Cygwin_Doc = os.path.join(dest_prefix_dir, 'share', 'doc', package)
1970 env.Install(Cygwin_Doc, [os.path.join(env.subst('$TOP_SRCDIR'), x) for x in \
1971 ['INSTALL', 'README', 'README.Cygwin', 'RELEASE-NOTES', 'COPYING', 'ANNOUNCE']])
1972 Alias('install', Cygwin_Doc)
1973 # cygwin fonts also need to be installed
1974 Cygwin_fonts = os.path.join(share_dest_dir, 'fonts')
1975 env.Install(Cygwin_fonts,
1976 [env.subst('$TOP_SRCDIR/development/Win32/packaging/bakoma/%s' % file) \
1977 for file in win32_bakoma_fonts])
1978 Alias('install', Cygwin_fonts)
1979 # we also need a post installation script
1980 tmp_script = utils.installCygwinPostinstallScript('/tmp')
1981 postinstall_path = os.path.join(dest_dir, 'etc', 'postinstall')
1982 env.Install(postinstall_path, tmp_script)
1983 Alias('install', postinstall_path)
1985 env.InstallAs(os.path.join(man_dest_dir, 'lyx' + version_suffix + '.1'),
1986 env.subst('$TOP_SRCDIR/lyx.1in'))
1987 env.InstallAs(os.path.join(man_dest_dir, 'tex2lyx' + version_suffix + '.1'),
1988 env.subst('$TOP_SRCDIR/src/tex2lyx/tex2lyx.1in'))
1989 env.InstallAs(os.path.join(man_dest_dir, 'lyxclient' + version_suffix + '.1'),
1990 env.subst('$TOP_SRCDIR/src/client/lyxclient.1in'))
1991 Alias('install', [os.path.join(man_dest_dir, x + version_suffix + '.1') for
1992 x in ['lyx', 'tex2lyx', 'lyxclient']])
1994 # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
1995 for gmo in gmo_files:
1996 lan = os.path.split(str(gmo))[1].split('.')[0]
1997 dest_file = os.path.join(locale_dest_dir, lan, 'LC_MESSAGES', 'lyx' + program_suffix + '.mo')
1998 env.InstallAs(dest_file, gmo)
1999 Alias('install', dest_file)
2002 if 'installer' in BUILD_TARGETS:
2004 # build windows installer using NSIS
2007 # There is a nsis builder on scons wiki but it does not work with
2008 # our lyx.nsi because it does not dig through all the include directives
2009 # and find the dependencies automatically. Also, it can not parse
2010 # OutFile in lyx.nsi since it is defined as SETUP_EXE which is in turn
2011 # something rely on date.
2012 # Because of this, I am doing a simple nsis builder here.
2013 if platform_name != 'win32':
2014 print 'installer target is only available for windows platform'
2016 if mode != 'release':
2017 print 'installer has to be built in release mode (use option mode=release)'
2019 installer_files = ['$TOP_SRCDIR/development/Win32/packaging/installer/%s' \
2020 % x for x in development_Win32_packaging_installer] + \
2021 ['$TOP_SRCDIR/development/Win32/packaging/installer/graphics/%s' \
2022 % x for x in development_Win32_packaging_installer_graphics] + \
2023 ['$TOP_SRCDIR/development/Win32/packaging/installer/gui/%s' \
2024 % x for x in development_Win32_packaging_installer_gui] + \
2025 ['$TOP_SRCDIR/development/Win32/packaging/installer/include/%s' \
2026 % x for x in development_Win32_packaging_installer_include] + \
2027 ['$TOP_SRCDIR/development/Win32/packaging/installer/lang/%s' \
2028 % x for x in development_Win32_packaging_installer_lang] + \
2029 ['$TOP_SRCDIR/development/Win32/packaging/installer/setup/%s' \
2030 % x for x in development_Win32_packaging_installer_setup]
2031 if env.has_key('NSIS') and env['NSIS'] is not None:
2032 # create a builder to strip and install
2033 env['BUILDERS']['installer'] = Builder(generator=utils.env_nsis)
2035 print 'No nsis compiler is found. Existing...'
2037 if not env.has_key('win_installer') or env['win_installer'] is None:
2039 env['win_installer'] = '%s-%s-%s-Installer.exe' % (package_name, package_version, time.strftime('%Y-%m-%d'))
2041 env['win_installer'] = '%s-%s-Installer.exe' % (package_name, package_version)
2042 # provide default setting
2043 if not env.has_key('deps_dir') or env['deps_dir'] is None:
2044 env['deps_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-deps-msvc-qt4')
2045 if not os.path.isdir(env.Dir('$deps_dir').abspath):
2046 print 'Development dependency package is not found.'
2049 env['deps_dir'] = env.Dir('$deps_dir').abspath
2051 if env.has_key('bundle_dir') and os.path.isdir(env.Dir('$bundle_dir').abspath):
2052 env['bundle_dir'] = env.Dir('$bundle_dir').abspath
2053 elif os.path.isdir(os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')):
2054 env['bundle_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')
2056 env['bundle_dir'] = None
2057 # if absolute path is given, use it, otherwise, write to current directory
2058 if not (':' in env['win_installer'] or '/' in env['win_installer'] or '\\' in env['win_installer']):
2059 env['win_installer'] = os.path.join(env.Dir('$BUILDDIR').abspath, env['win_installer'])
2060 env.Append(NSISDEFINES={
2061 'ExeFile':env['win_installer'],
2062 'BundleExeFile':env['win_installer'].replace('.exe', '-bundle.exe'),
2063 'FilesLyx':env.Dir(dest_prefix_dir).abspath,
2064 'FilesDeps':env['deps_dir'],
2065 'FilesBundle':env['bundle_dir'],
2067 installer = env.installer(env['win_installer'],
2068 '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2069 # since I can not use a scanner, explicit dependent is required
2070 env.Depends(installer, 'install')
2071 env.Depends(installer, installer_files)
2072 env.Alias('installer', installer)
2073 # also generate bundle?
2074 if env.has_key('bundle') and env['bundle']:
2075 if env['bundle_dir'] is None or not os.path.isdir(env['bundle_dir']):
2076 print 'Bundle directory does not exist (default to %s\lyx-windows-bundle-deps.' % env.Dir('$TOP_SRCDIR').abspath
2077 print 'Use bundle_dir option to specify'
2079 # generator of the builder will add bundle stuff depending on output name
2080 bundle_installer = env.installer(env['win_installer'].replace('.exe', '-bundle.exe'),
2081 '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2082 env.Depends(bundle_installer, 'install')
2083 env.Depends(bundle_installer, installer_files)
2084 env.Alias('installer', bundle_installer)
2087 Alias('all', ['lyx', 'client', 'tex2lyx'])