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.
12 # This is a scons based building system for lyx, you can use it as follows:
13 # (after of course installation of scons from www.scons.org)
15 # $ cd development/scons
16 # $ scons [options] [targets]
18 # $ scons -f development/scons/SConstruct [options] [targets]
20 # After compiling, you can install lyx by
21 # $ scons [prefix=.] install
24 # * targets can be one or more of lyx, tex2lyx, client, default to lyx
25 # * options: use scons -h for details about parameters, the most important
26 # one is frontend=qt3|qt4.
27 # * qt3 is used by default on linux, cygwin and mac
28 # * qt4 is used by default on win32/mingw
30 # File layouts (Important):
31 # * Unless you specify builddir=dir, building will happen
32 # in $BUILDDIR = $mode, which can be debug or release
33 # * $BUILDDIR has subdirectories
34 # libs: all intermediate libraries
35 # boost: boost libraries, if boost=included is used
37 # * lyx executable will be in directories like debug/linux-qt3
40 # * scons --config=force
41 # force re-configuration (use scons -H for details)
43 # * check config.log to see why config has failed
45 # * use extra_inc_path, extra_lib_path, qt_dir, qt_inc_path
46 # qt_lib_path to help locate qt and other libraries
47 # (there are extra_inc_path1, extra_lib_path1 for now)
49 # * (Important) use scons logfile=logfile.log to enable command line
50 # logging. (default is no logging)
53 # * Currently, all scons does is building lyx in
54 # $LYXROOT/$mode/$build_dir/
55 # where $mode is debug or release, $build_dir is the build_dir name
58 # * scons install etc may be added later. Interested contributors can follow
59 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/AccumulateBuilder
61 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/DistTarBuilder
62 # Please also see the commented out code in scons_utils.py
64 # * NSIS support can be found here.
65 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/NsisSconsTool
68 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/RpmHonchoTemp
70 # However, I decide to wait since scons seems to be standardizing these
76 # config/scons_utils.py defines a few utility function
77 sys.path.append('config')
78 import scons_utils as utils
80 SetOption('implicit_cache', 1)
82 #----------------------------------------------------------
83 # Required runtime environment
84 #----------------------------------------------------------
86 # FIXME: I remember lyx requires higher version of python?
87 EnsurePythonVersion(1, 5)
88 # Please use at least 0.96.91 (not 0.96.1)
89 EnsureSConsVersion(0, 96)
91 # determine where I am ...
93 # called as 'scons -f development/scons/SConstruct'
94 if os.path.isfile('SConstruct'):
97 # called as 'cd development/scons; scons'
100 SCONS_DIR = 'development/scons'
102 #----------------------------------------------------------
104 #----------------------------------------------------------
106 # some global settings
107 PACKAGE_VERSION = '1.5.0svn'
109 default_build_mode = 'debug'
112 PACKAGE_BUGREPORT = 'lyx-devel@lists.lyx.org'
114 PACKAGE_TARNAME = 'lyx'
115 PACKAGE_STRING = '%s %s' % (PACKAGE_NAME, PACKAGE_VERSION)
117 default_log_file = 'scons_lyx.log'
119 # FIXME: what is this? (They are used in src/support/package.C.in
120 LOCALEDIR = "../locale/"
121 LYX_DIR = "/usr/local/share/lyx"
123 # platform dependent default build_dir and other settings
125 # I know, somebody would say:
126 # This is TOTALLY wrong! Everything should be automatically
130 platform_name = 'win32'
131 default_frontend = 'qt4'
132 # boost and gettext are unlikely to be installed already
133 default_boost_opt = 'included'
134 default_gettext_opt = 'included'
135 default_pch_opt = False
136 default_with_x = False
137 spell_checker = 'auto'
138 # FIXME: I need to know what exactly is boost_posix
139 # EF: It indicates to boost which API to use (posix or windows).
140 # If not specified, boost tries to figure out by itself, but it may fail.
142 packaging_method = 'windows'
143 elif os.name == 'posix' and sys.platform != 'cygwin':
144 platform_name = sys.platform
145 default_frontend = 'qt3'
146 # try to use system boost/gettext libraries
147 default_boost_opt = 'auto'
148 default_gettext_opt = 'auto'
149 default_pch_opt = False
150 default_with_x = True
152 packaging_method = 'posix'
153 elif os.name == 'posix' and sys.platform == 'cygwin':
154 platform_name = 'cygwin'
155 default_frontend = 'qt3'
156 # force the use of cygwin/boost/gettext
157 default_boost_opt = 'system'
158 default_gettext_opt = 'system'
159 default_pch_opt = False
160 default_with_x = True
162 packaging_method = 'posix'
163 elif os.name == 'darwin':
164 platform_name = 'mac'
165 default_frontend = 'qt3'
167 default_boost_opt = 'included'
168 default_gettext_opt = 'included'
169 default_pch_opt = False
170 default_with_x = False
172 packaging_method = 'msc'
173 else: # unsupported system
174 platform_name = 'others'
175 default_frontend = 'qt3'
177 default_boost_opt = 'included'
178 default_gettext_opt = 'included'
179 default_pch_opt = False
180 default_with_x = True
182 packaging_method = 'posix'
184 #---------------------------------------------------------
186 #----------------------------------------------------------
187 # Note that if you set the options via the command line,
188 # they will be remembered in the file 'options.cache'
190 # NOTE: the scons people are trying to fix scons so that
191 # options like --prefix will be accepted. Right now,
192 # we have to use the KEY=VALUE style of scons
194 if os.path.isfile('options.cache'):
195 print "Getting options from auto-saved options.cache..."
196 print open('options.cache').read()
197 if os.path.isfile('config.py'):
198 print "Getting options from config.py..."
199 print open('config.py').read()
201 opts = Options(['options.cache', 'config.py'])
204 EnumOption('frontend', 'Main GUI',
206 allowed_values = ('xform', 'qt3', 'qt4', 'gtk') ),
207 # debug or release build
208 EnumOption('mode', 'Building method', default_build_mode,
209 allowed_values = ('debug', 'release') ),
212 'Use included, system boost library, or try sytem first.',
215 'auto', # detect boost, if not found, use included
216 'included', # always use included boost
217 'system', # always use system boost, fail if can not find
219 EnumOption('gettext',
220 'Use included, system gettext library, or try sytem first',
223 'auto', # detect gettext, if not found, use included
224 'included', # always use included gettext
225 'system', # always use system gettext, fail if can not find
227 # FIXME: I am not allowed to use '' as default, '.' is not good either.
228 PathOption('qt_dir', 'Path to qt directory', '.'),
229 PathOption('qt_include_path', 'Path to qt include directory', '.'),
230 PathOption('qt_lib_path', 'Path to qt library directory', '.'),
231 # FIXME: I do not know how pch is working. Ignore this option now.
232 BoolOption('pch', '(NA) Whether or not use pch', default_pch_opt),
233 # FIXME: Not implemented yet.
234 BoolOption('version_suffix', '(NA) Whether or not add version suffix', False),
235 # build directory, will replace build_dir if set
236 PathOption('build_dir', 'Build directory', '.'),
237 # extra include and libpath
238 PathOption('extra_inc_path', 'Extra include path', '.'),
239 PathOption('extra_lib_path', 'Extra library path', '.'),
240 PathOption('extra_inc_path1', 'Extra include path', '.'),
241 PathOption('extra_lib_path1', 'Extra library path', '.'),
242 # enable assertion, (config.h has ENABLE_ASSERTIOS
243 BoolOption('assertions', 'Use assertions', True),
244 # enable warning, (config.h has WITH_WARNINGS)
245 BoolOption('warnings', 'Use warnings', True),
246 # enable glib, (config.h has _GLIBCXX_CONCEPT_CHECKS)
247 BoolOption('concept_checks', 'Enable concept checks', True),
248 # FIXME: I do not know what is nls
249 BoolOption('nls', '(NA) Whether or not use native language support', False),
250 # FIXME: not implemented
251 BoolOption('profile', '(NA) Whether or not enable profiling', False),
253 PathOption('prefix', 'install architecture-independent files in PREFIX', '.'),
255 PathOption('exec_prefix', 'install architecture-independent executable files in PREFIX', '.'),
256 # FIXME: not implemented
257 BoolOption('std_debug', '(NA) Whether or not turn on stdlib debug', False),
259 BoolOption('X11', 'Use x11 windows system', default_with_x),
260 # FIXME: not implemented
261 BoolOption('libintl', '(NA) Use libintl library', False),
262 # FIXME: not implemented
263 PathOption('intl_prefix', '(NA) Path to intl library', '.'),
265 ('logfile', 'save commands (not outputs) to logfile', default_log_file),
267 PathOption('aikasurus_path', 'Path to aikasurus library', '.'),
269 EnumOption('spell', 'Choose spell checker to use.', 'auto',
270 allowed_values = ('aspell', 'pspell', 'ispell', 'auto') ),
271 # environment variable can be set as options
272 ('CC', '$CC', 'gcc'),
273 ('CPP', '$CPP', 'gcc -E'),
274 ('CXX', '$CXX', 'g++'),
275 ('CXXCPP', '$CXXCPP', 'g++ -E'),
276 ('CCFLAGS', '$CCFLAGS', ''),
277 ('CPPFLAGS', '$CPPFLAGS', ''),
278 ('CPPPATH', '$CPPPATH', ''),
279 ('LDFLAGS', '$LDFLAGS', ''),
283 #---------------------------------------------------------
284 # Setting up environment
285 #---------------------------------------------------------
287 env = Environment(options = opts)
289 # Determine the frontend to use, which may be loaded
291 frontend = env.get('frontend', default_frontend)
292 use_X11 = env.get('X11', default_with_x)
294 # set environment since I do not really like ENV = os.environ
295 env['ENV']['PATH'] = os.environ.get('PATH')
296 env['ENV']['HOME'] = os.environ.get('HOME')
297 env['TOP_SRC_DIR'] = TOP_SRC_DIR
298 env['SCONS_DIR'] = SCONS_DIR
299 # install to current directory by default
300 env['PREFIX'] = env.get('prefix', '.')
301 if env.has_key('exec_prefix') and env['exec_prefix'] != '.':
302 env['BIN_DIR'] = env['exec_prefix']
304 env['BIN_DIR'] = os.path.join(env['PREFIX'], 'bin')
306 # speed up source file processing
307 #env['CPPSUFFIXES'] = ['.C', '.cc', '.cpp']
308 #env['CXXSUFFIX'] = ['.C']
310 def getEnvVariable(env, name):
311 # first try command line argument (override environment settings)
312 if ARGUMENTS.has_key(name) and ARGUMENTS[name].strip() != '':
313 env[name] = ARGUMENTS[name]
314 # then try environment variable
315 elif os.environ.has_key(name) and os.environ[name].strip() != '':
316 env[name] = os.environ[name]
317 print "Acquiring varaible %s from system environment: %s" % (name, env[name])
319 getEnvVariable(env, 'CC')
320 getEnvVariable(env, 'CPP')
321 getEnvVariable(env, 'CXX')
322 getEnvVariable(env, 'CXXCPP')
323 getEnvVariable(env, 'CCFLAGS')
324 getEnvVariable(env, 'CXXFLAGS')
325 getEnvVariable(env, 'CPPFLAGS')
326 getEnvVariable(env, 'CPPPATH')
327 getEnvVariable(env, 'LDFLAGS')
329 # under windows, scons is confused by .C/.c and uses gcc instead of
330 # g++. I am forcing the use of g++ here. This is expected to change
331 # after lyx renames all .C files to .cpp
332 if platform_name == 'cygwin':
\r
337 # frontend, mode, BUILDDIR and LOCALLIBPATH=BUILDDIR/libs
339 env['frontend'] = frontend
340 env['mode'] = env.get('mode', default_build_mode)
341 # lyx will be built to $build/build_dir so it is possible
342 # to build multiple build_dirs using the same source
343 # $mode can be debug or release
344 if ARGUMENTS.has_key('build_dir'):
345 build_dir = ARGUMENTS['build_dir']
346 env['BUILDDIR'] = build_dir
348 # Determine the name of the build (platform+frontend
349 env['BUILDDIR'] = '#' + env['mode']
350 # all built libraries will go to build_dir/libs
351 # (This is different from the make file approach)
352 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
353 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
356 # QTDIR, QT_LIB_PATH, QT_INC_PATH
358 if platform_name == 'win32':
361 if env.has_key('qt_dir') and env['qt_dir'] != '.':
362 env['QTDIR'] = env['qt_dir']
363 # add path to the qt tools
364 env.AppendUnique(LIBPATH = [os.path.join(env['qt_dir'], 'lib')])
365 env.AppendUnique(CPPPATH = [os.path.join(env['qt_dir'], 'include')])
366 # set environment so that moc etc can be found even if its path is not set properly
367 env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
369 env['QTDIR'] = os.environ.get('QTDIR', '/usr/lib/qt-3.3')
371 if env.has_key('qt_lib_path') and env['qt_lib_path'] != '.':
372 env['QT_LIB_PATH'] = env['qt_lib_path']
374 env['QT_LIB_PATH'] = '$QTDIR/lib'
375 env.AppendUnique(LIBPATH = ['$QT_LIB_PATH'])
376 # qt4 seems to be using pkg_config
377 env.PrependENVPath('PKG_CONFIG_PATH', env.subst('$QT_LIB_PATH'))
379 if env.has_key('qt_inc_path') and env['qt_inc_path'] != '.':
380 env['QT_INC_PATH'] = env['qt_inc_path']
381 elif os.path.isdir(os.path.join(env.subst('$QTDIR'), 'include')):
382 env['QT_INC_PATH'] = '$QTDIR/include'
383 else: # have to guess
384 env['QT_INC_PATH'] = '/usr/include/$frontend/'
385 env.AppendUnique(CPPPATH = env['QT_INC_PATH'])
388 # extra_inc_path and extra_lib_path
390 if env.has_key('extra_inc_path'):
391 env.AppendUnique(CPPPATH = [env['extra_inc_path']])
392 if env.has_key('extra_lib_path'):
393 env.AppendUnique(LIBPATH = [env['extra_lib_path']])
394 if env.has_key('extra_inc_path1'):
395 env.AppendUnique(CPPPATH = [env['extra_inc_path1']])
396 if env.has_key('extra_lib_path1'):
397 env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
398 if env.has_key('aikasurus_path'):
399 env.AppendUnique(LIBPATH = [env['aikasurus_path']])
402 # this is a bit out of place (after auto-configration)
403 # but it is required to do the tests.
404 if platform_name == 'win32':
405 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
407 #----------------------------------------------------------
409 #----------------------------------------------------------
411 conf = Configure(env,
413 'CheckPkgConfig' : utils.checkPkgConfig,
414 'CheckPackage' : utils.checkPackage,
415 'CheckPutenv' : utils.checkPutenv,
416 'CheckIstreambufIterator' : utils.checkIstreambufIterator,
417 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
418 'CheckStdCount' : utils.checkStdCount,
419 'CheckSelectArgType' : utils.checkSelectArgType,
420 'CheckBoostLibraries' : utils.checkBoostLibraries,
424 # pkg-config? (if not, we use hard-coded options)
425 if conf.CheckPkgConfig('0.15.0'):
426 env['HAS_PKG_CONFIG'] = True
428 print 'pkg-config >= 0.1.50 is not found'
429 env['HAS_PKG_CONFIG'] = False
431 # zlib? This is required.
432 if not conf.CheckLibWithHeader('z', 'zlib.h', 'C'):
433 print 'Did not find libz or zlib.h, exiting!'
438 # qt3 does not use pkg_config
439 if env['frontend'] == 'qt3':
440 if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'):
441 print 'Did not find qt libraries, exiting!'
443 elif env['frontend'] == 'qt4':
445 # first: try pkg_config
446 if env['HAS_PKG_CONFIG']:
447 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
448 env['QT4_PKG_CONFIG'] = succ
449 # second: try to link to it
451 # FIXME: under linux, I can test the following perfectly
452 # However, under windows, lib names need to passed as libXXX4.a ...
453 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') or \
454 conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
455 # third: try to look up the path
458 for lib in ['QtCore', 'QtGui']:
459 # windows version has something like QtGui4 ...
460 if not (os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s.a' % lib)) or \
461 os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s4.a' % lib))):
464 # still can not find it
466 print "Qt4 libraries are found."
468 print 'Did not find qt libraries, exiting!'
472 env['SYSTEM_LIBS'] = []
473 if conf.CheckLib('socket'):
474 env['SYSTEM_LIBS'].append('socket')
476 # EF: This is the network services library and provides a
477 # transport-level interface to networking services.
478 if conf.CheckLib('nsl'):
479 env['SYSTEM_LIBS'].append('nsl')
481 # check boost libraries
482 boost_opt = ARGUMENTS.get('boost', default_boost_opt)
483 # check for system boost
485 if boost_opt in ['auto', 'system']:
486 pathes = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
487 sig = conf.CheckBoostLibraries('boost_signals', pathes)
488 reg = conf.CheckBoostLibraries('boost_regex', pathes)
489 fil = conf.CheckBoostLibraries('boost_filesystem', pathes)
490 ios = conf.CheckBoostLibraries('boost_iostreams', pathes)
491 # if any them is not found
492 if ('' in [sig[0], reg[0], fil[0], ios[0]]):
493 if boost_opt == 'system':
494 print "Can not find system boost libraries"
495 print "Please supply a path through extra_lib_path"
496 print "and try again."
499 env['BOOST_LIBRARIES'] = [sig[1], reg[1], fil[1], ios[1]]
500 # assume all boost libraries are in the same path...
502 env.AppendUnique(LIBPATH = [sig[0]])
503 env['INCLUDED_BOOST'] = False
505 # now, auto and succ = false, or included
507 # we do not need to set LIBPATH now.
508 env['BOOST_LIBRARIES'] = ['boost_signals', 'boost_regex',
509 'boost_filesystem', 'boost_iostreams']
510 env['INCLUDED_BOOST'] = True
516 print "Generating ", utils.config_h, "..."
518 # I do not handle all macros in src/config.h.in, rather I am following a list
519 # of *used-by-lyx* macros compiled by Abdelrazak Younes <younes.a@free.fr>
521 # Note: addToConfig etc are defined in scons_util
522 utils.startConfigH(TOP_SRC_DIR)
542 ('io.h', 'HAVE_IO_H', 'c'),
543 ('limits.h', 'HAVE_LIMITS_H', 'c'),
544 ('locale.h', 'HAVE_LOCALE_H', 'c'),
545 ('locale', 'HAVE_LOCALE', 'cxx'),
546 ('process.h', 'HAVE_PROCESS_H', 'c'),
547 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
548 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
549 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
550 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
551 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
552 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
553 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
554 ('utime.h', 'HAVE_UTIME_H', 'c'),
555 ('istream', 'HAVE_ISTREAM', 'cxx'),
556 ('ostream', 'HAVE_OSTREAM', 'cxx'),
557 ('ios', 'HAVE_IOS', 'cxx')
560 for header in headers:
561 if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
562 (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
563 utils.addToConfig('#define %s 1' % header[1], TOP_SRC_DIR)
565 utils.addToConfig('/* #undef %s */' % header[1], TOP_SRC_DIR)
586 ('open', 'HAVE_OPEN'),
587 ('close', 'HAVE_CLOSE'),
588 ('popen', 'HAVE_POPEN'),
589 ('pclose', 'HAVE_PCLOSE'),
590 ('_open', 'HAVE__OPEN'),
591 ('_close', 'HAVE__CLOSE'),
592 ('_popen', 'HAVE__POPEN'),
593 ('_pclose', 'HAVE__PCLOSE'),
594 ('getpid', 'HAVE_GETPID'),
595 ('_getpid', 'HAVE__GETPID'),
596 ('mkdir', 'HAVE_MKDIR'),
597 ('_mkdir', 'HAVE__MKDIR'),
598 ('mktemp', 'HAVE_MKTEMP'),
599 ('mkstemp', 'HAVE_MKSTEMP'),
600 ('strerror', 'HAVE_STRERROR'),
601 ('fcntl', 'HAVE_FCNTL')
604 for func in functions:
605 if conf.CheckFunc(func[0]):
606 utils.addToConfig('#define %s 1' % func[1], TOP_SRC_DIR)
608 utils.addToConfig('/* #undef %s */' % func[1], TOP_SRC_DIR)
613 utils.addToConfig('#define PACKAGE "%s"' % PACKAGE, TOP_SRC_DIR)
614 utils.addToConfig('#define PACKAGE_VERSION "%s"' % PACKAGE_VERSION, TOP_SRC_DIR)
616 utils.addToConfig('#define DEVEL_VERSION 1', TOP_SRC_DIR)
621 # _GLIBCXX_CONCEPT_CHECKS
623 # items are (ENV, ARGUMENTS)
625 ('ENABLE_ASSERTIONS', 'assertions'),
626 ('ENABLE_NLS', 'nls'),
627 ('WITH_WARNINGS', 'warnings'),
628 ('_GLIBCXX_CONCEPT_CHECKS', 'concept_checks'),
632 if (env.has_key(val[0]) and env[val[0]]) or \
633 ARGUMENTS.get(val[1]):
634 utils.addToConfig('#define %s 1' % val[0], TOP_SRC_DIR)
636 utils.addToConfig('/* #undef %s */' % val[0], TOP_SRC_DIR)
639 env['EXTRA_LIBS'] = []
641 # AIKSAURUS_H_LOCATION
642 if conf.CheckLib('Aiksaurus'):
643 utils.addToConfig("#define HAVE_LIBAIKSAURUS 1", TOP_SRC_DIR)
644 if (conf.CheckCXXHeader("Aiksaurus.h")):
645 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus.h>", TOP_SRC_DIR)
646 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
647 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus/Aiksaurus.h>", TOP_SRC_DIR)
649 utils.addToConfig("#define AIKSAURUS_H_LOCATION", TOP_SRC_DIR)
650 env['EXTRA_LIBS'].append('Aiksaurus')
656 # determine headers to use
657 spell_engine = ARGUMENTS.get('spell', 'auto')
658 spell_detected = False
659 if spell_engine in ['auto', 'aspell'] and \
660 conf.CheckLib('aspell'):
661 utils.addToConfig('#define USE_ASPELL 1', TOP_SRC_DIR)
662 env['USE_ASPELL'] = True
663 env['EXTRA_LIBS'].append('aspell')
664 spell_detected = True
665 elif spell_engine in ['auto', 'pspell'] and \
666 conf.CheckLib('pspell'):
667 utils.addToConfig('#define USE_PSPELL 1', TOP_SRC_DIR)
668 env['USE_PSPELL'] = True
669 env['EXTRA_LIBS'].append('pspell')
670 spell_detected = True
671 elif spell_engine in ['auto', 'ispell'] and \
672 conf.CheckLib('ispell'):
673 utils.addToConfig('#define USE_ISPELL 1', TOP_SRC_DIR)
674 env['USE_ISPELL'] = True
675 env['EXTRA_LIBS'].append('ispell')
676 spell_detected = True
678 if not spell_detected:
679 # FIXME: can lyx work without an spell engine
680 if spell_engine == 'auto':
681 print "Warning: Can not locate any spell checker"
683 print "Warning: Can not locate specified spell checker:", spell_engine
685 # USE_POSIX_PACKAGING
686 # USE_MACOSX_PACKAGING
687 # USE_WINDOWS_PACKAGING
688 if packaging_method == 'windows':
689 utils.addToConfig('#define USE_WINDOWS_PACKAGING 1', TOP_SRC_DIR)
690 elif packaging_method == 'posix':
691 utils.addToConfig('#define USE_POSIX_PACKAGING 1', TOP_SRC_DIR)
692 elif packaging_method == 'mac':
693 utils.addToConfig('#define USE_MACOSX_PACKAGING 1', TOP_SRC_DIR)
697 utils.addToConfig('#define BOOST_POSIX 1', TOP_SRC_DIR)
699 utils.addToConfig('/* #undef BOOST_POSIX */', TOP_SRC_DIR)
702 if conf.CheckPutenv():
703 utils.addToConfig('#define HAVE_PUTENV 1', TOP_SRC_DIR)
705 utils.addToConfig('/* #undef HAVE_PUTENV */', TOP_SRC_DIR)
707 # HAVE_DECL_ISTREAMBUF_ITERATOR
708 if conf.CheckIstreambufIterator():
709 utils.addToConfig('#define HAVE_DECL_ISTREAMBUF_ITERATOR 1', TOP_SRC_DIR)
711 utils.addToConfig('/* #undef HAVE_DECL_ISTREAMBUF_ITERATOR */', TOP_SRC_DIR)
713 # MKDIR_TAKES_ONE_ARG
714 if conf.CheckMkdirOneArg():
715 utils.addToConfig('#define MKDIR_TAKES_ONE_ARG 1', TOP_SRC_DIR)
717 utils.addToConfig('/* #undef MKDIR_TAKES_ONE_ARG */', TOP_SRC_DIR)
720 if conf.CheckStdCount():
721 utils.addToConfig('#define HAVE_STD_COUNT 1', TOP_SRC_DIR)
723 utils.addToConfig('/* #undef HAVE_STD_COUNT */', TOP_SRC_DIR)
728 (arg1, arg234, arg5) = conf.CheckSelectArgType()
729 utils.addToConfig('#define SELECT_TYPE_ARG1 %s' % arg1, TOP_SRC_DIR)
730 utils.addToConfig('#define SELECT_TYPE_ARG234 %s' % arg234, TOP_SRC_DIR)
731 utils.addToConfig('#define SELECT_TYPE_ARG5 %s' % arg5, TOP_SRC_DIR)
735 # WANT_GETFILEATTRIBUTESEX_WRAPPER
736 utils.endConfigH(TOP_SRC_DIR)
739 # Finish auto-configuration
742 #----------------------------------------------------------
743 # Now set up our build process accordingly
744 #----------------------------------------------------------
747 # QT_LIB etc (EXTRA_LIBS holds lib for each frontend)
749 # NOTE: Tool('qt') or Tool('qt4') will be loaded later
750 # in their respective directory and specialized env.
752 if frontend == 'qt3':
753 # note: env.Tool('qt') my set QT_LIB to qt
754 env['QT_LIB'] = 'qt-mt'
755 env['EXTRA_LIBS'] += ['qt-mt']
756 if platform_name == 'cygwin' and use_X11:
757 env['EXTRA_LIBS'] += ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr', 'Xcursor',
758 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 'resolv',
760 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
761 elif frontend == 'qt4':
762 # local qt4 toolset from
763 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
764 if platform_name == "win32":
765 env['QT_LIB'] = ['QtCore4', 'QtGui4']
767 env['QT_LIB'] = ['QtCore', 'QtGui']
768 env['EXTRA_LIBS'] += [x for x in env['QT_LIB']]
770 print "Can not locate qt tools"
771 print "What I get is "
772 print " QTDIR: ", env['QTDIR']
774 if platform_name in ['win32', 'cygwin']:
\r
775 env['SYSTEM_LIBS'] += ['shlwapi', 'z']
777 env['SYSTEM_LIBS'] += ['z']
780 # Build parameters CPPPATH etc
783 env.AppendUnique(CPPPATH = ['$TOP_SRC_DIR/boost', '$TOP_SRC_DIR/src'])
785 # TODO: add (more) appropriate compiling options (-DNDEBUG etc)
786 # for debug/release mode
787 if ARGUMENTS.get('mode', default_build_mode) == 'debug':
788 env.AppendUnique(CCFLAGS = [])
790 env.AppendUnique(CCFLAGS = [])
793 # Customized builders
795 # install customized builders
796 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
797 # FIXME: there must be a better way.
798 env['BUILDERS']['fileCopy'] = Builder(action = utils.env_filecopy)
801 # A Link script for cygwin see
802 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
803 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
806 if platform_name == 'cygwin' and env['frontend'] == 'qt3':
807 ld_script_path = '/usr/lib/qt3/mkspecs/cygwin-g++'
808 ld_script = utils.installCygwinLDScript(ld_script_path)
809 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
810 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
815 # src/support/package.C.in needs the following to replace
816 env['LYX_DIR'] = LYX_DIR
817 env['LOCALEDIR'] = LOCALEDIR
818 env['TOP_SRCDIR'] = str(Dir('#'))
819 env['PROGRAM_SUFFIX'] = PROGRAM_SUFFIX
820 # needed by src/version.C.in => src/version.C
821 env['PACKAGE_VERSION'] = PACKAGE_VERSION
822 # fill in the version info
823 env['VERSION_INFO'] = '''Configuration
825 Special build flags: %s
827 C Compiler flags: %s %s
829 C++ Compiler LyX flags: %s
830 C++ Compiler flags: %s %s
832 Linker user flags: %s
834 Builing directory: %s
835 Local library directory: %s
843 LyX binary dir: FIXME
845 ''' % (platform_name,
846 env.subst('$CCFLAGS'), env.subst('$CC'),
847 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
848 env.subst('$CXX'), env.subst('$CXXFLAGS'),
849 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
850 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
851 env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
852 str(env['LIBPATH']), str(env['BOOST_LIBRARIES']),
853 str(env['EXTRA_LIBS']), str(env['SYSTEM_LIBS']),
854 env['frontend'], packaging_method)
856 if env['frontend'] in ['qt3', 'qt4']:
857 env['VERSION_INFO'] += ''' include dir: %s
860 ''' % (env.subst('$QT_INC_PATH'), env.subst('$QT_LIB_PATH'), use_X11)
862 print env['VERSION_INFO']
865 # Mingw command line may be too short for our link usage,
866 # Here we use a trick from scons wiki
867 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
869 # I also would like to add logging (commands only) capacity to the
871 logfile = ARGUMENTS.get('logfile', default_log_file)
872 if logfile != '' or platform_name == 'win32':
874 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
875 info = '''# This is a log of commands used by scons to build lyx
879 ''' % (time.asctime(), ' '.join(sys.argv),
880 env['VERSION_INFO'].replace('\n','\n# ')) )
887 opts.Save('options.cache', env)
888 # -h will print out help info
889 Help(opts.GenerateHelpText(env))
892 #----------------------------------------------------------
894 #----------------------------------------------------------
897 SConsignFile(os.path.abspath('%s/sconsign' % env['BUILDDIR']))
899 env['BUILD_TARGETS'] = BUILD_TARGETS
901 print "Building all targets recursively"
903 env.SConscript('$SCONS_DIR/SConscript', duplicate = 0)