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 share_dir = 'Resources'
144 man_dir = 'Resouces/man/man1'
145 locale_dir = 'Resources/locale'
146 elif os.name == 'posix' and sys.platform != 'cygwin':
147 platform_name = sys.platform
148 default_frontend = 'qt3'
149 # try to use system boost/gettext libraries
150 default_boost_opt = 'auto'
151 default_gettext_opt = 'auto'
152 default_pch_opt = False
153 default_with_x = True
155 packaging_method = 'posix'
156 share_dir = 'share/lyx'
158 locale_dir = 'share/locale'
159 elif os.name == 'posix' and sys.platform == 'cygwin':
160 platform_name = 'cygwin'
161 default_frontend = 'qt3'
162 # force the use of cygwin/boost/gettext
163 default_boost_opt = 'system'
164 default_gettext_opt = 'system'
165 default_pch_opt = False
166 default_with_x = True
168 packaging_method = 'posix'
169 share_dir = 'share/lyx'
171 locale_dir = 'share/locale'
172 elif os.name == 'darwin':
173 platform_name = 'mac'
174 default_frontend = 'qt3'
176 default_boost_opt = 'included'
177 default_gettext_opt = 'included'
178 default_pch_opt = False
179 default_with_x = False
181 packaging_method = 'msc'
182 share_dir = 'Resources'
183 man_dir = 'Resouces/man/man1'
184 locale_dir = 'Resources/locale'
185 else: # unsupported system
186 platform_name = 'others'
187 default_frontend = 'qt3'
189 default_boost_opt = 'included'
190 default_gettext_opt = 'included'
191 default_pch_opt = False
192 default_with_x = True
194 packaging_method = 'posix'
195 share_dir = 'share/lyx'
197 locale_dir = 'share/locale'
199 #---------------------------------------------------------
201 #----------------------------------------------------------
202 # Note that if you set the options via the command line,
203 # they will be remembered in the file 'options.cache'
205 # NOTE: the scons people are trying to fix scons so that
206 # options like --prefix will be accepted. Right now,
207 # we have to use the KEY=VALUE style of scons
209 if os.path.isfile('options.cache'):
210 print "Getting options from auto-saved options.cache..."
211 print open('options.cache').read()
212 if os.path.isfile('config.py'):
213 print "Getting options from config.py..."
214 print open('config.py').read()
216 opts = Options(['options.cache', 'config.py'])
219 EnumOption('frontend', 'Main GUI',
221 allowed_values = ('xform', 'qt3', 'qt4', 'gtk') ),
222 # debug or release build
223 EnumOption('mode', 'Building method', default_build_mode,
224 allowed_values = ('debug', 'release') ),
227 'Use included, system boost library, or try sytem first.',
230 'auto', # detect boost, if not found, use included
231 'included', # always use included boost
232 'system', # always use system boost, fail if can not find
234 EnumOption('gettext',
235 'Use included, system gettext library, or try sytem first',
238 'auto', # detect gettext, if not found, use included
239 'included', # always use included gettext
240 'system', # always use system gettext, fail if can not find
242 # FIXME: I am not allowed to use '' as default, '.' is not good either.
243 PathOption('qt_dir', 'Path to qt directory', '.'),
244 PathOption('qt_include_path', 'Path to qt include directory', '.'),
245 PathOption('qt_lib_path', 'Path to qt library directory', '.'),
246 # FIXME: I do not know how pch is working. Ignore this option now.
247 BoolOption('pch', '(NA) Whether or not use pch', default_pch_opt),
248 # FIXME: Not implemented yet.
249 BoolOption('version_suffix', '(NA) Whether or not add version suffix', False),
250 # build directory, will replace build_dir if set
251 PathOption('build_dir', 'Build directory', '.'),
252 # extra include and libpath
253 PathOption('extra_inc_path', 'Extra include path', '.'),
254 PathOption('extra_lib_path', 'Extra library path', '.'),
255 PathOption('extra_inc_path1', 'Extra include path', '.'),
256 PathOption('extra_lib_path1', 'Extra library path', '.'),
257 # enable assertion, (config.h has ENABLE_ASSERTIOS
258 BoolOption('assertions', 'Use assertions', True),
259 # enable warning, (config.h has WITH_WARNINGS)
260 BoolOption('warnings', 'Use warnings', True),
261 # enable glib, (config.h has _GLIBCXX_CONCEPT_CHECKS)
262 BoolOption('concept_checks', 'Enable concept checks', True),
263 # FIXME: I do not know what is nls
264 BoolOption('nls', '(NA) Whether or not use native language support', False),
265 # FIXME: not implemented
266 BoolOption('profile', '(NA) Whether or not enable profiling', False),
268 PathOption('prefix', 'install architecture-independent files in PREFIX', '.'),
270 PathOption('exec_prefix', 'install architecture-independent executable files in PREFIX', '.'),
271 # FIXME: not implemented
272 BoolOption('std_debug', '(NA) Whether or not turn on stdlib debug', False),
274 BoolOption('X11', 'Use x11 windows system', default_with_x),
275 # FIXME: not implemented
276 BoolOption('libintl', '(NA) Use libintl library', False),
277 # FIXME: not implemented
278 PathOption('intl_prefix', '(NA) Path to intl library', '.'),
280 ('logfile', 'save commands (not outputs) to logfile', default_log_file),
282 PathOption('aikasurus_path', 'Path to aikasurus library', '.'),
284 EnumOption('spell', 'Choose spell checker to use.', 'auto',
285 allowed_values = ('aspell', 'pspell', 'ispell', 'auto') ),
286 # environment variable can be set as options
287 ('CC', '$CC', 'gcc'),
288 ('CPP', '$CPP', 'gcc -E'),
289 ('CXX', '$CXX', 'g++'),
290 ('CXXCPP', '$CXXCPP', 'g++ -E'),
291 ('CCFLAGS', '$CCFLAGS', ''),
292 ('CPPFLAGS', '$CPPFLAGS', ''),
293 ('CPPPATH', '$CPPPATH', ''),
294 ('LDFLAGS', '$LDFLAGS', ''),
298 #---------------------------------------------------------
299 # Setting up environment
300 #---------------------------------------------------------
302 env = Environment(options = opts)
304 # Determine the frontend to use, which may be loaded
306 frontend = env.get('frontend', default_frontend)
307 use_X11 = env.get('X11', default_with_x)
309 # set environment since I do not really like ENV = os.environ
310 env['ENV']['PATH'] = os.environ.get('PATH')
311 env['ENV']['HOME'] = os.environ.get('HOME')
312 env['TOP_SRC_DIR'] = TOP_SRC_DIR
313 env['SCONS_DIR'] = SCONS_DIR
314 # install to current directory by default
315 env['PREFIX'] = env.get('prefix', '.')
316 if env.has_key('exec_prefix') and env['exec_prefix'] != '.':
317 env['BIN_DIR'] = env['exec_prefix']
319 env['BIN_DIR'] = os.path.join(env['PREFIX'], 'bin')
320 env['SHARE_DIR'] = os.path.join(env['PREFIX'], share_dir)
321 env['MAN_DIR'] = os.path.join(env['PREFIX'], man_dir)
322 env['LOCALE_DIR'] = os.path.join(env['PREFIX'], locale_dir)
324 # speed up source file processing
325 #env['CPPSUFFIXES'] = ['.C', '.cc', '.cpp']
326 #env['CXXSUFFIX'] = ['.C']
328 def getEnvVariable(env, name):
329 # first try command line argument (override environment settings)
330 if ARGUMENTS.has_key(name) and ARGUMENTS[name].strip() != '':
331 env[name] = ARGUMENTS[name]
332 # then try environment variable
333 elif os.environ.has_key(name) and os.environ[name].strip() != '':
334 env[name] = os.environ[name]
335 print "Acquiring varaible %s from system environment: %s" % (name, env[name])
337 getEnvVariable(env, 'CC')
338 getEnvVariable(env, 'CPP')
339 getEnvVariable(env, 'CXX')
340 getEnvVariable(env, 'CXXCPP')
341 getEnvVariable(env, 'CCFLAGS')
342 getEnvVariable(env, 'CXXFLAGS')
343 getEnvVariable(env, 'CPPFLAGS')
344 getEnvVariable(env, 'CPPPATH')
345 getEnvVariable(env, 'LDFLAGS')
347 # under windows, scons is confused by .C/.c and uses gcc instead of
348 # g++. I am forcing the use of g++ here. This is expected to change
349 # after lyx renames all .C files to .cpp
351 # Solaris seems to use gcc for the last step as well, so, to
352 # make sure everyone uses a C++ compiler, linker, I do this for
356 if env.has_key('CXX') and env['CXX'] != '':
357 env['CC'] = env['CXX']
358 env['LINK'] = env['CXX']
364 # frontend, mode, BUILDDIR and LOCALLIBPATH=BUILDDIR/libs
366 env['frontend'] = frontend
367 env['mode'] = env.get('mode', default_build_mode)
368 # lyx will be built to $build/build_dir so it is possible
369 # to build multiple build_dirs using the same source
370 # $mode can be debug or release
371 if ARGUMENTS.has_key('build_dir'):
372 build_dir = ARGUMENTS['build_dir']
373 env['BUILDDIR'] = build_dir
375 # Determine the name of the build (platform+frontend
376 env['BUILDDIR'] = '#' + env['mode']
377 # all built libraries will go to build_dir/libs
378 # (This is different from the make file approach)
379 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
380 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
383 # QTDIR, QT_LIB_PATH, QT_INC_PATH
385 if platform_name == 'win32':
388 if env.has_key('qt_dir') and env['qt_dir'] != '.':
389 env['QTDIR'] = env['qt_dir']
390 # add path to the qt tools
391 env.AppendUnique(LIBPATH = [os.path.join(env['qt_dir'], 'lib')])
392 env.AppendUnique(CPPPATH = [os.path.join(env['qt_dir'], 'include')])
393 # set environment so that moc etc can be found even if its path is not set properly
394 env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
396 env['QTDIR'] = os.environ.get('QTDIR', '/usr/lib/qt-3.3')
398 if env.has_key('qt_lib_path') and env['qt_lib_path'] != '.':
399 env['QT_LIB_PATH'] = env['qt_lib_path']
401 env['QT_LIB_PATH'] = '$QTDIR/lib'
402 env.AppendUnique(LIBPATH = ['$QT_LIB_PATH'])
403 # qt4 seems to be using pkg_config
404 env.PrependENVPath('PKG_CONFIG_PATH', env.subst('$QT_LIB_PATH'))
406 if env.has_key('qt_inc_path') and env['qt_inc_path'] != '.':
407 env['QT_INC_PATH'] = env['qt_inc_path']
408 elif os.path.isdir(os.path.join(env.subst('$QTDIR'), 'include')):
409 env['QT_INC_PATH'] = '$QTDIR/include'
410 else: # have to guess
411 env['QT_INC_PATH'] = '/usr/include/$frontend/'
412 env.AppendUnique(CPPPATH = env['QT_INC_PATH'])
415 # extra_inc_path and extra_lib_path
417 if env.has_key('extra_inc_path'):
418 env.AppendUnique(CPPPATH = [env['extra_inc_path']])
419 if env.has_key('extra_lib_path'):
420 env.AppendUnique(LIBPATH = [env['extra_lib_path']])
421 if env.has_key('extra_inc_path1'):
422 env.AppendUnique(CPPPATH = [env['extra_inc_path1']])
423 if env.has_key('extra_lib_path1'):
424 env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
425 if env.has_key('aikasurus_path'):
426 env.AppendUnique(LIBPATH = [env['aikasurus_path']])
429 # this is a bit out of place (after auto-configration)
430 # but it is required to do the tests.
431 if platform_name == 'win32':
432 env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
434 #----------------------------------------------------------
436 #----------------------------------------------------------
438 conf = Configure(env,
440 'CheckPkgConfig' : utils.checkPkgConfig,
441 'CheckPackage' : utils.checkPackage,
442 'CheckPutenv' : utils.checkPutenv,
443 'CheckIstreambufIterator' : utils.checkIstreambufIterator,
444 'CheckMkdirOneArg' : utils.checkMkdirOneArg,
445 'CheckStdCount' : utils.checkStdCount,
446 'CheckSelectArgType' : utils.checkSelectArgType,
447 'CheckBoostLibraries' : utils.checkBoostLibraries,
451 # pkg-config? (if not, we use hard-coded options)
452 if conf.CheckPkgConfig('0.15.0'):
453 env['HAS_PKG_CONFIG'] = True
455 print 'pkg-config >= 0.1.50 is not found'
456 env['HAS_PKG_CONFIG'] = False
458 # zlib? This is required.
459 if not conf.CheckLibWithHeader('z', 'zlib.h', 'C'):
460 print 'Did not find libz or zlib.h, exiting!'
465 # qt3 does not use pkg_config
466 if env['frontend'] == 'qt3':
467 if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'):
468 print 'Did not find qt libraries, exiting!'
470 elif env['frontend'] == 'qt4':
472 # first: try pkg_config
473 if env['HAS_PKG_CONFIG']:
474 succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
475 env['QT4_PKG_CONFIG'] = succ
476 # second: try to link to it
478 # FIXME: under linux, I can test the following perfectly
479 # However, under windows, lib names need to passed as libXXX4.a ...
480 succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();') or \
481 conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
482 # third: try to look up the path
485 for lib in ['QtCore', 'QtGui']:
486 # windows version has something like QtGui4 ...
487 if not (os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s.a' % lib)) or \
488 os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s4.a' % lib))):
491 # still can not find it
493 print "Qt4 libraries are found."
495 print 'Did not find qt libraries, exiting!'
499 env['SOCKET_LIBS'] = []
500 if conf.CheckLib('socket'):
501 env['SOCKET_LIBS'].append('socket')
503 # EF: This is the network services library and provides a
504 # transport-level interface to networking services.
505 if conf.CheckLib('nsl'):
506 env['SOCKET_LIBS'].append('nsl')
508 # check boost libraries
509 boost_opt = ARGUMENTS.get('boost', default_boost_opt)
510 # check for system boost
512 if boost_opt in ['auto', 'system']:
513 pathes = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
514 sig = conf.CheckBoostLibraries('boost_signals', pathes)
515 reg = conf.CheckBoostLibraries('boost_regex', pathes)
516 fil = conf.CheckBoostLibraries('boost_filesystem', pathes)
517 ios = conf.CheckBoostLibraries('boost_iostreams', pathes)
518 # if any them is not found
519 if ('' in [sig[0], reg[0], fil[0], ios[0]]):
520 if boost_opt == 'system':
521 print "Can not find system boost libraries"
522 print "Please supply a path through extra_lib_path"
523 print "and try again."
526 env['BOOST_LIBRARIES'] = [sig[1], reg[1], fil[1], ios[1]]
527 # assume all boost libraries are in the same path...
529 env.AppendUnique(LIBPATH = [sig[0]])
530 env['INCLUDED_BOOST'] = False
532 # now, auto and succ = false, or included
534 # we do not need to set LIBPATH now.
535 env['BOOST_LIBRARIES'] = ['boost_signals', 'boost_regex',
536 'boost_filesystem', 'boost_iostreams']
537 env['INCLUDED_BOOST'] = True
543 print "Generating ", utils.config_h, "..."
545 # I do not handle all macros in src/config.h.in, rather I am following a list
546 # of *used-by-lyx* macros compiled by Abdelrazak Younes <younes.a@free.fr>
548 # Note: addToConfig etc are defined in scons_util
549 utils.startConfigH(TOP_SRC_DIR)
569 ('io.h', 'HAVE_IO_H', 'c'),
570 ('limits.h', 'HAVE_LIMITS_H', 'c'),
571 ('locale.h', 'HAVE_LOCALE_H', 'c'),
572 ('locale', 'HAVE_LOCALE', 'cxx'),
573 ('process.h', 'HAVE_PROCESS_H', 'c'),
574 ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
575 ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
576 ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
577 ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
578 ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
579 ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
580 ('unistd.h', 'HAVE_UNISTD_H', 'c'),
581 ('utime.h', 'HAVE_UTIME_H', 'c'),
582 ('istream', 'HAVE_ISTREAM', 'cxx'),
583 ('ostream', 'HAVE_OSTREAM', 'cxx'),
584 ('ios', 'HAVE_IOS', 'cxx')
587 for header in headers:
588 if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
589 (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
590 utils.addToConfig('#define %s 1' % header[1], TOP_SRC_DIR)
592 utils.addToConfig('/* #undef %s */' % header[1], TOP_SRC_DIR)
613 ('open', 'HAVE_OPEN'),
614 ('close', 'HAVE_CLOSE'),
615 ('popen', 'HAVE_POPEN'),
616 ('pclose', 'HAVE_PCLOSE'),
617 ('_open', 'HAVE__OPEN'),
618 ('_close', 'HAVE__CLOSE'),
619 ('_popen', 'HAVE__POPEN'),
620 ('_pclose', 'HAVE__PCLOSE'),
621 ('getpid', 'HAVE_GETPID'),
622 ('_getpid', 'HAVE__GETPID'),
623 ('mkdir', 'HAVE_MKDIR'),
624 ('_mkdir', 'HAVE__MKDIR'),
625 ('mktemp', 'HAVE_MKTEMP'),
626 ('mkstemp', 'HAVE_MKSTEMP'),
627 ('strerror', 'HAVE_STRERROR'),
628 ('fcntl', 'HAVE_FCNTL')
631 for func in functions:
632 if conf.CheckFunc(func[0]):
633 utils.addToConfig('#define %s 1' % func[1], TOP_SRC_DIR)
635 utils.addToConfig('/* #undef %s */' % func[1], TOP_SRC_DIR)
640 utils.addToConfig('#define PACKAGE "%s"' % PACKAGE, TOP_SRC_DIR)
641 utils.addToConfig('#define PACKAGE_VERSION "%s"' % PACKAGE_VERSION, TOP_SRC_DIR)
643 utils.addToConfig('#define DEVEL_VERSION 1', TOP_SRC_DIR)
648 # _GLIBCXX_CONCEPT_CHECKS
650 # items are (ENV, ARGUMENTS)
652 ('ENABLE_ASSERTIONS', 'assertions'),
653 ('ENABLE_NLS', 'nls'),
654 ('WITH_WARNINGS', 'warnings'),
655 ('_GLIBCXX_CONCEPT_CHECKS', 'concept_checks'),
659 if (env.has_key(val[0]) and env[val[0]]) or \
660 ARGUMENTS.get(val[1]):
661 utils.addToConfig('#define %s 1' % val[0], TOP_SRC_DIR)
663 utils.addToConfig('/* #undef %s */' % val[0], TOP_SRC_DIR)
666 env['EXTRA_LIBS'] = []
668 # AIKSAURUS_H_LOCATION
669 if conf.CheckLib('Aiksaurus'):
670 utils.addToConfig("#define HAVE_LIBAIKSAURUS 1", TOP_SRC_DIR)
671 if (conf.CheckCXXHeader("Aiksaurus.h")):
672 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus.h>", TOP_SRC_DIR)
673 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
674 utils.addToConfig("#define AIKSAURUS_H_LOCATION <Aiksaurus/Aiksaurus.h>", TOP_SRC_DIR)
676 utils.addToConfig("#define AIKSAURUS_H_LOCATION", TOP_SRC_DIR)
677 env['EXTRA_LIBS'].append('Aiksaurus')
683 # determine headers to use
684 spell_engine = ARGUMENTS.get('spell', 'auto')
685 spell_detected = False
686 if spell_engine in ['auto', 'aspell'] and \
687 conf.CheckLib('aspell'):
688 utils.addToConfig('#define USE_ASPELL 1', TOP_SRC_DIR)
689 env['USE_ASPELL'] = True
690 env['EXTRA_LIBS'].append('aspell')
691 spell_detected = True
692 elif spell_engine in ['auto', 'pspell'] and \
693 conf.CheckLib('pspell'):
694 utils.addToConfig('#define USE_PSPELL 1', TOP_SRC_DIR)
695 env['USE_PSPELL'] = True
696 env['EXTRA_LIBS'].append('pspell')
697 spell_detected = True
698 elif spell_engine in ['auto', 'ispell'] and \
699 conf.CheckLib('ispell'):
700 utils.addToConfig('#define USE_ISPELL 1', TOP_SRC_DIR)
701 env['USE_ISPELL'] = True
702 env['EXTRA_LIBS'].append('ispell')
703 spell_detected = True
705 if not spell_detected:
706 # FIXME: can lyx work without an spell engine
707 if spell_engine == 'auto':
708 print "Warning: Can not locate any spell checker"
710 print "Warning: Can not locate specified spell checker:", spell_engine
712 # USE_POSIX_PACKAGING
713 # USE_MACOSX_PACKAGING
714 # USE_WINDOWS_PACKAGING
715 if packaging_method == 'windows':
716 utils.addToConfig('#define USE_WINDOWS_PACKAGING 1', TOP_SRC_DIR)
717 elif packaging_method == 'posix':
718 utils.addToConfig('#define USE_POSIX_PACKAGING 1', TOP_SRC_DIR)
719 elif packaging_method == 'mac':
720 utils.addToConfig('#define USE_MACOSX_PACKAGING 1', TOP_SRC_DIR)
724 utils.addToConfig('#define BOOST_POSIX 1', TOP_SRC_DIR)
726 utils.addToConfig('/* #undef BOOST_POSIX */', TOP_SRC_DIR)
729 if conf.CheckPutenv():
730 utils.addToConfig('#define HAVE_PUTENV 1', TOP_SRC_DIR)
732 utils.addToConfig('/* #undef HAVE_PUTENV */', TOP_SRC_DIR)
734 # HAVE_DECL_ISTREAMBUF_ITERATOR
735 if conf.CheckIstreambufIterator():
736 utils.addToConfig('#define HAVE_DECL_ISTREAMBUF_ITERATOR 1', TOP_SRC_DIR)
738 utils.addToConfig('/* #undef HAVE_DECL_ISTREAMBUF_ITERATOR */', TOP_SRC_DIR)
740 # MKDIR_TAKES_ONE_ARG
741 if conf.CheckMkdirOneArg():
742 utils.addToConfig('#define MKDIR_TAKES_ONE_ARG 1', TOP_SRC_DIR)
744 utils.addToConfig('/* #undef MKDIR_TAKES_ONE_ARG */', TOP_SRC_DIR)
747 if conf.CheckStdCount():
748 utils.addToConfig('#define HAVE_STD_COUNT 1', TOP_SRC_DIR)
750 utils.addToConfig('/* #undef HAVE_STD_COUNT */', TOP_SRC_DIR)
755 (arg1, arg234, arg5) = conf.CheckSelectArgType()
756 utils.addToConfig('#define SELECT_TYPE_ARG1 %s' % arg1, TOP_SRC_DIR)
757 utils.addToConfig('#define SELECT_TYPE_ARG234 %s' % arg234, TOP_SRC_DIR)
758 utils.addToConfig('#define SELECT_TYPE_ARG5 %s' % arg5, TOP_SRC_DIR)
762 # WANT_GETFILEATTRIBUTESEX_WRAPPER
763 utils.endConfigH(TOP_SRC_DIR)
766 # Finish auto-configuration
769 #----------------------------------------------------------
770 # Now set up our build process accordingly
771 #----------------------------------------------------------
774 # QT_LIB etc (EXTRA_LIBS holds lib for each frontend)
776 # NOTE: Tool('qt') or Tool('qt4') will be loaded later
777 # in their respective directory and specialized env.
779 if frontend == 'qt3':
780 # note: env.Tool('qt') my set QT_LIB to qt
781 env['QT_LIB'] = 'qt-mt'
782 env['EXTRA_LIBS'] += ['qt-mt']
783 if platform_name == 'cygwin' and use_X11:
784 env['EXTRA_LIBS'] += ['GL', 'Xmu', 'Xi', 'Xrender', 'Xrandr', 'Xcursor',
785 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 'resolv',
787 env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
788 elif frontend == 'qt4':
789 # local qt4 toolset from
790 # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
791 if platform_name == "win32":
792 env['QT_LIB'] = ['QtCore4', 'QtGui4']
794 env['QT_LIB'] = ['QtCore', 'QtGui']
795 env['EXTRA_LIBS'] += [x for x in env['QT_LIB']]
797 print "Can not locate qt tools"
798 print "What I get is "
799 print " QTDIR: ", env['QTDIR']
801 if platform_name in ['win32', 'cygwin']:
\r
802 env['SYSTEM_LIBS'] = ['shlwapi', 'z']
804 env['SYSTEM_LIBS'] = ['z']
807 # Build parameters CPPPATH etc
810 env.AppendUnique(CPPPATH = ['$TOP_SRC_DIR/boost', '$TOP_SRC_DIR/src'])
812 # TODO: add (more) appropriate compiling options (-DNDEBUG etc)
813 # for debug/release mode
814 if ARGUMENTS.get('mode', default_build_mode) == 'debug':
815 env.AppendUnique(CCFLAGS = [])
817 env.AppendUnique(CCFLAGS = [])
820 # Customized builders
822 # install customized builders
823 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
824 # FIXME: there must be a better way.
825 env['BUILDERS']['fileCopy'] = Builder(action = utils.env_filecopy)
828 # A Link script for cygwin see
829 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
830 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
833 if platform_name == 'cygwin' and env['frontend'] == 'qt3':
834 ld_script_path = '/usr/lib/qt3/mkspecs/cygwin-g++'
835 ld_script = utils.installCygwinLDScript(ld_script_path)
836 env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
837 '-Wl,--script,%s' % ld_script, '-Wl,-s'])
842 # src/support/package.C.in needs the following to replace
843 env['LYX_DIR'] = LYX_DIR
844 env['LOCALEDIR'] = LOCALEDIR
845 env['TOP_SRCDIR'] = str(Dir('#'))
846 env['PROGRAM_SUFFIX'] = PROGRAM_SUFFIX
847 # needed by src/version.C.in => src/version.C
848 env['PACKAGE_VERSION'] = PACKAGE_VERSION
849 # fill in the version info
850 env['VERSION_INFO'] = '''Configuration
852 Special build flags: %s
854 C Compiler flags: %s %s
856 C++ Compiler LyX flags: %s
857 C++ Compiler flags: %s %s
859 Linker user flags: %s
861 Builing directory: %s
862 Local library directory: %s
870 LyX binary dir: FIXME
872 ''' % (platform_name,
873 env.subst('$CCFLAGS'), env.subst('$CC'),
874 env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
875 env.subst('$CXX'), env.subst('$CXXFLAGS'),
876 env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
877 env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
878 env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
879 str(env['LIBPATH']), str(env['BOOST_LIBRARIES']),
880 str(env['EXTRA_LIBS']), str(env['SYSTEM_LIBS']),
881 env['frontend'], packaging_method)
883 if env['frontend'] in ['qt3', 'qt4']:
884 env['VERSION_INFO'] += ''' include dir: %s
887 ''' % (env.subst('$QT_INC_PATH'), env.subst('$QT_LIB_PATH'), use_X11)
889 print env['VERSION_INFO']
892 # Mingw command line may be too short for our link usage,
893 # Here we use a trick from scons wiki
894 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
896 # I also would like to add logging (commands only) capacity to the
898 logfile = ARGUMENTS.get('logfile', default_log_file)
899 if logfile != '' or platform_name == 'win32':
901 utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
902 info = '''# This is a log of commands used by scons to build lyx
906 ''' % (time.asctime(), ' '.join(sys.argv),
907 env['VERSION_INFO'].replace('\n','\n# ')) )
914 opts.Save('options.cache', env)
915 # -h will print out help info
916 Help(opts.GenerateHelpText(env))
919 #----------------------------------------------------------
921 #----------------------------------------------------------
924 SConsignFile(os.path.abspath('%s/sconsign' % env['BUILDDIR']))
926 env['BUILD_TARGETS'] = BUILD_TARGETS
928 print "Building all targets recursively"
930 env.SConscript('$SCONS_DIR/SConscript', duplicate = 0)