]> git.lyx.org Git - lyx.git/blob - SConstruct
Glade tweakage: make OK button default in citation dialog
[lyx.git] / SConstruct
1 # vi:filetype=python:expandtab:tabstop=2:shiftwidth=2
2 #
3 # file SConstruct
4
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7
8 # \author Bo Peng
9 # Full author contact details are available in file CREDITS.
10 #
11 #
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)
14 #  
15 #    scons [frontend=qt3|gt4] [boost=included|auto] ...
16 #
17 # Where:
18 #   * use scons -h for details about parameters
19 #   * qt3 is used by default on linux, cygwin and mac
20 #   * qt4 is used by default on win32
21 #
22 # File layouts (Important):
23 #   * Unless you specify builddir=dir, building will happen
24 #     in $BUILDDIR = $mode/$platform-$frontend. E.g., something like
25 #       debug/linux-qt3/
26 #   * All shared libs will be put in $BUILDDIR/libs, e.g.
27 #       debug/linux-qt3/libs
28 #   * lyx executable will be in directories like debug/linux-qt3
29 #  
30 # Hints:
31 #   * scons --config=force
32 #     force re-configuration (use scons -H for details)
33 #   
34 #   * check config.log to see why config has failed
35 #
36 #   * use extra_inc_path, extra_lib_path, qt_dir, qt_inc_path
37 #     qt_lib_path to help locate qt and other libraries
38 #
39 #   * (Important) use scons logfile=logfile.log to enable command line
40 #     logging. (default is no logging)
41 #
42 # Notes:
43 #   * Currently, all scons does is building lyx in
44 #       $LYXROOT/$mode/$build_dir/
45 #     where $mode is debug or release, $build_dir is the build_dir name 
46 #     listed above
47 #
48 #   * scons install etc may be added later. Interested contributors can follow
49 #       http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/AccumulateBuilder
50 #     or
51 #       http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/DistTarBuilder
52 #     Please also see the commented out code in scons_utils.py
53 #       
54 #   * NSIS support can be found here.
55 #     http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/NsisSconsTool
56 #
57 #   * rpm support?
58 #     http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/RpmHonchoTemp
59 #
60 #   However, I decide to wait since scons seems to be standardizing these
61 #   features.
62 #
63
64 import os, sys
65
66 # scons_util defines a few utility function
67 import scons_utils as utils
68
69 #----------------------------------------------------------
70 # Required runtime environment
71 #----------------------------------------------------------
72
73 # FIXME: I remember lyx requires higher version of python?
74 EnsurePythonVersion(1, 5)
75 # Please use at least 0.96.91 (not 0.96.1)
76 EnsureSConsVersion(0, 96)
77
78 #----------------------------------------------------------
79 # Global definitions
80 #----------------------------------------------------------
81
82 # some global settings
83 PACKAGE_VERSION = '1.5.0svn'
84 DEVEL_VERSION = True
85 default_build_mode = 'debug'
86
87 PACKAGE = 'lyx'
88 PACKAGE_BUGREPORT = 'lyx-devel@lists.lyx.org'
89 PACKAGE_NAME = 'LyX'
90 PACKAGE_TARNAME = 'lyx'
91 PACKAGE_STRING = '%s %s' % (PACKAGE_NAME, PACKAGE_VERSION)
92 PROGRAM_SUFFIX = ''
93 config_h = os.path.join('src', 'config.h')
94 default_log_file = 'scons_lyx.log'
95
96 # FIXME: what is this? (They are used in src/support/package.C.in
97 LOCALEDIR = "../locale/"
98 LYX_DIR = "/usr/local/share/lyx"
99
100 # platform dependent default build_dir and other settings
101 #
102 # I know, somebody would say: 
103 #   This is TOTALLY wrong! Everything should be automatically
104 #   determined.
105 #
106 if os.name == 'nt':
107   platform_name = 'win32'
108   default_frontend = 'qt4'
109   # boost and gettext are unlikely to be installed already
110   default_boost_opt = 'included'
111   default_gettext_opt = 'included'
112   default_pch_opt = False
113   default_with_x = False
114   spell_checker = 'auto'
115   # FIXME: I need to know what exactly is boost_posix
116   boost_posix = False
117   packaging_method = 'windows'
118 elif os.name == 'posix' and sys.platform != 'cygwin':
119   platform_name = 'linux'
120   default_frontend = 'qt3'
121   # try to use system boost/gettext libraries
122   default_boost_opt = 'auto'
123   default_gettext_opt = 'auto'
124   default_pch_opt = False
125   default_with_x = True
126   boost_posix = False
127   packaging_method = 'posix'
128 elif os.name == 'posix' and sys.platform == 'cygwin':
129   platform_name = 'cygwin'
130   default_frontend = 'qt3'
131   # force the use of cygwin/boost/gettext
132   default_boost_opt = 'system'
133   default_gettext_opt = 'system'
134   default_pch_opt = False
135   default_with_x = True
136   boost_posix = True
137   packaging_method = 'posix'
138 elif os.name == 'darwin':
139   platform_name = 'mac'
140   default_frontend = 'qt3'
141   # to be safe
142   default_boost_opt = 'included'
143   default_gettext_opt = 'included'
144   default_pch_opt = False
145   default_with_x = False
146   boost_posix = False
147   packaging_method = 'msc'
148 else:  # unsupported system
149   platform_name = 'others'
150   default_frontend = 'qt3'
151   # to be safe
152   default_boost_opt = 'included'
153   default_gettext_opt = 'included'
154   default_pch_opt = False
155   default_with_x = True
156   boost_posix = False
157   packaging_method = 'posix'
158
159 #---------------------------------------------------------
160 # Handling options
161 #----------------------------------------------------------
162 # Note that if you set the options via the command line, 
163 # they will be remembered in the file 'options.cache'
164
165 # NOTE: the scons people are trying to fix scons so that
166 # options like --prefix will be accepted. Right now,
167 # we have to use the KEY=VALUE style of scons
168
169 opts = Options(['options.cache', 'config.py'])
170 opts.AddOptions(
171   # frontend, 
172   EnumOption('frontend', 'Main GUI', 
173     default_frontend,
174     allowed_values = ('xform', 'qt3', 'qt4', 'gtk') ),
175   # debug or release build
176   EnumOption('mode', 'Building method', default_build_mode,
177     allowed_values = ('debug', 'release') ),
178   # boost libraries
179   EnumOption('boost', 
180     'Use included, system boost library, or try sytem first.', 
181     default_boost_opt,
182     allowed_values = (
183       'auto',       # detect boost, if not found, use included
184       'included',   # always use included boost
185       'system',     # always use system boost, fail if can not find
186       ) ),
187   EnumOption('gettext', 
188     'Use included, system gettext library, or try sytem first', 
189     default_gettext_opt,
190     allowed_values = (
191       'auto',       # detect gettext, if not found, use included
192       'included',   # always use included gettext
193       'system',     # always use system gettext, fail if can not find
194       ) ),
195   # FIXME: I am not allowed to use '' as default, '.' is not good either.
196   PathOption('qt_dir', 'Path to qt directory', '.'),
197   PathOption('qt_include_path', 'Path to qt include directory', '.'),
198   PathOption('qt_lib_path', 'Path to qt library directory', '.'),
199   # FIXME: I do not know how pch is working. Ignore this option now.
200   BoolOption('pch', '(NA) Whether or not use pch', default_pch_opt),
201   # FIXME: Not implemented yet.
202   BoolOption('version_suffix', '(NA) Whether or not add version suffix', False),
203   # build directory, will replace build_dir if set
204   PathOption('build_dir', 'Build directory', '.'),
205   # extra include and libpath
206   PathOption('extra_inc_path', 'Extra include path', '.'),
207   PathOption('extra_lib_path', 'Extra library path', '.'),
208   # enable assertion, (config.h has  ENABLE_ASSERTIOS
209   BoolOption('assertions', 'Use assertions', True),
210   # enable warning, (config.h has  WITH_WARNINGS)
211   BoolOption('warnings', 'Use warnings', True),
212   # enable glib, (config.h has  _GLIBCXX_CONCEPT_CHECKS)
213   BoolOption('concept_checks', 'Enable concept checks', True),
214   # FIXME: I do not know what is nls
215   BoolOption('nls', '(NA) Whether or not use native language support', False),
216   # FIXME: not implemented
217   BoolOption('profile', '(NA) Whether or not enable profiling', False),
218   # FIXME: not implemented
219   PathOption('prefix', '(NA) install architecture-independent files in PREFIX', '.'),
220   # FIXME: not implemented
221   PathOption('exec_prefix', '(NA) install architecture-independent executable files in PREFIX', '.'),
222   # FIXME: not implemented
223   BoolOption('std_debug', '(NA) Whether or not turn on stdlib debug', False),
224   # using x11?
225   BoolOption('X11', 'Use x11 windows system', default_with_x),
226   # FIXME: not implemented
227   BoolOption('libintl', '(NA) Use libintl library', False),
228   # FIXME: not implemented
229   PathOption('intl_prefix', '(NA) Path to intl library', '.'),
230   # log file
231   ('logfile', 'save commands (not outputs) to logfile', default_log_file),
232   # What is aiksaurus?
233   BoolOption('aikasurus', 'Whether or not use aikasurus library', False),
234   #
235   EnumOption('spell', 'Choose spell checker to use.', 'auto',
236     allowed_values = ('aspell', 'pspell', 'ispell', 'auto') )
237 )  
238
239 # Determine the frontend to use
240 frontend = ARGUMENTS.get('frontend', default_frontend)
241 use_X11 = ARGUMENTS.get('X11', default_with_x)
242
243 #---------------------------------------------------------
244 # Setting up environment
245 #---------------------------------------------------------
246
247 env = Environment(
248   options = opts 
249 )
250
251 # set environment since I do not really like ENV = os.environ
252 env['ENV']['PATH'] = os.environ.get('PATH')
253 env['ENV']['HOME'] = os.environ.get('HOME')
254 env['ENV']['PKG_CONFIG_PATH'] = os.environ.get('PKG_CONFIG_PATH')
255 env['TOP_SRC_DIR'] = Dir('.').abspath
256
257 #
258 # frontend, mode, BUILDDIR and LOCALLIBPATH=BUILDDIR/libs
259
260 env['frontend'] = frontend
261 env['mode'] = ARGUMENTS.get('mode', default_build_mode)
262 # lyx will be built to $build/build_dir so it is possible
263 # to build multiple build_dirs using the same source 
264 # $mode can be debug or release
265 if ARGUMENTS.has_key('build_dir'):
266   build_dir = ARGUMENTS['build_dir']
267   env['BUILDDIR'] = build_dir
268 else:
269   # Determine the name of the build (platform+frontend
270   build_dir = '%s-%s' % (platform_name, frontend)
271   if use_X11 and platform_name == 'cygwin':
272     build_dir += '-X11'
273   env['BUILDDIR'] = os.path.join('$mode', build_dir)
274 # all built libraries will go to build_dir/libs
275 # (This is different from the make file approach)
276 env['LOCALLIBPATH'] = '#$BUILDDIR/libs'
277 env.Append(LIBPATH = ['$LOCALLIBPATH'])
278
279 #
280 # QTDIR, QT_LIB_PATH, QT_INC_PATH
281 #
282 if platform_name == 'win32':
283   env.Tool('mingw')
284
285 if ARGUMENTS.has_key('qt_dir'):
286   env['QTDIR'] = ARGUMENTS['qt_dir']
287   # add path to the qt tools
288   env.Append(LIBPATH = [os.path.join(ARGUMENTS['qt_dir'], 'lib')])
289   env.Append(CPPPATH = [os.path.join(ARGUMENTS['qt_dir'], 'include')])
290   # set environment so that moc etc can be found even if its path is not set properly
291   env['ENV']['PATH'] = os.path.join(ARGUMENTS['qt_dir'], 'bin') + os.pathsep + env['ENV']['PATH']
292 else:
293   env['QTDIR'] = os.environ.get('QTDIR', '/usr/lib/qt-3.3')
294
295 if ARGUMENTS.has_key('qt_lib_path'):
296   env['QT_LIB_PATH'] = ARGUMENTS['qt_lib_path']
297 else:
298   env['QT_LIB_PATH'] = '$QTDIR/lib'
299 env.Append(LIBPATH = ['$QT_LIB_PATH'])
300 # qt4 seems to be using pkg_config
301 env['ENV']['PKG_CONFIG_PATH'] = env.subst('$QT_LIB_PATH')
302
303 if ARGUMENTS.has_key('qt_inc_path'):
304   env['QT_INC_PATH'] = ARGUMENTS['qt_inc_path']
305 elif os.path.isdir(os.path.join(env.subst('$QTDIR'), 'include')):
306   env['QT_INC_PATH'] = '$QTDIR/include'
307 else: # have to guess
308   env['QT_INC_PATH'] = '/usr/include/$frontend/'
309 env.Append(CPPPATH = env['QT_INC_PATH'])  
310
311 #
312 # extra_inc_path and extra_lib_path
313 #
314 if ARGUMENTS.has_key('extra_inc_path'):
315   env.Append(CPPPATH = [ARGUMENTS['extra_inc_path']])
316 if ARGUMENTS.has_key('extra_lib_path'):
317   env.Append(LIBPATH = [ARGUMENTS['extra_lib_path']])
318
319 #
320 # this is a bit out of place (after auto-configration)
321 # but it is required to do the tests.
322 if platform_name == 'win32':
323   env.Append(CPPPATH = ['#c:/MinGW/include'])
324
325 #----------------------------------------------------------
326 # Autoconf business 
327 #----------------------------------------------------------
328
329 conf = Configure(env,
330   custom_tests = {
331     'CheckPkgConfig' : utils.checkPkgConfig,
332     'CheckPackage' : utils.checkPackage,
333     'CheckPutenv' : utils.checkPutenv,
334     'CheckIstreambufIterator' : utils.checkIstreambufIterator,
335     'CheckMkdirOneArg' : utils.checkMkdirOneArg,
336     'CheckStdCount' : utils.checkStdCount,
337     'CheckSelectArgType' : utils.checkSelectArgType,
338     'CheckBoostLibraries' : utils.checkBoostLibraries,
339   }
340 )
341
342 # pkg-config? (if not, we use hard-coded options)
343 if conf.CheckPkgConfig('0.15.0'):
344   env['HAS_PKG_CONFIG'] = True
345 else:
346   print 'pkg-config >= 0.1.50 is not found'
347   env['HAS_PKG_CONFIG'] = False
348
349 # zlib? This is required.
350 if not conf.CheckLibWithHeader('z', 'zlib.h', 'C'): 
351   print 'Did not find libz or zlib.h, exiting!'
352   Exit(1)
353
354 # qt libraries?
355 #
356 # qt3 does not use pkg_config
357 if env['frontend'] == 'qt3':
358   if not conf.CheckLibWithHeader('qt-mt', 'qapp.h', 'c++', 'QApplication qapp();'):
359     print 'Did not find qt libraries, exiting!'
360     Exit(1)
361 elif env['frontend'] == 'qt4':
362   succ = False
363   # first: try pkg_config
364   if env['HAS_PKG_CONFIG']:
365     succ = conf.CheckPackage('QtCore')
366     env['QT4_PKG_CONFIG'] = succ
367   # second: try to link to it
368   if not succ:
369     # FIXME: under linux, I can test the following perfectly
370     # However, under windows, lib names need to passed as libXXX4.a ...
371     succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
372   # third: try to look up the path
373   if not succ:
374     succ = True
375     for lib in ['QtCore', 'QtGui', 'Qt3Support']:
376       # windows version has something like QtGui4 ...
377       if not (os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s.a' % lib)) or \
378         os.path.isfile(os.path.join(env.subst('$QT_LIB_PATH'), 'lib%s4.a' % lib))):
379         succ = False
380         break
381   # still can not find it
382   if not succ:
383     print 'Did not find qt libraries, exiting!'
384     Exit(1)
385
386 # check socket libs
387 env['socket_libs'] = []
388 if conf.CheckLib('socket'):
389   env.Append(socket_libs = ['socket'])
390
391 # FIXME: What is nsl, is it related to socket?
392 if conf.CheckLib('nsl'):
393   env.Append(socket_libs = ['nsl'])
394
395 # check boost libraries
396 boost_opt = ARGUMENTS.get('boost', default_boost_opt)
397 # check for system boost
398 succ = False
399 if boost_opt in ['auto', 'system']:
400   pathes = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
401   sig = conf.CheckBoostLibraries('boost_signals', pathes)
402   reg = conf.CheckBoostLibraries('boost_regex', pathes)
403   fil = conf.CheckBoostLibraries('boost_filesystem', pathes)
404   ios = conf.CheckBoostLibraries('boost_iostreams', pathes)
405   # if any them is not found
406   if ('' in [sig[0], reg[0], fil[0], ios[0]]):
407     if boost_opt == 'system':
408       print "Can not find system boost libraries"
409       print "Please supply a path through extra_lib_path"
410       print "and try again."
411       Exit(2)
412   else:
413     env['BOOST_LIBRARIES'] = [sig[1], reg[1], fil[1], ios[1]]
414     # assume all boost libraries are in the same path...
415     env.Append(LIBPATH = sig[0])
416     env['INCLUDED_BOOST'] = False
417     succ = True
418 # now, auto and succ = false, or included
419 if not succ:
420   # we do not need to set LIBPATH now.
421   env['BOOST_LIBRARIES'] = ['boost_signals', 'boost_regex', 
422     'boost_filesystem', 'boost_iostreams']
423   env['INCLUDED_BOOST'] = True
424   
425 #
426 # Building config.h
427
428
429 print "Generating ", config_h, "..."
430
431 # I do not handle all macros in src/config.h.in, rather I am following a list
432 # of *used-by-lyx* macros compiled by Abdelrazak Younes <younes.a@free.fr> 
433
434 # Note: addToConfig etc are defined in scons_util
435 utils.startConfigH(config_h)
436
437 # HAVE_IO_H
438 # HAVE_LIMITS_H
439 # HAVE_LOCALE_H
440 # HAVE_LOCALE
441 # HAVE_PROCESS_H
442 # HAVE_STDLIB_H
443 # HAVE_SYS_STAT_H
444 # HAVE_SYS_TIME_H
445 # HAVE_SYS_TYPES_H
446 # HAVE_SYS_UTIME_H
447 # HAVE_UNISTD_H
448 # HAVE_UTIME_H
449 # HAVE_ISTREAM
450 # HAVE_OSTREAM
451 # HAVE_IOS
452
453 # Check header files
454 headers = [
455   ('io.h', 'HAVE_IO_H', 'c'),
456   ('limits.h', 'HAVE_LIMITS_H', 'c'),
457   ('locale.h', 'HAVE_LOCALE_H', 'c'),
458   ('locale', 'HAVE_LOCALE', 'cxx'),
459   ('process.h', 'HAVE_PROCESS_H', 'c'),
460   ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
461   ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
462   ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
463   ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
464   ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
465   ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
466   ('unistd.h', 'HAVE_UNISTD_H', 'c'),
467   ('utime.h', 'HAVE_UTIME_H', 'c'),
468   ('istream', 'HAVE_ISTREAM', 'cxx'),
469   ('ostream', 'HAVE_OSTREAM', 'cxx'),
470   ('ios', 'HAVE_IOS', 'cxx')
471 ]
472
473 for header in headers:
474   if (header[2] == 'c' and conf.CheckCHeader(header[0])) or \
475     (header[2] == 'cxx' and conf.CheckCXXHeader(header[0])):
476     utils.addToConfig('#define %s 1' % header[1])
477   else:
478     utils.addToConfig('/* #undef %s */' % header[1])
479
480 # HAVE_OPEN
481 # HAVE_CLOSE
482 # HAVE_POPEN
483 # HAVE_PCLOSE
484 # HAVE__OPEN
485 # HAVE__CLOSE
486 # HAVE__POPEN
487 # HAVE__PCLOSE
488 # HAVE_GETPID
489 # HAVE__GETPID
490 # HAVE_MKDIR
491 # HAVE__MKDIR
492 # HAVE_MKTEMP
493 # HAVE_MKSTEMP
494 # HAVE_STRERROR
495
496 # Check functions
497 functions = [
498   ('open', 'HAVE_OPEN'),
499   ('close', 'HAVE_CLOSE'),
500   ('popen', 'HAVE_POPEN'),
501   ('pclose', 'HAVE_PCLOSE'),
502   ('_open', 'HAVE__OPEN'),
503   ('_close', 'HAVE__CLOSE'),
504   ('_popen', 'HAVE__POPEN'),
505   ('_pclose', 'HAVE__PCLOSE'),
506   ('getpid', 'HAVE_GETPID'),
507   ('_getpid', 'HAVE__GETPID'),
508   ('mkdir', 'HAVE_MKDIR'),
509   ('_mkdir', 'HAVE__MKDIR'),
510   ('mktemp', 'HAVE_MKTEMP'),
511   ('mkstemp', 'HAVE_MKSTEMP'),
512   ('strerror', 'HAVE_STRERROR')
513 ]
514
515 for func in functions:
516   if conf.CheckFunc(func[0]):
517     utils.addToConfig('#define %s 1' % func[1])
518   else:
519     utils.addToConfig('/* #undef %s */' % func[1])
520
521 # PACKAGE
522 # PACKAGE_VERSION
523 # DEVEL_VERSION
524 utils.addToConfig('#define PACKAGE "%s"' % PACKAGE)
525 utils.addToConfig('#define PACKAGE_VERSION "%s"' % PACKAGE_VERSION)
526 if DEVEL_VERSION:
527   utils.addToConfig('#define DEVEL_VERSION 1')
528
529 # ENABLE_ASSERTIONS
530 # ENABLE_NLS
531 # WITH_WARNINGS
532 # _GLIBCXX_CONCEPT_CHECKS
533
534 # items are (ENV, ARGUMENTS)
535 values = [
536   ('ENABLE_ASSERTIONS', 'assertions'),
537   ('ENABLE_NLS', 'nls'),
538   ('WITH_WARNINGS', 'warnings'),
539   ('_GLIBCXX_CONCEPT_CHECKS', 'concept_checks'),
540 ]
541
542 for val in values:
543   if (env.has_key(val[0]) and env[val[0]]) or \
544       ARGUMENTS.get(val[1]):
545     utils.addToConfig('#define %s 1' % val[0])
546   else:
547     utils.addToConfig('/* #undef %s */' % val[0])
548
549 # AIKSAURUS_H_LOCATION
550 if ARGUMENTS.get('aiksaurus'):
551   if conf.CheckLib('Aiksaurus'):
552     utils.addToConfig("#define AIKSAURUS_H_LOCATION")
553   else:
554     print 'Library Aiksaurus not found'
555     Exit(2)
556
557 # USE_ASPELL
558 # USE_PSPELL
559 # USE_ISPELL
560
561 # determine headers to use
562 spell_engine = ARGUMENTS.get('spell', 'auto')
563 spell_detected = False
564 if spell_engine in ['auto', 'aspell'] and \
565   conf.CheckLibWithHeader('aspell', 'aspell.h', 'C'):
566   utils.addToConfig('#define USE_ASPELL 1')
567   spell_detected = True
568 elif spell_engine in ['auto', 'pspell'] and \
569   conf.CheckLibWithHeader('pspell', 'pspell.h', 'C'):
570   utils.addToConfig('#define USE_PSPELL 1')
571   spell_detected = True
572 elif spell_engine in ['auto', 'ispell'] and \
573   conf.CheckLibWithHeader('ispell', 'ispell.h', 'C'):
574   utils.addToConfig('#define USE_ISPELL 1')
575   spell_detected = False
576
577 if not spell_detected:
578   # FIXME: can lyx work without an spell engine
579   if spell_engine == 'auto':
580     print "Warning: Can not locate any spell checker"
581   else:
582     print "Warning: Can not locate specified spell checker:", spell_engine
583
584 # USE_POSIX_PACKAGING
585 # USE_MACOSX_PACKAGING
586 # USE_WINDOWS_PACKAGING
587 if packaging_method == 'windows':
588   utils.addToConfig('#define USE_WINDOWS_PACKAGING 1')
589 elif packaging_method == 'posix':
590   utils.addToConfig('#define USE_POSIX_PACKAGING 1')
591 elif packaging_method == 'mac':
592   utils.addToConfig('#define USE_MACOSX_PACKAGING 1')
593
594 # BOOST_POSIX
595 if boost_posix:
596   utils.addToConfig('#define BOOST_POSIX 1')
597 else:
598   utils.addToConfig('/* #undef BOOST_POSIX */')
599
600 # HAVE_PUTENV
601 if conf.CheckPutenv():
602   utils.addToConfig('#define HAVE_PUTENV 1')
603 else:
604   utils.addToConfig('/* #undef HAVE_PUTENV */')
605   
606 # HAVE_DECL_ISTREAMBUF_ITERATOR
607 if conf.CheckIstreambufIterator():
608   utils.addToConfig('#define HAVE_DECL_ISTREAMBUF_ITERATOR 1')
609 else:
610   utils.addToConfig('/* #undef HAVE_DECL_ISTREAMBUF_ITERATOR */')
611
612 # MKDIR_TAKES_ONE_ARG
613 if conf.CheckMkdirOneArg():
614   utils.addToConfig('#define MKDIR_TAKES_ONE_ARG 1')
615 else:
616   utils.addToConfig('/* #undef MKDIR_TAKES_ONE_ARG */')
617
618 # HAVE_STD_COUNT
619 if conf.CheckStdCount():
620   utils.addToConfig('#define HAVE_STD_COUNT 1')
621 else:
622   utils.addToConfig('/* #undef HAVE_STD_COUNT */')
623
624 # SELECT_TYPE_ARG1
625 # SELECT_TYPE_ARG234
626 # SELECT_TYPE_ARG5
627 (arg1, arg234, arg5) = conf.CheckSelectArgType()
628 utils.addToConfig('#define SELECT_TYPE_ARG1 %s' % arg1)
629 utils.addToConfig('#define SELECT_TYPE_ARG234 %s' % arg234)
630 utils.addToConfig('#define SELECT_TYPE_ARG5 %s' % arg5)
631
632 # mkstemp
633 # USE_BOOST_FORMAT
634 # WANT_GETFILEATTRIBUTESEX_WRAPPER
635 utils.endConfigH(config_h)
636
637 #
638 # Finish auto-configuration
639 env = conf.Finish()
640
641 #----------------------------------------------------------
642 # Now set up our build process accordingly 
643 #----------------------------------------------------------
644
645 #
646 # QT_LIB etc (EXTRA_LIBS holds lib for each frontend)
647 #
648 # NOTE: Tool('qt') or Tool('qt4') will be loaded later
649 # in their respective directory and specialized env.
650 try:
651   if frontend == 'qt3':
652     # note: env.Tool('qt') my set QT_LIB to qt
653     env['QT_LIB'] = 'qt-mt'
654     env['EXTRA_LIBS'] = ['qt-mt']
655     if platform_name == 'cygwin' and use_X11:
656       env['EXTRA_LIBS'] += ['GL',  'Xmu', 'Xi', 'Xrender', 'Xrandr', 'Xcursor',
657         'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 'resolv',
658         'pthread']
659       env.Append(LIBPATH = ['/usr/X11R6/lib'])
660   elif frontend == 'qt4':
661     # local qt4 toolset from 
662     # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
663     env['QT_LIB'] = ['QtCore', 'QtGui', 'Qt3Support']
664     env['EXTRA_LIBS'] = env['QT_LIB']
665 except:
666   print "Can not locate qt tools"
667   print "What I get is "
668   print "  QTDIR: ", env['QTDIR']
669
670 #
671 # Build parameters CPPPATH etc
672 #
673 # boost is always in
674 env.Append(CPPPATH = ['#boost', '#src'])
675
676 # TODO: add (more) appropriate compiling options (-DNDEBUG etc)
677 # for debug/release mode 
678 if ARGUMENTS.get('mode', default_build_mode) == 'debug':
679   env.Append(CCFLAGS = [])
680 else:
681   env.Append(CCFLAGS = [])
682
683 #
684 # Customized builders
685 #
686 # install customized builders
687 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
688 # FIXME: there must be a better way.
689 env['BUILDERS']['fileCopy'] = Builder(action = utils.env_filecopy)
690
691 #
692 # A Link script for cygwin see
693 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
694 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
695 # for details
696
697 if platform_name == 'cygwin' and env['frontend'] == 'qt3':
698   ld_script_path = '/usr/lib/qt3/mkspecs/cygwin-g++'
699   ld_script = utils.installCygwinLDScript(ld_script_path)
700   env.Append(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc', 
701     '-Wl,--script,%s' % ld_script, '-Wl,-s'])
702
703 #
704 # Report results
705 #
706 # src/support/package.C.in needs the following to replace
707 env['LYX_DIR'] = LYX_DIR
708 env['LOCALEDIR'] = LOCALEDIR
709 env['TOP_SRCDIR'] = str(Dir('#'))
710 env['PROGRAM_SUFFIX'] = PROGRAM_SUFFIX
711 # needed by src/version.C.in => src/version.C
712 env['PACKAGE_VERSION'] = PACKAGE_VERSION
713 # fill in the version info
714 env['VERSION_INFO'] = '''Configuration
715   Host type:                      %s
716   Special build flags:            %s
717   C   Compiler:                   %s
718   C   Compiler flags:             %s %s
719   C++ Compiler:                   %s
720   C++ Compiler LyX flags:         %s
721   C++ Compiler flags:             %s %s
722   Linker flags:                   %s
723   Linker user flags:              %s
724 Build info: 
725   Builing directory:              %s
726   Local library directory:        %s
727   Libraries pathes:               %s
728   Boost libraries:                %s
729 Frontend: 
730   Frontend:                       %s
731   Packaging:                      %s
732   LyX binary dir:                 FIXME
733   LyX files dir:                  FIXME
734 ''' % (platform_name, 
735   env.subst('$CCFLAGS'), env.subst('$CC'),
736   env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
737   env.subst('$CXX'), env.subst('$CXXFLAGS'),
738   env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
739   env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
740   env.subst('$BUILDDIR'), env.subst('$LOCALLIBPATH'),
741   str(env['LIBPATH']), str(env['BOOST_LIBRARIES']),
742   env['frontend'], packaging_method)
743
744 if env['frontend'] in ['qt3', 'qt4']:
745   env['VERSION_INFO'] += '''  include dir:                    %s
746   library dir:                    %s
747   X11:                            %s
748 ''' % (env.subst('$QT_INC_PATH'), env.subst('$QT_LIB_PATH'), use_X11)
749
750 print env['VERSION_INFO']
751
752 #
753 # Mingw command line may be too short for our link usage, 
754 # Here we use a trick from scons wiki
755 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
756 #
757 # I also would like to add logging (commands only) capacity to the
758 # spawn system. 
759 logfile = ARGUMENTS.get('logfile', default_log_file)
760 if logfile != '' or platform_name == 'win32':
761   import time
762   utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
763     info = '''# This is a log of commands used by scons to build lyx
764 # Time: %s 
765 # Command: %s
766 # Info: %s
767 ''' % (time.asctime(), ' '.join(sys.argv), 
768   env['VERSION_INFO'].replace('\n','\n# ')) )
769
770
771 #
772 # Cleanup stuff
773 #
774 # save options
775 opts.Save('options.cache', env)
776 # -h will print out help info
777 Help(opts.GenerateHelpText(env))
778
779
780
781 #----------------------------------------------------------
782 # Start building
783 #----------------------------------------------------------
784 Export('env')
785 env.BuildDir('$BUILDDIR', 'src')
786 print "Building all targets recursively"
787
788 client = env.SConscript('#$BUILDDIR/client/SConscript')
789 lyx = env.SConscript('#$BUILDDIR/SConscript')
790 tex2lyx = env.SConscript('#$BUILDDIR/tex2lyx/SConscript')
791
792 # avoid using full path to build them
793 Alias('client', client)
794 Alias('tex2lyx', tex2lyx)
795 Alias('lyx', lyx)
796
797 Default('lyx', 'tex2lyx')
798
799 print "Buinging lyx done with targets", map(str, BUILD_TARGETS)
800