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', ''),
282 # Determine the frontend to use
283 frontend = ARGUMENTS.get('frontend', default_frontend)
284 use_X11 = ARGUMENTS.get('X11', default_with_x)
286 #---------------------------------------------------------
287 # Setting up environment
288 #---------------------------------------------------------
290 env = Environment(options = opts)
292 # set environment since I do not really like ENV = os.environ
293 env['ENV']['PATH'] = os.environ.get('PATH')
294 env['ENV']['HOME'] = os.environ.get('HOME')
295 env['TOP_SRC_DIR'] = TOP_SRC_DIR
296 env['SCONS_DIR'] = SCONS_DIR
297 # install to current directory by default
298 env['PREFIX'] = ARGUMENTS.get('prefix', '.')
299 env['BIN_DIR'] = ARGUMENTS.get('exec_prefix',
300 os.path.join(env['PREFIX'], 'bin'))
302 # speed up source file processing
303 #env['CPPSUFFIXES'] = ['.C', '.cc', '.cpp']
304 #env['CXXSUFFIX'] = ['.C']
306 def getEnvVariable(env, name):
307 # first try command line argument (override environment settings)
308 if ARGUMENTS.has_key(name) and ARGUMENTS[name].strip() != '':
309 env[name] = ARGUMENTS[name]
310 # then try environment variable
311 elif os.environ.has_key(name) and os.environ[name].strip() != '':
312 env[name] = os.environ[name]
313 print "Acquiring varaible %s from system environment: %s" % (name, env[name])
315 getEnvVariable(env, 'CC')
316 getEnvVariable(env, 'CPP')
317 getEnvVariable(env, 'CXX')
318 getEnvVariable(env, 'CXXCPP')
319 getEnvVariable(env, 'CCFLAGS')
320 getEnvVariable(env, 'CXXFLAGS')
321 getEnvVariable(env, 'CPPFLAGS')
322 getEnvVariable(env, 'CPPPATH')
323 getEnvVariable(env, 'LDFLAGS')
325 # under windows, scons is confused by .C/.c and uses gcc instead of
326 # g++. I am forcing the use of g++ here. This is expected to change
327 # after lyx renames all .C files to .cpp
328 if platform_name in ['win32', 'cygwin']:
333 # frontend, mode, BUILDDIR and LOCALLIBPATH=BUILDDIR/libs
335 env['frontend'] = frontend
336 env['mode'] = ARGUMENTS.get('mode', default_build_mode)
337 # lyx will be built to $build/build_dir so it is possible
338 # to build multiple build_dirs using the same source
339 # $mode can be debug or release
340 if ARGUMENTS.has_key('build_dir'):
341 build_dir = ARGUMENTS['build_dir']
342 env['BUILDDIR'] = build_dir
344 # Determine the name of the build (platform+frontend
345 env['BUILDDIR'] = '#' + env['mode']
346 # all built libraries will go to build_dir/libs
347 # (This is different from the make file approach)
348 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
349 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
352 # QTDIR, QT_LIB_PATH, QT_INC_PATH
354 if platform_name == 'win32':
357 if ARGUMENTS.has_key('qt_dir'):
358 env['QTDIR'] = ARGUMENTS['qt_dir']
359 # add path to the qt tools
360 env.AppendUnique(LIBPATH = [os.path.join(ARGUMENTS['qt_dir'], 'lib')])
361 env.AppendUnique(CPPPATH = [os.path.join(ARGUMENTS['qt_dir'], 'include')])
362 # set environment so that moc etc can be found even if its path is not set properly
363 env.PrependENVPath('PATH', os.path.join(ARGUMENTS['qt_dir'], 'bin'))
365 env['QTDIR'] = os.environ.get('QTDIR', '/usr/lib/qt-3.3')
367 if ARGUMENTS.has_key('qt_lib_path'):
368 env['QT_LIB_PATH'] = ARGUMENTS['qt_lib_path']
370 env['QT_LIB_PATH'] = '$QTDIR/lib'
371 env.AppendUnique(LIBPATH = ['$QT_LIB_PATH'])
372 # qt4 seems to be using pkg_config
373 env.PrependENVPath('PKG_CONFIG_PATH', env.subst('$QT_LIB_PATH'))
375 if ARGUMENTS.has_key('qt_inc_path'):
376 env['QT_INC_PATH'] = ARGUMENTS['qt_inc_path']
377 elif os.path.isdir(os.path.join(env.subst('$QTDIR'), 'include')):
378 env['QT_INC_PATH'] = '$QTDIR/include'
379 else: # have to guess
380 env['QT_INC_PATH'] = '/usr/include/$frontend/'
381 env.AppendUnique(CPPPATH = env['QT_INC_PATH'])
384 # extra_inc_path and extra_lib_path
386 if ARGUMENTS.has_key('extra_inc_path'):
387 env.AppendUnique(CPPPATH = [ARGUMENTS['extra_inc_path']])
388 if ARGUMENTS.has_key('extra_lib_path'):
389 env.AppendUnique(LIBPATH = [ARGUMENTS['extra_lib_path']])
390 if ARGUMENTS.has_key('extra_inc_path1'):
391 env.AppendUnique(CPPPATH = [ARGUMENTS['extra_inc_path1']])
392 if ARGUMENTS.has_key('extra_lib_path1'):
393 env.AppendUnique(LIBPATH = [ARGUMENTS['extra_lib_path1']])
394 if ARGUMENTS.has_key('aikasurus_path'):
395 env.AppendUnique(LIBPATH = [ARGUMENTS['aikasurus_path']])
398 # this is a bit out of place (after auto-configration)
399 # but it is required to do the tests.
400 if platform_name == 'win32':
401 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
403 #----------------------------------------------------------
405 #----------------------------------------------------------
407 conf = Configure(env,
409 'CheckPkgConfig' : utils.checkPkgConfig,
410 'CheckPackage' : utils.checkPackage,
411 'CheckPutenv' : utils.checkPutenv,
412 'CheckIstreambufIterator' : utils.checkIstreambufIterator,
413 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
414 'CheckStdCount' : utils.checkStdCount,
415 'CheckSelectArgType' : utils.checkSelectArgType,
416 'CheckBoostLibraries' : utils.checkBoostLibraries,
420 # pkg-config? (if not, we use hard-coded options)
421 if conf.CheckPkgConfig('0.15.0'):
422 env['HAS_PKG_CONFIG'] = True
424 print 'pkg-config >= 0.1.50 is not found'
425 env['HAS_PKG_CONFIG'] = False
427 # zlib? This is required.
428 if not conf.CheckLibWithHeader('z', 'zlib.h', 'C'):
429 print 'Did not find libz or zlib.h, exiting!'
434 # qt3 does not use pkg_config
435 if env['frontend'] == 'qt3':
436 if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'):
437 print 'Did not find qt libraries, exiting!'
439 elif env['frontend'] == 'qt4':
441 # first: try pkg_config
442 if env['HAS_PKG_CONFIG']:
443 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
444 env['QT4_PKG_CONFIG'] = succ
445 # second: try to link to it
447 # FIXME: under linux, I can test the following perfectly
448 # However, under windows, lib names need to passed as libXXX4.a ...
449 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') or \
450 conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
451 # third: try to look up the path
454 for lib in ['QtCore', 'QtGui', 'Qt3Support']:
455 # windows version has something like QtGui4 ...
456 if not (os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s.a' % lib)) or \
457 os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s4.a' % lib))):
460 # still can not find it
462 print "Qt4 libraries are found."
464 print 'Did not find qt libraries, exiting!'
468 env['socket_libs'] = []
469 if conf.CheckLib('socket'):
470 env.AppendUnique(socket_libs = ['socket'])
472 # FIXME: What is nsl, is it related to socket?
473 if conf.CheckLib('nsl'):
474 env.AppendUnique(socket_libs = ['nsl'])
476 # check boost libraries
477 boost_opt = ARGUMENTS.get('boost', default_boost_opt)
478 # check for system boost
480 if boost_opt in ['auto', 'system']:
481 pathes = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
482 sig = conf.CheckBoostLibraries('boost_signals', pathes)
483 reg = conf.CheckBoostLibraries('boost_regex', pathes)
484 fil = conf.CheckBoostLibraries('boost_filesystem', pathes)
485 ios = conf.CheckBoostLibraries('boost_iostreams', pathes)
486 # if any them is not found
487 if ('' in [sig[0], reg[0], fil[0], ios[0]]):
488 if boost_opt == 'system':
489 print "Can not find system boost libraries"
490 print "Please supply a path through extra_lib_path"
491 print "and try again."
494 env['BOOST_LIBRARIES'] = [sig[1], reg[1], fil[1], ios[1]]
495 # assume all boost libraries are in the same path...
497 env.AppendUnique(LIBPATH = [sig[0]])
498 env['INCLUDED_BOOST'] = False
500 # now, auto and succ = false, or included
502 # we do not need to set LIBPATH now.
503 env['BOOST_LIBRARIES'] = ['boost_signals', 'boost_regex',
504 'boost_filesystem', 'boost_iostreams']
505 env['INCLUDED_BOOST'] = True
511 print "Generating ", utils.config_h, "..."
513 # I do not handle all macros in src/config.h.in, rather I am following a list
514 # of *used-by-lyx* macros compiled by Abdelrazak Younes <younes.a@free.fr>
516 # Note: addToConfig etc are defined in scons_util
517 utils.startConfigH(TOP_SRC_DIR)
537 ('io.h', 'HAVE_IO_H', 'c'),
538 ('limits.h', 'HAVE_LIMITS_H', 'c'),
539 ('locale.h', 'HAVE_LOCALE_H', 'c'),
540 ('locale', 'HAVE_LOCALE', 'cxx'),
541 ('process.h', 'HAVE_PROCESS_H', 'c'),
542 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
543 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
544 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
545 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
546 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
547 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
548 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
549 ('utime.h', 'HAVE_UTIME_H', 'c'),
550 ('istream', 'HAVE_ISTREAM', 'cxx'),
551 ('ostream', 'HAVE_OSTREAM', 'cxx'),
552 ('ios', 'HAVE_IOS', 'cxx')
555 for header in headers:
556 if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
557 (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
558 utils.addToConfig('#define %s 1' % header[1], TOP_SRC_DIR)
560 utils.addToConfig('/* #undef %s */' % header[1], TOP_SRC_DIR)
580 ('open', 'HAVE_OPEN'),
581 ('close', 'HAVE_CLOSE'),
582 ('popen', 'HAVE_POPEN'),
583 ('pclose', 'HAVE_PCLOSE'),
584 ('_open', 'HAVE__OPEN'),
585 ('_close', 'HAVE__CLOSE'),
586 ('_popen', 'HAVE__POPEN'),
587 ('_pclose', 'HAVE__PCLOSE'),
588 ('getpid', 'HAVE_GETPID'),
589 ('_getpid', 'HAVE__GETPID'),
590 ('mkdir', 'HAVE_MKDIR'),
591 ('_mkdir', 'HAVE__MKDIR'),
592 ('mktemp', 'HAVE_MKTEMP'),
593 ('mkstemp', 'HAVE_MKSTEMP'),
594 ('strerror', 'HAVE_STRERROR')
597 for func in functions:
598 if conf.CheckFunc(func[0]):
599 utils.addToConfig('#define %s 1' % func[1], TOP_SRC_DIR)
601 utils.addToConfig('/* #undef %s */' % func[1], TOP_SRC_DIR)
606 utils.addToConfig('#define PACKAGE "%s"' % PACKAGE, TOP_SRC_DIR)
607 utils.addToConfig('#define PACKAGE_VERSION "%s"' % PACKAGE_VERSION, TOP_SRC_DIR)
609 utils.addToConfig('#define DEVEL_VERSION 1', TOP_SRC_DIR)
614 # _GLIBCXX_CONCEPT_CHECKS
616 # items are (ENV, ARGUMENTS)
618 ('ENABLE_ASSERTIONS', 'assertions'),
619 ('ENABLE_NLS', 'nls'),
620 ('WITH_WARNINGS', 'warnings'),
621 ('_GLIBCXX_CONCEPT_CHECKS', 'concept_checks'),
625 if (env.has_key(val[0]) and env[val[0]]) or \
626 ARGUMENTS.get(val[1]):
627 utils.addToConfig('#define %s 1' % val[0], TOP_SRC_DIR)
629 utils.addToConfig('/* #undef %s */' % val[0], TOP_SRC_DIR)
632 env['EXTRA_LIBS'] = []
634 # AIKSAURUS_H_LOCATION
635 if conf.CheckLib('Aiksaurus'):
636 utils.addToConfig("#define HAVE_LIBAIKSAURUS 1", TOP_SRC_DIR)
637 if (conf.CheckCXXHeader("Aiksaurus.h")):
638 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus.h>", TOP_SRC_DIR)
639 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
640 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus/Aiksaurus.h>", TOP_SRC_DIR)
642 utils.addToConfig("#define AIKSAURUS_H_LOCATION", TOP_SRC_DIR)
643 env['EXTRA_LIBS'].append('Aiksaurus')
649 # determine headers to use
650 spell_engine = ARGUMENTS.get('spell', 'auto')
651 spell_detected = False
652 if spell_engine in ['auto', 'aspell'] and \
653 conf.CheckLib('aspell'):
654 utils.addToConfig('#define USE_ASPELL 1', TOP_SRC_DIR)
655 env['USE_ASPELL'] = True
656 env['EXTRA_LIBS'].append('aspell')
657 spell_detected = True
658 elif spell_engine in ['auto', 'pspell'] and \
659 conf.CheckLib('pspell'):
660 utils.addToConfig('#define USE_PSPELL 1', TOP_SRC_DIR)
661 env['USE_PSPELL'] = True
662 env['EXTRA_LIBS'].append('pspell')
663 spell_detected = True
664 elif spell_engine in ['auto', 'ispell'] and \
665 conf.CheckLib('ispell'):
666 utils.addToConfig('#define USE_ISPELL 1', TOP_SRC_DIR)
667 env['USE_ISPELL'] = True
668 env['EXTRA_LIBS'].append('ispell')
669 spell_detected = True
671 if not spell_detected:
672 # FIXME: can lyx work without an spell engine
673 if spell_engine == 'auto':
674 print "Warning: Can not locate any spell checker"
676 print "Warning: Can not locate specified spell checker:", spell_engine
678 # USE_POSIX_PACKAGING
679 # USE_MACOSX_PACKAGING
680 # USE_WINDOWS_PACKAGING
681 if packaging_method == 'windows':
682 utils.addToConfig('#define USE_WINDOWS_PACKAGING 1', TOP_SRC_DIR)
683 elif packaging_method == 'posix':
684 utils.addToConfig('#define USE_POSIX_PACKAGING 1', TOP_SRC_DIR)
685 elif packaging_method == 'mac':
686 utils.addToConfig('#define USE_MACOSX_PACKAGING 1', TOP_SRC_DIR)
690 utils.addToConfig('#define BOOST_POSIX 1', TOP_SRC_DIR)
692 utils.addToConfig('/* #undef BOOST_POSIX */', TOP_SRC_DIR)
695 if conf.CheckPutenv():
696 utils.addToConfig('#define HAVE_PUTENV 1', TOP_SRC_DIR)
698 utils.addToConfig('/* #undef HAVE_PUTENV */', TOP_SRC_DIR)
700 # HAVE_DECL_ISTREAMBUF_ITERATOR
701 if conf.CheckIstreambufIterator():
702 utils.addToConfig('#define HAVE_DECL_ISTREAMBUF_ITERATOR 1', TOP_SRC_DIR)
704 utils.addToConfig('/* #undef HAVE_DECL_ISTREAMBUF_ITERATOR */', TOP_SRC_DIR)
706 # MKDIR_TAKES_ONE_ARG
707 if conf.CheckMkdirOneArg():
708 utils.addToConfig('#define MKDIR_TAKES_ONE_ARG 1', TOP_SRC_DIR)
710 utils.addToConfig('/* #undef MKDIR_TAKES_ONE_ARG */', TOP_SRC_DIR)
713 if conf.CheckStdCount():
714 utils.addToConfig('#define HAVE_STD_COUNT 1', TOP_SRC_DIR)
716 utils.addToConfig('/* #undef HAVE_STD_COUNT */', TOP_SRC_DIR)
721 (arg1, arg234, arg5) = conf.CheckSelectArgType()
722 utils.addToConfig('#define SELECT_TYPE_ARG1 %s' % arg1, TOP_SRC_DIR)
723 utils.addToConfig('#define SELECT_TYPE_ARG234 %s' % arg234, TOP_SRC_DIR)
724 utils.addToConfig('#define SELECT_TYPE_ARG5 %s' % arg5, TOP_SRC_DIR)
728 # WANT_GETFILEATTRIBUTESEX_WRAPPER
729 utils.endConfigH(TOP_SRC_DIR)
732 # Finish auto-configuration
735 #----------------------------------------------------------
736 # Now set up our build process accordingly
737 #----------------------------------------------------------
740 # QT_LIB etc (EXTRA_LIBS holds lib for each frontend)
742 # NOTE: Tool('qt') or Tool('qt4') will be loaded later
743 # in their respective directory and specialized env.
745 if frontend == 'qt3':
746 # note: env.Tool('qt') my set QT_LIB to qt
747 env['QT_LIB'] = 'qt-mt'
748 env['EXTRA_LIBS'] += ['qt-mt']
749 if platform_name == 'cygwin' and use_X11:
750 env['EXTRA_LIBS'] += ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr', 'Xcursor',
751 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 'resolv',
753 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
754 elif frontend == 'qt4':
755 # local qt4 toolset from
756 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
757 if platform_name == "win32":
758 env['QT_LIB'] = ['QtCore4', 'QtGui4', 'Qt3Support4']
760 env['QT_LIB'] = ['QtCore', 'QtGui', 'Qt3Support']
761 env['EXTRA_LIBS'] += [x for x in env['QT_LIB']]
763 print "Can not locate qt tools"
764 print "What I get is "
765 print " QTDIR: ", env['QTDIR']
767 if platform_name == 'win32':
768 env['SYSTEM_LIBS'] = ['shlwapi', 'zlib1']
769 elif platform_name == 'cygwin':
770 env['SYSTEM_LIBS'] = ['shlwapi', 'z']
772 env['SYSTEM_LIBS'] = ['z']
775 # Build parameters CPPPATH etc
778 env.AppendUnique(CPPPATH = ['$TOP_SRC_DIR/boost', '$TOP_SRC_DIR/src'])
780 # TODO: add (more) appropriate compiling options (-DNDEBUG etc)
781 # for debug/release mode
782 if ARGUMENTS.get('mode', default_build_mode) == 'debug':
783 env.AppendUnique(CCFLAGS = [])
785 env.AppendUnique(CCFLAGS = [])
788 # Customized builders
790 # install customized builders
791 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
792 # FIXME: there must be a better way.
793 env['BUILDERS']['fileCopy'] = Builder(action = utils.env_filecopy)
795 env['BUILDERS']['installProg'] = Builder(action = utils.env_installProg)
796 env['BUILDERS']['installFile'] = Builder(action = utils.env_installFile)
799 # A Link script for cygwin see
800 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
801 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
804 if platform_name == 'cygwin' and env['frontend'] == 'qt3':
805 ld_script_path = '/usr/lib/qt3/mkspecs/cygwin-g++'
806 ld_script = utils.installCygwinLDScript(ld_script_path)
807 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
808 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
813 # src/support/package.C.in needs the following to replace
814 env['LYX_DIR'] = LYX_DIR
815 env['LOCALEDIR'] = LOCALEDIR
816 env['TOP_SRCDIR'] = str(Dir('#'))
817 env['PROGRAM_SUFFIX'] = PROGRAM_SUFFIX
818 # needed by src/version.C.in => src/version.C
819 env['PACKAGE_VERSION'] = PACKAGE_VERSION
820 # fill in the version info
821 env['VERSION_INFO'] = '''Configuration
823 Special build flags: %s
825 C Compiler flags: %s %s
827 C++ Compiler LyX flags: %s
828 C++ Compiler flags: %s %s
830 Linker user flags: %s
832 Builing directory: %s
833 Local library directory: %s
841 LyX binary dir: FIXME
843 ''' % (platform_name,
844 env.subst('$CCFLAGS'), env.subst('$CC'),
845 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
846 env.subst('$CXX'), env.subst('$CXXFLAGS'),
847 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
848 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
849 env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
850 str(env['LIBPATH']), str(env['BOOST_LIBRARIES']),
851 str(env['EXTRA_LIBS']), str(env['SYSTEM_LIBS']),
852 env['frontend'], packaging_method)
854 if env['frontend'] in ['qt3', 'qt4']:
855 env['VERSION_INFO'] += ''' include dir: %s
858 ''' % (env.subst('$QT_INC_PATH'), env.subst('$QT_LIB_PATH'), use_X11)
860 print env['VERSION_INFO']
863 # Mingw command line may be too short for our link usage,
864 # Here we use a trick from scons wiki
865 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
867 # I also would like to add logging (commands only) capacity to the
869 logfile = ARGUMENTS.get('logfile', default_log_file)
870 if logfile != '' or platform_name == 'win32':
872 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
873 info = '''# This is a log of commands used by scons to build lyx
877 ''' % (time.asctime(), ' '.join(sys.argv),
878 env['VERSION_INFO'].replace('\n','\n# ')) )
885 opts.Save('options.cache', env)
886 # -h will print out help info
887 Help(opts.GenerateHelpText(env))
891 #----------------------------------------------------------
893 #----------------------------------------------------------
896 SConsignFile(os.path.abspath('%s/sconsign' % env['BUILDDIR']))
898 print "Building all targets recursively"
900 env.SConscript('$SCONS_DIR/SConscript', duplicate = 0)