]> git.lyx.org Git - lyx.git/blob - development/scons/SConstruct
improve function name
[lyx.git] / development / scons / SConstruct
1 # vi:filetype=python:expandtab:tabstop=4:shiftwidth=4
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 # This is a scons based building system for lyx, please refer
12 # to INSTALL.scons for detailed instructions.
13 #
14
15 import os, sys, copy, cPickle, glob, time
16
17 # determine where I am ...
18 #
19 from SCons.Node.FS import default_fs
20 # default_fs.SConstruct_dir is where SConstruct file is located.
21 scons_dir = default_fs.SConstruct_dir.path
22 scons_absdir = default_fs.SConstruct_dir.abspath
23
24 # if SConstruct is copied to the top source directory
25 if os.path.exists(os.path.join(scons_dir, 'development', 'scons', 'scons_manifest.py')):
26     scons_dir = os.path.join(scons_dir, 'development', 'scons')
27     scons_absdir = os.path.join(scons_absdir, 'development', 'scons')
28 # get the ../.. of scons_dir
29 top_src_dir = os.path.split(os.path.split(scons_absdir)[0])[0]
30
31 sys.path.extend([scons_absdir, os.path.join(top_src_dir, 'lib', 'doc')])
32
33 # scons_utils.py defines a few utility function
34 import scons_utils as utils
35 # import all file lists
36 from scons_manifest import *
37
38 # scons asks for 1.5.2, lyx requires 2.3
39 EnsurePythonVersion(2, 3)
40 # Please use at least version 0.97
41 EnsureSConsVersion(0, 97)
42
43 #----------------------------------------------------------
44 # Global definitions
45 #----------------------------------------------------------
46
47 # some global settings
48 #
49 # get version number from configure.ac so that JMarc does
50 # not have to change SConstruct during lyx release
51 package_version, majmin_ver, lyx_date = utils.getVerFromConfigure(top_src_dir)
52 try:
53     lyx_major_version = package_version.split('.')[0]
54     lyx_minor_version = package_version.split('.')[1]
55 except IndexError, e:
56     lyx_major_version = majmin_ver[0]
57     lyx_minor_version = majmin_ver[1]
58
59 package_cygwin_version = '%s-1' % package_version
60 boost_version = ['1_34']
61
62 if 'svn' in package_version:
63     devel_version = True
64     default_build_mode = 'debug'
65 else:
66     devel_version = False
67     default_build_mode = 'release'
68
69 package = 'lyx'
70 package_bugreport = 'lyx-devel@lists.lyx.org'
71 package_name = 'LyX'
72 package_tarname = 'lyx'
73 package_string = '%s %s' % (package_name, package_version)
74
75 # various cache/log files
76 default_log_file = 'scons_lyx.log'
77 opt_cache_file = 'opt.cache'
78
79
80 #----------------------------------------------------------
81 # platform dependent settings
82 #----------------------------------------------------------
83
84 if os.name == 'nt':
85     platform_name = 'win32'
86     default_prefix = 'c:/program files/lyx'
87     default_with_x = False
88     default_packaging_method = 'windows'
89 elif os.name == 'posix' and sys.platform != 'cygwin':
90     platform_name = sys.platform
91     default_prefix = '/usr/local'
92     default_with_x = True
93     default_packaging_method = 'posix'
94 elif os.name == 'posix' and sys.platform == 'cygwin':
95     platform_name = 'cygwin'
96     default_prefix = '/usr'
97     default_with_x = True
98     default_packaging_method = 'posix'
99 elif os.name == 'darwin':
100     platform_name = 'macosx'
101     # FIXME: macOSX default prefix?
102     default_prefix = '.'
103     default_with_x = False
104     default_packaging_method = 'macosx'
105 else:  # unsupported system, assume posix behavior
106     platform_name = 'others'
107     default_prefix = '.'
108     default_with_x = True
109     default_packaging_method = 'posix'
110
111 #---------------------------------------------------------
112 # Handling options
113 #----------------------------------------------------------
114 #
115 # You can set perminant default values in config.py
116 if os.path.isfile('config.py'):
117     print "Getting options from config.py..."
118     print open('config.py').read()
119
120 opts = Variables(['config.py'])
121 opts.AddVariables(
122     # frontend
123     EnumVariable('frontend', 'Main GUI', 'qt4',
124         allowed_values = ('qt4',) ),
125     # debug or release build
126     EnumVariable('mode', 'Building method', default_build_mode,
127         allowed_values = ('debug', 'release') ),
128     # boost libraries
129     EnumVariable('boost',
130         'Use included, system boost library, or try sytem boost first.',
131         'auto', allowed_values = (
132             'auto',       # detect boost, if not found, use included
133             'included',   # always use included boost
134             'system',     # always use system boost, fail if can not find
135             ) ),
136     #
137     EnumVariable('gettext',
138         'Use included, system gettext library, or try sytem gettext first',
139         'auto', allowed_values = (
140             'auto',       # detect gettext, if not found, use included
141             'included',   # always use included gettext
142             'system',     # always use system gettext, fail if can not find
143             ) ),
144     #
145     EnumVariable('spell', 'Choose spell checker to use.', 'auto',
146                 allowed_values = ('aspell', 'enchant', 'hunspell', 'auto', 'no') ),
147     # packaging method
148     EnumVariable('packaging', 'Packaging method to use.', default_packaging_method,
149         allowed_values = ('windows', 'posix', 'macosx')),
150     #
151     BoolVariable('fast_start', 'This option is obsolete.', False),
152     # No precompiled header support (too troublesome to make it work for msvc)
153     # BoolVariable('pch', 'Whether or not use pch', False),
154     # enable assertion, (config.h has ENABLE_ASSERTIOS
155     BoolVariable('assertions', 'Use assertions', True),
156     # config.h define _GLIBCXX_CONCEPT_CHECKS
157     # Note: for earlier version of gcc (3.3) define _GLIBCPP_CONCEPT_CHECKS
158     BoolVariable('concept_checks', 'Enable concept checks', True),
159     #
160     BoolVariable('nls', 'Whether or not use native language support', True),
161     #
162     BoolVariable('profiling', 'Whether or not enable profiling', False),
163     # config.h define _GLIBCXX_DEBUG and _GLIBCXX_DEBUG_PEDANTIC
164     BoolVariable('stdlib_debug', 'Whether or not turn on stdlib debug', False),
165     # using x11?
166     BoolVariable('X11', 'Use x11 windows system', default_with_x),
167     # use MS VC++ to build lyx
168     BoolVariable('use_vc', 'Use MS VC++ to build lyx (cl.exe will be probed)', None),
169     #
170     PathVariable('qt_dir', 'Path to qt directory', None),
171     #
172     PathVariable('qt_inc_path', 'Path to qt include directory', None),
173     #
174     PathVariable('qt_lib_path', 'Path to qt library directory', None),
175     # extra include and libpath
176     PathVariable('extra_inc_path', 'Extra include path', None),
177     #
178     PathVariable('extra_lib_path', 'Extra library path', None),
179     #
180     PathVariable('extra_bin_path', 'A convenient way to add a path to $PATH', None),
181     #
182     PathVariable('extra_inc_path1', 'Extra include path', None),
183     #
184     PathVariable('extra_lib_path1', 'Extra library path', None),
185     #
186     ('rebuild', 'Obsolete option', None),
187     # can be set to a non-existing directory
188     ('prefix', 'install architecture-independent files in PREFIX', default_prefix),
189     # replace the default name and location of the windows installer
190     ('win_installer', 'name or full path to the windows installer', None),
191     # the deps package used to create minimal installer (qt and other libraries)
192     ('deps_dir', 'path to the development depedency packages with zlib, iconv, zlib and qt libraries', None),
193     # whether or not build bundle installer
194     BoolVariable('bundle', 'Whether or not build bundle installer', False),
195     # the bundle directory, containing bundled applications
196     PathVariable('bundle_dir', 'path to the bundle dependency package with miktex setup.exe etc', None),
197     # build directory, will use $mode if not set
198     ('build_dir', 'Build directory', None),
199     # version suffix
200     ('version_suffix', 'install lyx as lyx-suffix', None),
201     # how to load options
202     ('load_option', '''load option from previous scons run. option can be
203         yes (default): load all options
204         no: do not load any option
205         opt1,opt2: load specified options
206         -opt1,opt2: load all options other than specified ones''', 'yes'),
207     #
208     ('optimization', 'optimization CCFLAGS option.', None),
209     #
210     PathVariable('exec_prefix', 'install architecture-independent executable files in PREFIX', None),
211     # log file
212     ('logfile', 'save commands (not outputs) to logfile', default_log_file),
213     # provided for backward compatibility
214     ('dest_dir', 'install to DESTDIR. (Provided for backward compatibility only)', None),
215     # environment variable can be set as options.
216     ('DESTDIR', 'install to DESTDIR', None),
217     ('CC', 'replace default $CC', None),
218     ('LINK', 'replace default $LINK', None),
219     ('CPP', 'replace default $CPP', None),
220     ('CXX', 'replace default $CXX', None),
221     ('CXXCPP', 'replace default $CXXCPP', None),
222     ('CCFLAGS', 'replace default $CCFLAGS', None),
223     ('CPPFLAGS', 'replace default $CPPFLAGS', None),
224     ('LINKFLAGS', 'replace default $LINKFLAGS', None),
225 )
226
227 # allowed options
228 all_options = [x.key for x in opts.options]
229
230 # copied from SCons/Variables/BoolVariable.py
231 # We need to use them before a boolean ARGUMENTS option is available
232 # in env as bool.
233 true_strings  = ('y', 'yes', 'true', 't', '1', 'on' , 'all' )
234 false_strings = ('n', 'no', 'false', 'f', '0', 'off', 'none')
235
236 if ARGUMENTS.has_key('fast_start'):
237     print 'fast_start option is obsolete'
238
239 # if load_option=yes (default), load saved comand line options
240 #
241 # This option can take value yes/no/opt1,opt2/-opt1,opt2
242 # and tries to be clever in choosing options to load
243 if (not ARGUMENTS.has_key('load_option') or \
244     ARGUMENTS['load_option'] not in false_strings) \
245     and os.path.isfile(opt_cache_file):
246     cache_file = open(opt_cache_file)
247     opt_cache = cPickle.load(cache_file)
248     cache_file.close()
249     # import cached options, but we should ignore qt_dir when frontend changes
250     if ARGUMENTS.has_key('frontend') and opt_cache.has_key('frontend') \
251         and ARGUMENTS['frontend'] != opt_cache['frontend'] \
252         and opt_cache.has_key('qt_dir'):
253         opt_cache.pop('qt_dir')
254     # and we do not cache some options (dest_dir is obsolete)
255     for arg in ['load_option', 'dest_dir', 'bundle']:
256         if opt_cache.has_key(arg):
257             opt_cache.pop(arg)
258     # remove obsolete cached keys (well, SConstruct is evolving. :-)
259     for arg in opt_cache.keys():
260         if arg not in all_options:
261             print 'Option %s is obsolete, do not load it' % arg
262             opt_cache.pop(arg)
263     # now, if load_option=opt1,opt2 or -opt1,opt2
264     if ARGUMENTS.has_key('load_option') and \
265         ARGUMENTS['load_option'] not in true_strings + false_strings:
266         # if -opt1,opt2 is specified, do not load these options
267         if ARGUMENTS['load_option'][0] == '-':
268             for arg in ARGUMENTS['load_option'][1:].split(','):
269                 if opt_cache.has_key(arg):
270                     opt_cache.pop(arg)
271         # if opt1,opt2 is specified, only load specified options
272         else:
273             args = ARGUMENTS['load_option'].split(',')
274             for arg in opt_cache.keys():
275                 if arg not in args:
276                     opt_cache.pop(arg)
277     # now restore options as if entered from command line
278     for key in opt_cache.keys():
279         if not ARGUMENTS.has_key(key):
280             ARGUMENTS[key] = opt_cache[key]
281             print "Restoring cached option  %s=%s" % (key, ARGUMENTS[key])
282     print
283
284 # check if there is unused (or misspelled) argument
285 for arg in ARGUMENTS.keys():
286     if arg not in all_options:
287         import textwrap
288         print "Unknown option '%s'... exiting." % arg
289         print
290         print "Available options are (check 'scons -help' for details):"
291         print '    ' + '\n    '.join(textwrap.wrap(',  '.join(all_options)))
292         Exit(1)
293
294 # save options used
295 cache_file = open(opt_cache_file, 'w')
296 cPickle.dump(ARGUMENTS, cache_file)
297 cache_file.close()
298
299 #---------------------------------------------------------
300 # Setting up environment
301 #---------------------------------------------------------
302
303 # I do not really like ENV=os.environ, but you may add it
304 # here if you experience some environment related problem
305 env = Environment(options = opts)
306
307 # set individual variables since I do not really like ENV = os.environ
308 env['ENV']['PATH'] = os.environ.get('PATH')
309 env['ENV']['HOME'] = os.environ.get('HOME')
310 # these are defined for MSVC
311 env['ENV']['LIB'] = os.environ.get('LIB')
312 env['ENV']['INCLUDE'] = os.environ.get('INCLUDE')
313
314 # for simplicity, use var instead of env[var]
315 frontend = env['frontend']
316 prefix = env['prefix']
317 mode = env['mode']
318
319 if platform_name == 'win32':
320     if env.has_key('use_vc'):
321         use_vc = env['use_vc']
322         if WhereIs('cl.exe') is None:
323             print "cl.exe is not found. Are you using the MSVC environment?"
324             Exit(2)
325     elif WhereIs('cl.exe') is not None:
326         use_vc = True
327     else:
328         use_vc = False
329 else:
330     use_vc = False
331
332 if env.has_key('build_dir') and env['build_dir'] is not None:
333     env['BUILDDIR'] = env['build_dir']
334 else:
335     # Determine the name of the build $mode
336     env['BUILDDIR'] = '#' + mode
337
338 # all built libraries will go to build_dir/libs
339 # (This is different from the make file approach)
340 env['LOCALLIBPATH'] = '$BUILDDIR/libs'
341 env.AppendUnique(LIBPATH = ['$LOCALLIBPATH'])
342
343
344 # Here is a summary of variables defined in env
345 # 1. defined options
346 # 2. undefined options with a non-None default value
347 # 3. compiler commands and flags like CCFLAGS.
348 #     MSGFMT used to process po files
349 # 4. Variables that will be used to replace variables in some_file.in
350 #     lib/lyx2lyx/lyx2lyx_version.py.in
351 #       PACKAGE_VERSION
352
353 # full path name is used to build msvs project files
354 # and to replace TOP_SRCDIR in package.C
355 env['TOP_SRCDIR'] = Dir(top_src_dir).abspath
356
357 # determine share_dir etc
358 packaging_method = env.get('packaging')
359 if packaging_method == 'windows':
360     share_dir = 'Resources'
361     man_dir = 'Resources/man/man1'
362     locale_dir = 'Resources/locale'
363 else:
364     share_dir = 'share/lyx'
365     locale_dir = 'share/locale'
366     if platform_name == 'cygwin':
367         man_dir = 'share/man/man1'
368     else:
369         man_dir = 'man/man1'
370
371 # program suffix: can be yes, or a string
372 if env.has_key('version_suffix'):
373     if env['version_suffix'] in true_strings:
374         program_suffix = package_version
375     elif env['version_suffix'] in false_strings:
376         program_suffix = ''
377     else:
378         program_suffix = env['version_suffix']
379 else:
380     program_suffix = ''
381
382
383 # whether or not add suffix to file and directory names
384 add_suffix = packaging_method != 'windows'
385 # Absolute data directory
386 if mode == 'release':
387     if add_suffix:
388         env['LYX_DATA_DIR'] = Dir(os.path.join(prefix, share_dir + program_suffix)).abspath
389     else:
390         env['LYX_DATA_DIR'] = Dir(os.path.join(prefix, share_dir)).abspath
391 else:
392     # in the debug mode, use $TOP_SRCDIR/lib to make sure lyx can be started from anyway
393     # by using this directory as data directory
394     env['LYX_DATA_DIR'] = os.path.join(env.subst('$TOP_SRCDIR'), 'lib')
395 # we need absolute path for package.C
396 env['LOCALEDIR'] = Dir(os.path.join(prefix, locale_dir)).abspath
397
398
399 #---------------------------------------------------------
400 # Setting building environment (Tools, compiler flags etc)
401 #---------------------------------------------------------
402
403 # Since Tool('mingw') will reset CCFLAGS etc, this should be
404 # done before getEnvVariable
405 if platform_name == 'win32':
406     if use_vc:
407         env.Tool('msvc')
408         env.Tool('mslink')
409     else:
410         env.Tool('mingw')
411         env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
412         # fix a scons winres bug (there is a missing space between ${RCINCPREFIX} and ${SOURCE.dir}
413         # in version 0.96.93
414         env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
415     
416
417 # we differentiate between hard-coded options and default options
418 # hard-coded options are required and will always be there
419 # default options can be replaced by enviromental variables or command line options
420 CCFLAGS_required = []
421 CXXFLAGS_required = []
422 LINKFLAGS_required = []
423 CCFLAGS_default = []
424
425 # if we use ms vc, the commands are fine (cl.exe and link.exe)
426 if use_vc:
427     # C4819: The file contains a character that cannot be represented
428     #   in the current code page (number)
429     # C4996: foo was decleared deprecated
430     CCFLAGS_required.append('/EHsc')
431     CXXFLAGS_required.append('/Zc:wchar_t-')
432     if mode == 'debug':
433         CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MDd'])
434     else:
435         CCFLAGS_default.extend(['/wd4819', '/wd4996', '/nologo', '/MD'])
436
437 # for debug/release mode
438 if env.has_key('optimization') and env['optimization'] is not None:
439     # if user supplies optimization flags, use it anyway
440     CCFLAGS_required.extend(env['optimization'].split())
441     # and do not use default
442     set_default_optimization_flags = False
443 else:
444     set_default_optimization_flags = True
445
446 if mode == 'debug':
447     if use_vc:
448         CCFLAGS_required.append('/Zi')
449         LINKFLAGS_required.extend(['/debug', '/map'])
450     else:
451         CCFLAGS_required.append('-g')
452         CCFLAGS_default.append('-O')
453 elif mode == 'release' and set_default_optimization_flags:
454     if use_vc:
455         CCFLAGS_default.append('/O2')
456     else:
457         CCFLAGS_default.append('-O2')
458
459 # msvc uses separate tools for profiling
460 if env.has_key('profiling') and env['profiling']:
461     if use_vc:
462         print 'Visual C++ does not use profiling options'
463     else:
464         CCFLAGS_required.append('-pg')
465         LINKFLAGS_required.append('-pg')
466
467 if env.has_key('warnings') and env['warnings']:
468     if use_vc:
469         CCFLAGS_default.append('/W2')
470     else:
471         # Note: autotools detect gxx version and pass -W for 3.x
472         # and -Wextra for other versions of gcc
473         CCFLAGS_default.append('-Wall')
474
475 # Now, set the variables as follows:
476 # 1. if command line option exists: replace default
477 # 2. then if s envronment variable exists: replace default
478 # 3. set variable to required + default
479 def setEnvVariable(env, name, required = None, default = None, split = True):
480     ''' env: environment to set variable
481             name: variable
482             required: hardcoded options
483             default: default options that can be replaced by command line or
484                 environment variables
485             split: whether or not split obtained variable like '-02 -g'
486     '''
487     # 1. ARGUMENTS is already set to env[name], override default.
488     if ARGUMENTS.has_key(name):
489         # env[name] may be rewritten when building tools are reloaded
490         # if that is the case, commandline option will override it.
491         env[name] = ARGUMENTS[name]
492         default = None
493     # then use environment default
494     elif os.environ.has_key(name):
495         print "Acquiring variable %s from system environment: %s" % (name, os.environ[name])
496         default = os.environ[name]
497         if split:
498             default = default.split()
499     # the real value should be env[name] + default + required
500     if split:
501         value = []
502         if env.has_key(name):
503             value = str(env[name]).split()
504         if required is not None:
505             value += required
506         if default is not None:
507             value += default
508     else:
509         value = ""
510         if env.has_key(name):
511             value = str(env[name])
512         if required is not None:
513             value += " " + required
514         if default is not None:
515             value += " " + default
516     env[name] = value
517     # print name, env[name]
518
519 setEnvVariable(env, 'DESTDIR', split=False)
520 setEnvVariable(env, 'CC')
521 setEnvVariable(env, 'LINK')
522 setEnvVariable(env, 'CPP')
523 setEnvVariable(env, 'CXX')
524 setEnvVariable(env, 'CXXCPP')
525 setEnvVariable(env, 'CCFLAGS', CCFLAGS_required, CCFLAGS_default)
526 setEnvVariable(env, 'CXXFLAGS', CXXFLAGS_required)
527 setEnvVariable(env, 'CPPFLAGS')
528 setEnvVariable(env, 'LINKFLAGS', LINKFLAGS_required)
529
530 # if DESTDIR is not set...
531 if env.has_key('dest_dir'):
532     print "This option is obsolete. Please use DESTDIR instead."
533     env['DESTDIR'] = env['dest_dir']
534
535 #
536 # extra_inc_path and extra_lib_path
537 #
538 extra_inc_paths = []
539 if env.has_key('extra_inc_path') and env['extra_inc_path']:
540     extra_inc_paths.append(env['extra_inc_path'])
541 if env.has_key('extra_lib_path') and env['extra_lib_path']:
542     env.AppendUnique(LIBPATH = [env['extra_lib_path']])
543 if env.has_key('extra_inc_path1') and env['extra_inc_path1']:
544     extra_inc_paths.append(env['extra_inc_path1'])
545 if env.has_key('extra_lib_path1') and env['extra_lib_path1']:
546     env.AppendUnique(LIBPATH = [env['extra_lib_path1']])
547 if env.has_key('extra_bin_path') and env['extra_bin_path']:
548     # only the first one is needed (a scons bug?)
549     os.environ['PATH'] += os.pathsep + env['extra_bin_path']
550     env.PrependENVPath('PATH', env['extra_bin_path'])
551 # extra_inc_paths will be used later by intlenv etc
552 env.AppendUnique(CPPPATH = extra_inc_paths)
553
554
555 #----------------------------------------------------------
556 # Autoconf business
557 #----------------------------------------------------------
558
559 conf = Configure(env,
560     custom_tests = {
561         'CheckPkgConfig' : utils.checkPkgConfig,
562         'CheckPackage' : utils.checkPackage,
563         'CheckMkdirOneArg' : utils.checkMkdirOneArg,
564         'CheckSelectArgType' : utils.checkSelectArgType,
565         'CheckBoostLibraries' : utils.checkBoostLibraries,
566         'CheckCommand' : utils.checkCommand,
567         'CheckNSIS' : utils.checkNSIS,
568         'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd,
569         'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
570         'CheckIconvConst' : utils.checkIconvConst,
571         'CheckSizeOfWChar' : utils.checkSizeOfWChar,
572         'CheckDeclaration' : utils.checkDeclaration,
573     }
574 )
575
576 # When using msvc, windows.h is required
577 if use_vc and not conf.CheckCHeader('windows.h'):
578     print 'Windows.h is not found. Please install Windows Platform SDK.'
579     print 'Please check config.log for more information.'
580     Exit(1)
581
582 # pkg-config? (if not, we use hard-coded options)
583 if conf.CheckPkgConfig('0.15.0'):
584     env['HAS_PKG_CONFIG'] = True
585 else:
586     print 'pkg-config >= 0.1.50 is not found'
587     env['HAS_PKG_CONFIG'] = False
588
589 # zlib? This is required.
590 if (not use_vc and not conf.CheckLibWithHeader('z', 'zlib.h', 'C')) \
591     or (use_vc and not conf.CheckLibWithHeader('zdll', 'zlib.h', 'C')):
592     print 'Did not find zdll.lib or zlib.h, exiting!'
593     print 'Please check config.log for more information.'
594     Exit(1)
595 if conf.CheckLib('iconv'):
596     env['ICONV_LIB'] = 'iconv'
597 elif conf.CheckLib('libiconv'):
598     env['ICONV_LIB'] = 'libiconv'
599 elif conf.CheckFunc('iconv_open'):
600     env['ICONV_LIB'] = None
601 else:
602     print 'Did not find iconv or libiconv, exiting!'
603     print 'Please check config.log for more information.'
604     Exit(1)
605
606 # check socket libs
607 socket_libs = []
608 if conf.CheckLib('socket'):
609     socket_libs.append('socket')
610 # nsl is the network services library and provides a
611 # transport-level interface to networking services.
612 if conf.CheckLib('nsl'):
613     socket_libs.append('nsl')
614
615 # check available boost libs (since lyx1.4 does not use iostream)
616 boost_libs = []
617 for lib in ['signals', 'regex']:
618     if os.path.isdir(os.path.join(top_src_dir, 'boost', 'libs', lib)):
619         boost_libs.append(lib)
620
621 # check boost libraries
622 boost_opt = ARGUMENTS.get('boost', 'auto')
623 # check for system boost
624 lib_paths = env['LIBPATH'] + ['/usr/lib', '/usr/local/lib']
625 inc_paths = env['CPPPATH'] + ['/usr/include', '/usr/local/include']
626 # default to $BUILDDIR/libs (use None since this path will be added anyway)
627 boost_libpath = None
628 # here I assume that all libraries are in the same directory
629 if boost_opt == 'included':
630     boost_libraries = ['included_boost_%s' % x for x in boost_libs]
631     included_boost = True
632     env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
633 elif boost_opt == 'auto':
634     res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
635     # if not found, use local boost
636     if res[0] is None:
637         boost_libraries = ['included_boost_%s' % x for x in boost_libs]
638         included_boost = True
639         env['BOOST_INC_PATH'] = '$TOP_SRCDIR/boost'
640     else:
641         included_boost = False
642         (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
643 elif boost_opt == 'system':
644     res = conf.CheckBoostLibraries(boost_libs, lib_paths, inc_paths, boost_version, mode == 'debug')
645     if res[0] is None:
646         print "Can not find system boost libraries with version %s " % boost_version
647         print "Please supply a path through extra_lib_path and try again."
648         print "Or use boost=included to use included boost libraries."
649         Exit(2)
650     else:
651         included_boost = False
652         (boost_libraries, boost_libpath, env['BOOST_INC_PATH']) = res
653
654
655 if boost_libpath is not None:
656     env.AppendUnique(LIBPATH = [boost_libpath])
657
658
659 env['ENABLE_NLS'] = env['nls']
660
661 if not env['ENABLE_NLS']:
662     intl_libs = []
663     included_gettext = False
664 else:
665     # check gettext libraries
666     gettext_opt = ARGUMENTS.get('gettext', 'auto')
667     # check for system gettext
668     succ = False
669     if gettext_opt in ['auto', 'system']:
670         if conf.CheckFunc('gettext'):
671             included_gettext = False
672             intl_libs = []
673             succ = True
674         elif conf.CheckLib('intl'):
675             included_gettext = False
676             intl_libs = ['intl']
677             succ = True
678         else: # no found
679             if gettext_opt == 'system':
680                 print "Can not find system gettext library"
681                 print "Please supply a path through extra_lib_path and try again."
682                 print "Or use gettext=included to use included gettext libraries."
683                 Exit(2)
684     # now, auto and succ = false, or gettext=included
685     if not succ:
686         # we do not need to set LIBPATH now.
687         included_gettext = True
688         intl_libs = ['included_intl']
689
690
691 #
692 # check for msgfmt command
693 env['MSGFMT'] = conf.CheckCommand('msgfmt')
694 env['MSGMERGE'] = conf.CheckCommand('msgmerge')
695 env['XGETTEXT'] = conf.CheckCommand('xgettext')
696 env['MSGUNIQ'] = conf.CheckCommand('msguniq')
697
698 # if under windows, check the nsis compiler
699 if platform_name == 'win32':
700     env['NSIS'] = conf.CheckNSIS()
701
702 # cygwin packaging requires the binaries to be stripped
703 if platform_name == 'cygwin':
704     env['STRIP'] = conf.CheckCommand('strip')
705
706 #
707 # Customized builders
708 #
709 # install customized builders
710 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
711 #env['BUILDERS']['installTOC'] = Builder(action = utils.env_toc)
712 env['BUILDERS']['potfiles'] = Builder(action = utils.env_potfiles)
713
714
715 #----------------------------------------------------------
716 # Generating config.h
717 #----------------------------------------------------------
718 aspell_lib = 'aspell'
719 # assume that we use aspell, aspelld compiled for msvc
720 if platform_name == 'win32' and mode == 'debug' and use_vc:
721     aspell_lib = 'aspelld'
722
723 hunspell_lib = 'libhunspell'
724
725 # check the existence of config.h
726 config_h = os.path.join(env.Dir('$BUILDDIR/src').path, 'config.h')
727 boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h')
728 #
729 print "Creating %s..." % boost_config_h
730 #
731 utils.createConfigFile(conf,
732     config_file = boost_config_h,
733     config_pre = r'''/* boost/config.h.  Generated by SCons.  */
734
735 /* -*- C++ -*- */
736 /*
737 * \file config.h
738 * This file is part of LyX, the document processor.
739 * Licence details can be found in the file COPYING.
740 *
741 * This is the compilation configuration file for LyX.
742 * It was generated by scon.
743 * You might want to change some of the defaults if something goes wrong
744 * during the compilation.
745 */
746
747 #ifndef _BOOST_CONFIG_H
748 #define _BOOST_CONFIG_H
749 ''',
750     headers = [
751         ('ostream', 'HAVE_OSTREAM', 'cxx'),
752         ('locale', 'HAVE_LOCALE', 'cxx'),
753         ('sstream', 'HAVE_SSTREAM', 'cxx'),
754     ],
755     custom_tests = [
756         (env.has_key('assertions') and env['assertions'] and mode == 'debug',
757             'ENABLE_ASSERTIONS',
758             'Define if you want assertions to be enabled in the code'
759         ),
760     ],
761     types = [
762         ('wchar_t', 'HAVE_WCHAR_T', None),
763     ],
764     config_post = '''
765
766 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
767 #  define USE_BOOST_FORMAT 1
768 #else
769 #  define USE_BOOST_FORMAT 0
770 #endif
771
772 #if !defined(ENABLE_ASSERTIONS)
773 #  define BOOST_DISABLE_ASSERTS 1
774 #endif
775 #define BOOST_ENABLE_ASSERT_HANDLER 1
776
777 #define BOOST_DISABLE_THREADS 1
778 #define BOOST_NO_WSTRING 1
779
780 #ifdef __CYGWIN__
781 #  define BOOST_POSIX 1
782 #  define BOOST_POSIX_API 1
783 #  define BOOST_POSIX_PATH 1
784 #endif
785
786 #define BOOST_ALL_NO_LIB 1
787
788 /*
789  * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
790  * support compiled in:
791  * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
792  * And we are not interested at all what libc
793  * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
794  * has the needed wchar_t support and uses UCS4. Whether it
795  * implements this with the help of libc, or whether it has own code
796  * does not matter for us, because we don't use libc directly (Georg)
797 */
798 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
799 #  define USE_WCHAR_T
800 #endif
801
802 #endif
803 '''
804 )
805 #
806 print "\nGenerating %s..." % config_h
807
808 # AIKSAURUS_H_LOCATION
809 if (conf.CheckCXXHeader("Aiksaurus.h")):
810     aik_location = '<Aiksaurus.h>'
811 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
812     aik_location = '<Aiksaurus/Aiksaurus.h>'
813 else:
814     aik_location = ''
815
816 # determine headers to use
817 spell_opt = ARGUMENTS.get('spell', 'auto')
818 env['USE_ASPELL'] = False
819 env['USE_ENCHANT'] = False
820 env['USE_HUNSPELL'] = False
821 if spell_opt in ['auto', 'aspell'] and conf.CheckLib(aspell_lib):
822     spell_engine = 'USE_ASPELL'
823 elif spell_opt in ['auto', 'enchant'] and conf.CheckLib('enchant'):
824     spell_engine = 'USE_ENCHANT'
825 elif spell_opt in ['auto', 'hunspell'] and conf.CheckLib(hunspell_lib):
826     spell_engine = 'USE_HUNSPELL'
827 else:
828     spell_engine = None
829
830 if spell_engine is not None:
831     env[spell_engine] = True
832 else:
833     if spell_opt == 'auto':
834         print "Warning: Can not locate any spell checker"
835     elif spell_opt != 'no':
836         print "Warning: Can not locate specified spell checker:", spell_opt
837         print 'Please check config.log for more information.'
838         Exit(1)
839
840 # check arg types of select function
841 (select_arg1, select_arg234, select_arg5) = conf.CheckSelectArgType()
842
843 # check the size of wchar_t
844 sizeof_wchar_t = conf.CheckSizeOfWChar()
845 # something wrong
846 if sizeof_wchar_t == 0:
847     print 'Error: Can not determine the size of wchar_t.'
848     print 'Please check config.log for more information.'
849     Exit(1)
850
851
852 # fill in the version info
853 env['VERSION_INFO'] = '''Configuration
854   Host type:                      %s
855   Special build flags:            %s
856   C   Compiler:                   %s
857   C   Compiler flags:             %s %s
858   C++ Compiler:                   %s
859   C++ Compiler LyX flags:         %s
860   C++ Compiler flags:             %s %s
861   Linker flags:                   %s
862   Linker user flags:              %s
863 Build info:
864   Builing directory:              %s
865   Libraries paths:                %s
866   Boost libraries:                %s
867   include search path:            %s
868 Frontend:
869   Frontend:                       %s
870   Packaging:                      %s
871   LyX dir:                        %s
872   LyX files dir:                  %s
873 ''' % (platform_name,
874     env.subst('$CCFLAGS'), env.subst('$CC'),
875     env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
876     env.subst('$CXX'), env.subst('$CXXFLAGS'),
877     env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
878     env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
879     env.subst('$LOCALLIBPATH'),
880     env.subst('$LIBPATH'), str(boost_libraries),
881     env.subst('$CPPPATH'),
882     frontend, packaging_method,
883     prefix, env['LYX_DATA_DIR'])
884
885 #
886 # create config.h
887 result = utils.createConfigFile(conf,
888     config_file = config_h,
889     config_pre = r'''/* config.h.  Generated by SCons.  */
890
891 /* -*- C++ -*- */
892 /*
893 * \file config.h
894 * This file is part of LyX, the document processor.
895 * Licence details can be found in the file COPYING.
896 *
897 * This is the compilation configuration file for LyX.
898 * It was generated by scon.
899 * You might want to change some of the defaults if something goes wrong
900 * during the compilation.
901 */
902
903 #ifndef _CONFIG_H
904 #define _CONFIG_H
905 ''',
906     headers = [
907         ('io.h', 'HAVE_IO_H', 'c'),
908         ('limits.h', 'HAVE_LIMITS_H', 'c'),
909         ('locale.h', 'HAVE_LOCALE_H', 'c'),
910         ('process.h', 'HAVE_PROCESS_H', 'c'),
911         ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
912         ('string.h', 'HAVE_STRING_H', 'c'),
913         ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
914         ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
915         ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
916         ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
917         ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
918         ('unistd.h', 'HAVE_UNISTD_H', 'c'),
919         ('utime.h', 'HAVE_UTIME_H', 'c'),
920         ('direct.h', 'HAVE_DIRECT_H', 'c'),
921         ('istream', 'HAVE_ISTREAM', 'cxx'),
922         ('ios', 'HAVE_IOS', 'cxx'),
923     ],
924     functions = [
925         ('open', 'HAVE_OPEN', None),
926         ('chmod', 'HAVE_CHMOD', None),
927         ('close', 'HAVE_CLOSE', None),
928         ('popen', 'HAVE_POPEN', None),
929         ('pclose', 'HAVE_PCLOSE', None),
930         ('_open', 'HAVE__OPEN', None),
931         ('_close', 'HAVE__CLOSE', None),
932         ('_popen', 'HAVE__POPEN', None),
933         ('_pclose', 'HAVE__PCLOSE', None),
934         ('getpid', 'HAVE_GETPID', None),
935         ('_getpid', 'HAVE__GETPID', None),
936         ('mkdir', 'HAVE_MKDIR', None),
937         ('_mkdir', 'HAVE__MKDIR', None),
938         ('mktemp', 'HAVE_MKTEMP', None),
939         ('mkstemp', 'HAVE_MKSTEMP', None),
940         ('strerror', 'HAVE_STRERROR', None),
941         ('getcwd', 'HAVE_GETCWD', None),
942         ('setenv', 'HAVE_SETENV', None),
943         ('putenv', 'HAVE_PUTENV', None),
944         ('fcntl', 'HAVE_FCNTL', None),
945         ('mkfifo', 'HAVE_MKFIFO', None),
946     ],
947     declarations = [
948         ('mkstemp', 'HAVE_DECL_MKSTEMP', ['unistd.h', 'stdlib.h']),
949     ],
950     types = [
951         ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
952             '#include <streambuf>\n#include <istream>'),
953         ('wchar_t', 'HAVE_WCHAR_T', None),
954         ('mode_t', 'HAVE_MODE_T', "#include <sys/types.h>"),
955     ],
956     libs = [
957         ('gdi32', 'HAVE_LIBGDI32'),
958         (('Aiksaurus', 'libAiksaurus'), 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB'),
959     ],
960     custom_tests = [
961         (conf.CheckType('pid_t', includes='#include <sys/types.h>'),
962             'HAVE_PID_T',
963             'Define is sys/types.h does not have pid_t',
964             '',
965             '#define pid_t int',
966         ),
967         (conf.CheckCXXGlobalCstd(),
968             'CXX_GLOBAL_CSTD',
969             'Define if your C++ compiler puts C library functions in the global namespace'
970         ),
971         (conf.CheckMkdirOneArg(),
972             'MKDIR_TAKES_ONE_ARG',
973             'Define if mkdir takes only one argument.'
974         ),
975         (conf.CheckIconvConst(),
976             'ICONV_CONST',
977             'Define as const if the declaration of iconv() needs const.',
978             '#define ICONV_CONST const',
979             '#define ICONV_CONST',
980         ),
981         (conf.CheckLC_MESSAGES(),
982             'HAVE_LC_MESSAGES',
983             'Define if your <locale.h> file defines LC_MESSAGES.'
984         ),
985         (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'),
986         (env['nls'],
987             'ENABLE_NLS',
988             "Define to 1 if translation of program messages to the user's native anguage is requested.",
989         ),
990         (env['nls'] and not included_gettext,
991             'HAVE_GETTEXT',
992             'Define to 1 if using system gettext library'
993         ),
994         (env.has_key('concept_checks') and env['concept_checks'],
995             '_GLIBCXX_CONCEPT_CHECKS',
996             'libstdc++ concept checking'
997         ),
998         (env.has_key('stdlib_debug') and env['stdlib_debug'],
999             '_GLIBCXX_DEBUG',
1000             'libstdc++ debug mode'
1001         ),
1002         (env.has_key('stdlib_debug') and env['stdlib_debug'],
1003             '_GLIBCXX_DEBUG_PEDANTIC',
1004             'libstdc++ pedantic debug mode'
1005         ),
1006         (os.name != 'nt', 'BOOST_POSIX',
1007             'Indicates to boost < 1.34 which API to use (posix or windows).'
1008         ),
1009         (os.name != 'nt', 'BOOST_POSIX_API',
1010             'Indicates to boost 1.34 which API to use (posix or windows).'
1011         ),
1012         (os.name != 'nt', 'BOOST_POSIX_PATH',
1013             'Indicates to boost 1.34 which path style to use (posix or windows).'
1014         ),
1015         (spell_engine is not None, spell_engine,
1016             'Spell engine to use'
1017         ),
1018         # we need to know the byte order for unicode conversions
1019         (sys.byteorder == 'big', 'WORDS_BIGENDIAN',
1020             'Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX).'
1021         ),
1022     ],
1023     extra_items = [
1024         ('#define PACKAGE "%s%s"' % (package, program_suffix),
1025             'Name of package'),
1026         ('#define PACKAGE_BUGREPORT "%s"' % package_bugreport,
1027             'Define to the address where bug reports for this package should be sent.'),
1028         ('#define PACKAGE_NAME "%s"' % package_name,
1029             'Define to the full name of this package.'),
1030         ('#define PACKAGE_STRING "%s"' % package_string,
1031             'Define to the full name and version of this package.'),
1032         ('#define PACKAGE_TARNAME "%s"' % package_tarname,
1033             'Define to the one symbol short name of this package.'),
1034         ('#define PACKAGE_VERSION "%s"' % package_version,
1035             'Define to the version of this package.'),
1036         ('#define LYX_MAJOR_VERSION %d' % int(lyx_major_version),
1037             'Define to the major version of this package.'),
1038         ('#define LYX_MINOR_VERSION %d' % int(lyx_minor_version),
1039             'Define to the minor version of this package.'),
1040         ('#define VERSION_INFO "%s"' % env['VERSION_INFO'].replace('\n', '\\n'),
1041             'Full version info'),
1042         ('#define LYX_DIR_VER "LYX_DIR_%sx"' % majmin_ver,
1043             'Versioned env var for system dir'),
1044         ('#define LYX_USERDIR_VER "LYX_USERDIR_%sx"' % majmin_ver,
1045             'Versioned env var for user dir'),
1046         ('#define LYX_DATE "%s"' % lyx_date,
1047             'Date of release'),
1048         ('#define PROGRAM_SUFFIX "%s"' % program_suffix,
1049             'Program version suffix'),
1050         ('#define LYX_ABS_INSTALLED_DATADIR "%s"' % env.subst('$LYX_DATA_DIR').replace('\\', '/'),
1051             'Hard coded system support directory'),
1052         ('#define LYX_ABS_INSTALLED_LOCALEDIR "%s"' % env.subst('$LOCALEDIR').replace('\\', '/'),
1053             'Hard coded locale directory'),
1054         ('#define LYX_ABS_TOP_SRCDIR "%s"' % env.subst('$TOP_SRCDIR').replace('\\', '/'),
1055             'Top source directory'),
1056         ('#define BOOST_ALL_NO_LIB 1',
1057             'disable automatic linking of boost libraries.'),
1058         ('#define USE_%s_PACKAGING 1' % packaging_method.upper(),
1059             'Packaging method'),
1060         ('#define AIKSAURUS_H_LOCATION ' + aik_location,
1061             'Aiksaurus include file'),
1062         ('#define SELECT_TYPE_ARG1 %s' % select_arg1,
1063             "Define to the type of arg 1 for `select'."),
1064         ('#define SELECT_TYPE_ARG234 %s' % select_arg234,
1065             "Define to the type of arg 2, 3, 4 for `select'."),
1066         ('#define SELECT_TYPE_ARG5 %s' % select_arg5,
1067             "Define to the type of arg 5 for `select'."),
1068         ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1069             'Define to be the size of type wchar_t'),
1070     ],
1071     config_post = '''/************************************************************
1072 ** You should not need to change anything beyond this point */
1073
1074 #ifndef HAVE_STRERROR
1075 #if defined(__cplusplus)
1076 extern "C"
1077 #endif
1078 char * strerror(int n);
1079 #endif
1080
1081 #include <../boost/config.h>
1082
1083 #endif
1084 '''
1085 )
1086
1087 # these keys are needed in env
1088 for key in ['USE_ASPELL', 'USE_ENCHANT', 'USE_HUNSPELL', 'HAVE_FCNTL',\
1089     'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB']:
1090     # USE_ASPELL etc does not go through result
1091     if result.has_key(key):
1092         env[key] = result[key]
1093
1094 #
1095 # if nls=yes and gettext=included, create intl/config.h
1096 # intl/libintl.h etc
1097 #
1098 intl_config_h = os.path.join(env.Dir('$BUILDDIR/intl').path, 'config.h')
1099 if env['nls'] and included_gettext:
1100     #
1101     print "Creating %s..." % intl_config_h
1102     #
1103     # create intl/config.h
1104     result = utils.createConfigFile(conf,
1105         config_file = intl_config_h,
1106         config_pre = r'''/* intl/config.h.  Generated by SCons.  */
1107
1108 /* -*- C++ -*- */
1109 /*
1110 * \file config.h
1111 * This file is part of LyX, the document processor.
1112 * Licence details can be found in the file COPYING.
1113 *
1114 * This is the compilation configuration file for LyX.
1115 * It was generated by scon.
1116 * You might want to change some of the defaults if something goes wrong
1117 * during the compilation.
1118 */
1119
1120 #ifndef _INTL_CONFIG_H
1121 #define _INTL_CONFIG_H
1122 ''',
1123         headers = [
1124             ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1125             ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
1126             ('string.h', 'HAVE_STRING_H', 'c'),
1127             ('strings.h', 'HAVE_STRINGS_H', 'c'),
1128             ('argz.h', 'HAVE_ARGZ_H', 'c'),
1129             ('limits.h', 'HAVE_LIMITS_H', 'c'),
1130             ('alloca.h', 'HAVE_ALLOCA_H', 'c'),
1131             ('stddef.h', 'HAVE_STDDEF_H', 'c'),
1132             ('stdint.h', 'HAVE_STDINT_H', 'c'),
1133             ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'),
1134         ],
1135         functions = [
1136             ('getcwd', 'HAVE_GETCWD', None),
1137             ('stpcpy', 'HAVE_STPCPY', None),
1138             ('strcasecmp', 'HAVE_STRCASECMP', None),
1139             ('strdup', 'HAVE_STRDUP', None),
1140             ('strtoul', 'HAVE_STRTOUL', None),
1141             ('alloca', 'HAVE_ALLOCA', None),
1142             ('__fsetlocking', 'HAVE___FSETLOCKING', None),
1143             ('mempcpy', 'HAVE_MEMPCPY', None),
1144             ('__argz_count', 'HAVE___ARGZ_COUNT', None),
1145             ('__argz_next', 'HAVE___ARGZ_NEXT', None),
1146             ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None),
1147             ('setlocale', 'HAVE_SETLOCALE', None),
1148             ('tsearch', 'HAVE_TSEARCH', None),
1149             ('getegid', 'HAVE_GETEGID', None),
1150             ('getgid', 'HAVE_GETGID', None),
1151             ('getuid', 'HAVE_GETUID', None),
1152             ('wcslen', 'HAVE_WCSLEN', None),
1153             ('asprintf', 'HAVE_ASPRINTF', None),
1154             ('wprintf', 'HAVE_WPRINTF', None),
1155             ('snprintf', 'HAVE_SNPRINTF', None),
1156             ('printf', 'HAVE_POSIX_PRINTF', None),
1157             ('fcntl', 'HAVE_FCNTL', None),
1158         ],
1159         types = [
1160             ('intmax_t', 'HAVE_INTMAX_T', None),
1161             ('long double', 'HAVE_LONG_DOUBLE', None),
1162             ('long long', 'HAVE_LONG_LONG', None),
1163             ('wchar_t', 'HAVE_WCHAR_T', None),
1164             ('wint_t', 'HAVE_WINT_T', None),
1165             ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include <inttypes.h>'),
1166             ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include <stdint.h>'),
1167         ],
1168         libs = [
1169             ('c', 'HAVE_LIBC'),
1170         ],
1171         custom_tests = [
1172             (conf.CheckLC_MESSAGES(),
1173                 'HAVE_LC_MESSAGES',
1174                 'Define if your <locale.h> file defines LC_MESSAGES.'
1175             ),
1176             (conf.CheckIconvConst(),
1177                 'ICONV_CONST',
1178                 'Define as const if the declaration of iconv() needs const.',
1179                 '#define ICONV_CONST const',
1180                 '#define ICONV_CONST',
1181             ),
1182             (conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
1183             conf.CheckType('intmax_t', includes='#include <inttypes.h>'),
1184                 'HAVE_INTMAX_T',
1185                 "Define to 1 if you have the `intmax_t' type."
1186             ),
1187             (env.has_key('nls') and env['nls'],
1188                 'ENABLE_NLS',
1189                 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1190             ),
1191         ],
1192         extra_items = [
1193             ('#define HAVE_ICONV 1', 'Define if iconv or libiconv is found'),
1194             ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1195                 'Define to be the size of type wchar_t'),
1196         ],
1197         config_post = '#endif'
1198     )
1199
1200     # these keys are needed in env
1201     for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1202         'HAVE_POSIX_PRINTF', 'HAVE_LIBC']:
1203         # USE_ASPELL etc does not go through result
1204         if result.has_key(key):
1205             env[key] = result[key]
1206
1207
1208 # this looks misplaced, but intl/libintl.h is needed by src/message.C
1209 if env['nls'] and included_gettext:
1210     # libgnuintl.h.in => libintl.h
1211     env.Depends('$TOP_SRCDIR/intl/libintl.h', '$BUILDDIR/intl/config.h')
1212     env.substFile('$BUILDDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in')
1213     env.Command('$BUILDDIR/intl/libgnuintl.h', '$BUILDDIR/intl/libintl.h',
1214         [Copy('$TARGET', '$SOURCE')])
1215
1216 #
1217 # Finish auto-configuration
1218 env = conf.Finish()
1219
1220 #----------------------------------------------------------
1221 # Now set up our build process accordingly
1222 #----------------------------------------------------------
1223
1224 if env['ICONV_LIB'] is None:
1225     system_libs = []
1226 else:
1227     system_libs = [env['ICONV_LIB']]
1228 if platform_name in ['win32', 'cygwin']:
1229     # the final link step needs stdc++ to succeed under mingw
1230     # FIXME: shouldn't g++ automatically link to stdc++?
1231     if use_vc:
1232         system_libs += ['ole32', 'shlwapi', 'psapi', 'shell32', 'advapi32', 'zdll']
1233     else:
1234         system_libs += ['shlwapi', 'psapi', 'stdc++', 'z']
1235 elif platform_name == 'cygwin' and env['X11']:
1236     system_libs += ['GL',  'Xmu', 'Xi', 'Xrender', 'Xrandr',
1237         'Xcursor', 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 
1238         'resolv', 'pthread', 'z']
1239 else:
1240     system_libs += ['z']
1241
1242 libs = [
1243     ('HAVE_LIBGDI32', 'gdi32'),
1244     ('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
1245     ('USE_ASPELL', aspell_lib),
1246     ('USE_ENCHANT', 'enchant'),
1247     ('USE_HUNSPELL', hunspell_lib)
1248 ]
1249
1250 for lib in libs:
1251     if env[lib[0]]:
1252         system_libs.append(lib[1])
1253
1254 #
1255 # Build parameters CPPPATH etc
1256 #
1257 if env['X11']:
1258     env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
1259
1260 #
1261 # boost: for boost header files
1262 # BUILDDIR/src: for config.h
1263 # TOP_SRCDIR/src: for support/* etc
1264 #
1265 env['CPPPATH'] += ['$BUILDDIR/src', '$TOP_SRCDIR/src']
1266 #
1267 # Separating boost directories from CPPPATH stops scons from building
1268 # the dependency tree for boost header files, and effectively reduce
1269 # the null build time of lyx from 29s to 16s. Since lyx may tweak local
1270 # boost headers, the following is not 100% safe.
1271 #    env.AppendUnique(CPPPATH = ['$BOOST_INC_PATH'])
1272 env.PrependUnique(CCFLAGS = ['$INCPREFIX$BOOST_INC_PATH'])
1273
1274 # for intl/config.h, intl/libintl.h and intl/libgnuintl.h
1275 if env['nls'] and included_gettext:
1276     env['CPPPATH'].append('$BUILDDIR/intl')
1277 #
1278
1279 #
1280 # A Link script for cygwin see
1281 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1282 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
1283 # for details
1284 #
1285 if platform_name == 'cygwin':
1286     ld_script_path = '/tmp'
1287     ld_script = utils.installCygwinLDScript(ld_script_path)
1288     env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
1289         '-Wl,--script,%s' % ld_script, '-Wl,-s'])
1290
1291
1292 #---------------------------------------------------------
1293 # Frontend related variables (QTDIR etc)
1294 #---------------------------------------------------------
1295
1296 #
1297 # create a separate environment so that other files do not have
1298 # to be built with all the include directories etc
1299 #
1300 if frontend == 'qt4':
1301     env['BUILDERS']['qtResource'] = Builder(action = utils.env_qtResource)
1302
1303     # handle qt related user specified paths
1304     # set environment so that moc etc can be found even if its path is not set properly
1305     if env.has_key('qt_dir') and env['qt_dir']:
1306         env['QTDIR'] = env['qt_dir']
1307         if os.path.isdir(os.path.join(env['qt_dir'], 'bin')):
1308             os.environ['PATH'] += os.pathsep + os.path.join(env['qt_dir'], 'bin')
1309             env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
1310         if os.path.isdir(os.path.join(env['qt_dir'], 'lib')):
1311             env.PrependENVPath('PKG_CONFIG_PATH', os.path.join(env['qt_dir'], 'lib'))
1312
1313     # if separate qt_lib_path is given
1314     if env.has_key('qt_lib_path') and env['qt_lib_path']:
1315         qt_lib_path = env.subst('$qt_lib_path')
1316         env.AppendUnique(LIBPATH = [qt_lib_path])
1317         env.PrependENVPath('PKG_CONFIG_PATH', qt_lib_path)
1318     else:
1319         qt_lib_path = None
1320
1321     # if separate qt_inc_path is given
1322     if env.has_key('qt_inc_path') and env['qt_inc_path']:
1323         qt_inc_path = env['qt_inc_path']
1324     else:
1325         qt_inc_path = None
1326
1327     # local qt4 toolset from
1328     # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
1329     #
1330     # NOTE: I have to patch qt4.py since it does not automatically
1331     # process .C file!!! (add to cxx_suffixes )
1332     #
1333     env.Tool('qt4', [scons_dir])
1334     env['QT_AUTOSCAN'] = 0
1335     env['QT4_AUTOSCAN'] = 0
1336     env['QT4_UICDECLFLAGS'] = '-tr lyx::qt_'
1337     if platform_name == 'win32':
1338         env['QT4_MOCFROMHFLAGS'] = '-D_WIN32'
1339
1340     if qt_lib_path is None:
1341         qt_lib_path = os.path.join(env.subst('$QTDIR'), 'lib')
1342     if qt_inc_path is None:
1343         qt_inc_path = os.path.join(env.subst('$QTDIR'), 'include')
1344
1345
1346     conf = Configure(env,
1347         custom_tests = { 
1348             'CheckPackage' : utils.checkPackage,
1349             'CheckCommand' : utils.checkCommand,
1350         }
1351     )
1352
1353     succ = False
1354     # first: try pkg_config
1355     if env['HAS_PKG_CONFIG']:
1356         succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
1357         # FIXME: use pkg_config information?
1358         #env['QT4_PKG_CONFIG'] = succ
1359     # second: try to link to it
1360     if not succ:
1361         # Under linux, I can test the following perfectly
1362         # Under windows, lib names need to passed as libXXX4.a ...
1363         if platform_name == 'win32':
1364             succ = conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1365         else:
1366             succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1367     # still can not find it
1368     if not succ:
1369         print 'Did not find qt libraries, exiting!'
1370         print 'Please check config.log for more information.'
1371         Exit(1)
1372     #
1373     # Now, determine the correct suffix:
1374     qt_libs = ['QtCore', 'QtGui']
1375     if platform_name == 'win32':
1376         if mode == 'debug' and use_vc and \
1377             conf.CheckLibWithHeader('QtCored4', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1378             qt_lib_suffix = 'd4'
1379             use_qt_debug_libs = True
1380         else:
1381             qt_lib_suffix = '4'
1382             use_qt_debug_libs = False
1383     else:
1384         if mode == 'debug' and conf.CheckLibWithHeader('QtCore_debug', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1385             qt_lib_suffix = '_debug'
1386             use_qt_debug_libs = True
1387         else:
1388             qt_lib_suffix = ''
1389             use_qt_debug_libs = False
1390     env.EnableQt4Modules(qt_libs, debug = (mode == 'debug' and use_qt_debug_libs))
1391     frontend_libs = [x + qt_lib_suffix for x in qt_libs]
1392     qtcore_lib = ['QtCore' + qt_lib_suffix]
1393
1394     # check uic and moc commands for qt frontends
1395     if conf.CheckCommand('uic') == None or conf.CheckCommand('moc') == None:
1396         print 'uic or moc command is not found for frontend', frontend
1397         Exit(1)
1398     
1399     # now, if msvc2005 is used, we will need to embed lyx.exe.manifest to lyx.exe
1400     # NOTE: previously, lyx.exe had to be linked to some qt manifest to work.
1401     # For some unknown changes in msvc or qt, this is no longer needed.
1402     if use_vc:
1403         env['LINKCOM'] = [env['LINKCOM'], \
1404             'mt.exe /MANIFEST %s /outputresource:$TARGET;1' % \
1405             env.File('$BUILDDIR/lyx.exe.manifest').path]
1406
1407     env = conf.Finish()
1408
1409 #
1410 # Report results
1411 #
1412 print env['VERSION_INFO']
1413
1414 #
1415 # Mingw command line may be too short for our link usage,
1416 # Here we use a trick from scons wiki
1417 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
1418 #
1419 # I also would like to add logging (commands only) capacity to the
1420 # spawn system.
1421 logfile = env.get('logfile', default_log_file)
1422 if logfile != '' or platform_name == 'win32':
1423     import time
1424     utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
1425         info = '''# This is a log of commands used by scons to build lyx
1426 # Time: %s
1427 # Command: %s
1428 # Info: %s
1429 ''' % (time.asctime(), ' '.join(sys.argv),
1430     env['VERSION_INFO'].replace('\n','\n# ')) )
1431
1432
1433 # Cleanup stuff
1434 #
1435 # -h will print out help info
1436 Help(opts.GenerateHelpText(env))
1437
1438
1439 #----------------------------------------------------------
1440 # Start building
1441 #----------------------------------------------------------
1442 # this has been the source of problems on some platforms...
1443 # I find that I need to supply it with full path name
1444 env.SConsignFile(os.path.join(Dir(env['BUILDDIR']).abspath, '.sconsign'))
1445 # this usage needs further investigation.
1446 #env.CacheDir('%s/Cache/%s' % (env['BUILDDIR'], frontend))
1447 env.VariantDir('$BUILDDIR/boost', '$TOP_SRCDIR/boost/libs', duplicate = 0)
1448 env.VariantDir('$BUILDDIR/intl', '$TOP_SRCDIR/intl', duplicate = 0)
1449 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1450 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1451
1452 print "Building all targets recursively"
1453
1454 def libExists(libname):
1455     ''' Check whether or not lib $LOCALLIBNAME/libname already exists'''
1456     return os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath)
1457
1458
1459 if (included_boost and not libExists('included_boost_regex')) or 'boost' in BUILD_TARGETS:
1460     #
1461     # boost/libs
1462     #
1463     for lib in boost_libs:
1464         boostlib = env.StaticLibrary(
1465             target = '$LOCALLIBPATH/included_boost_%s' % lib,
1466             source = ['$BUILDDIR/boost/%s/src/%s' % (lib, x) for x in eval('boost_libs_%s_src_files' % lib)],
1467             # do not use global CPPPATH because src/config.h will mess up with boost/config.h
1468             CPPPATH = ['$BUILDDIR/boost'] + extra_inc_paths,
1469             CCFLAGS = ['$CCFLAGS', '$INCPREFIX$TOP_SRCDIR/boost', '-DBOOST_USER_CONFIG="<config.h>"']
1470         )
1471         Alias('boost', boostlib)
1472
1473
1474 if (included_gettext and not libExists('included_intl')) or 'intl' in BUILD_TARGETS:
1475     #
1476     # intl
1477     #
1478     INTL_CCFLAGS =  [
1479         r'-DLOCALEDIR=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1480         r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1481         r'-DLIBDIR=\"' + env['TOP_SRCDIR'].replace('\\', '\\\\') + r'/lib\"',
1482         '-DIN_LIBINTL',
1483         '-DENABLE_RELOCATABLE=1',
1484         '-DIN_LIBRARY',
1485         r'-DINSTALLDIR=\"' + prefix.replace('\\', '\\\\') + r'/lib\"',
1486         '-DNO_XMALLOC',
1487         '-Dset_relocation_prefix=libintl_set_relocation_prefix',
1488         '-Drelocate=libintl_relocate',
1489         '-DDEPENDS_ON_LIBICONV=1',
1490         '-DHAVE_CONFIG_H'
1491         ]
1492     if use_vc:
1493         INTL_CCFLAGS.extend(['/Dinline#', '/D__attribute__(x)#', '/Duintmax_t=UINT_MAX'])
1494
1495     intl = env.StaticLibrary(
1496         target = '$LOCALLIBPATH/included_intl',
1497         LIBS = ['c'],
1498         CCFLAGS = INTL_CCFLAGS,
1499         # do not use global CPPPATH because src/config.h will mess up with intl/config.h
1500         CPPPATH =  ['$BUILDDIR/intl'] + extra_inc_paths,
1501         source = ['$BUILDDIR/intl/%s' % x for x in intl_files]
1502     )
1503     Alias('intl', intl)
1504
1505 #
1506 # src/support
1507 #
1508 env['QT4_MOCHPREFIX'] = 'moc_'
1509 env['QT4_MOCHSUFFIX'] = '.cpp'
1510
1511 support_moced_files = [env.Moc4('$BUILDDIR/src/support/%s' % x)
1512     for x in src_support_header_files ]
1513 support = env.StaticLibrary(
1514     target = '$LOCALLIBPATH/support',
1515     source = ['$BUILDDIR/src/support/%s' % x for x in src_support_files],
1516     CCFLAGS =  [
1517         '$CCFLAGS',
1518         '-DHAVE_CONFIG_H',
1519         '-DQT_NO_STL',
1520         '-DQT_NO_KEYWORDS',
1521     ],
1522     CPPPATH = ['$CPPPATH', '$BUILDDIR/src/support']
1523 )
1524 Alias('support', support)
1525
1526 #
1527 if env['HAVE_FCNTL']:
1528     client = env.Program(
1529         target = '$BUILDDIR/src/client/lyxclient',
1530         LIBS = ['support'] + intl_libs + system_libs +
1531             socket_libs + boost_libraries + qtcore_lib,
1532         source = ['$BUILDDIR/src/client/%s' % x for x in src_client_files] + \
1533             utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/client.rc')
1534     )
1535     Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
1536         client, [Copy('$TARGET', '$SOURCE')]))
1537 else:
1538     client = None
1539 Alias('client', client)
1540
1541
1542 #
1543 # tex2lyx
1544 #
1545 for file in src_tex2lyx_copied_files + src_tex2lyx_copied_header_files:
1546     env.Command('$BUILDDIR/src/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
1547         [Copy('$TARGET', '$SOURCE')])
1548
1549 tex2lyx = env.Program(
1550     target = '$BUILDDIR/src/tex2lyx/tex2lyx',
1551     LIBS = ['support'] + boost_libraries + intl_libs + system_libs + qtcore_lib,
1552     source = ['$BUILDDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files + src_tex2lyx_copied_files] + \
1553         utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/tex2lyx.rc'),
1554     CPPPATH = ['$BUILDDIR/src/tex2lyx', '$BUILDDIR/src', '$CPPPATH'],
1555     LIBPATH = ['#$LOCALLIBPATH', '$LIBPATH'],
1556     CCFLAGS = ['$CCFLAGS', '-DTEX2LYX'],
1557 )
1558 Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
1559     tex2lyx, [Copy('$TARGET', '$SOURCE')]))
1560 Alias('tex2lyx', tex2lyx)
1561
1562
1563 #
1564 # Build lyx with given frontend
1565 #
1566 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1567     src_post_files.append('AspellChecker.cpp')
1568     src_post_files.append('PersonalWordList.cpp')
1569 elif env.has_key('USE_ENCHANT') and env['USE_ENCHANT']:
1570     src_post_files.append('EnchantChecker.cpp')
1571     src_post_files.append('PersonalWordList.cpp')
1572 elif env.has_key('USE_HUNSPELL') and env['USE_HUNSPELL']:
1573     src_post_files.append('HunspellChecker.cpp')
1574     src_post_files.append('PersonalWordList.cpp')
1575
1576 # tells scons how to get these moced files, although not all moced files are needed
1577 # (or are actually generated).
1578 qt4_moced_files = [env.Moc4('$BUILDDIR/src/frontends/qt4/%s' % x)
1579     for x in src_frontends_qt4_header_files ]
1580 src_moced_files = [env.Moc4('$BUILDDIR/src/%s' % x)
1581     for x in src_header_files ]
1582 ui_files = [env.Uic4('$BUILDDIR/src/frontends/qt4/ui/%s' % x.split('.')[0])
1583     for x in src_frontends_qt4_ui_files]
1584 resource = env.Qrc(env.qtResource(
1585     '$BUILDDIR/src/frontends/qt4/Resource.qrc',
1586     ['$TOP_SRCDIR/lib/images/%s' % x for x in lib_images_files] +
1587     ['$TOP_SRCDIR/lib/images/math/%s' % x for x in lib_images_math_files] +
1588     ['$TOP_SRCDIR/lib/images/commands/%s' % x for x in lib_images_commands_files]))
1589
1590 lyx = env.Program(
1591     target = '$BUILDDIR/lyx',
1592     source = ['$BUILDDIR/src/main.cpp'] +
1593         ['$BUILDDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files] +
1594         resource +
1595         ['$BUILDDIR/src/graphics/%s' % x for x in src_graphics_files] +
1596         ['$BUILDDIR/src/mathed/%s' % x for x in src_mathed_files] +
1597         ['$BUILDDIR/src/insets/%s' % x for x in src_insets_files] +
1598         ['$BUILDDIR/src/frontends/%s' % x for x in src_frontends_files] +
1599         ['$BUILDDIR/src/%s' % x for x in src_pre_files] +
1600         ["$BUILDDIR/src/%s" % x for x in src_post_files] +
1601         utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/lyx.rc'),
1602     CPPPATH = [
1603         '$CPPPATH',
1604         '$BUILDDIR/src',
1605         '$BUILDDIR/src/images',
1606         '$BUILDDIR/src/frontends',
1607         '$BUILDDIR/src/frontends/qt4',
1608         '$BUILDDIR/src/frontends/qt4/ui',
1609     ],
1610     CCFLAGS =  [
1611         '$CCFLAGS',
1612         '-DHAVE_CONFIG_H',
1613         '-DQT_NO_STL',
1614         '-DQT_NO_KEYWORDS',
1615     ],
1616     LIBS = [
1617         'support',
1618         ] +
1619         boost_libraries + 
1620         frontend_libs +
1621         intl_libs +
1622         socket_libs +
1623         system_libs
1624 )
1625 Alias('lyx', lyx)
1626
1627
1628 if use_vc and 'msvs_projects' in BUILD_TARGETS:
1629     def build_project(target, full_target = None, src = [], inc = [], res = []):
1630         ''' build mavs project files
1631             target:      alias (correspond to directory name)
1632             full_target: full path/filename of the target
1633             src:         source files
1634             inc:         include files
1635             res:         resource files
1636
1637         For non-debug-able targets like static libraries, target (alias) is
1638         enough to build the target. For executable targets, msvs need to know
1639         the full path to start debug them.
1640         '''
1641         # project
1642         proj = env.MSVSProject(
1643             target = target + env['MSVSPROJECTSUFFIX'],
1644             # this allows easy access to header files (along with source)
1645             srcs = [env.subst(x) for x in src + inc],
1646             incs = [env.subst('$TOP_SRCDIR/src/config.h')],
1647             localincs = [env.subst(x) for x in inc],
1648             resources = [env.subst(x) for x in res],
1649             buildtarget = full_target,
1650             variant = 'Debug'
1651         )
1652         Alias('msvs_projects', proj)
1653     #
1654     build_project('client', src = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_files],
1655         inc = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files],
1656         full_target = File(env.subst('$BUILDDIR/src/client/lyxclient$PROGSUFFIX')).abspath)
1657     #
1658     build_project('tex2lyx', src = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files],
1659         inc = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files],
1660         full_target = File(env.subst('$BUILDDIR/src/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
1661     #
1662     build_project('lyx', 
1663         src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files + ['version.cpp']] + \
1664             ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files + ['Package.cpp'] ] + \
1665             ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_files] + \
1666             ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files] + \
1667             ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files] + \
1668             ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files] + \
1669             ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files],
1670         inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files] + \
1671             ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files] + \
1672             ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files] + \
1673             ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files] + \
1674             ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files] + \
1675             ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files] + \
1676             ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
1677         res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1678         full_target = File(env.subst('$BUILDDIR/lyx$PROGSUFFIX')).abspath)
1679
1680
1681 if 'update_po' in BUILD_TARGETS:
1682     #
1683     # update po files
1684     #
1685     print 'Updating po/*.po files...'
1686
1687     # whether or not update po files
1688     if not env['XGETTEXT'] or not env['MSGMERGE'] or not env['MSGUNIQ']:
1689         print 'xgettext or msgmerge does not exist. Cannot merge po files'
1690         Exit(1)
1691     # rebuild POTFILES.in
1692     POTFILES_in = env.potfiles('$TOP_SRCDIR/po/POTFILES.in', 
1693         ['$TOP_SRCDIR/src/%s' % x for x in  src_header_files + src_pre_files + src_post_files + \
1694             src_extra_src_files] + \
1695         ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files + src_support_files + \
1696             src_support_extra_header_files + src_support_extra_src_files] + \
1697         ['$TOP_SRCDIR/src/mathed/%s' % x for x in  src_mathed_header_files + src_mathed_files] + \
1698         ['$TOP_SRCDIR/src/insets/%s' % x for x in  src_insets_header_files + src_insets_files] + \
1699         ['$TOP_SRCDIR/src/frontends/%s' % x for x in  src_frontends_header_files + src_frontends_files] + \
1700         ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files + src_graphics_files] + \
1701         ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files + src_frontends_qt4_files] + \
1702         ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files + src_client_files ]  + \
1703         ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
1704     )
1705     Alias('update_po', POTFILES_in)
1706     # build language_l10n.pot, encodings_10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n
1707     # and combine them to lyx.po
1708     env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
1709     lyx_po = env.Command('$BUILDDIR/po/lyx.po',
1710         env.Command('$BUILDDIR/po/all.po',
1711             [env.Command('$BUILDDIR/po/qt4_l10n.pot', 
1712                 ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1713                 '$LYX_POT -b $TOP_SRCDIR -t qt4 -o $TARGET $SOURCES'),
1714              env.Command('$BUILDDIR/po/layouts_l10n.pot', 
1715                 ['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files + lib_layouts_inc_files + lib_layouts_module_files],
1716                 '$LYX_POT -b $TOP_SRCDIR -t layouts -o $TARGET $SOURCES'),
1717              env.Command('$BUILDDIR/po/languages_l10n.pot', '$TOP_SRCDIR/lib/languages',
1718                 '$LYX_POT -b $TOP_SRCDIR -t languages -o $TARGET $SOURCES'),
1719              env.Command('$BUILDDIR/po/encodings_l10n.pot', '$TOP_SRCDIR/lib/encodings',
1720                 '$LYX_POT -b $TOP_SRCDIR -t encodings -o $TARGET $SOURCES'),
1721              env.Command('$BUILDDIR/po/ui_l10n.pot', 
1722                 ['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files],
1723                 '$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
1724              env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
1725                 '$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
1726              env.Command('$BUILDDIR/po/formats_l10n.pot', '$TOP_SRCDIR/lib/configure.py',
1727                 '$LYX_POT -b $TOP_SRCDIR -t formats -o $TARGET $SOURCES'),
1728              ], utils.env_cat),
1729             ['$MSGUNIQ -o $TARGET $SOURCE',
1730              '''$XGETTEXT --default-domain=${TARGET.base} \
1731                 --directory=$TOP_SRCDIR --add-comments=TRANSLATORS: \
1732                 --language=C++ --join-existing \
1733                 --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ \
1734                 --files-from=$TOP_SRCDIR/po/POTFILES.in \
1735                 --copyright-holder="LyX Developers" \
1736                 --msgid-bugs-address="lyx-devel@lists.lyx.org" ''']
1737         )
1738     env.Depends(lyx_po, POTFILES_in)
1739     # copy lyx.po to lyx.pot
1740     lyx_pot = env.Command('$BUILDDIR/po/lyx.pot', lyx_po,
1741         Copy('$TARGET', '$SOURCE'))
1742     #
1743     import glob
1744     # files to translate
1745     transfiles = glob.glob(os.path.join(env.Dir('$TOP_SRCDIR/po').abspath, '*.po'))
1746     # possibly *only* handle these languages
1747     languages = None
1748     if env.has_key('languages'):
1749         languages = env.make_list(env['languages'])
1750     # merge. if I use lan.po as $TARGET, it will be removed
1751     # before it is merged. In this builder,
1752     # $BUILDDIR/po/lang.po is merged from po/lang.po and $BUILDDIR/po/lyx.pot
1753     # and is copied to po/lang.po
1754     env['BUILDERS']['msgmerge'] = Builder(action=[
1755         '$MSGMERGE $TOP_SRCDIR/po/${TARGET.filebase}.po $SOURCE -o $TARGET',
1756         Copy('$TOP_SRCDIR/po/${TARGET.filebase}.po', '$TARGET')]
1757         )
1758     # for each po file, generate pot
1759     for po_file in transfiles:
1760         # get filename
1761         fname = os.path.split(po_file)[1]
1762         # country code
1763         country = fname.split('.')[0]
1764         #
1765         if not languages or country in languages:
1766             # merge po files, the generated lan.po_new file is copied to lan.po file.
1767             po = env.msgmerge('$BUILDDIR/po/%s.po' % country, lyx_pot)
1768             env.Depends(po, POTFILES_in)
1769             Alias('update_po', po)
1770
1771
1772 # if 'install' is not in the target, do not process this
1773 if 'install' in BUILD_TARGETS or 'installer' in BUILD_TARGETS:
1774     #
1775     # this part is a bit messy right now. Since scons will provide
1776     # --DESTDIR option soon, at least the dest_dir handling can be 
1777     # removed later.
1778     #
1779     #
1780     # po/
1781     #
1782     import glob
1783     # handle po files
1784     #
1785     # files to translate
1786     transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
1787     # possibly *only* handle these languages
1788     languages = None
1789     if env.has_key('languages'):
1790         languages = env.make_list(env['lanauges'])
1791     # use default msgfmt
1792     gmo_files = []
1793     if not env['MSGFMT']:
1794         print 'msgfmt does not exist. Can not process po files'
1795     else:
1796         # create a builder
1797         env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -c --statistics -o $TARGET',suffix='.gmo',src_suffix='.po')
1798         #
1799         for f in transfiles:
1800             # get filename
1801             fname = os.path.split(f)[1]
1802             # country code
1803             country = fname.split('.')[0]
1804             #
1805             if not languages or country in languages:
1806                 gmo_files.extend(env.Transfiles(f))
1807     # how to join dest_dir and prefix
1808     def joinPaths(path1, path2):
1809         ''' join path1 and path2, do not use os.path.join because
1810             under window, c:\destdir\d:\program is invalid '''
1811         if path1 == '':
1812             return os.path.normpath(path2)
1813         # separate drive letter
1814         (drive, path) = os.path.splitdrive(os.path.normpath(path2))
1815         # ignore drive letter, so c:\destdir + c:\program = c:\destdir\program
1816         return os.path.join(os.path.normpath(path1), path[1:])
1817     #
1818     # install to dest_dir/prefix
1819     dest_dir = env.get('DESTDIR', '')
1820     dest_prefix_dir = joinPaths(dest_dir, env.Dir(prefix).abspath)
1821     # create the directory if needed
1822     if not os.path.isdir(dest_prefix_dir):
1823         try:
1824             os.makedirs(dest_prefix_dir)
1825         except:
1826             pass
1827         if not os.path.isdir(dest_prefix_dir):
1828             print 'Can not create directory', dest_prefix_dir
1829             Exit(3)
1830     #
1831     if env.has_key('exec_prefix'):
1832         bin_dest_dir = joinPaths(dest_dir, Dir(env['exec_prefix']).abspath)
1833     else:
1834         bin_dest_dir = os.path.join(dest_prefix_dir, 'bin')
1835     if add_suffix:
1836         share_dest_dir = os.path.join(dest_prefix_dir, share_dir + program_suffix)
1837     else:
1838         share_dest_dir = os.path.join(dest_prefix_dir, share_dir)
1839     man_dest_dir = os.path.join(dest_prefix_dir, man_dir)
1840     locale_dest_dir = os.path.join(dest_prefix_dir, locale_dir)
1841     env['LYX2LYX_DEST'] = os.path.join(share_dest_dir, 'lyx2lyx')
1842     #
1843     import glob
1844     #
1845     # install executables (lyxclient may be None)
1846     #
1847     if add_suffix:
1848         version_suffix = program_suffix
1849     else:
1850         version_suffix = ''
1851     #
1852     # install lyx, if in release mode, try to strip the binary
1853     if env.has_key('STRIP') and env['STRIP'] is not None and mode != 'debug':
1854         # create a builder to strip and install
1855         env['BUILDERS']['StripInstallAs'] = Builder(action='$STRIP $SOURCE -o $TARGET')
1856
1857     # install executables
1858     for (name, obj) in (('lyx', lyx), ('tex2lyx', tex2lyx), ('client', client)):
1859         if obj is None:
1860             continue
1861         target_name = os.path.split(str(obj[0]))[1].replace(name, '%s%s' % (name, version_suffix))
1862         target = os.path.join(bin_dest_dir, target_name)
1863         if env['BUILDERS'].has_key('StripInstallAs'):
1864             env.StripInstallAs(target, obj)
1865         else:
1866             env.InstallAs(target, obj)
1867         Alias('install', target)
1868
1869     # share/lyx
1870     dirs = []
1871     for (dir,files) in [
1872             ('.', lib_files),  
1873             ('bind', lib_bind_files),
1874             ('bind/de', lib_bind_de_files),
1875             ('commands', lib_commands_files),
1876             ('doc', lib_doc_files),
1877             ('doc/biblio', lib_doc_biblio_files),
1878             ('doc/clipart', lib_doc_clipart_files),
1879             ('doc/ca', lib_doc_ca_files),
1880             ('doc/cs', lib_doc_cs_files),
1881             ('doc/da', lib_doc_da_files),
1882             ('doc/de', lib_doc_de_files),
1883             ('doc/de/clipart', lib_doc_de_clipart_files),
1884             ('doc/el', lib_doc_el_files),
1885             ('doc/es', lib_doc_es_files),
1886             ('doc/es/clipart', lib_doc_es_clipart_files),
1887             ('doc/eu', lib_doc_eu_files),
1888             ('doc/fr', lib_doc_fr_files),
1889             ('doc/fr/clipart', lib_doc_fr_clipart_files),
1890             ('doc/gl', lib_doc_gl_files),
1891             ('doc/he', lib_doc_he_files),
1892             ('doc/hu', lib_doc_hu_files),
1893             ('doc/id', lib_doc_id_files),
1894             ('doc/id/clipart', lib_doc_id_clipart_files),
1895             ('doc/it', lib_doc_it_files),
1896             ('doc/it/clipart', lib_doc_it_clipart_files),
1897             ('doc/ja', lib_doc_ja_files),
1898             ('doc/ja/clipart', lib_doc_ja_clipart_files),
1899             ('doc/nl', lib_doc_nl_files),
1900             ('doc/nb', lib_doc_nb_files),
1901             ('doc/pl', lib_doc_pl_files),
1902             ('doc/pt', lib_doc_pt_files),
1903             ('doc/ro', lib_doc_ro_files),
1904             ('doc/ru', lib_doc_ru_files),
1905             ('doc/sk', lib_doc_sk_files),
1906             ('doc/sl', lib_doc_sl_files),
1907             ('doc/sv', lib_doc_sv_files),
1908             ('doc/uk', lib_doc_uk_files),
1909             ('doc/uk/clipart', lib_doc_uk_clipart_files),
1910             ('doc/zh_CN', lib_doc_zhCN_files),
1911             ('examples', lib_examples_files),
1912             ('examples/ca', lib_examples_ca_files),
1913             ('examples/cs', lib_examples_cs_files),
1914             ('examples/da', lib_examples_da_files),
1915             ('examples/de', lib_examples_de_files),
1916             ('examples/el', lib_examples_el_files),
1917             ('examples/es', lib_examples_es_files),
1918             ('examples/eu', lib_examples_eu_files),
1919             ('examples/fa', lib_examples_fa_files),
1920             ('examples/fr', lib_examples_fr_files),
1921             ('examples/gl', lib_examples_gl_files),
1922             ('examples/he', lib_examples_he_files),
1923             ('examples/hu', lib_examples_hu_files),
1924             ('examples/id', lib_examples_id_files),
1925             ('examples/it', lib_examples_it_files),
1926             ('examples/ja', lib_examples_ja_files),
1927             ('examples/nl', lib_examples_nl_files),
1928             ('examples/pl', lib_examples_pl_files),
1929             ('examples/pt', lib_examples_pt_files),
1930             ('examples/ro', lib_examples_ro_files),
1931             ('examples/ru', lib_examples_ru_files),
1932             ('examples/sk', lib_examples_sk_files),
1933             ('examples/sl', lib_examples_sl_files),
1934             ('examples/sr', lib_examples_sr_files),
1935             ('examples/sv', lib_examples_sv_files),
1936             ('examples/uk', lib_examples_uk_files),
1937             ('fonts', lib_fonts_files),
1938             ('images', lib_images_files),
1939             ('images/math', lib_images_math_files),
1940             ('images/commands', lib_images_commands_files),
1941             ('kbd', lib_kbd_files),
1942             ('layouts', lib_layouts_files + lib_layouts_inc_files + lib_layouts_module_files),
1943             ('lyx2lyx', lib_lyx2lyx_files),
1944             ('scripts', lib_scripts_files),
1945             ('templates', lib_templates_files),
1946             ('templates/thesis', lib_templates_thesis_files),
1947             ('tex', lib_tex_files),
1948             ('ui', lib_ui_files)]:
1949         dirs.append(env.Install(os.path.join(share_dest_dir, dir),
1950             [env.subst('$TOP_SRCDIR/lib/%s/%s' % (dir, file)) for file in files]))
1951     Alias('install', dirs)
1952
1953     # subst and install lyx2lyx_version.py which is not in scons_manifest.py
1954     env.Depends(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py', '$BUILDDIR/src/config.h')
1955     env.substFile(share_dest_dir + '/lyx2lyx/lyx2lyx_version.py',
1956         '$TOP_SRCDIR/lib/lyx2lyx/lyx2lyx_version.py.in')
1957     Alias('install', share_dest_dir + '/lyx2lyx/lyx2lyx_version.py')
1958     sys.path.append(share_dest_dir + '/lyx2lyx')
1959     
1960     if platform_name == 'cygwin':
1961         # cygwin packaging requires a file /usr/share/doc/Cygwin/foot-vendor-suffix.README
1962         Cygwin_README = os.path.join(dest_prefix_dir, 'share', 'doc', 'Cygwin', 
1963             '%s-%s.README' % (package, package_cygwin_version))
1964         env.InstallAs(Cygwin_README,
1965             os.path.join(env.subst('$TOP_SRCDIR'), 'README.cygwin'))
1966         Alias('install', Cygwin_README)
1967         # also a directory /usr/share/doc/lyx for README etc
1968         Cygwin_Doc = os.path.join(dest_prefix_dir, 'share', 'doc', package)
1969         env.Install(Cygwin_Doc, [os.path.join(env.subst('$TOP_SRCDIR'), x) for x in \
1970             ['INSTALL', 'README', 'README.Cygwin', 'RELEASE-NOTES', 'COPYING', 'ANNOUNCE']])
1971         Alias('install', Cygwin_Doc)
1972         # cygwin fonts also need to be installed
1973         Cygwin_fonts = os.path.join(share_dest_dir, 'fonts')
1974         env.Install(Cygwin_fonts, 
1975             [env.subst('$TOP_SRCDIR/development/Win32/packaging/bakoma/%s' % file) \
1976                   for file in win32_bakoma_fonts])
1977         Alias('install', Cygwin_fonts)
1978         # we also need a post installation script
1979         tmp_script = utils.installCygwinPostinstallScript('/tmp')
1980         postinstall_path = os.path.join(dest_dir, 'etc', 'postinstall')
1981         env.Install(postinstall_path, tmp_script)
1982         Alias('install', postinstall_path)
1983     # man
1984     env.InstallAs(os.path.join(man_dest_dir, 'lyx' + version_suffix + '.1'),
1985         env.subst('$TOP_SRCDIR/lyx.1in'))
1986     env.InstallAs(os.path.join(man_dest_dir, 'tex2lyx' + version_suffix + '.1'),
1987         env.subst('$TOP_SRCDIR/src/tex2lyx/tex2lyx.1in'))
1988     env.InstallAs(os.path.join(man_dest_dir, 'lyxclient' + version_suffix + '.1'),
1989         env.subst('$TOP_SRCDIR/src/client/lyxclient.1in'))
1990     Alias('install', [os.path.join(man_dest_dir, x + version_suffix + '.1') for
1991         x in ['lyx', 'tex2lyx', 'lyxclient']])
1992     # locale files?
1993     # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
1994     for gmo in gmo_files:
1995         lan = os.path.split(str(gmo))[1].split('.')[0]
1996         dest_file = os.path.join(locale_dest_dir, lan, 'LC_MESSAGES', 'lyx' + program_suffix + '.mo')
1997         env.InstallAs(dest_file, gmo)
1998         Alias('install', dest_file)
1999
2000
2001 if 'installer' in BUILD_TARGETS:
2002     #
2003     # build windows installer using NSIS
2004     #
2005     # NOTE:
2006     # There is a nsis builder on scons wiki but it does not work with
2007     # our lyx.nsi because it does not dig through all the include directives
2008     # and find the dependencies automatically. Also, it can not parse
2009     # OutFile in lyx.nsi since it is defined as SETUP_EXE which is in turn
2010     # something rely on date.
2011     # Because of this, I am doing a simple nsis builder here.
2012     if platform_name != 'win32':
2013         print 'installer target is only available for windows platform'
2014         Exit(1)
2015     if mode != 'release':
2016         print 'installer has to be built in release mode (use option mode=release)'
2017         Exit(1)
2018     installer_files = ['$TOP_SRCDIR/development/Win32/packaging/installer/%s' \
2019             % x for x in development_Win32_packaging_installer] + \
2020         ['$TOP_SRCDIR/development/Win32/packaging/installer/graphics/%s' \
2021             % x for x in development_Win32_packaging_installer_graphics] + \
2022         ['$TOP_SRCDIR/development/Win32/packaging/installer/gui/%s' \
2023             % x for x in development_Win32_packaging_installer_gui] + \
2024         ['$TOP_SRCDIR/development/Win32/packaging/installer/include/%s' \
2025             % x for x in development_Win32_packaging_installer_include] + \
2026         ['$TOP_SRCDIR/development/Win32/packaging/installer/lang/%s' \
2027             % x for x in development_Win32_packaging_installer_lang] + \
2028         ['$TOP_SRCDIR/development/Win32/packaging/installer/setup/%s' \
2029             % x for x in development_Win32_packaging_installer_setup]
2030     if env.has_key('NSIS') and env['NSIS'] is not None:
2031         # create a builder to strip and install
2032         env['BUILDERS']['installer'] = Builder(generator=utils.env_nsis)
2033     else:
2034         print 'No nsis compiler is found. Existing...'
2035         Exit(2)
2036     if not env.has_key('win_installer') or env['win_installer'] is None:
2037         if devel_version:
2038             env['win_installer'] = '%s-%s-%s-Installer.exe' % (package_name, package_version, time.strftime('%Y-%m-%d'))
2039         else:
2040             env['win_installer'] = '%s-%s-Installer.exe' % (package_name, package_version)
2041     # provide default setting            
2042     if not env.has_key('deps_dir') or env['deps_dir'] is None:
2043         env['deps_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-deps-msvc-qt4')
2044     if not os.path.isdir(env.Dir('$deps_dir').abspath):
2045         print 'Development dependency package is not found.'
2046         Exit(1)    
2047     else:
2048         env['deps_dir'] = env.Dir('$deps_dir').abspath
2049     # build bundle?
2050     if env.has_key('bundle_dir') and os.path.isdir(env.Dir('$bundle_dir').abspath):
2051         env['bundle_dir'] = env.Dir('$bundle_dir').abspath
2052     elif os.path.isdir(os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')):
2053         env['bundle_dir'] = os.path.join(env.Dir('$TOP_SRCDIR').abspath, 'lyx-windows-bundle-deps')
2054     else:
2055         env['bundle_dir'] = None
2056     # if absolute path is given, use it, otherwise, write to current directory
2057     if not (':' in env['win_installer'] or '/' in env['win_installer'] or '\\' in env['win_installer']):
2058         env['win_installer'] = os.path.join(env.Dir('$BUILDDIR').abspath, env['win_installer'])
2059     env.Append(NSISDEFINES={
2060         'ExeFile':env['win_installer'],
2061         'BundleExeFile':env['win_installer'].replace('.exe', '-bundle.exe'),
2062         'FilesLyx':env.Dir(dest_prefix_dir).abspath,
2063         'FilesDeps':env['deps_dir'],
2064         'FilesBundle':env['bundle_dir'],
2065         })
2066     installer = env.installer(env['win_installer'],
2067         '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2068     # since I can not use a scanner, explicit dependent is required
2069     env.Depends(installer, 'install')
2070     env.Depends(installer, installer_files)
2071     env.Alias('installer', installer)
2072     # also generate bundle?
2073     if env.has_key('bundle') and env['bundle']:
2074         if env['bundle_dir'] is None or not os.path.isdir(env['bundle_dir']):
2075             print 'Bundle directory does not exist (default to %s\lyx-windows-bundle-deps.' % env.Dir('$TOP_SRCDIR').abspath
2076             print 'Use bundle_dir option to specify'
2077             Exit(1)
2078         # generator of the builder will add bundle stuff depending on output name
2079         bundle_installer = env.installer(env['win_installer'].replace('.exe', '-bundle.exe'),
2080             '$TOP_SRCDIR/development/Win32/packaging/installer/lyx.nsi')
2081         env.Depends(bundle_installer, 'install')
2082         env.Depends(bundle_installer, installer_files)
2083         env.Alias('installer', bundle_installer)
2084
2085 Default('lyx')
2086 Alias('all', ['lyx', 'client', 'tex2lyx'])