]> git.lyx.org Git - lyx.git/blob - development/scons/SConstruct
* move system-specific file locations to settings.nsh
[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 # check the existence of config.h
724 config_h = os.path.join(env.Dir('$BUILDDIR/src').path, 'config.h')
725 boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h')
726 #
727 print "Creating %s..." % boost_config_h
728 #
729 utils.createConfigFile(conf,
730     config_file = boost_config_h,
731     config_pre = r'''/* boost/config.h.  Generated by SCons.  */
732
733 /* -*- C++ -*- */
734 /*
735 * \file config.h
736 * This file is part of LyX, the document processor.
737 * Licence details can be found in the file COPYING.
738 *
739 * This is the compilation configuration file for LyX.
740 * It was generated by scon.
741 * You might want to change some of the defaults if something goes wrong
742 * during the compilation.
743 */
744
745 #ifndef _BOOST_CONFIG_H
746 #define _BOOST_CONFIG_H
747 ''',
748     headers = [
749         ('ostream', 'HAVE_OSTREAM', 'cxx'),
750         ('locale', 'HAVE_LOCALE', 'cxx'),
751         ('sstream', 'HAVE_SSTREAM', 'cxx'),
752     ],
753     custom_tests = [
754         (env.has_key('assertions') and env['assertions'] and mode == 'debug',
755             'ENABLE_ASSERTIONS',
756             'Define if you want assertions to be enabled in the code'
757         ),
758     ],
759     types = [
760         ('wchar_t', 'HAVE_WCHAR_T', None),
761     ],
762     config_post = '''
763
764 #if defined(HAVE_OSTREAM) && defined(HAVE_LOCALE) && defined(HAVE_SSTREAM)
765 #  define USE_BOOST_FORMAT 1
766 #else
767 #  define USE_BOOST_FORMAT 0
768 #endif
769
770 #if !defined(ENABLE_ASSERTIONS)
771 #  define BOOST_DISABLE_ASSERTS 1
772 #endif
773 #define BOOST_ENABLE_ASSERT_HANDLER 1
774
775 #define BOOST_DISABLE_THREADS 1
776 #define BOOST_NO_WSTRING 1
777
778 #ifdef __CYGWIN__
779 #  define BOOST_POSIX 1
780 #  define BOOST_POSIX_API 1
781 #  define BOOST_POSIX_PATH 1
782 #endif
783
784 #define BOOST_ALL_NO_LIB 1
785
786 /*
787  * the FreeBSD libc uses UCS4, but libstdc++ has no proper wchar_t
788  * support compiled in:
789  * http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#3_9
790  * And we are not interested at all what libc
791  * does: What we need is a 32bit wide wchar_t, and a libstdc++ that
792  * has the needed wchar_t support and uses UCS4. Whether it
793  * implements this with the help of libc, or whether it has own code
794  * does not matter for us, because we don't use libc directly (Georg)
795 */
796 #if defined(HAVE_WCHAR_T) && SIZEOF_WCHAR_T == 4 && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
797 #  define USE_WCHAR_T
798 #endif
799
800 #endif
801 '''
802 )
803 #
804 print "\nGenerating %s..." % config_h
805
806 # AIKSAURUS_H_LOCATION
807 if (conf.CheckCXXHeader("Aiksaurus.h")):
808     aik_location = '<Aiksaurus.h>'
809 elif (conf.CheckCXXHeader("Aiksaurus/Aiksaurus.h")):
810     aik_location = '<Aiksaurus/Aiksaurus.h>'
811 else:
812     aik_location = ''
813
814 # determine headers to use
815 spell_opt = ARGUMENTS.get('spell', 'auto')
816 env['USE_ASPELL'] = False
817 env['USE_ENCHANT'] = False
818 env['USE_HUNSPELL'] = False
819 if spell_opt in ['auto', 'aspell'] and conf.CheckLib(aspell_lib):
820     spell_engine = 'USE_ASPELL'
821 elif spell_opt in ['auto', 'enchant'] and conf.CheckLib('enchant'):
822     spell_engine = 'USE_ENCHANT'
823 elif spell_opt in ['auto', 'hunspell'] and conf.CheckLib('hunspell'):
824     spell_engine = 'USE_HUNSPELL'
825 else:
826     spell_engine = None
827
828 if spell_engine is not None:
829     env[spell_engine] = True
830 else:
831     if spell_opt == 'auto':
832         print "Warning: Can not locate any spell checker"
833     elif spell_opt != 'no':
834         print "Warning: Can not locate specified spell checker:", spell_opt
835         print 'Please check config.log for more information.'
836         Exit(1)
837
838 # check arg types of select function
839 (select_arg1, select_arg234, select_arg5) = conf.CheckSelectArgType()
840
841 # check the size of wchar_t
842 sizeof_wchar_t = conf.CheckSizeOfWChar()
843 # something wrong
844 if sizeof_wchar_t == 0:
845     print 'Error: Can not determine the size of wchar_t.'
846     print 'Please check config.log for more information.'
847     Exit(1)
848
849
850 # fill in the version info
851 env['VERSION_INFO'] = '''Configuration
852   Host type:                      %s
853   Special build flags:            %s
854   C   Compiler:                   %s
855   C   Compiler flags:             %s %s
856   C++ Compiler:                   %s
857   C++ Compiler LyX flags:         %s
858   C++ Compiler flags:             %s %s
859   Linker flags:                   %s
860   Linker user flags:              %s
861 Build info:
862   Builing directory:              %s
863   Libraries paths:                %s
864   Boost libraries:                %s
865   include search path:            %s
866 Frontend:
867   Frontend:                       %s
868   Packaging:                      %s
869   LyX dir:                        %s
870   LyX files dir:                  %s
871 ''' % (platform_name,
872     env.subst('$CCFLAGS'), env.subst('$CC'),
873     env.subst('$CPPFLAGS'), env.subst('$CFLAGS'),
874     env.subst('$CXX'), env.subst('$CXXFLAGS'),
875     env.subst('$CPPFLAGS'), env.subst('$CXXFLAGS'),
876     env.subst('$LINKFLAGS'), env.subst('$LINKFLAGS'),
877     env.subst('$LOCALLIBPATH'),
878     env.subst('$LIBPATH'), str(boost_libraries),
879     env.subst('$CPPPATH'),
880     frontend, packaging_method,
881     prefix, env['LYX_DATA_DIR'])
882
883 #
884 # create config.h
885 result = utils.createConfigFile(conf,
886     config_file = config_h,
887     config_pre = r'''/* config.h.  Generated by SCons.  */
888
889 /* -*- C++ -*- */
890 /*
891 * \file config.h
892 * This file is part of LyX, the document processor.
893 * Licence details can be found in the file COPYING.
894 *
895 * This is the compilation configuration file for LyX.
896 * It was generated by scon.
897 * You might want to change some of the defaults if something goes wrong
898 * during the compilation.
899 */
900
901 #ifndef _CONFIG_H
902 #define _CONFIG_H
903 ''',
904     headers = [
905         ('io.h', 'HAVE_IO_H', 'c'),
906         ('limits.h', 'HAVE_LIMITS_H', 'c'),
907         ('locale.h', 'HAVE_LOCALE_H', 'c'),
908         ('process.h', 'HAVE_PROCESS_H', 'c'),
909         ('stdlib.h', 'HAVE_STDLIB_H', 'c'),
910         ('string.h', 'HAVE_STRING_H', 'c'),
911         ('sys/stat.h', 'HAVE_SYS_STAT_H', 'c'),
912         ('sys/time.h', 'HAVE_SYS_TIME_H', 'c'),
913         ('sys/types.h', 'HAVE_SYS_TYPES_H', 'c'),
914         ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
915         ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
916         ('unistd.h', 'HAVE_UNISTD_H', 'c'),
917         ('utime.h', 'HAVE_UTIME_H', 'c'),
918         ('direct.h', 'HAVE_DIRECT_H', 'c'),
919         ('istream', 'HAVE_ISTREAM', 'cxx'),
920         ('ios', 'HAVE_IOS', 'cxx'),
921     ],
922     functions = [
923         ('open', 'HAVE_OPEN', None),
924         ('chmod', 'HAVE_CHMOD', None),
925         ('close', 'HAVE_CLOSE', None),
926         ('popen', 'HAVE_POPEN', None),
927         ('pclose', 'HAVE_PCLOSE', None),
928         ('_open', 'HAVE__OPEN', None),
929         ('_close', 'HAVE__CLOSE', None),
930         ('_popen', 'HAVE__POPEN', None),
931         ('_pclose', 'HAVE__PCLOSE', None),
932         ('getpid', 'HAVE_GETPID', None),
933         ('_getpid', 'HAVE__GETPID', None),
934         ('mkdir', 'HAVE_MKDIR', None),
935         ('_mkdir', 'HAVE__MKDIR', None),
936         ('mktemp', 'HAVE_MKTEMP', None),
937         ('mkstemp', 'HAVE_MKSTEMP', None),
938         ('strerror', 'HAVE_STRERROR', None),
939         ('getcwd', 'HAVE_GETCWD', None),
940         ('setenv', 'HAVE_SETENV', None),
941         ('putenv', 'HAVE_PUTENV', None),
942         ('fcntl', 'HAVE_FCNTL', None),
943         ('mkfifo', 'HAVE_MKFIFO', None),
944     ],
945     declarations = [
946         ('mkstemp', 'HAVE_DECL_MKSTEMP', ['unistd.h', 'stdlib.h']),
947     ],
948     types = [
949         ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
950             '#include <streambuf>\n#include <istream>'),
951         ('wchar_t', 'HAVE_WCHAR_T', None),
952         ('mode_t', 'HAVE_MODE_T', "#include <sys/types.h>"),
953     ],
954     libs = [
955         ('gdi32', 'HAVE_LIBGDI32'),
956         (('Aiksaurus', 'libAiksaurus'), 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB'),
957     ],
958     custom_tests = [
959         (conf.CheckType('pid_t', includes='#include <sys/types.h>'),
960             'HAVE_PID_T',
961             'Define is sys/types.h does not have pid_t',
962             '',
963             '#define pid_t int',
964         ),
965         (conf.CheckCXXGlobalCstd(),
966             'CXX_GLOBAL_CSTD',
967             'Define if your C++ compiler puts C library functions in the global namespace'
968         ),
969         (conf.CheckMkdirOneArg(),
970             'MKDIR_TAKES_ONE_ARG',
971             'Define if mkdir takes only one argument.'
972         ),
973         (conf.CheckIconvConst(),
974             'ICONV_CONST',
975             'Define as const if the declaration of iconv() needs const.',
976             '#define ICONV_CONST const',
977             '#define ICONV_CONST',
978         ),
979         (conf.CheckLC_MESSAGES(),
980             'HAVE_LC_MESSAGES',
981             'Define if your <locale.h> file defines LC_MESSAGES.'
982         ),
983         (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'),
984         (env['nls'],
985             'ENABLE_NLS',
986             "Define to 1 if translation of program messages to the user's native anguage is requested.",
987         ),
988         (env['nls'] and not included_gettext,
989             'HAVE_GETTEXT',
990             'Define to 1 if using system gettext library'
991         ),
992         (env.has_key('concept_checks') and env['concept_checks'],
993             '_GLIBCXX_CONCEPT_CHECKS',
994             'libstdc++ concept checking'
995         ),
996         (env.has_key('stdlib_debug') and env['stdlib_debug'],
997             '_GLIBCXX_DEBUG',
998             'libstdc++ debug mode'
999         ),
1000         (env.has_key('stdlib_debug') and env['stdlib_debug'],
1001             '_GLIBCXX_DEBUG_PEDANTIC',
1002             'libstdc++ pedantic debug mode'
1003         ),
1004         (os.name != 'nt', 'BOOST_POSIX',
1005             'Indicates to boost < 1.34 which API to use (posix or windows).'
1006         ),
1007         (os.name != 'nt', 'BOOST_POSIX_API',
1008             'Indicates to boost 1.34 which API to use (posix or windows).'
1009         ),
1010         (os.name != 'nt', 'BOOST_POSIX_PATH',
1011             'Indicates to boost 1.34 which path style to use (posix or windows).'
1012         ),
1013         (spell_engine is not None, spell_engine,
1014             'Spell engine to use'
1015         ),
1016         # we need to know the byte order for unicode conversions
1017         (sys.byteorder == 'big', 'WORDS_BIGENDIAN',
1018             'Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX).'
1019         ),
1020     ],
1021     extra_items = [
1022         ('#define PACKAGE "%s%s"' % (package, program_suffix),
1023             'Name of package'),
1024         ('#define PACKAGE_BUGREPORT "%s"' % package_bugreport,
1025             'Define to the address where bug reports for this package should be sent.'),
1026         ('#define PACKAGE_NAME "%s"' % package_name,
1027             'Define to the full name of this package.'),
1028         ('#define PACKAGE_STRING "%s"' % package_string,
1029             'Define to the full name and version of this package.'),
1030         ('#define PACKAGE_TARNAME "%s"' % package_tarname,
1031             'Define to the one symbol short name of this package.'),
1032         ('#define PACKAGE_VERSION "%s"' % package_version,
1033             'Define to the version of this package.'),
1034         ('#define LYX_MAJOR_VERSION %d' % int(lyx_major_version),
1035             'Define to the major version of this package.'),
1036         ('#define LYX_MINOR_VERSION %d' % int(lyx_minor_version),
1037             'Define to the minor version of this package.'),
1038         ('#define VERSION_INFO "%s"' % env['VERSION_INFO'].replace('\n', '\\n'),
1039             'Full version info'),
1040         ('#define LYX_DIR_VER "LYX_DIR_%sx"' % majmin_ver,
1041             'Versioned env var for system dir'),
1042         ('#define LYX_USERDIR_VER "LYX_USERDIR_%sx"' % majmin_ver,
1043             'Versioned env var for user dir'),
1044         ('#define LYX_DATE "%s"' % lyx_date,
1045             'Date of release'),
1046         ('#define PROGRAM_SUFFIX "%s"' % program_suffix,
1047             'Program version suffix'),
1048         ('#define LYX_ABS_INSTALLED_DATADIR "%s"' % env.subst('$LYX_DATA_DIR').replace('\\', '/'),
1049             'Hard coded system support directory'),
1050         ('#define LYX_ABS_INSTALLED_LOCALEDIR "%s"' % env.subst('$LOCALEDIR').replace('\\', '/'),
1051             'Hard coded locale directory'),
1052         ('#define LYX_ABS_TOP_SRCDIR "%s"' % env.subst('$TOP_SRCDIR').replace('\\', '/'),
1053             'Top source directory'),
1054         ('#define BOOST_ALL_NO_LIB 1',
1055             'disable automatic linking of boost libraries.'),
1056         ('#define USE_%s_PACKAGING 1' % packaging_method.upper(),
1057             'Packaging method'),
1058         ('#define AIKSAURUS_H_LOCATION ' + aik_location,
1059             'Aiksaurus include file'),
1060         ('#define SELECT_TYPE_ARG1 %s' % select_arg1,
1061             "Define to the type of arg 1 for `select'."),
1062         ('#define SELECT_TYPE_ARG234 %s' % select_arg234,
1063             "Define to the type of arg 2, 3, 4 for `select'."),
1064         ('#define SELECT_TYPE_ARG5 %s' % select_arg5,
1065             "Define to the type of arg 5 for `select'."),
1066         ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1067             'Define to be the size of type wchar_t'),
1068     ],
1069     config_post = '''/************************************************************
1070 ** You should not need to change anything beyond this point */
1071
1072 #ifndef HAVE_STRERROR
1073 #if defined(__cplusplus)
1074 extern "C"
1075 #endif
1076 char * strerror(int n);
1077 #endif
1078
1079 #include <../boost/config.h>
1080
1081 #endif
1082 '''
1083 )
1084
1085 # these keys are needed in env
1086 for key in ['USE_ASPELL', 'USE_ENCHANT', 'USE_HUNSPELL', 'HAVE_FCNTL',\
1087     'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS', 'AIKSAURUS_LIB']:
1088     # USE_ASPELL etc does not go through result
1089     if result.has_key(key):
1090         env[key] = result[key]
1091
1092 #
1093 # if nls=yes and gettext=included, create intl/config.h
1094 # intl/libintl.h etc
1095 #
1096 intl_config_h = os.path.join(env.Dir('$BUILDDIR/intl').path, 'config.h')
1097 if env['nls'] and included_gettext:
1098     #
1099     print "Creating %s..." % intl_config_h
1100     #
1101     # create intl/config.h
1102     result = utils.createConfigFile(conf,
1103         config_file = intl_config_h,
1104         config_pre = r'''/* intl/config.h.  Generated by SCons.  */
1105
1106 /* -*- C++ -*- */
1107 /*
1108 * \file config.h
1109 * This file is part of LyX, the document processor.
1110 * Licence details can be found in the file COPYING.
1111 *
1112 * This is the compilation configuration file for LyX.
1113 * It was generated by scon.
1114 * You might want to change some of the defaults if something goes wrong
1115 * during the compilation.
1116 */
1117
1118 #ifndef _INTL_CONFIG_H
1119 #define _INTL_CONFIG_H
1120 ''',
1121         headers = [
1122             ('unistd.h', 'HAVE_UNISTD_H', 'c'),
1123             ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
1124             ('string.h', 'HAVE_STRING_H', 'c'),
1125             ('strings.h', 'HAVE_STRINGS_H', 'c'),
1126             ('argz.h', 'HAVE_ARGZ_H', 'c'),
1127             ('limits.h', 'HAVE_LIMITS_H', 'c'),
1128             ('alloca.h', 'HAVE_ALLOCA_H', 'c'),
1129             ('stddef.h', 'HAVE_STDDEF_H', 'c'),
1130             ('stdint.h', 'HAVE_STDINT_H', 'c'),
1131             ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'),
1132         ],
1133         functions = [
1134             ('getcwd', 'HAVE_GETCWD', None),
1135             ('stpcpy', 'HAVE_STPCPY', None),
1136             ('strcasecmp', 'HAVE_STRCASECMP', None),
1137             ('strdup', 'HAVE_STRDUP', None),
1138             ('strtoul', 'HAVE_STRTOUL', None),
1139             ('alloca', 'HAVE_ALLOCA', None),
1140             ('__fsetlocking', 'HAVE___FSETLOCKING', None),
1141             ('mempcpy', 'HAVE_MEMPCPY', None),
1142             ('__argz_count', 'HAVE___ARGZ_COUNT', None),
1143             ('__argz_next', 'HAVE___ARGZ_NEXT', None),
1144             ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None),
1145             ('setlocale', 'HAVE_SETLOCALE', None),
1146             ('tsearch', 'HAVE_TSEARCH', None),
1147             ('getegid', 'HAVE_GETEGID', None),
1148             ('getgid', 'HAVE_GETGID', None),
1149             ('getuid', 'HAVE_GETUID', None),
1150             ('wcslen', 'HAVE_WCSLEN', None),
1151             ('asprintf', 'HAVE_ASPRINTF', None),
1152             ('wprintf', 'HAVE_WPRINTF', None),
1153             ('snprintf', 'HAVE_SNPRINTF', None),
1154             ('printf', 'HAVE_POSIX_PRINTF', None),
1155             ('fcntl', 'HAVE_FCNTL', None),
1156         ],
1157         types = [
1158             ('intmax_t', 'HAVE_INTMAX_T', None),
1159             ('long double', 'HAVE_LONG_DOUBLE', None),
1160             ('long long', 'HAVE_LONG_LONG', None),
1161             ('wchar_t', 'HAVE_WCHAR_T', None),
1162             ('wint_t', 'HAVE_WINT_T', None),
1163             ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include <inttypes.h>'),
1164             ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include <stdint.h>'),
1165         ],
1166         libs = [
1167             ('c', 'HAVE_LIBC'),
1168         ],
1169         custom_tests = [
1170             (conf.CheckLC_MESSAGES(),
1171                 'HAVE_LC_MESSAGES',
1172                 'Define if your <locale.h> file defines LC_MESSAGES.'
1173             ),
1174             (conf.CheckIconvConst(),
1175                 'ICONV_CONST',
1176                 'Define as const if the declaration of iconv() needs const.',
1177                 '#define ICONV_CONST const',
1178                 '#define ICONV_CONST',
1179             ),
1180             (conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
1181             conf.CheckType('intmax_t', includes='#include <inttypes.h>'),
1182                 'HAVE_INTMAX_T',
1183                 "Define to 1 if you have the `intmax_t' type."
1184             ),
1185             (env.has_key('nls') and env['nls'],
1186                 'ENABLE_NLS',
1187                 "Define to 1 if translation of program messages to the user's native anguage is requested.",
1188             ),
1189         ],
1190         extra_items = [
1191             ('#define HAVE_ICONV 1', 'Define if iconv or libiconv is found'),
1192             ('#define SIZEOF_WCHAR_T %d' % sizeof_wchar_t,
1193                 'Define to be the size of type wchar_t'),
1194         ],
1195         config_post = '#endif'
1196     )
1197
1198     # these keys are needed in env
1199     for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \
1200         'HAVE_POSIX_PRINTF', 'HAVE_LIBC']:
1201         # USE_ASPELL etc does not go through result
1202         if result.has_key(key):
1203             env[key] = result[key]
1204
1205
1206 # this looks misplaced, but intl/libintl.h is needed by src/message.C
1207 if env['nls'] and included_gettext:
1208     # libgnuintl.h.in => libintl.h
1209     env.Depends('$TOP_SRCDIR/intl/libintl.h', '$BUILDDIR/intl/config.h')
1210     env.substFile('$BUILDDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in')
1211     env.Command('$BUILDDIR/intl/libgnuintl.h', '$BUILDDIR/intl/libintl.h',
1212         [Copy('$TARGET', '$SOURCE')])
1213
1214 #
1215 # Finish auto-configuration
1216 env = conf.Finish()
1217
1218 #----------------------------------------------------------
1219 # Now set up our build process accordingly
1220 #----------------------------------------------------------
1221
1222 if env['ICONV_LIB'] is None:
1223     system_libs = []
1224 else:
1225     system_libs = [env['ICONV_LIB']]
1226 if platform_name in ['win32', 'cygwin']:
1227     # the final link step needs stdc++ to succeed under mingw
1228     # FIXME: shouldn't g++ automatically link to stdc++?
1229     if use_vc:
1230         system_libs += ['ole32', 'shlwapi', 'psapi', 'shell32', 'advapi32', 'zdll']
1231     else:
1232         system_libs += ['shlwapi', 'psapi', 'stdc++', 'z']
1233 elif platform_name == 'cygwin' and env['X11']:
1234     system_libs += ['GL',  'Xmu', 'Xi', 'Xrender', 'Xrandr',
1235         'Xcursor', 'Xft', 'freetype', 'fontconfig', 'Xext', 'X11', 'SM', 'ICE', 
1236         'resolv', 'pthread', 'z']
1237 else:
1238     system_libs += ['z']
1239
1240 libs = [
1241     ('HAVE_LIBGDI32', 'gdi32'),
1242     ('HAVE_LIBAIKSAURUS', env['AIKSAURUS_LIB']),
1243     ('USE_ASPELL', aspell_lib),
1244     ('USE_ENCHANT', 'enchant'),
1245     ('USE_HUNSPELL', 'hunspell')
1246 ]
1247
1248 for lib in libs:
1249     if env[lib[0]]:
1250         system_libs.append(lib[1])
1251
1252 #
1253 # Build parameters CPPPATH etc
1254 #
1255 if env['X11']:
1256     env.AppendUnique(LIBPATH = ['/usr/X11R6/lib'])
1257
1258 #
1259 # boost: for boost header files
1260 # BUILDDIR/src: for config.h
1261 # TOP_SRCDIR/src: for support/* etc
1262 #
1263 env['CPPPATH'] += ['$BUILDDIR/src', '$TOP_SRCDIR/src']
1264 #
1265 # Separating boost directories from CPPPATH stops scons from building
1266 # the dependency tree for boost header files, and effectively reduce
1267 # the null build time of lyx from 29s to 16s. Since lyx may tweak local
1268 # boost headers, the following is not 100% safe.
1269 #    env.AppendUnique(CPPPATH = ['$BOOST_INC_PATH'])
1270 env.PrependUnique(CCFLAGS = ['$INCPREFIX$BOOST_INC_PATH'])
1271
1272 # for intl/config.h, intl/libintl.h and intl/libgnuintl.h
1273 if env['nls'] and included_gettext:
1274     env['CPPPATH'].append('$BUILDDIR/intl')
1275 #
1276
1277 #
1278 # A Link script for cygwin see
1279 # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html
1280 # http://www.cygwin.com/ml/cygwin-apps/2004-09/msg00309.html
1281 # for details
1282 #
1283 if platform_name == 'cygwin':
1284     ld_script_path = '/tmp'
1285     ld_script = utils.installCygwinLDScript(ld_script_path)
1286     env.AppendUnique(LINKFLAGS = ['-Wl,--enable-runtime-pseudo-reloc',
1287         '-Wl,--script,%s' % ld_script, '-Wl,-s'])
1288
1289
1290 #---------------------------------------------------------
1291 # Frontend related variables (QTDIR etc)
1292 #---------------------------------------------------------
1293
1294 #
1295 # create a separate environment so that other files do not have
1296 # to be built with all the include directories etc
1297 #
1298 if frontend == 'qt4':
1299     env['BUILDERS']['qtResource'] = Builder(action = utils.env_qtResource)
1300
1301     # handle qt related user specified paths
1302     # set environment so that moc etc can be found even if its path is not set properly
1303     if env.has_key('qt_dir') and env['qt_dir']:
1304         env['QTDIR'] = env['qt_dir']
1305         if os.path.isdir(os.path.join(env['qt_dir'], 'bin')):
1306             os.environ['PATH'] += os.pathsep + os.path.join(env['qt_dir'], 'bin')
1307             env.PrependENVPath('PATH', os.path.join(env['qt_dir'], 'bin'))
1308         if os.path.isdir(os.path.join(env['qt_dir'], 'lib')):
1309             env.PrependENVPath('PKG_CONFIG_PATH', os.path.join(env['qt_dir'], 'lib'))
1310
1311     # if separate qt_lib_path is given
1312     if env.has_key('qt_lib_path') and env['qt_lib_path']:
1313         qt_lib_path = env.subst('$qt_lib_path')
1314         env.AppendUnique(LIBPATH = [qt_lib_path])
1315         env.PrependENVPath('PKG_CONFIG_PATH', qt_lib_path)
1316     else:
1317         qt_lib_path = None
1318
1319     # if separate qt_inc_path is given
1320     if env.has_key('qt_inc_path') and env['qt_inc_path']:
1321         qt_inc_path = env['qt_inc_path']
1322     else:
1323         qt_inc_path = None
1324
1325     # local qt4 toolset from
1326     # http://www.iua.upf.es/~dgarcia/Codders/sconstools.html
1327     #
1328     # NOTE: I have to patch qt4.py since it does not automatically
1329     # process .C file!!! (add to cxx_suffixes )
1330     #
1331     env.Tool('qt4', [scons_dir])
1332     env['QT_AUTOSCAN'] = 0
1333     env['QT4_AUTOSCAN'] = 0
1334     env['QT4_UICDECLFLAGS'] = '-tr lyx::qt_'
1335     if platform_name == 'win32':
1336         env['QT4_MOCFROMHFLAGS'] = '-D_WIN32'
1337
1338     if qt_lib_path is None:
1339         qt_lib_path = os.path.join(env.subst('$QTDIR'), 'lib')
1340     if qt_inc_path is None:
1341         qt_inc_path = os.path.join(env.subst('$QTDIR'), 'include')
1342
1343
1344     conf = Configure(env,
1345         custom_tests = { 
1346             'CheckPackage' : utils.checkPackage,
1347             'CheckCommand' : utils.checkCommand,
1348         }
1349     )
1350
1351     succ = False
1352     # first: try pkg_config
1353     if env['HAS_PKG_CONFIG']:
1354         succ = conf.CheckPackage('QtCore') or conf.CheckPackage('QtCore4')
1355         # FIXME: use pkg_config information?
1356         #env['QT4_PKG_CONFIG'] = succ
1357     # second: try to link to it
1358     if not succ:
1359         # Under linux, I can test the following perfectly
1360         # Under windows, lib names need to passed as libXXX4.a ...
1361         if platform_name == 'win32':
1362             succ = conf.CheckLibWithHeader('QtCore4', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1363         else:
1364             succ = conf.CheckLibWithHeader('QtCore', 'QtGui/QApplication', 'c++', 'QApplication qapp();')
1365     # still can not find it
1366     if not succ:
1367         print 'Did not find qt libraries, exiting!'
1368         print 'Please check config.log for more information.'
1369         Exit(1)
1370     #
1371     # Now, determine the correct suffix:
1372     qt_libs = ['QtCore', 'QtGui']
1373     if platform_name == 'win32':
1374         if mode == 'debug' and use_vc and \
1375             conf.CheckLibWithHeader('QtCored4', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1376             qt_lib_suffix = 'd4'
1377             use_qt_debug_libs = True
1378         else:
1379             qt_lib_suffix = '4'
1380             use_qt_debug_libs = False
1381     else:
1382         if mode == 'debug' and conf.CheckLibWithHeader('QtCore_debug', 'QtGui/QApplication', 'c++', 'QApplication qapp();'):
1383             qt_lib_suffix = '_debug'
1384             use_qt_debug_libs = True
1385         else:
1386             qt_lib_suffix = ''
1387             use_qt_debug_libs = False
1388     env.EnableQt4Modules(qt_libs, debug = (mode == 'debug' and use_qt_debug_libs))
1389     frontend_libs = [x + qt_lib_suffix for x in qt_libs]
1390     qtcore_lib = ['QtCore' + qt_lib_suffix]
1391
1392     # check uic and moc commands for qt frontends
1393     if conf.CheckCommand('uic') == None or conf.CheckCommand('moc') == None:
1394         print 'uic or moc command is not found for frontend', frontend
1395         Exit(1)
1396     
1397     # now, if msvc2005 is used, we will need to embed lyx.exe.manifest to lyx.exe
1398     # NOTE: previously, lyx.exe had to be linked to some qt manifest to work.
1399     # For some unknown changes in msvc or qt, this is no longer needed.
1400     if use_vc:
1401         env['LINKCOM'] = [env['LINKCOM'], \
1402             'mt.exe /MANIFEST %s /outputresource:$TARGET;1' % \
1403             env.File('$BUILDDIR/lyx.exe.manifest').path]
1404
1405     env = conf.Finish()
1406
1407 #
1408 # Report results
1409 #
1410 print env['VERSION_INFO']
1411
1412 #
1413 # Mingw command line may be too short for our link usage,
1414 # Here we use a trick from scons wiki
1415 # http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/LongCmdLinesOnWin32
1416 #
1417 # I also would like to add logging (commands only) capacity to the
1418 # spawn system.
1419 logfile = env.get('logfile', default_log_file)
1420 if logfile != '' or platform_name == 'win32':
1421     import time
1422     utils.setLoggedSpawn(env, logfile, longarg = (platform_name == 'win32'),
1423         info = '''# This is a log of commands used by scons to build lyx
1424 # Time: %s
1425 # Command: %s
1426 # Info: %s
1427 ''' % (time.asctime(), ' '.join(sys.argv),
1428     env['VERSION_INFO'].replace('\n','\n# ')) )
1429
1430
1431 # Cleanup stuff
1432 #
1433 # -h will print out help info
1434 Help(opts.GenerateHelpText(env))
1435
1436
1437 #----------------------------------------------------------
1438 # Start building
1439 #----------------------------------------------------------
1440 # this has been the source of problems on some platforms...
1441 # I find that I need to supply it with full path name
1442 env.SConsignFile(os.path.join(Dir(env['BUILDDIR']).abspath, '.sconsign'))
1443 # this usage needs further investigation.
1444 #env.CacheDir('%s/Cache/%s' % (env['BUILDDIR'], frontend))
1445 env.VariantDir('$BUILDDIR/boost', '$TOP_SRCDIR/boost/libs', duplicate = 0)
1446 env.VariantDir('$BUILDDIR/intl', '$TOP_SRCDIR/intl', duplicate = 0)
1447 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1448 env.VariantDir('$BUILDDIR/src', '$TOP_SRCDIR/src', duplicate = 0)
1449
1450 print "Building all targets recursively"
1451
1452 def libExists(libname):
1453     ''' Check whether or not lib $LOCALLIBNAME/libname already exists'''
1454     return os.path.isfile(File(env.subst('$LOCALLIBPATH/${LIBPREFIX}%s$LIBSUFFIX'%libname)).abspath)
1455
1456
1457 if (included_boost and not libExists('included_boost_regex')) or 'boost' in BUILD_TARGETS:
1458     #
1459     # boost/libs
1460     #
1461     for lib in boost_libs:
1462         boostlib = env.StaticLibrary(
1463             target = '$LOCALLIBPATH/included_boost_%s' % lib,
1464             source = ['$BUILDDIR/boost/%s/src/%s' % (lib, x) for x in eval('boost_libs_%s_src_files' % lib)],
1465             # do not use global CPPPATH because src/config.h will mess up with boost/config.h
1466             CPPPATH = ['$BUILDDIR/boost'] + extra_inc_paths,
1467             CCFLAGS = ['$CCFLAGS', '$INCPREFIX$TOP_SRCDIR/boost', '-DBOOST_USER_CONFIG="<config.h>"']
1468         )
1469         Alias('boost', boostlib)
1470
1471
1472 if (included_gettext and not libExists('included_intl')) or 'intl' in BUILD_TARGETS:
1473     #
1474     # intl
1475     #
1476     INTL_CCFLAGS =  [
1477         r'-DLOCALEDIR=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1478         r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALEDIR'].replace('\\', '\\\\') + r'\"',
1479         r'-DLIBDIR=\"' + env['TOP_SRCDIR'].replace('\\', '\\\\') + r'/lib\"',
1480         '-DIN_LIBINTL',
1481         '-DENABLE_RELOCATABLE=1',
1482         '-DIN_LIBRARY',
1483         r'-DINSTALLDIR=\"' + prefix.replace('\\', '\\\\') + r'/lib\"',
1484         '-DNO_XMALLOC',
1485         '-Dset_relocation_prefix=libintl_set_relocation_prefix',
1486         '-Drelocate=libintl_relocate',
1487         '-DDEPENDS_ON_LIBICONV=1',
1488         '-DHAVE_CONFIG_H'
1489         ]
1490     if use_vc:
1491         INTL_CCFLAGS.extend(['/Dinline#', '/D__attribute__(x)#', '/Duintmax_t=UINT_MAX'])
1492
1493     intl = env.StaticLibrary(
1494         target = '$LOCALLIBPATH/included_intl',
1495         LIBS = ['c'],
1496         CCFLAGS = INTL_CCFLAGS,
1497         # do not use global CPPPATH because src/config.h will mess up with intl/config.h
1498         CPPPATH =  ['$BUILDDIR/intl'] + extra_inc_paths,
1499         source = ['$BUILDDIR/intl/%s' % x for x in intl_files]
1500     )
1501     Alias('intl', intl)
1502
1503 #
1504 # src/support
1505 #
1506 env['QT4_MOCHPREFIX'] = 'moc_'
1507 env['QT4_MOCHSUFFIX'] = '.cpp'
1508
1509 support_moced_files = [env.Moc4('$BUILDDIR/src/support/%s' % x)
1510     for x in src_support_header_files ]
1511 support = env.StaticLibrary(
1512     target = '$LOCALLIBPATH/support',
1513     source = ['$BUILDDIR/src/support/%s' % x for x in src_support_files],
1514     CCFLAGS =  [
1515         '$CCFLAGS',
1516         '-DHAVE_CONFIG_H',
1517         '-DQT_NO_STL',
1518         '-DQT_NO_KEYWORDS',
1519     ],
1520     CPPPATH = ['$CPPPATH', '$BUILDDIR/src/support']
1521 )
1522 Alias('support', support)
1523
1524 #
1525 if env['HAVE_FCNTL']:
1526     client = env.Program(
1527         target = '$BUILDDIR/src/client/lyxclient',
1528         LIBS = ['support'] + intl_libs + system_libs +
1529             socket_libs + boost_libraries + qtcore_lib,
1530         source = ['$BUILDDIR/src/client/%s' % x for x in src_client_files] + \
1531             utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/client.rc')
1532     )
1533     Alias('client', env.Command(os.path.join('$BUILDDIR', os.path.split(str(client[0]))[1]),
1534         client, [Copy('$TARGET', '$SOURCE')]))
1535 else:
1536     client = None
1537 Alias('client', client)
1538
1539
1540 #
1541 # tex2lyx
1542 #
1543 for file in src_tex2lyx_copied_files + src_tex2lyx_copied_header_files:
1544     env.Command('$BUILDDIR/src/tex2lyx/'+file, '$TOP_SRCDIR/src/'+file,
1545         [Copy('$TARGET', '$SOURCE')])
1546
1547 tex2lyx = env.Program(
1548     target = '$BUILDDIR/src/tex2lyx/tex2lyx',
1549     LIBS = ['support'] + boost_libraries + intl_libs + system_libs + qtcore_lib,
1550     source = ['$BUILDDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files + src_tex2lyx_copied_files] + \
1551         utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/tex2lyx.rc'),
1552     CPPPATH = ['$BUILDDIR/src/tex2lyx', '$BUILDDIR/src', '$CPPPATH'],
1553     LIBPATH = ['#$LOCALLIBPATH', '$LIBPATH'],
1554     CCFLAGS = ['$CCFLAGS', '-DTEX2LYX'],
1555 )
1556 Alias('tex2lyx', env.Command(os.path.join('$BUILDDIR', os.path.split(str(tex2lyx[0]))[1]),
1557     tex2lyx, [Copy('$TARGET', '$SOURCE')]))
1558 Alias('tex2lyx', tex2lyx)
1559
1560
1561 #
1562 # Build lyx with given frontend
1563 #
1564 if env.has_key('USE_ASPELL') and env['USE_ASPELL']:
1565     src_post_files.append('AspellChecker.cpp')
1566     src_post_files.append('PersonalWordList.cpp')
1567 elif env.has_key('USE_ENCHANT') and env['USE_ENCHANT']:
1568     src_post_files.append('EnchantChecker.cpp')
1569     src_post_files.append('PersonalWordList.cpp')
1570 elif env.has_key('USE_HUNSPELL') and env['USE_HUNSPELL']:
1571     src_post_files.append('HunspellChecker.cpp')
1572     src_post_files.append('PersonalWordList.cpp')
1573
1574 # tells scons how to get these moced files, although not all moced files are needed
1575 # (or are actually generated).
1576 qt4_moced_files = [env.Moc4('$BUILDDIR/src/frontends/qt4/%s' % x)
1577     for x in src_frontends_qt4_header_files ]
1578 src_moced_files = [env.Moc4('$BUILDDIR/src/%s' % x)
1579     for x in src_header_files ]
1580 ui_files = [env.Uic4('$BUILDDIR/src/frontends/qt4/ui/%s' % x.split('.')[0])
1581     for x in src_frontends_qt4_ui_files]
1582 resource = env.Qrc(env.qtResource(
1583     '$BUILDDIR/src/frontends/qt4/Resource.qrc',
1584     ['$TOP_SRCDIR/lib/images/%s' % x for x in lib_images_files] +
1585     ['$TOP_SRCDIR/lib/images/math/%s' % x for x in lib_images_math_files] +
1586     ['$TOP_SRCDIR/lib/images/commands/%s' % x for x in lib_images_commands_files]))
1587
1588 lyx = env.Program(
1589     target = '$BUILDDIR/lyx',
1590     source = ['$BUILDDIR/src/main.cpp'] +
1591         ['$BUILDDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files] +
1592         resource +
1593         ['$BUILDDIR/src/graphics/%s' % x for x in src_graphics_files] +
1594         ['$BUILDDIR/src/mathed/%s' % x for x in src_mathed_files] +
1595         ['$BUILDDIR/src/insets/%s' % x for x in src_insets_files] +
1596         ['$BUILDDIR/src/frontends/%s' % x for x in src_frontends_files] +
1597         ['$BUILDDIR/src/%s' % x for x in src_pre_files] +
1598         ["$BUILDDIR/src/%s" % x for x in src_post_files] +
1599         utils.createResFromIcon(env, 'lyx.ico', '$LOCALLIBPATH/lyx.rc'),
1600     CPPPATH = [
1601         '$CPPPATH',
1602         '$BUILDDIR/src',
1603         '$BUILDDIR/src/images',
1604         '$BUILDDIR/src/frontends',
1605         '$BUILDDIR/src/frontends/qt4',
1606         '$BUILDDIR/src/frontends/qt4/ui',
1607     ],
1608     CCFLAGS =  [
1609         '$CCFLAGS',
1610         '-DHAVE_CONFIG_H',
1611         '-DQT_NO_STL',
1612         '-DQT_NO_KEYWORDS',
1613     ],
1614     LIBS = [
1615         'support',
1616         ] +
1617         boost_libraries + 
1618         frontend_libs +
1619         intl_libs +
1620         socket_libs +
1621         system_libs
1622 )
1623 Alias('lyx', lyx)
1624
1625
1626 if use_vc and 'msvs_projects' in BUILD_TARGETS:
1627     def build_project(target, full_target = None, src = [], inc = [], res = []):
1628         ''' build mavs project files
1629             target:      alias (correspond to directory name)
1630             full_target: full path/filename of the target
1631             src:         source files
1632             inc:         include files
1633             res:         resource files
1634
1635         For non-debug-able targets like static libraries, target (alias) is
1636         enough to build the target. For executable targets, msvs need to know
1637         the full path to start debug them.
1638         '''
1639         # project
1640         proj = env.MSVSProject(
1641             target = target + env['MSVSPROJECTSUFFIX'],
1642             # this allows easy access to header files (along with source)
1643             srcs = [env.subst(x) for x in src + inc],
1644             incs = [env.subst('$TOP_SRCDIR/src/config.h')],
1645             localincs = [env.subst(x) for x in inc],
1646             resources = [env.subst(x) for x in res],
1647             buildtarget = full_target,
1648             variant = 'Debug'
1649         )
1650         Alias('msvs_projects', proj)
1651     #
1652     build_project('client', src = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_files],
1653         inc = ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files],
1654         full_target = File(env.subst('$BUILDDIR/src/client/lyxclient$PROGSUFFIX')).abspath)
1655     #
1656     build_project('tex2lyx', src = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_files],
1657         inc = ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files],
1658         full_target = File(env.subst('$BUILDDIR/src/tex2lyx/tex2lyx$PROGSUFFIX')).abspath)
1659     #
1660     build_project('lyx', 
1661         src = ['$TOP_SRCDIR/src/%s' % x for x in src_pre_files + src_post_files + ['version.cpp']] + \
1662             ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_files + ['Package.cpp'] ] + \
1663             ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_files] + \
1664             ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_files] + \
1665             ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_files] + \
1666             ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_files] + \
1667             ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_files],
1668         inc = ['$TOP_SRCDIR/src/%s' % x for x in src_header_files] + \
1669             ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files] + \
1670             ['$TOP_SRCDIR/src/mathed/%s' % x for x in src_mathed_header_files] + \
1671             ['$TOP_SRCDIR/src/insets/%s' % x for x in src_insets_header_files] + \
1672             ['$TOP_SRCDIR/src/frontends/%s' % x for x in src_frontends_header_files] + \
1673             ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files] + \
1674             ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files],
1675         res = ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1676         full_target = File(env.subst('$BUILDDIR/lyx$PROGSUFFIX')).abspath)
1677
1678
1679 if 'update_po' in BUILD_TARGETS:
1680     #
1681     # update po files
1682     #
1683     print 'Updating po/*.po files...'
1684
1685     # whether or not update po files
1686     if not env['XGETTEXT'] or not env['MSGMERGE'] or not env['MSGUNIQ']:
1687         print 'xgettext or msgmerge does not exist. Cannot merge po files'
1688         Exit(1)
1689     # rebuild POTFILES.in
1690     POTFILES_in = env.potfiles('$TOP_SRCDIR/po/POTFILES.in', 
1691         ['$TOP_SRCDIR/src/%s' % x for x in  src_header_files + src_pre_files + src_post_files + \
1692             src_extra_src_files] + \
1693         ['$TOP_SRCDIR/src/support/%s' % x for x in src_support_header_files + src_support_files + \
1694             src_support_extra_header_files + src_support_extra_src_files] + \
1695         ['$TOP_SRCDIR/src/mathed/%s' % x for x in  src_mathed_header_files + src_mathed_files] + \
1696         ['$TOP_SRCDIR/src/insets/%s' % x for x in  src_insets_header_files + src_insets_files] + \
1697         ['$TOP_SRCDIR/src/frontends/%s' % x for x in  src_frontends_header_files + src_frontends_files] + \
1698         ['$TOP_SRCDIR/src/graphics/%s' % x for x in src_graphics_header_files + src_graphics_files] + \
1699         ['$TOP_SRCDIR/src/frontends/qt4/%s' % x for x in src_frontends_qt4_header_files + src_frontends_qt4_files] + \
1700         ['$TOP_SRCDIR/src/client/%s' % x for x in src_client_header_files + src_client_files ]  + \
1701         ['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
1702     )
1703     Alias('update_po', POTFILES_in)
1704     # build language_l10n.pot, encodings_10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n
1705     # and combine them to lyx.po
1706     env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
1707     lyx_po = env.Command('$BUILDDIR/po/lyx.po',
1708         env.Command('$BUILDDIR/po/all.po',
1709             [env.Command('$BUILDDIR/po/qt4_l10n.pot', 
1710                 ['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files],
1711                 '$LYX_POT -b $TOP_SRCDIR -t qt4 -o $TARGET $SOURCES'),
1712              env.Command('$BUILDDIR/po/layouts_l10n.pot', 
1713                 ['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files + lib_layouts_inc_files + lib_layouts_module_files],
1714                 '$LYX_POT -b $TOP_SRCDIR -t layouts -o $TARGET $SOURCES'),
1715              env.Command('$BUILDDIR/po/languages_l10n.pot', '$TOP_SRCDIR/lib/languages',
1716                 '$LYX_POT -b $TOP_SRCDIR -t languages -o $TARGET $SOURCES'),
1717              env.Command('$BUILDDIR/po/encodings_l10n.pot', '$TOP_SRCDIR/lib/encodings',
1718                 '$LYX_POT -b $TOP_SRCDIR -t encodings -o $TARGET $SOURCES'),
1719              env.Command('$BUILDDIR/po/ui_l10n.pot', 
1720                 ['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files],
1721                 '$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
1722              env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
1723                 '$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
1724              env.Command('$BUILDDIR/po/formats_l10n.pot', '$TOP_SRCDIR/lib/configure.py',
1725                 '$LYX_POT -b $TOP_SRCDIR -t formats -o $TARGET $SOURCES'),
1726              ], utils.env_cat),
1727             ['$MSGUNIQ -o $TARGET $SOURCE',
1728              '''$XGETTEXT --default-domain=${TARGET.base} \
1729                 --directory=$TOP_SRCDIR --add-comments=TRANSLATORS: \
1730                 --language=C++ --join-existing \
1731                 --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ \
1732                 --files-from=$TOP_SRCDIR/po/POTFILES.in \
1733                 --copyright-holder="LyX Developers" \
1734                 --msgid-bugs-address="lyx-devel@lists.lyx.org" ''']
1735         )
1736     env.Depends(lyx_po, POTFILES_in)
1737     # copy lyx.po to lyx.pot
1738     lyx_pot = env.Command('$BUILDDIR/po/lyx.pot', lyx_po,
1739         Copy('$TARGET', '$SOURCE'))
1740     #
1741     import glob
1742     # files to translate
1743     transfiles = glob.glob(os.path.join(env.Dir('$TOP_SRCDIR/po').abspath, '*.po'))
1744     # possibly *only* handle these languages
1745     languages = None
1746     if env.has_key('languages'):
1747         languages = env.make_list(env['languages'])
1748     # merge. if I use lan.po as $TARGET, it will be removed
1749     # before it is merged. In this builder,
1750     # $BUILDDIR/po/lang.po is merged from po/lang.po and $BUILDDIR/po/lyx.pot
1751     # and is copied to po/lang.po
1752     env['BUILDERS']['msgmerge'] = Builder(action=[
1753         '$MSGMERGE $TOP_SRCDIR/po/${TARGET.filebase}.po $SOURCE -o $TARGET',
1754         Copy('$TOP_SRCDIR/po/${TARGET.filebase}.po', '$TARGET')]
1755         )
1756     # for each po file, generate pot
1757     for po_file in transfiles:
1758         # get filename
1759         fname = os.path.split(po_file)[1]
1760         # country code
1761         country = fname.split('.')[0]
1762         #
1763         if not languages or country in languages:
1764             # merge po files, the generated lan.po_new file is copied to lan.po file.
1765             po = env.msgmerge('$BUILDDIR/po/%s.po' % country, lyx_pot)
1766             env.Depends(po, POTFILES_in)
1767             Alias('update_po', po)
1768
1769
1770 # if 'install' is not in the target, do not process this
1771 if 'install' in BUILD_TARGETS or 'installer' in BUILD_TARGETS:
1772     #
1773     # this part is a bit messy right now. Since scons will provide
1774     # --DESTDIR option soon, at least the dest_dir handling can be 
1775     # removed later.
1776     #
1777     #
1778     # po/
1779     #
1780     import glob
1781     # handle po files
1782     #
1783     # files to translate
1784     transfiles = glob.glob(os.path.join(env.subst('$TOP_SRCDIR'), 'po', '*.po'))
1785     # possibly *only* handle these languages
1786     languages = None
1787     if env.has_key('languages'):
1788         languages = env.make_list(env['lanauges'])
1789     # use defulat msgfmt
1790     gmo_files = []
1791     if not env['MSGFMT']:
1792         print 'msgfmt does not exist. Can not process po files'
1793     else:
1794         # create a builder
1795         env['BUILDERS']['Transfiles'] = Builder(action='$MSGFMT $SOURCE -c --statistics -o $TARGET',suffix='.gmo',src_suffix='.po')
1796         #
1797         for f in transfiles:
1798             # get filename
1799             fname = os.path.split(f)[1]
1800             # country code
1801             country = fname.split('.')[0]
1802             #
1803             if not languages or country in languages:
1804                 gmo_files.extend(env.Transfiles(f))
1805     # how to join dest_dir and prefix
1806     def joinPaths(path1, path2):
1807         ''' join path1 and path2, do not use os.path.join because
1808             under window, c:\destdir\d:\program is invalid '''
1809         if path1 == '':
1810             return os.path.normpath(path2)
1811         # separate drive letter
1812         (drive, path) = os.path.splitdrive(os.path.normpath(path2))
1813         # ignore drive letter, so c:\destdir + c:\program = c:\destdir\program
1814         return os.path.join(os.path.normpath(path1), path[1:])
1815     #
1816     # install to dest_dir/prefix
1817     dest_dir = env.get('DESTDIR', '')
1818     dest_prefix_dir = joinPaths(dest_dir, env.Dir(prefix).abspath)
1819     # create the directory if needed
1820     if not os.path.isdir(dest_prefix_dir):
1821         try:
1822             os.makedirs(dest_prefix_dir)
1823         except:
1824             pass
1825         if not os.path.isdir(dest_prefix_dir):
1826             print 'Can not create directory', dest_prefix_dir
1827             Exit(3)
1828     #
1829     if env.has_key('exec_prefix'):
1830         bin_dest_dir = joinPaths(dest_dir, Dir(env['exec_prefix']).abspath)
1831     else:
1832         bin_dest_dir = os.path.join(dest_prefix_dir, 'bin')
1833     if add_suffix:
1834         share_dest_dir = os.path.join(dest_prefix_dir, share_dir + program_suffix)
1835     else:
1836         share_dest_dir = os.path.join(dest_prefix_dir, share_dir)
1837     man_dest_dir = os.path.join(dest_prefix_dir, man_dir)
1838     locale_dest_dir = os.path.join(dest_prefix_dir, locale_dir)
1839     env['LYX2LYX_DEST'] = os.path.join(share_dest_dir, 'lyx2lyx')
1840     #
1841     import glob
1842     #
1843     # install executables (lyxclient may be None)
1844     #
1845     if add_suffix:
1846         version_suffix = program_suffix
1847     else:
1848         version_suffix = ''
1849     #
1850     # install lyx, if in release mode, try to strip the binary
1851     if env.has_key('STRIP') and env['STRIP'] is not None and mode != 'debug':
1852         # create a builder to strip and install
1853         env['BUILDERS']['StripInstallAs'] = Builder(action='$STRIP $SOURCE -o $TARGET')
1854
1855     # install executables
1856     for (name, obj) in (('lyx', lyx), ('tex2lyx', tex2lyx), ('client', client)):
1857         if obj is None:
1858             continue
1859         target_name = os.path.split(str(obj[0]))[1].replace(name, '%s%s' % (name, version_suffix))
1860         target = os.path.join(bin_dest_dir, target_name)
1861         if env['BUILDERS'].has_key('StripInstallAs'):
1862             env.StripInstallAs(target, obj)
1863         else:
1864             env.InstallAs(target, obj)
1865         Alias('install', target)
1866
1867     # share/lyx
1868     dirs = []
1869     for (dir,files) in [
1870             ('.', lib_files),  
1871             ('bind', lib_bind_files),
1872             ('bind/de', lib_bind_de_files),
1873             ('bind/fi', lib_bind_fi_files),
1874             ('bind/pt', lib_bind_pt_files),
1875             ('bind/sv', lib_bind_sv_files),
1876             ('commands', lib_commands_files),
1877             ('doc', lib_doc_files),
1878             ('doc/biblio', lib_doc_biblio_files),
1879             ('doc/clipart', lib_doc_clipart_files),
1880             ('doc/ca', lib_doc_ca_files),
1881             ('doc/cs', lib_doc_cs_files),
1882             ('doc/da', lib_doc_da_files),
1883             ('doc/de', lib_doc_de_files),
1884             ('doc/de/clipart', lib_doc_de_clipart_files),
1885             ('doc/el', lib_doc_el_files),
1886             ('doc/es', lib_doc_es_files),
1887             ('doc/es/clipart', lib_doc_es_clipart_files),
1888             ('doc/eu', lib_doc_eu_files),
1889             ('doc/fr', lib_doc_fr_files),
1890             ('doc/fr/clipart', lib_doc_fr_clipart_files),
1891             ('doc/gl', lib_doc_gl_files),
1892             ('doc/he', lib_doc_he_files),
1893             ('doc/hu', lib_doc_hu_files),
1894             ('doc/id', lib_doc_id_files),
1895             ('doc/id/clipart', lib_doc_id_clipart_files),
1896             ('doc/it', lib_doc_it_files),
1897             ('doc/it/clipart', lib_doc_it_clipart_files),
1898             ('doc/ja', lib_doc_ja_files),
1899             ('doc/ja/clipart', lib_doc_ja_clipart_files),
1900             ('doc/nl', lib_doc_nl_files),
1901             ('doc/nb', lib_doc_nb_files),
1902             ('doc/pl', lib_doc_pl_files),
1903             ('doc/pt', lib_doc_pt_files),
1904             ('doc/ro', lib_doc_ro_files),
1905             ('doc/ru', lib_doc_ru_files),
1906             ('doc/sk', lib_doc_sk_files),
1907             ('doc/sl', lib_doc_sl_files),
1908             ('doc/sv', lib_doc_sv_files),
1909             ('doc/uk', lib_doc_uk_files),
1910             ('doc/uk/clipart', lib_doc_uk_clipart_files),
1911             ('doc/zh_CN', lib_doc_zhCN_files),
1912             ('examples', lib_examples_files),
1913             ('examples/ca', lib_examples_ca_files),
1914             ('examples/cs', lib_examples_cs_files),
1915             ('examples/da', lib_examples_da_files),
1916             ('examples/de', lib_examples_de_files),
1917             ('examples/el', lib_examples_el_files),
1918             ('examples/es', lib_examples_es_files),
1919             ('examples/eu', lib_examples_eu_files),
1920             ('examples/fa', lib_examples_fa_files),
1921             ('examples/fr', lib_examples_fr_files),
1922             ('examples/gl', lib_examples_gl_files),
1923             ('examples/he', lib_examples_he_files),
1924             ('examples/hu', lib_examples_hu_files),
1925             ('examples/id', lib_examples_id_files),
1926             ('examples/it', lib_examples_it_files),
1927             ('examples/ja', lib_examples_ja_files),
1928             ('examples/nl', lib_examples_nl_files),
1929             ('examples/pl', lib_examples_pl_files),
1930             ('examples/pt', lib_examples_pt_files),
1931             ('examples/ro', lib_examples_ro_files),
1932             ('examples/ru', lib_examples_ru_files),
1933             ('examples/sk', lib_examples_sk_files),
1934             ('examples/sl', lib_examples_sl_files),
1935             ('examples/sr', lib_examples_sr_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'])