1 # vi:filetype=python:expandtab:tabstop=2:shiftwidth=2
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
9 # Full author contact details are available in file CREDITS.
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
17 # config/scons_utils.py defines a few utility function
18 sys.path.append('config')
19 import scons_utils as utils
21 #----------------------------------------------------------
22 # Required runtime environment
23 #----------------------------------------------------------
25 # scons asks for 1.5.2, lyx requires 2.3
26 EnsurePythonVersion(2, 3)
27 # Please use at least 0.96.91 (not 0.96.1)
28 EnsureSConsVersion(0, 96)
30 # determine where I am ...
32 # called as 'scons -f development/scons/SConstruct'
33 if os.path.isfile('SConstruct'):
36 # called as 'cd development/scons; scons'
39 scons_dir = 'development/scons'
42 #----------------------------------------------------------
44 #----------------------------------------------------------
46 # some global settings
48 # detect version of lyx
49 # only 1.4.x has frontends/qt2
50 if os.path.isdir(os.path.join(top_src_dir, 'src', 'frontends', 'qt2')):
51 package_version = '1.4.2svn'
53 package_version = '1.5.0svn'
56 default_build_mode = 'debug'
60 package_bugreport = 'lyx-devel@lists.lyx.org'
62 package_tarname = 'lyx'
63 package_string = '%s %s' % (package_name, package_version)
65 # various cache/log files
66 default_log_file = 'scons_lyx.log'
67 env_cache_file = 'env.cache'
70 #----------------------------------------------------------
71 # platform dependent settings
72 #----------------------------------------------------------
75 platform_name = 'win32'
76 default_frontend = 'qt4'
77 default_prefix = 'c:/program files/lyx'
78 default_with_x = False
79 default_packaging_method = 'windows'
80 elif os.name == 'posix' and sys.platform != 'cygwin':
81 platform_name = sys.platform
82 default_frontend = 'qt3'
83 default_prefix = '/usr/local'
85 default_packaging_method = 'posix'
86 elif os.name == 'posix' and sys.platform == 'cygwin':
87 platform_name = 'cygwin'
88 default_frontend = 'qt3'
89 default_prefix = '/usr/local'
91 default_packaging_method = 'posix'
92 elif os.name == 'darwin':
93 platform_name = 'macosx'
94 default_frontend = 'qt3'
95 # FIXME: macOSX default prefix?
97 default_with_x = False
98 default_packaging_method = 'macosx'
99 else: # unsupported system, assume posix behavior
100 platform_name = 'others'
101 default_frontend = 'qt3'
103 default_with_x = True
104 default_packaging_method = 'posix'
107 #---------------------------------------------------------
109 #----------------------------------------------------------
111 # You can set perminant default values in config.py
112 if os.path.isfile('config.py'):
113 print "Getting options from config.py..."
114 print open('config.py').read()
116 opts = Options(['config.py'])
119 EnumOption('frontend', 'Main GUI', default_frontend,
120 allowed_values = ('xform', 'qt2', 'qt3', 'qt4', 'gtk') ),
121 # debug or release build
122 EnumOption('mode', 'Building method', default_build_mode,
123 allowed_values = ('debug', 'release') ),
126 'Use included, system boost library, or try sytem boost first.',
127 'auto', allowed_values = (
128 'auto', # detect boost, if not found, use included
129 'included', # always use included boost
130 'system', # always use system boost, fail if can not find
133 EnumOption('gettext',
134 'Use included, system gettext library, or try sytem gettext first',
135 'auto', allowed_values = (
136 'auto', # detect gettext, if not found, use included
137 'included', # always use included gettext
138 'system', # always use system gettext, fail if can not find
141 EnumOption('spell', 'Choose spell checker to use.', 'auto',
142 allowed_values = ('aspell', 'pspell', 'ispell', 'auto', 'no') ),
144 EnumOption('packaging', 'Packaging method to use.', default_packaging_method,
145 allowed_values = ('windows', 'posix', 'macosx')),
147 BoolOption('fast_start', 'Whether or not use cached tests and keep current config.h', True),
148 # FIXME: I do not know how pch is working. Ignore this option now.
149 BoolOption('pch', '(NA) Whether or not use pch', None),
150 # enable assertion, (config.h has ENABLE_ASSERTIOS
151 BoolOption('assertions', 'Use assertions', True),
152 # enable warning, (config.h has WITH_WARNINGS)
153 # default to False since MSVC does not have #warning
154 BoolOption('warnings', 'Use warnings', False),
155 # enable glib, (config.h has _GLIBCXX_CONCEPT_CHECKS)
156 BoolOption('concept_checks', 'Enable concept checks', True),
158 BoolOption('nls', 'Whether or not use native language support', True),
159 # FIXME: not implemented
160 BoolOption('profile', '(NA) Whether or not enable profiling', False),
161 # FIXME: not implemented
162 BoolOption('std_debug', '(NA) Whether or not turn on stdlib debug', False),
164 BoolOption('X11', 'Use x11 windows system', default_with_x),
165 # use MS VC++ to build lyx
166 BoolOption('use_vc', 'Use MS VC++ to build lyx (cl.exe will be probed)', None),
168 PathOption('qt_dir', 'Path to qt directory', None),
170 PathOption('qt_include_path', 'Path to qt include directory', None),
172 PathOption('qt_lib_path', 'Path to qt library directory', None),
173 # build directory, will use $mode if not set
174 PathOption('build_dir', 'Build directory', None),
175 # extra include and libpath
176 PathOption('extra_inc_path', 'Extra include path', None),
178 PathOption('extra_lib_path', 'Extra library path', None),
180 PathOption('extra_bin_path', 'A convenient way to add a path to $PATH', None),
182 PathOption('extra_inc_path1', 'Extra include path', None),
184 PathOption('extra_lib_path1', 'Extra library path', None),
185 # rebuild only specifed, comma separated targets
186 ('rebuild', 'rebuild only specifed, comma separated targets', None),
187 # can be set to a non-existing directory
188 ('prefix', 'install architecture-independent files in PREFIX', default_prefix),
190 ('version_suffix', 'install lyx as lyx-suffix', None),
191 # how to load options
192 ('load_option', '''load option from previous scons run. option can be
193 yes (default): load all options
194 no: do not load any option
195 opt1,opt2: load specified options
196 -opt1,opt2: load all options other than specified ones''', 'yes'),
198 ('optimization', 'optimization CCFLAGS option.', None),
200 PathOption('exec_prefix', 'install architecture-independent executable files in PREFIX', None),
202 ('logfile', 'save commands (not outputs) to logfile', default_log_file),
203 # provided for backward compatibility
204 ('dest_dir', 'install to DESTDIR. (Provided for backward compatibility only)', None),
205 # environment variable can be set as options.
206 ('DESTDIR', 'install to DESTDIR', None),
207 ('CC', 'replace default $CC', None),
208 ('LINK', 'replace default $LINK', None),
209 ('CPP', 'replace default $CPP', None),
210 ('CXX', 'replace default $CXX', None),
211 ('CXXCPP', 'replace default $CXXCPP', None),
212 ('CCFLAGS', 'replace default $CCFLAGS', None),
213 ('CPPFLAGS', 'replace default $CPPFLAGS', None),
214 ('LINKFLAGS', 'replace default $LINKFLAGS', None),
217 # copied from SCons/Options/BoolOption.py
218 # We need to use them before a boolean ARGUMENTS option is available
220 true_strings = ('y', 'yes', 'true', 't', '1', 'on' , 'all' )
221 false_strings = ('n', 'no', 'false', 'f', '0', 'off', 'none')
223 # whether or not use current config.h, and cached tests
225 # if fast_start=yes (default), load variables from env_cache_file
226 if (not ARGUMENTS.has_key('fast_start') or \
227 ARGUMENTS['fast_start'] in true_strings) \
228 and os.path.isfile(env_cache_file):
230 cache_file = open(env_cache_file)
231 env_cache = cPickle.load(cache_file)
233 print '------------ fast_start mode --------------------'
234 print ' Use cached test results and current config.h'
235 print ' use fast_start=no to override'
241 # if load_option=yes (default), load saved comand line options
243 # This option can take value yes/no/opt1,opt2/-opt1,opt2
244 # and tries to be clever in choosing options to load
245 if (not ARGUMENTS.has_key('load_option') or \
246 ARGUMENTS['load_option'] not in false_strings) \
247 and os.path.isfile(env_cache_file):
248 cache_file = open(env_cache_file)
249 opt_cache = cPickle.load(cache_file)['arg_cache']
251 # import cached options, but we should ignore qt_dir when frontend changes
252 if ARGUMENTS.has_key('frontend') and opt_cache.has_key('frontend') \
253 and ARGUMENTS['frontend'] != opt_cache['frontend'] \
254 and opt_cache.has_key('qt_dir'):
255 opt_cache.pop('qt_dir')
256 # some options will require full rebuild
257 # these are in general things that will change src/config.h
258 for arg in ['version_suffix', 'nls', 'boost', 'spell']:
259 if ARGUMENTS.has_key(arg) and ((not opt_cache.has_key(arg)) or \
260 ARGUMENTS[arg] != opt_cache[arg]):
262 print " ** fast_start is disabled because of the change of option", arg
265 # and we do not cache some options
266 for arg in ['fast_start', 'load_option']:
267 if opt_cache.has_key(arg):
269 # now, if load_option=opt1,opt2 or -opt1,opt2
270 if ARGUMENTS.has_key('load_option') and \
271 ARGUMENTS['load_option'] not in true_strings + false_strings:
272 # if -opt1,opt2 is specified, do not load these options
273 if ARGUMENTS['load_option'][0] == '-':
274 for arg in ARGUMENTS['load_option'][1:].split(','):
275 if opt_cache.has_key(arg):
277 # if opt1,opt2 is specified, only load specified options
279 args = ARGUMENTS['load_option'].split(',')
280 for arg in opt_cache.keys():
283 # now restore options as if entered from command line
284 for key in opt_cache.keys():
285 if not ARGUMENTS.has_key(key):
286 ARGUMENTS[key] = opt_cache[key]
287 print "Restoring cached option %s=%s" % (key, ARGUMENTS[key])
291 env_cache['arg_cache'] = ARGUMENTS
294 #---------------------------------------------------------
295 # Setting up environment
296 #---------------------------------------------------------
298 # I do not really like ENV=os.environ, but you may add it
299 # here if you experience some environment related problem
300 env = Environment(options = opts)
302 # set individual variables since I do not really like ENV = os.environ
303 env['ENV']['PATH'] = os.environ.get('PATH')
304 env['ENV']['HOME'] = os.environ.get('HOME')
305 # these are defined for MSVC
306 env['ENV']['LIB'] = os.environ.get('LIB')
307 env['ENV']['INCLUDE'] = os.environ.get('INCLUDE')
309 # for simplicity, use var instead of env[var]
310 frontend = env['frontend']
311 prefix = env['prefix']
313 if platform_name == 'win32':
314 if env.has_key('use_vc'):
315 use_vc = env['use_vc']
316 if WhereIs('cl.exe') is None:
317 print "cl.exe is not found. Are you using the MSVC environment?"
319 elif WhereIs('cl.exe') is not None:
326 # lyx will be built to $build/build_dir so it is possible
327 # to build multiple build_dirs using the same source
328 # $mode can be debug or release
329 if env.has_key('build_dir') and env['build_dir'] is not None:
330 env['BUILDDIR'] = env['build_dir']
332 # Determine the name of the build $mode
333 env['BUILDDIR'] = '#' + env['mode']
335 # all built libraries will go to build_dir/libs
336 # (This is different from the make file approach)
337 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
338 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
341 # Here is a summary of variables defined in env
343 # 2. undefined options with a non-None default value
344 # 3. compiler commands and flags like CCFLAGS.
345 # MSGFMT used to process po files
346 # 4. Variables that will be used to replace variables in some_file.in
347 # src/support/package.C.in:
348 # TOP_SRCDIR, LOCALEDIR, LYX_DIR, PROGRAM_SUFFIX
349 # lib/lyx2lyx/lyx2lyx_version.py.in
352 # PACKAGE_VERSION, VERSION_INFO
353 # src/frontends/xforms/lyx_xpm.h.in
355 # src/frontends/xforms/lyx_forms.h.in
358 # full path name is used to build msvs project files
359 # and to replace TOP_SRCDIR in package.C
360 env['TOP_SRCDIR'] = Dir(top_src_dir).abspath
361 # needed by src/version.C.in => src/version.C
362 env['PACKAGE_VERSION'] = package_version
364 # determine share_dir etc
365 packaging_method = env.get('packaging')
366 if packaging_method == 'windows':
367 share_dir = 'Resources'
368 man_dir = 'Resources/man/man1'
369 locale_dir = 'Resources/locale'
370 default_prefix = 'c:/program files/lyx'
372 share_dir = 'share/lyx'
374 locale_dir = 'share/locale'
375 default_prefix = '/usr/local/'
377 # install to default_prefix by default
378 # program suffix: can be yes, or a string
379 if env.has_key('version_suffix'):
380 if env['version_suffix'] in true_strings:
381 program_suffix = package_version
382 elif env['version_suffix'] in false_strings:
385 program_suffix = env['version_suffix']
388 # used by package.C.in
389 env['PROGRAM_SUFFIX'] = program_suffix
391 # whether or not add suffix to file and directory names
392 add_suffix = packaging_method != 'windows'
393 # LYX_DIR are different (used in package.C.in)
395 env['LYX_DIR'] = Dir(os.path.join(prefix, share_dir + program_suffix)).abspath
397 env['LYX_DIR'] = Dir(os.path.join(prefix, share_dir)).abspath
398 # we need absolute path for package.C
399 env['LOCALEDIR'] = Dir(os.path.join(prefix, locale_dir)).abspath
402 #---------------------------------------------------------
403 # Setting building environment (Tools, compiler flags etc)
404 #---------------------------------------------------------
406 # Since Tool('mingw') will reset CCFLAGS etc, this should be
407 # done before getEnvVariable
408 if platform_name == 'win32':
414 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
416 # we differentiate between hard-coded options and default options
417 # hard-coded options are required and will always be there
418 # default options can be replaced by enviromental variables or command line options
419 CCFLAGS_required = []
420 LINKFLAGS_required = []
423 # under windows, scons is confused by .C/.c and uses gcc instead of
424 # g++. I am forcing the use of g++ here. This is expected to change
425 # after lyx renames all .C files to .cpp
427 # save the old c compiler and CCFLAGS (used by libintl)
428 C_COMPILER = env.subst('$CC')
429 C_CCFLAGS = env.subst('$CCFLAGS').split()
430 # if we use ms vc, the commands are fine (cl.exe and link.exe)
432 # /TP treat all source code as C++
433 # C4819: The file contains a character that cannot be represented
434 # in the current code page (number)
435 # C4996: foo was decleared deprecated
436 CCFLAGS_required.extend(['/TP', '/EHsc'])
437 CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo'])
439 if env.has_key('CXX') and env['CXX']:
440 env['CC'] = env.subst('$CXX')
441 env['LINK'] = env.subst('$CXX')
446 # for debug/release mode
447 if env.has_key('optimization') and env['optimization'] is not None:
448 # if user supplies optimization flags, use it anyway
449 CCFLAGS_required.extend(env['optimization'].split())
450 # and do not use default
451 set_default_optimization_flags = False
453 set_default_optimization_flags = True
455 if env['mode'] == 'debug':
457 CCFLAGS_required.append('/Zi')
458 LINKFLAGS_required.extend(['/debug', '/map'])
460 CCFLAGS_required.append('-g')
461 CCFLAGS_default.append('-Wall')
462 elif env['mode'] == 'release' and set_default_optimization_flags:
464 CCFLAGS_default.append('/O2')
466 CCFLAGS_default.append('-O2')
468 # Now, set the variables as follows:
469 # 1. if command line option exists: replace default
470 # 2. then if s envronment variable exists: replace default
471 # 3. set variable to required + default
472 def setEnvVariable(env, name, required = None, default = None, split = True):
473 ''' env: environment to set variable
475 required: hardcoded options
476 default: default options that can be replaced by command line or
477 environment variables
478 split: whether or not split obtained variable like '-02 -g'
480 # first try command line argument (override environment settings)
481 if ARGUMENTS.has_key(name):
482 default = ARGUMENTS[name]
484 default = default.split()
485 # then use environment default
486 elif os.environ.has_key(name):
487 print "Acquiring varaible %s from system environment: %s" % (name, os.environ[name])
488 default = os.environ[name]
490 default = default.split()
492 if required is not None:
494 if default is not None:
495 if env.has_key(name):
500 setEnvVariable(env, 'DESTDIR', split=False)
501 setEnvVariable(env, 'CC')
502 setEnvVariable(env, 'LINK')
503 setEnvVariable(env, 'CPP')
504 setEnvVariable(env, 'CXX')
505 setEnvVariable(env, 'CXXCPP')
506 setEnvVariable(env, 'CCFLAGS', CCFLAGS_required, CCFLAGS_default)
507 setEnvVariable(env, 'CXXFLAGS')
508 setEnvVariable(env, 'CPPFLAGS')
509 setEnvVariable(env, 'LINKFLAGS', LINKFLAGS_required)
511 # if DESTDIR is not set...
512 if env.has_key('dest_dir'):
513 print "This option is obsolete. Please use DESTDIR instead."
514 env['DESTDIR'] = env['dest_dir']
515 dest_dir = env.get('DESTDIR', prefix)
517 #---------------------------------------------------------
518 # Frontend related variables (QTDIR etc)
519 #---------------------------------------------------------
521 if env.has_key('qt_dir') and env['qt_dir']:
522 env['QTDIR'] = env['qt_dir']
523 # add path to the qt tools
524 env.AppendUnique(LIBPATH = [os.path.join(env['qt_dir'], 'lib')])
525 # set environment so that moc etc can be found even if its path is not set properly
526 env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
528 env['QTDIR'] = os.environ.get('QTDIR', '/usr/lib/qt-3.3')
530 if env.has_key('qt_lib_path') and env['qt_lib_path']:
531 qt_lib_path = env.subst('$qt_lib_path')
533 qt_lib_path = env.subst('$QTDIR/lib')
534 env.AppendUnique(LIBPATH = [qt_lib_path])
535 # qt4 seems to be using pkg_config
536 env.PrependENVPath('PKG_CONFIG_PATH', qt_lib_path)
538 if env.has_key('qt_inc_path') and env['qt_inc_path']:
539 qt_inc_path = env['qt_inc_path']
540 elif os.path.isdir(os.path.join(env.subst('$QTDIR'), 'include')):
541 qt_inc_path = '$QTDIR/include'
542 # this is the path for cygwin.
543 elif os.path.isdir('/usr/include/' + frontend):
544 qt_inc_path = '/usr/include/$frontend'
546 print "Qt include directory not found. Please specify it using qt_inc_path"
548 # Note that this CPPPATH is for testing only
549 # it will be removed before calling SConscript
550 env['CPPPATH'] = [qt_inc_path]
553 # extra_inc_path and extra_lib_path
556 if env.has_key('extra_inc_path') and env['extra_inc_path']:
557 extra_inc_paths.append(env['extra_inc_path'])
558 if env.has_key('extra_lib_path') and env['extra_lib_path']:
559 env.AppendUnique(LIBPATH = [env['extra_lib_path']])
560 if env.has_key('extra_inc_path1') and env['extra_inc_path1']:
561 extra_inc_paths.append(env['extra_inc_path1'])
562 if env.has_key('extra_lib_path1') and env['extra_lib_path1']:
563 env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
564 if env.has_key('extra_bin_path') and env['extra_bin_path']:
565 # maybe only one of them is needed
566 os.environ['PATH'] += os.pathsep + env['extra_bin_path']
567 env['ENV']['PATH'] += os.pathsep + env['extra_bin_path']
568 # extra_inc_paths will be used later by intlenv etc
569 env.AppendUnique(CPPPATH = extra_inc_paths)
572 #----------------------------------------------------------
574 #----------------------------------------------------------
576 conf = Configure(env,
578 'CheckPkgConfig' : utils.checkPkgConfig,
579 'CheckPackage' : utils.checkPackage,
580 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
581 'CheckSelectArgType' : utils.checkSelectArgType,
582 'CheckBoostLibraries' : utils.checkBoostLibraries,
583 'CheckCommand' : utils.checkCommand,
584 'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd,
585 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
589 # pkg-config? (if not, we use hard-coded options)
591 if conf.CheckPkgConfig('0.15.0'):
592 env['HAS_PKG_CONFIG'] = True
594 print 'pkg-config >= 0.1.50 is not found'
595 env['HAS_PKG_CONFIG'] = False
596 env_cache['HAS_PKG_CONFIG'] = env['HAS_PKG_CONFIG']
598 env['HAS_PKG_CONFIG'] = env_cache['HAS_PKG_CONFIG']
600 # zlib? This is required. (fast_start assumes the existance of zlib)
602 if (not use_vc and not conf.CheckLibWithHeader('z', 'zlib.h', 'C')) \
603 or (use_vc and not conf.CheckLibWithHeader('zdll', 'zlib.h', 'C')):
604 print 'Did not find zdll.lib or zlib.h, exiting!'
610 # qt3 does not use pkg_config
611 if frontend in ['qt2', 'qt3']:
612 if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'):
613 print 'Did not find qt libraries, exiting!'
615 elif frontend == 'qt4':
617 # first: try pkg_config
618 if env['HAS_PKG_CONFIG']:
619 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
620 env['QT4_PKG_CONFIG'] = succ
621 # second: try to link to it
623 # FIXME: under linux, I can test the following perfectly
624 # However, under windows, lib names need to passed as libXXX4.a ...
625 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') or \
626 conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
627 # third: try to look up the path
630 for lib in ['QtCore', 'QtGui']:
631 # windows version has something like QtGui4 ...
632 if not (os.path.isfile(os.path.join(qt_lib_path, 'lib%s.a' % lib)) or \
633 os.path.isfile(os.path.join(qt_lib_path, 'lib%s4.a' % lib))):
636 # still can not find it
638 print "Qt4 libraries are found."
640 print 'Did not find qt libraries, exiting!'
643 # now, if msvc2005 is used, we will need that QT_LIB_PATH/QT_LIB.manifest file
645 # glob file xxx.dll.manifest (msvc 2003 may not have it)
646 manifests = glob.glob(os.path.join(qt_lib_path, '*.dll.manifest'))
648 env['LINKCOM'] = [env['LINKCOM'], 'mt.exe /MANIFEST %s /outputresource:$TARGET;1' % manifests[0]]
653 if conf.CheckLib('socket'):
654 socket_libs.append('socket')
655 # nsl is the network services library and provides a
656 # transport-level interface to networking services.
657 if conf.CheckLib('nsl'):
658 socket_libs.append('nsl')
659 env_cache['SOCKET_LIBS'] = socket_libs
661 socket_libs = env_cache['SOCKET_LIBS']
663 # check available boost libs (since lyx1.4 does not use iostream)
665 for lib in ['signals', 'regex', 'filesystem', 'iostreams']:
666 if os.path.isdir(os.path.join(top_src_dir, 'boost', 'libs', lib)):
667 boost_libs.append(lib)
670 # check boost libraries
671 boost_opt = ARGUMENTS.get('boost', 'auto')
672 # check for system boost
673 paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
676 # here I assume that all libraries are in the same directory
677 for lib in boost_libs:
678 if boost_opt == 'included':
679 boost_libraries.append('included_boost_%s' % lib)
680 env['INCLUDED_BOOST'] = True
681 elif boost_opt == 'auto':
682 res = conf.CheckBoostLibraries('boost_%s' % lib , paths)
685 boost_libraries.append('included_boost_%s' % lib)
686 env['INCLUDED_BOOST'] = True
688 boost_libraries.append(res[1])
689 env['INCLUDED_BOOST'] = False
690 boost_libpath = res[0]
691 elif boost_opt == 'system':
692 res = conf.CheckBoostLibraries('boost_%s' % lib , paths)
694 print "Can not find system boost libraries"
695 print "Please supply a path through extra_lib_path and try again."
696 print "Or use boost=included to use included boost libraries."
699 boost_libraries.append(res[1])
700 env.AppendUnique(LIBPATH = [res[0]])
701 boost_libpath = res[0]
702 env_cache['BOOST_LIBRARIES'] = boost_libraries
703 env_cache['INCLUDED_BOOST'] = env['INCLUDED_BOOST']
704 env_cache['BOOST_LIBPATH'] = boost_libpath
706 boost_libraries = env_cache['BOOST_LIBRARIES']
707 if env_cache['BOOST_LIBPATH'] is not None:
708 env.AppendUnique(LIBPATH = [env_cache['BOOST_LIBPATH']])
709 env['INCLUDED_BOOST'] = env_cache['INCLUDED_BOOST']
712 env['ENABLE_NLS'] = env['nls']
715 if not env['ENABLE_NLS']:
717 included_gettext = False
719 # check gettext libraries
720 gettext_opt = ARGUMENTS.get('gettext', 'auto')
721 # check for system gettext
723 if gettext_opt in ['auto', 'system']:
724 if conf.CheckLib('intl'):
725 included_gettext = False
729 if gettext_opt == 'system':
730 print "Can not find system gettext library"
731 print "Please supply a path through extra_lib_path and try again."
732 print "Or use gettext=included to use included gettext libraries."
734 # now, auto and succ = false, or gettext=included
736 # we do not need to set LIBPATH now.
737 included_gettext = True
738 intl_libs = ['included_intl']
739 env_cache['INCLUDED_GETTEXT'] = included_gettext
740 env_cache['INTL_LIBS'] = intl_libs
742 intl_libs = env_cache['INTL_LIBS']
743 included_gettext = env_cache['INCLUDED_GETTEXT']
746 # check for msgfmt command
748 env['MSGFMT'] = conf.CheckCommand('msgfmt')
749 env_cache['MSGFMT'] = env['MSGFMT']
751 env['MSGFMT'] = env_cache['MSGFMT']
754 #----------------------------------------------------------
755 # Generating config.h
756 #----------------------------------------------------------
758 print "Generating src/config.h..."
760 # AIKSAURUS_H_LOCATION
761 if (conf.CheckCXXHeader("Aiksaurus.h")):
762 aik_location = '<Aiksaurus.h>'
763 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
764 aik_location = '<Aiksaurus/Aiksaurus.h>'
768 # determine headers to use
769 spell_opt = ARGUMENTS.get('spell', 'auto')
770 env['USE_ASPELL'] = False
771 env['USE_PSPELL'] = False
772 env['USE_ISPELL'] = False
773 if spell_opt in ['auto', 'aspell'] and conf.CheckLib('aspell'):
774 spell_engine = 'USE_ASPELL'
775 elif spell_opt in ['auto', 'pspell'] and conf.CheckLib('pspell'):
776 spell_engine = 'USE_PSPELL'
777 elif spell_opt in ['auto', 'ispell'] and conf.CheckLib('ispell'):
778 spell_engine = 'USE_ISPELL'
782 if spell_engine is not None:
783 env[spell_engine] = True
785 if spell_opt == 'auto':
786 print "Warning: Can not locate any spell checker"
787 elif spell_opt != 'no':
788 print "Warning: Can not locate specified spell checker:", spell_opt
791 # check arg types of select function
792 (select_arg1, select_arg234, select_arg5) = conf.CheckSelectArgType()
796 result = utils.createConfigFile(conf,
797 config_file = os.path.join(top_src_dir, 'src', 'config.h'),
798 config_pre = '''/* src/config.h. Generated by SCons. */
803 * This file is part of LyX, the document processor.
804 * Licence details can be found in the file COPYING.
806 * This is the compilation configuration file for LyX.
807 * It was generated by scon.
808 * You might want to change some of the defaults if something goes wrong
809 * during the compilation.
816 ('io.h', 'HAVE_IO_H', 'c'),
817 ('limits.h', 'HAVE_LIMITS_H', 'c'),
818 ('locale.h', 'HAVE_LOCALE_H', 'c'),
819 ('locale', 'HAVE_LOCALE', 'cxx'),
820 ('process.h', 'HAVE_PROCESS_H', 'c'),
821 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
822 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
823 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
824 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
825 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
826 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
827 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
828 ('utime.h', 'HAVE_UTIME_H', 'c'),
829 ('direct.h', 'HAVE_DIRECT_H', 'c'),
830 ('istream', 'HAVE_ISTREAM', 'cxx'),
831 ('ostream', 'HAVE_OSTREAM', 'cxx'),
832 ('ios', 'HAVE_IOS', 'cxx'),
835 ('open', 'HAVE_OPEN', None),
836 ('close', 'HAVE_CLOSE', None),
837 ('popen', 'HAVE_POPEN', None),
838 ('pclose', 'HAVE_PCLOSE', None),
839 ('_open', 'HAVE__OPEN', None),
840 ('_close', 'HAVE__CLOSE', None),
841 ('_popen', 'HAVE__POPEN', None),
842 ('_pclose', 'HAVE__PCLOSE', None),
843 ('getpid', 'HAVE_GETPID', None),
844 ('_getpid', 'HAVE__GETPID', None),
845 ('mkdir', 'HAVE_MKDIR', None),
846 ('_mkdir', 'HAVE__MKDIR', None),
847 ('mktemp', 'HAVE_MKTEMP', None),
848 ('mkstemp', 'HAVE_MKSTEMP', None),
849 ('strerror', 'HAVE_STRERROR', None),
850 ('count', 'HAVE_STD_COUNT', '''
855 return std::count(a, a+5, 'l');
858 ('getcwd', 'HAVE_GETCWD', None),
859 ('setenv', 'HAVE_SETENV', None),
860 ('putenv', 'HAVE_PUTENV', None),
861 ('fcntl', 'HAVE_FCNTL', None),
864 ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
865 '#include <streambuf>\n#include <istream>')
868 ('gdi32', 'HAVE_LIBGDI32'),
869 (('iconv', 'libiconv'), 'HAVE_ICONV', 'ICONV_LIB'),
870 (('Aiksaurus', 'libAiksaurus'), 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB'),
873 (conf.CheckType('pid_t', includes='#include <sys/types.h>'),
875 'Define is sys/types.h does not have pid_t',
879 (conf.CheckCXXGlobalCstd(),
881 'Define if your C++ compiler puts C library functions in the global namespace'
883 (conf.CheckMkdirOneArg(),
884 'MKDIR_TAKES_ONE_ARG',
885 'Define if mkdir takes only one argument.'
887 (conf.CheckLC_MESSAGES(),
889 'Define if your <locale.h> file defines LC_MESSAGES.'
891 (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'),
892 (env.has_key('assertions') and env['assertions'],
894 'Define if you want assertions to be enabled in the code'
896 (env.has_key('nls') and env['nls'],
898 "Define to 1 if translation of program messages to the user's native anguage is requested.",
900 (env.has_key('warnings') and env['warnings'],
902 'Define this if you want to see the warning directives put here and there by the developpers to get attention'
904 (env.has_key('concept_checks') and env['concept_checks'],
905 '_GLIBCXX_CONCEPT_CHECKS',
906 'libstdc++ concept checking'
908 (os.name != 'nt', 'BOOST_POSIZ',
909 'Indicates to boost which API to use (posix or windows).'
911 (spell_engine is not None, spell_engine,
912 'Spell engine to use'
916 ('#define PACKAGE "%s%s"' % (package, program_suffix),
918 ('#define PACKAGE_BUGREPORT "%s"' % package_bugreport,
919 'Define to the address where bug reports for this package should be sent.'),
920 ('#define PACKAGE_NAME "%s"' % package_name,
921 'Define to the full name of this package.'),
922 ('#define PACKAGE_STRING "%s"' % package_string,
923 'Define to the full name and version of this package.'),
924 ('#define PACKAGE_TARNAME "%s"' % package_tarname,
925 'Define to the one symbol short name of this package.'),
926 ('#define PACKAGE_VERSION "%s"' % package_version,
927 'Define to the version of this package.'),
928 ('#define BOOST_ALL_NO_LIB 1',
929 'disable automatic linking of boost libraries.'),
930 ('#define USE_%s_PACKAGING 1' % packaging_method.upper(),
932 ('#define AIKSAURUS_H_LOCATION ' + aik_location,
933 'Aiksaurus include file'),
934 ('#define SELECT_TYPE_ARG1 %s' % select_arg1,
935 "Define to the type of arg 1 for `select'."),
936 ('#define SELECT_TYPE_ARG234 %s' % select_arg234,
937 "Define to the type of arg 2, 3, 4 for `select'."),
938 ('#define SELECT_TYPE_ARG5 %s' % select_arg5,
939 "Define to the type of arg 5 for `select'."),
941 config_post = '''/************************************************************
942 ** You should not need to change anything beyond this point */
944 #ifndef HAVE_STRERROR
945 #if defined(__cplusplus)
948 char * strerror(int n);
952 #ifndef HAVE_DECL_MKSTEMP
953 #if defined(__cplusplus)
960 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
961 # define USE_BOOST_FORMAT 1
963 # define USE_BOOST_FORMAT 0
966 #define BOOST_USER_CONFIG <config.h>
968 #if !defined(ENABLE_ASSERTIONS)
969 # define BOOST_DISABLE_ASSERTS 1
971 #define BOOST_ENABLE_ASSERT_HANDLER 1
973 #define BOOST_DISABLE_THREADS 1
974 #define BOOST_NO_WREGEX 1
975 #define BOOST_NO_WSTRING 1
978 # define BOOST_POSIX 1
981 #if defined(HAVE_NEWAPIS_H)
982 # define WANT_GETFILEATTRIBUTESEX_WRAPPER 1
989 # these keys are needed in env
990 for key in ['USE_ASPELL', 'USE_PSPELL', 'USE_ISPELL', 'HAVE_FCNTL',\
991 'HAVE_ICONV', 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS',
992 'ICONV_LIB', 'AIKSAURUS_LIB']:
993 # USE_ASPELL etc does not go through result
994 if result.has_key(key):
995 env[key] = result[key]
996 env_cache[key] = env[key]
999 # this comes as a big surprise, without this line
1000 # (doing nothing obvious), adding fast_start=yes
1001 # to a build with fast_start=no will result in a rebuild
1002 # Note that the exact header file to check does not matter
1003 conf.CheckCHeader('io.h')
1004 # only a few variables need to be rescanned
1005 for key in ['USE_ASPELL', 'USE_PSPELL', 'USE_ISPELL', 'HAVE_FCNTL',\
1006 'HAVE_ICONV', 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS',
1007 'ICONV_LIB', 'AIKSAURUS_LIB']:
1008 env[key] = env_cache[key]
1011 # Finish auto-configuration
1014 #----------------------------------------------------------
1015 # Now set up our build process accordingly
1016 #----------------------------------------------------------
1021 # NOTE: Tool('qt') or Tool('qt4') will be loaded later
1022 # in their respective directory and specialized env.
1024 if frontend in ['qt2', 'qt3']:
1025 # note: env.Tool('qt') my set QT_LIB to qt
1027 frontend_libs = ['qt-mt']
1028 elif frontend == 'qt4':
1029 if platform_name == "win32":
1030 qt_libs = ['QtCore4', 'QtGui4']
1032 qt_libs = ['QtCore', 'QtGui']
1033 frontend_libs = qt_libs
1035 print "Can not locate qt tools"
1036 print "What I get is "
1037 print " QTDIR: ", env['QTDIR']
1040 if platform_name in ['win32', 'cygwin']:
1041 # the final link step needs stdc++ to succeed under mingw
1042 # FIXME: shouldn't g++ automatically link to stdc++?
1044 system_libs = ['shlwapi', 'shell32', 'advapi32', 'zdll']
1046 system_libs = ['shlwapi', 'stdc++', 'z']
1047 elif platform_name == 'cygwin' and env['X11']:
1048 system_libs = ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr', 'Xcursor',
1049 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 'resolv',
1055 ('HAVE_ICONV', env['ICONV_LIB']),
1056 ('HAVE_LIBGDI32', 'gdi32'),
1057 ('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
1058 ('USE_ASPELL', 'aspell'),
1059 ('USE_ISPELL', 'ispell'),
1060 ('USE_PSPELL', 'pspell'),
1065 system_libs.append(lib[1])
1068 # Build parameters CPPPATH etc
1071 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
1074 # boost is always in, src is needed for config.h
1076 # QT_INC_PATH is not needed for *every* source file
1077 env['CPPPATH'].remove(qt_inc_path)
1078 env['CPPPATH'] += ['$TOP_SRCDIR/boost', '$TOP_SRCDIR/src']
1081 # Customized builders
1083 # install customized builders
1084 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
1087 # A Link script for cygwin see
1088 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1089 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
1092 if platform_name == 'cygwin':
1093 ld_script_path = '/usr/lib/qt3/mkspecs/cygwin-g++'
1094 ld_script = utils.installCygwinLDScript(ld_script_path)
1095 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
1096 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
1101 # fill in the version info
1102 env['VERSION_INFO'] = '''Configuration
1104 Special build flags: %s
1106 C Compiler flags: %s %s
1108 C++ Compiler LyX flags: %s
1109 C++ Compiler flags: %s %s
1111 Linker user flags: %s
1113 Builing directory: %s
1114 Local library directory: %s
1117 Frontend libraries: %s
1118 System libraries: %s
1119 include search path: %s
1125 ''' % (platform_name,
1126 env.subst('$CCFLAGS'), env.subst('$CC'),
1127 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
1128 env.subst('$CXX'), env.subst('$CXXFLAGS'),
1129 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
1130 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
1131 env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
1132 str(env['LIBPATH']), str(boost_libraries),
1133 str(frontend_libs), str(system_libs), str(env['CPPPATH']),
1134 frontend, packaging_method,
1135 prefix, env['LYX_DIR'])
1137 if frontend in ['qt2', 'qt3', 'qt4']:
1138 env['VERSION_INFO'] += ''' include dir: %s
1141 ''' % (qt_inc_path, qt_lib_path, env['X11'])
1144 print env['VERSION_INFO']
1147 # Mingw command line may be too short for our link usage,
1148 # Here we use a trick from scons wiki
1149 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
1151 # I also would like to add logging (commands only) capacity to the
1153 logfile = env.get('logfile', default_log_file)
1154 if logfile != '' or platform_name == 'win32':
1156 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
1157 info = '''# This is a log of commands used by scons to build lyx
1161 ''' % (time.asctime(), ' '.join(sys.argv),
1162 env['VERSION_INFO'].replace('\n','\n# ')) )
1167 # -h will print out help info
1168 Help(opts.GenerateHelpText(env))
1171 #----------------------------------------------------------
1173 #----------------------------------------------------------
1174 # this has been the source of problems on some platforms...
1175 # I find that I need to supply it with full path name
1176 env.SConsignFile(os.path.join(Dir(env['BUILDDIR']).abspath, '.sconsign'))
1177 # this usage needs further investigation.
1178 #env.CacheDir('%s/Cache/%s' % (env['BUILDDIR'], frontend))
1180 print "Building all targets recursively"
1182 if env.has_key('rebuild'):
1183 rebuild_targets = env['rebuild'].split(',')
1185 rebuild_targets = None
1187 def libExists(libname):
1188 ''' Check whether or not lib $LOCALLIBNAME/libname already exists'''
1189 return os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath)
1191 targets = BUILD_TARGETS
1192 # msvc need to pass full target name, so I have to look for path/lyx etc
1193 build_lyx = targets == [] or True in ['lyx' in x for x in targets] \
1194 or 'install' in targets or 'all' in targets
1195 build_boost = (env['INCLUDED_BOOST'] and not libExists('boost_regex')) or 'boost' in targets
1196 build_intl = (included_gettext and not libExists('included_intl')) or 'intl' in targets
1197 build_support = build_lyx or True in [x in targets for x in ['support', 'client', 'tex2lyx']]
1198 build_mathed = build_lyx or 'mathed' in targets
1199 build_insets = build_lyx or 'insets' in targets
1200 build_frontends = build_lyx or 'frontends' in targets
1201 build_graphics = build_lyx or 'graphics' in targets
1202 build_controllers = build_lyx or 'controllers' in targets
1203 build_client = True in ['client' in x for x in targets] \
1204 or 'install' in targets or 'all' in targets
1205 build_tex2lyx = True in ['tex2lyx' in x for x in targets] \
1206 or 'install' in targets or 'all' in targets
1207 build_lyxbase = build_lyx or 'lyxbase' in targets
1208 build_po = 'po' in targets or 'install' in targets or 'all' in targets
1209 build_qt2 = (build_lyx and frontend == 'qt2') or 'qt2' in targets
1210 build_qt3 = (build_lyx and frontend == 'qt3') or 'qt3' in targets
1211 build_qt4 = (build_lyx and frontend == 'qt4') or 'qt4' in targets
1212 build_msvs_projects = use_vc and 'msvs_projects' in targets
1215 # now, if rebuild_targets is specified, do not rebuild some targets
1216 rebuild_targets = rebuild_targets
1218 def ifBuildLib(name, libname, old_value):
1219 # explicitly asked to rebuild
1220 if name in rebuild_targets:
1222 # else if not rebuild, and if the library already exists
1223 elif libExists(libname):
1225 # do not change the original value
1228 build_boost = ifBuildLib('boost', 'included_boost_filesystem', build_boost)
1229 build_intl = ifBuildLib('intl', 'included_intl', build_intl)
1230 build_support = ifBuildLib('support', 'support', build_support)
1231 build_mathed = ifBuildLib('mathed', 'mathed', build_mathed)
1232 build_insets = ifBuildLib('insets', 'insets', build_insets)
1233 build_frontends = ifBuildLib('frontends', 'frontends', build_frontends)
1234 build_graphics = ifBuildLib('graphics', 'graphics', build_graphics)
1235 build_controllers = ifBuildLib('controllers', 'controllers', build_controllers)
1236 build_lyxbase = ifBuildLib('lyxbase', 'lyxbase_pre', build_lyxbase)
1237 build_qt2 = ifBuildLib('qt2', 'qt2', build_qt2)
1238 build_qt3 = ifBuildLib('qt3', 'qt3', build_qt3)
1239 build_qt4 = ifBuildLib('qt4', 'qt4', build_qt4)
1241 # sync frontend and frontend (maybe build qt4 with frontend=qt3)
1255 env.BuildDir('$BUILDDIR/boost', '$TOP_SRCDIR/boost/libs', duplicate = 0)
1257 boostenv = env.Copy()
1259 boost_config_h = os.path.join(top_src_dir, 'boost', 'libs', 'config.h')
1260 if not os.path.isfile(boost_config_h) or not fast_start:
1262 print "Creating boost/config.h..."
1264 # start another configuration session.
1265 conf = Configure(boostenv,
1266 custom_tests = {'CheckMkdirOneArg' : utils.checkMkdirOneArg},
1270 result = utils.createConfigFile(conf,
1271 config_file = boost_config_h,
1272 config_pre = '''/* boost/libs/config.h. Generated by SCons. */
1277 * This file is part of LyX, the document processor.
1278 * Licence details can be found in the file COPYING.
1280 * This is the compilation configuration file for LyX.
1281 * It was generated by scon.
1282 * You might want to change some of the defaults if something goes wrong
1283 * during the compilation.
1290 ('io.h', 'HAVE_IO_H', 'c'),
1291 ('limits.h', 'HAVE_LIMITS_H', 'c'),
1292 ('locale.h', 'HAVE_LOCALE_H', 'c'),
1293 ('locale', 'HAVE_LOCALE', 'cxx'),
1294 ('process.h', 'HAVE_PROCESS_H', 'c'),
1295 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
1296 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
1297 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
1298 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
1299 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
1300 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
1301 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1302 ('utime.h', 'HAVE_UTIME_H', 'c'),
1303 ('direct.h', 'HAVE_DIRECT_H', 'c'),
1304 ('istream', 'HAVE_ISTREAM', 'cxx'),
1305 ('ostream', 'HAVE_OSTREAM', 'cxx'),
1306 ('ios', 'HAVE_IOS', 'cxx'),
1309 ('open', 'HAVE_OPEN', None),
1310 ('close', 'HAVE_CLOSE', None),
1311 ('popen', 'HAVE_POPEN', None),
1312 ('pclose', 'HAVE_PCLOSE', None),
1313 ('_open', 'HAVE__OPEN', None),
1314 ('_close', 'HAVE__CLOSE', None),
1315 ('_popen', 'HAVE__POPEN', None),
1316 ('_pclose', 'HAVE__PCLOSE', None),
1317 ('getpid', 'HAVE_GETPID', None),
1318 ('_getpid', 'HAVE__GETPID', None),
1319 ('mkdir', 'HAVE_MKDIR', None),
1320 ('_mkdir', 'HAVE__MKDIR', None),
1321 ('mktemp', 'HAVE_MKTEMP', None),
1322 ('mkstemp', 'HAVE_MKSTEMP', None),
1323 ('strerror', 'HAVE_STRERROR', None),
1324 ('getcwd', 'HAVE_GETCWD', None),
1325 ('setenv', 'HAVE_SETENV', None),
1326 ('putenv', 'HAVE_PUTENV', None),
1327 ('fcntl', 'HAVE_FCNTL', None),
1330 (conf.CheckMkdirOneArg(),
1331 'MKDIR_TAKES_ONE_ARG',
1332 'Define if mkdir takes only one argument.'
1334 (env.has_key('assertions') and env['assertions'],
1335 'ENABLE_ASSERTIONS',
1336 'Define if you want assertions to be enabled in the code'
1338 (env.has_key('warnings') and env['warnings'],
1340 'Define this if you want to see the warning directives put here and there by the developpers to get attention'
1342 (env.has_key('concept_checks') and env['concept_checks'],
1343 '_GLIBCXX_CONCEPT_CHECKS',
1344 'libstdc++ concept checking'
1346 (os.name != 'nt', 'BOOST_POSIZ',
1347 'Indicates to boost which API to use (posix or windows).'
1351 ('#define BOOST_ALL_NO_LIB 1',
1352 'disable automatic linking of boost libraries.'),
1356 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
1357 # define USE_BOOST_FORMAT 1
1359 # define USE_BOOST_FORMAT 0
1362 #define BOOST_USER_CONFIG <config.h>
1364 #if !defined(ENABLE_ASSERTIONS)
1365 # define BOOST_DISABLE_ASSERTS 1
1367 #define BOOST_ENABLE_ASSERT_HANDLER 1
1369 #define BOOST_DISABLE_THREADS 1
1370 #define BOOST_NO_WREGEX 1
1371 #define BOOST_NO_WSTRING 1
1374 # define BOOST_POSIX 1
1382 # boost use its own config.h
1383 boostenv['CPPPATH'] = ['$TOP_SRCDIR/boost', '$TOP_SRCDIR/boost/libs'] + extra_inc_paths
1384 boostenv.AppendUnique(CCFLAGS = ['-DBOOST_USER_CONFIG="<config.h>"'])
1386 for lib in boost_libs:
1387 print 'Processing files in boost/libs/%s/src...' % lib
1388 boostlib = boostenv.StaticLibrary(
1389 target = '$LOCALLIBPATH/included_boost_%s' % lib,
1390 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/boost/libs/%s/src' % lib),
1391 pattern = '*.cpp', build_dir = '$BUILDDIR/boost/%s/src' % lib)
1393 Alias('boost', boostlib)
1400 intlenv = env.Copy()
1402 intl_config_h = os.path.join(top_src_dir, 'intl', 'config.h')
1403 if not os.path.isfile(intl_config_h) or not fast_start:
1405 print "Creating intl/config.h..."
1407 # start another configuration session.
1408 conf = Configure(intlenv,
1410 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
1411 'CheckIconvConst' : utils.checkIconvConst,
1415 result = utils.createConfigFile(conf,
1416 config_file = intl_config_h,
1417 config_pre = '''/* intl/config.h. Generated by SCons. */
1422 * This file is part of LyX, the document processor.
1423 * Licence details can be found in the file COPYING.
1425 * This is the compilation configuration file for LyX.
1426 * It was generated by scon.
1427 * You might want to change some of the defaults if something goes wrong
1428 * during the compilation.
1435 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1436 ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
1437 ('string.h', 'HAVE_STRING_H', 'c'),
1438 ('strings.h', 'HAVE_STRINGS_H', 'c'),
1439 ('argz.h', 'HAVE_ARGZ_H', 'c'),
1440 ('limits.h', 'HAVE_LIMITS_H', 'c'),
1441 ('alloca.h', 'HAVE_ALLOCA_H', 'c'),
1442 ('stddef.h', 'HAVE_STDDEF_H', 'c'),
1443 ('stdint.h', 'HAVE_STDINT_H', 'c'),
1444 ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'),
1447 ('getcwd', 'HAVE_GETCWD', None),
1448 ('stpcpy', 'HAVE_STPCPY', None),
1449 ('strcasecmp', 'HAVE_STRCASECMP', None),
1450 ('strdup', 'HAVE_STRDUP', None),
1451 ('strtoul', 'HAVE_STRTOUL', None),
1452 ('alloca', 'HAVE_ALLOCA', None),
1453 ('__fsetlocking', 'HAVE___FSETLOCKING', None),
1454 ('mempcpy', 'HAVE_MEMPCPY', None),
1455 ('__argz_count', 'HAVE___ARGZ_COUNT', None),
1456 ('__argz_next', 'HAVE___ARGZ_NEXT', None),
1457 ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None),
1458 ('setlocale', 'HAVE_SETLOCALE', None),
1459 ('tsearch', 'HAVE_TSEARCH', None),
1460 ('getegid', 'HAVE_GETEGID', None),
1461 ('getgid', 'HAVE_GETGID', None),
1462 ('getuid', 'HAVE_GETUID', None),
1463 ('wcslen', 'HAVE_WCSLEN', None),
1464 ('asprintf', 'HAVE_ASPRINTF', None),
1465 ('wprintf', 'HAVE_WPRINTF', None),
1466 ('snprintf', 'HAVE_SNPRINTF', None),
1467 ('printf', 'HAVE_POSIX_PRINTF', None),
1468 ('fcntl', 'HAVE_FCNTL', None),
1471 ('intmax_t', 'HAVE_INTMAX_T', None),
1472 ('long double', 'HAVE_LONG_DOUBLE', None),
1473 ('long long', 'HAVE_LONG_LONG', None),
1474 ('wchar_t', 'HAVE_WCHAR_T', None),
1475 ('wint_t', 'HAVE_WINT_T', None),
1476 ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include <inttypes.h>'),
1477 ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include <stdint.h>'),
1480 (('iconv', 'libiconv'), 'HAVE_ICONV', 'ICONV_LIB'),
1484 (conf.CheckLC_MESSAGES(),
1486 'Define if your <locale.h> file defines LC_MESSAGES.'
1488 (conf.CheckIconvConst(),
1490 'Define as const if the declaration of iconv() needs const.',
1491 '#define ICONV_CONST',
1492 '#define ICONV_CONST const',
1494 (conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
1495 conf.CheckType('intmax_t', includes='#include <inttypes.h>'),
1497 "Define to 1 if you have the `intmax_t' type."
1499 (env.has_key('nls') and env['nls'],
1501 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1504 config_post = '#endif'
1507 # these keys are needed in env
1508 for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1509 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']:
1510 # USE_ASPELL etc does not go through result
1511 if result.has_key(key):
1512 env[key] = result[key]
1513 env_cache[key] = env[key]
1515 # only a few variables need to be rescanned
1516 for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1517 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']:
1518 env[key] = env_cache[key]
1520 print "Processing files in intl..."
1522 env.BuildDir('$BUILDDIR/intl', '$TOP_SRCDIR/intl', duplicate = 0)
1524 # we need the original C compiler for these files
1525 intlenv['CC'] = C_COMPILER
1526 intlenv['CCFLAGS'] = C_CCFLAGS
1528 intlenv.Append(CCFLAGS=['/Dinline#', '/D__attribute__(x)#', '/Duintmax_t=UINT_MAX'])
1529 # intl does not use global config.h
1530 intlenv['CPPPATH'] = ['intl'] + extra_inc_paths
1532 intlenv.Append(CCFLAGS = [
1533 r'-DLOCALEDIR=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1534 r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1535 r'-DLIBDIR=\"' + env['TOP_SRCDIR'].replace('\\', '\\\\') + r'/lib\"',
1537 '-DENABLE_RELOCATABLE=1',
1539 r'-DINSTALLDIR=\"' + prefix.replace('\\', '\\\\') + r'/lib\"',
1541 '-Dset_relocation_prefix=libintl_set_relocation_prefix',
1542 '-Drelocate=libintl_relocate',
1543 '-DDEPENDS_ON_LIBICONV=1',
1548 # libgnuintl.h.in => libintl.h
1549 env.substFile('$TOP_SRCDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in')
1550 env.Command('$TOP_SRCDIR/intl/libgnuintl.h', '$TOP_SRCDIR/intl/libintl.h',
1551 [Copy('$TARGET', '$SOURCE')])
1553 intl = intlenv.StaticLibrary(
1554 target = '$LOCALLIBPATH/included_intl',
1556 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/intl'), pattern = '*.c',
1557 exclude = ['vasnprintf.c', 'printf-parse.c', 'printf-args.c', 'os2compat.c'],
1558 build_dir = '$BUILDDIR/intl')
1564 # Now, src code under src/
1566 env.BuildDir('$BUILDDIR/common', '$TOP_SRCDIR/src', duplicate = 0)
1573 print "Processing files in src/support..."
1575 env.substFile('$BUILDDIR/common/support/package.C', '$TOP_SRCDIR/src/support/package.C.in')
1577 support = env.StaticLibrary(
1578 target = '$LOCALLIBPATH/support',
1579 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/support'), pattern = lyx_ext,
1580 exclude = ['os_win32.C', 'os_unix.C', 'os_cygwin.C', 'os_os2.C', 'atexit.c'],
1581 include = ['package.C'], build_dir = '$BUILDDIR/common/support')
1583 Alias('support', support)
1590 print "Processing files in src/mathed..."
1592 mathed = env.StaticLibrary(
1593 target = '$LOCALLIBPATH/mathed',
1594 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/mathed'), pattern = lyx_ext,
1595 exclude = ['math_xyarrowinset.C', 'math_mboxinset.C', 'formulamacro.C'],
1596 build_dir = '$BUILDDIR/common/mathed')
1598 Alias('mathed', mathed)
1605 print "Processing files in src/insets..."
1607 insets = env.StaticLibrary(
1608 target = '$LOCALLIBPATH/insets',
1609 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/insets'), pattern = lyx_ext,
1610 exclude = ['insettheorem.C'], build_dir = '$BUILDDIR/common/insets')
1612 Alias('insets', insets)
1619 print "Processing files in src/frontends..."
1621 frontends = env.StaticLibrary(
1622 target = '$LOCALLIBPATH/frontends',
1623 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends'), pattern = lyx_ext,
1624 build_dir = '$BUILDDIR/common/frontends')
1626 Alias('frontends', frontends)
1633 print "Processing files in src/graphics..."
1635 graphics = env.StaticLibrary(
1636 target = '$LOCALLIBPATH/graphics',
1637 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/graphics'), pattern = lyx_ext,
1638 build_dir = '$BUILDDIR/common/graphics')
1640 Alias('graphics', graphics)
1643 if build_controllers:
1645 # src/frontends/controllers
1647 print "Processing files in src/frontends/controllers..."
1649 controllers = env.StaticLibrary(
1650 target = '$LOCALLIBPATH/controllers',
1651 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/controllers'), pattern = lyx_ext,
1652 build_dir = '$BUILDDIR/common/frontends/controllers')
1654 Alias('controllers', controllers)
1658 # src/frontend/qt2/3/4
1660 if build_qt2 or build_qt3 or build_qt4:
1661 env.BuildDir('$BUILDDIR/$frontend', '$TOP_SRCDIR/src/frontend/$frontend', duplicate = 0)
1665 print "Processing files in src/frontends/qt2..."
1668 # disable auto scan to speed up non build time
1669 qt2env['QT_AUTOSCAN'] = 0
1670 qt2env['QT_MOCHPREFIX'] = ''
1675 qt2env.AppendUnique(CPPPATH = [
1677 '$BUILDDIR/common/images',
1678 '$BUILDDIR/common/frontends',
1679 '$BUILDDIR/common/frontends/qt2',
1680 '$BUILDDIR/common/frontends/controllers',
1684 qt2_moc_files = ["$BUILDDIR/common/frontends/qt2/%s" % x for x in Split('''
1687 FileDialog_private.C
1726 QSpellcheckerDialog.C
1728 QTabularCreateDialog.C
1743 # manually moc and uic files for better performance
1744 qt2_moced_files = [qt2env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt2_moc_files]
1746 qt2_uiced_files = [qt2env.Uic('$BUILDDIR/common/frontends/qt2/ui/'+x) for x in \
1747 utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt2/ui'), pattern = '*.ui')]
1749 qt2_uiced_cc_files = []
1750 for x in qt2_uiced_files:
1751 qt2_uiced_cc_files.extend(x[1:])
1753 qt2 = qt2env.StaticLibrary(
1754 target = '$LOCALLIBPATH/qt2',
1755 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt2/'), pattern = lyx_ext,
1756 build_dir = '$BUILDDIR/common/frontends/qt2') + qt2_moced_files + qt2_uiced_cc_files
1762 print "Processing files in src/frontends/qt3..."
1765 # disable auto scan to speed up non build time
1766 qt3env['QT_AUTOSCAN'] = 0
1767 qt3env['QT_MOCHPREFIX'] = ''
1772 qt3env.AppendUnique(CPPPATH = [
1774 '$BUILDDIR/common/images',
1775 '$BUILDDIR/common/frontends',
1776 '$BUILDDIR/common/frontends/qt3',
1777 '$BUILDDIR/common/frontends/controllers',
1781 qt3_moc_files = ["$BUILDDIR/common/frontends/qt3/%s" % x for x in Split('''
1784 FileDialog_private.C
1824 QSpellcheckerDialog.C
1826 QTabularCreateDialog.C
1841 # manually moc and uic files for better performance
1842 qt3_moced_files = [qt3env.Moc(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt3_moc_files]
1844 qt3_uiced_files = [qt3env.Uic('$BUILDDIR/common/frontends/qt3/ui/'+x) for x in \
1845 utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt3/ui'), pattern = '*.ui')]
1847 qt3_uiced_cc_files = []
1848 for x in qt3_uiced_files:
1849 qt3_uiced_cc_files.extend(x[1:])
1851 qt3 = qt3env.StaticLibrary(
1852 target = '$LOCALLIBPATH/qt3',
1853 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt3/'), pattern = lyx_ext,
1854 build_dir = '$BUILDDIR/common/frontends/qt3') + qt3_moced_files + qt3_uiced_cc_files
1860 print "Processing files in src/frontends/qt4..."
1863 qt4env['QT_AUTOSCAN'] = 0
1865 # local qt4 toolset from
1866 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
1868 # NOTE: I have to patch qt4.py since it does not automatically
1869 # process .C file!!! (add to cxx_suffixes )
1871 qt4env.Tool('qt4', [scons_dir])
1872 qt4env.EnableQt4Modules(qt_libs, debug = False)
1874 qt4env.AppendUnique(CPPPATH = [
1876 '$BUILDDIR/common/images',
1877 '$BUILDDIR/common/frontends',
1878 '$BUILDDIR/common/frontends/qt4',
1879 '$BUILDDIR/common/frontends/controllers',
1884 # FIXME: replace by something from pkg_config
1885 qt4env.Append(CCFLAGS = [
1887 '-DQT_CLEAN_NAMESPACE',
1895 qt4_moc_files = ["$BUILDDIR/common/frontends/qt4/%s" % x for x in Split('''
1898 FileDialog_private.C
1941 QSpellcheckerDialog.C
1943 QTabularCreateDialog.C
1962 resources = [qt4env.Uic4(x.split('.')[0]) for x in \
1963 utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt4/ui'), pattern = '*.ui',
1964 build_dir = '$BUILDDIR/common/frontends/qt4/ui')]
1967 # moc qt4_moc_files, the moced files are included in the original files
1969 qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
1971 qt4 = qt4env.StaticLibrary(
1972 target = '$LOCALLIBPATH/qt4',
1974 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/frontends/qt4'), pattern = lyx_ext,
1975 exclude = ['QBrowseBox.C'], build_dir = '$BUILDDIR/common/frontends/qt4')
1984 env.BuildDir('$BUILDDIR/common', '$TOP_SRCDIR/src', duplicate = 0)
1986 print "Processing files in src/client..."
1988 if env['HAVE_FCNTL']:
1989 client = env.Program(
1990 target = '$BUILDDIR/common/client/lyxclient',
1991 LIBS = ['support'] + intl_libs + system_libs +
1992 socket_libs + boost_libraries,
1993 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/client'), pattern = lyx_ext,
1994 build_dir = '$BUILDDIR/common/client')
1996 Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
1997 client, [Copy('$TARGET', '$SOURCE')]))
2000 Alias('client', client)
2007 print "Processing files in src/tex2lyx..."
2009 tex2lyx_env = env.Copy()
2010 # the order is important here.
2011 tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
2012 tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
2014 for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C',
2015 'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
2016 env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
2017 [Copy('$TARGET', '$SOURCE')])
2019 tex2lyx = tex2lyx_env.Program(
2020 target = '$BUILDDIR/common/tex2lyx/tex2lyx',
2021 LIBS = ['support'] + boost_libraries + system_libs,
2022 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src/tex2lyx'), pattern = lyx_ext,
2023 include = ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.C',
2024 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C'],
2025 build_dir = '$BUILDDIR/common/tex2lyx')
2027 Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
2028 tex2lyx, [Copy('$TARGET', '$SOURCE')]))
2029 Alias('tex2lyx', tex2lyx)
2036 print "Processing files in src..."
2038 env.substFile('$BUILDDIR/common/version.C', '$TOP_SRCDIR/src/version.C.in')
2040 lyx_post_source = Split('''
2049 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
2050 lyx_post_source.append('aspell.C')
2051 elif env.has_key('USE_PSPELL') and env['USE_PSPELL']:
2052 lyx_post_source.append('pspell.C')
2053 elif env.has_key('USE_ISPELL') and env['USE_ISPELL']:
2054 lyx_post_source.append('ispell.C')
2056 # msvc requires at least one source file with main()
2057 # so I exclude main.C from lyxbase
2058 lyxbase_pre = env.StaticLibrary(
2059 target = '$LOCALLIBPATH/lyxbase_pre',
2060 source = utils.globSource(dir = env.subst('$TOP_SRCDIR/src'), pattern = lyx_ext,
2061 exclude = lyx_post_source + ['main.C', 'aspell.C', 'pspell.C',
2062 'ispell.C', 'Variables.C', 'Sectioning.C'],
2063 include = ['version.C'], build_dir = '$BUILDDIR/common')
2065 lyxbase_post = env.StaticLibrary(
2066 target = '$LOCALLIBPATH/lyxbase_post',
2067 source = ["$BUILDDIR/common/%s" % x for x in lyx_post_source]
2069 Alias('lyxbase', lyxbase_pre)
2070 Alias('lyxbase', lyxbase_post)
2075 # Build lyx with given frontend
2078 target = '$BUILDDIR/$frontend/lyx',
2079 source = ['$BUILDDIR/common/main.C'],
2097 # [/path/to/lyx.ext] => lyx-qt3.ext
2098 target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s' % frontend)
2099 Alias('lyx', env.Command(os.path.join('$BUILDDIR', target_name), lyx,
2100 [Copy('$TARGET', '$SOURCE')]))
2104 if build_msvs_projects:
2105 def build_project(target, dir, full_target = None,
2106 src_pattern = lyx_ext, include = [], resource = None, rebuild = True):
2107 ''' build mavs project files
2108 target: alias (correspond to directory name)
2109 dir: source directory or directories (a list)
2110 full_target: full path/filename of the target
2111 src_pattern: glob pattern
2112 include: files to include into source
2113 resource: directory or directories with resource (.ui) files
2114 rebuild: whether or not only rebuild this target
2116 For non-debug-able targets like static libraries, target (alias) is
2117 enough to build the target. For executable targets, msvs need to know
2118 the full path to start debug them.
2120 if resource is not None:
2121 res = utils.globSource(dir = env.subst('$TOP_SRCDIR/'+resource), pattern = '*.ui',
2122 build_dir = env.subst('$TOP_SRCDIR/'+resource))
2126 cmds = 'faststart=yes rebuild='+target
2128 cmds = 'faststart=yes'
2129 if type(dir) == type([]):
2133 src.extend(utils.globSource(dir = env.subst('$TOP_SRCDIR/' + d),
2134 pattern = src_pattern, include = include,
2135 build_dir = env.subst('$TOP_SRCDIR/' + d) ))
2136 inc.extend(utils.globSource(dir = env.subst('$TOP_SRCDIR/' + d),
2138 build_dir = env.subst('$TOP_SRCDIR/' + d) ))
2140 src = utils.globSource(dir = env.subst('$TOP_SRCDIR/' + dir),
2141 pattern = src_pattern, include = include,
2142 build_dir = env.subst('$TOP_SRCDIR/' + dir) )
2143 inc = utils.globSource(dir = env.subst('$TOP_SRCDIR/' + dir),
2145 build_dir = env.subst('$TOP_SRCDIR/' + dir) )
2146 if full_target is None:
2147 build_target = target
2149 build_target = full_target
2151 proj = env.MSVSProject(
2152 target = target + env['MSVSPROJECTSUFFIX'],
2154 incs = [env.subst('$TOP_SRCDIR/src/config.h')],
2157 buildtarget = build_target,
2161 Alias('msvs_projects', proj)
2163 build_project('boost', ['boost/libs/%s/src' % x for x in boost_libs],
2164 src_pattern = '*.cpp')
2166 build_project('intl', 'intl', src_pattern = '*.c')
2168 build_project('support', 'src/support', include=['package.C.in'])
2170 build_project('mathed', 'src/mathed')
2172 build_project('insets', 'src/insets')
2174 build_project('frontends', 'src/frontends')
2176 build_project('graphics', 'src/graphics')
2178 build_project('controllers', 'src/frontends/controllers')
2180 build_project('qt3', 'src/frontends/qt3', resource = 'src/frontends/qt3/ui')
2182 build_project('qt4', 'src/frontends/qt4', resource = 'src/frontends/qt4/ui')
2184 build_project('client', 'src/client', rebuild=False,
2185 full_target = File(env.subst('$BUILDDIR/common/client/lyxclient$PROGSUFFIX')).abspath)
2187 build_project('tex2lyx', 'src/tex2lyx', rebuild=False,
2188 full_target = File(env.subst('$BUILDDIR/common/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
2190 build_project('lyxbase', 'src')
2192 if frontend == 'qt3':
2193 build_project('lyx', ['src', 'src/support', 'src/mathed', 'src/insets',
2194 'src/frontends', 'src/graphics', 'src/frontends/controllers',
2195 'src/frontends/qt3'], resource = 'src/frontends/qt3/ui',
2196 full_target = File(env.subst('$BUILDDIR/$frontend/lyx$PROGSUFFIX')).abspath)
2198 build_project('lyx', ['src', 'src/support', 'src/mathed', 'src/insets',
2199 'src/frontends', 'src/graphics', 'src/frontends/controllers',
2200 'src/frontends/qt4'], resource = 'src/frontends/qt4/ui',
2201 full_target = File(env.subst('$BUILDDIR/$frontend/lyx$PROGSUFFIX')).abspath)
2208 print 'Processing files in po...'
2213 # files to translate
2214 transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
2215 # possibly *only* handle these languages
2217 if env.has_key('languages'):
2218 languages = env.make_list(env['lanauges'])
2219 # use defulat msgfmt
2220 if not env['MSGFMT']:
2221 print 'msgfmt does not exist. Can not process po files'
2224 env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -o $TARGET',suffix='.gmo',src_suffix='.po')
2227 for f in transfiles:
2229 fname = os.path.split(f)[1]
2231 country = fname.split('.')[0]
2233 if not languages or country in languages:
2234 gmo_files.extend(env.Transfiles(f))
2237 if 'install' in targets:
2238 # if dest_dir is different from prefix.
2239 if env.has_key('exec_prefix'):
2240 bin_dest_dir = env['exec_prefix']
2242 bin_dest_dir = os.path.join(dest_dir, 'bin')
2244 share_dest_dir = os.path.join(dest_dir, share_dir + program_suffix)
2246 share_dest_dir = os.path.join(dest_dir, share_dir)
2247 man_dest_dir = os.path.join(dest_dir, man_dir)
2248 locale_dest_dir = os.path.join(dest_dir, locale_dir)
2249 # create the directory if needed
2250 if not os.path.isdir(dest_dir):
2252 os.makedirs(dest_dir)
2255 if not os.path.isdir(dest_dir):
2256 print 'Can not create directory', dest_dir
2261 # do not install these files
2262 exclude_list = ['Makefile.am', 'Makefile.in', 'Makefile',
2263 'lyx2lyx_version.py', 'lyx2lyx_version.py.in']
2265 def install(dest, src):
2266 ''' recusive installation of src to dest '''
2267 # separate file and directory
2268 files = filter(lambda x: os.path.isfile(x) and not os.path.split(x)[1] in exclude_list, src)
2269 dirs = filter(os.path.isdir, src)
2271 env.Install(dest, files)
2275 ins_dir.extend(install(os.path.join(dest, os.path.basename(dir)),
2276 glob.glob(os.path.join(dir, '*'))) )
2279 # executables (some of them may be none)
2282 version_suffix = program_suffix
2287 target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx%s' % version_suffix)
2288 target = os.path.join(bin_dest_dir, target_name)
2289 env.InstallAs(target, lyx)
2290 Alias('install', target)
2291 # install lyx as lyx-qt3
2292 target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s%s' % (frontend, version_suffix))
2293 target = os.path.join(bin_dest_dir, target_name)
2294 env.InstallAs(target, lyx)
2295 Alias('install', target)
2298 target_name = os.path.split(str(tex2lyx[0]))[1].replace('tex2lyx', 'tex2lyx%s' % version_suffix)
2299 target = os.path.join(bin_dest_dir, target_name)
2300 env.InstallAs(target, tex2lyx)
2301 Alias('install', target)
2303 # install lyxclient, may not exist
2305 target_name = os.path.split(str(client[0]))[1].replace('client', 'client%s' % version_suffix)
2306 target = os.path.join(bin_dest_dir, target_name)
2307 env.InstallAs(target, client)
2308 Alias('install', target)
2311 dirs = install(share_dest_dir,
2312 [env.subst('$TOP_SRCDIR/lib/') + file for file in ['configure.py', 'encodings',
2313 'chkconfig.ltx', 'CREDITS', 'external_templates', 'symbols', 'languages',
2314 'lyxrc.example', 'syntax.default', 'bind', 'images', 'layouts', 'scripts',
2315 'templates', 'examples', 'kbd', 'lyx2lyx', 'tex', 'clipart', 'doc', 'ui']]
2317 env.substFile(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py',
2318 '$TOP_SRCDIR/lib/lyx2lyx/lyx2lyx_version.py.in')
2319 Alias('install', dirs)
2321 env.InstallAs(os.path.join(man_dest_dir, 'lyx' + version_suffix + '.1'),
2322 env.subst('$TOP_SRCDIR/lyx.man'))
2323 env.InstallAs(os.path.join(man_dest_dir, 'tex2lyx' + version_suffix + '.1'),
2324 env.subst('$TOP_SRCDIR/src/tex2lyx/tex2lyx.man'))
2325 env.InstallAs(os.path.join(man_dest_dir, 'lyxclient' + version_suffix + '.1'),
2326 env.subst('$TOP_SRCDIR/src/client/lyxclient.man'))
2327 Alias('install', [os.path.join(man_dest_dir, x + version_suffix + '.1') for
2328 x in ['lyx', 'tex2lyx', 'lyxclient']])
2330 # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
2331 for gmo in gmo_files:
2332 lan = os.path.split(str(gmo))[1].split('.')[0]
2333 dest_file = os.path.join(locale_dest_dir, lan, 'LC_MESSAGES', 'lyx' + version_suffix + '.mo')
2334 env.InstallAs(dest_file, gmo)
2335 Alias('install', dest_file)
2339 Alias('all', ['lyx', 'client', 'tex2lyx'])
2342 # save environment settings (for fast_start option)
2343 cache_file = open(env_cache_file, 'w')
2344 cPickle.dump(env_cache, cache_file)