diff --git a/development/scons/SConstruct b/development/scons/SConstruct index 4d98a6ac7e..f714508df4 100644 --- a/development/scons/SConstruct +++ b/development/scons/SConstruct @@ -510,7 +510,7 @@ def setEnvVariable(env, name, required = None, default = None, split = True): if required is not None: env[name] = required if default is not None: - if env.has_key(name): + if env.has_key(name) and env[name] != default: env[name] += default else: env[name] = default @@ -530,7 +530,6 @@ setEnvVariable(env, 'LINKFLAGS', LINKFLAGS_required) if env.has_key('dest_dir'): print "This option is obsolete. Please use DESTDIR instead." env['DESTDIR'] = env['dest_dir'] -dest_dir = env.get('DESTDIR', prefix) #--------------------------------------------------------- @@ -602,6 +601,7 @@ conf = Configure(env, 'CheckCommand' : utils.checkCommand, 'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd, 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES, + 'CheckIconvConst' : utils.checkIconvConst, } ) @@ -775,6 +775,12 @@ if not fast_start: else: env['MSGFMT'] = env_cache['MSGFMT'] +# +# Customized builders +# +# install customized builders +env['BUILDERS']['substFile'] = Builder(action = utils.env_subst) + #---------------------------------------------------------- # Generating config.h @@ -784,9 +790,11 @@ aspell_lib = 'aspell' if platform_name == 'win32' and mode == 'debug' and use_vc: aspell_lib = 'aspelld' -if not fast_start: - # - boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h') +# check the existence of config.h +config_h = os.path.join(env.Dir('$BUILDDIR/common').path, 'config.h') +boost_config_h = os.path.join(env.Dir('$BUILDDIR/boost').path, 'config.h') +if not fast_start or not os.path.isfile(boost_config_h) \ + or not os.path.isfile(config_h): # print "Creating %s..." % boost_config_h # @@ -852,9 +860,6 @@ if not fast_start: ''' ) # - # config.h for each build - config_h = os.path.join(env.Dir('$BUILDDIR/common').path, 'config.h') - print "\nGenerating %s..." % config_h # AIKSAURUS_H_LOCATION @@ -895,7 +900,7 @@ if not fast_start: # create config.h result = utils.createConfigFile(conf, config_file = config_h, - config_pre = '''/* src/config.h. Generated by SCons. */ + config_pre = '''/* config.h. Generated by SCons. */ /* -*- C++ -*- */ /* @@ -987,10 +992,14 @@ int count() 'Define if your file defines LC_MESSAGES.' ), (devel_version, 'DEVEL_VERSION', 'Whether or not a development version'), - (env.has_key('nls') and env['nls'], + (env['nls'], 'ENABLE_NLS', "Define to 1 if translation of program messages to the user's native anguage is requested.", ), + (env['nls'] and not included_gettext, + 'HAVE_GETTEXT', + 'Define to 1 if using system gettext library' + ), (env.has_key('warnings') and env['warnings'], 'WITH_WARNINGS', 'Define this if you want to see the warning directives put here and there by the developpers to get attention' @@ -1073,6 +1082,117 @@ int mkstemp(char*); if result.has_key(key): env[key] = result[key] env_cache[key] = env[key] + + # + # if nls=yes and gettext=included, create intl/config.h + # intl/libintl.h etc + # + intl_config_h = os.path.join(env.Dir('$BUILDDIR/intl').path, 'config.h') + if env['nls'] and included_gettext: + # + print "Creating %s..." % intl_config_h + # + # create intl/config.h + result = utils.createConfigFile(conf, + config_file = intl_config_h, + config_pre = '''/* intl/config.h. Generated by SCons. */ + +/* -*- C++ -*- */ +/* + * \file config.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * This is the compilation configuration file for LyX. + * It was generated by scon. + * You might want to change some of the defaults if something goes wrong + * during the compilation. + */ + +#ifndef _CONFIG_H +#define _CONFIG_H +''', + headers = [ + ('unistd.h', 'HAVE_UNISTD_H', 'c'), + ('inttypes.h', 'HAVE_INTTYPES_H', 'c'), + ('string.h', 'HAVE_STRING_H', 'c'), + ('strings.h', 'HAVE_STRINGS_H', 'c'), + ('argz.h', 'HAVE_ARGZ_H', 'c'), + ('limits.h', 'HAVE_LIMITS_H', 'c'), + ('alloca.h', 'HAVE_ALLOCA_H', 'c'), + ('stddef.h', 'HAVE_STDDEF_H', 'c'), + ('stdint.h', 'HAVE_STDINT_H', 'c'), + ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'), + ], + functions = [ + ('getcwd', 'HAVE_GETCWD', None), + ('stpcpy', 'HAVE_STPCPY', None), + ('strcasecmp', 'HAVE_STRCASECMP', None), + ('strdup', 'HAVE_STRDUP', None), + ('strtoul', 'HAVE_STRTOUL', None), + ('alloca', 'HAVE_ALLOCA', None), + ('__fsetlocking', 'HAVE___FSETLOCKING', None), + ('mempcpy', 'HAVE_MEMPCPY', None), + ('__argz_count', 'HAVE___ARGZ_COUNT', None), + ('__argz_next', 'HAVE___ARGZ_NEXT', None), + ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None), + ('setlocale', 'HAVE_SETLOCALE', None), + ('tsearch', 'HAVE_TSEARCH', None), + ('getegid', 'HAVE_GETEGID', None), + ('getgid', 'HAVE_GETGID', None), + ('getuid', 'HAVE_GETUID', None), + ('wcslen', 'HAVE_WCSLEN', None), + ('asprintf', 'HAVE_ASPRINTF', None), + ('wprintf', 'HAVE_WPRINTF', None), + ('snprintf', 'HAVE_SNPRINTF', None), + ('printf', 'HAVE_POSIX_PRINTF', None), + ('fcntl', 'HAVE_FCNTL', None), + ], + types = [ + ('intmax_t', 'HAVE_INTMAX_T', None), + ('long double', 'HAVE_LONG_DOUBLE', None), + ('long long', 'HAVE_LONG_LONG', None), + ('wchar_t', 'HAVE_WCHAR_T', None), + ('wint_t', 'HAVE_WINT_T', None), + ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include '), + ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include '), + ], + libs = [ + (('iconv', 'libiconv'), 'HAVE_ICONV', 'ICONV_LIB'), + ('c', 'HAVE_LIBC'), + ], + custom_tests = [ + (conf.CheckLC_MESSAGES(), + 'HAVE_LC_MESSAGES', + 'Define if your file defines LC_MESSAGES.' + ), + (conf.CheckIconvConst(), + 'ICONV_CONST', + 'Define as const if the declaration of iconv() needs const.', + '#define ICONV_CONST', + '#define ICONV_CONST const', + ), + (conf.CheckType('intmax_t', includes='#include ') or \ + conf.CheckType('intmax_t', includes='#include '), + 'HAVE_INTMAX_T', + "Define to 1 if you have the `intmax_t' type." + ), + (env.has_key('nls') and env['nls'], + 'ENABLE_NLS', + "Define to 1 if translation of program messages to the user's native anguage is requested.", + ), + ], + config_post = '#endif' + ) + + # these keys are needed in env + for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \ + 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']: + # USE_ASPELL etc does not go through result + if result.has_key(key): + env[key] = result[key] + env_cache[key] = env[key] + else: # # this comes as a big surprise, without this line @@ -1085,6 +1205,20 @@ else: 'HAVE_ICONV', 'HAVE_LIBGDI32', 'HAVE_LIBAIKSAURUS', 'ICONV_LIB', 'AIKSAURUS_LIB']: env[key] = env_cache[key] + # + # nls related keys + if env['nls'] and included_gettext: + # only a few variables need to be rescanned + for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \ + 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']: + env[key] = env_cache[key] + +# this looks misplaced, but intl/libintl.h is needed by src/message.C +if env['nls'] and included_gettext: + # libgnuintl.h.in => libintl.h + env.substFile('$BUILDDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in') + env.Command('$BUILDDIR/intl/libgnuintl.h', '$BUILDDIR/intl/libintl.h', + [Copy('$TARGET', '$SOURCE')]) # # Finish auto-configuration @@ -1163,16 +1297,13 @@ if env['X11']: # TOP_SRCDIR/src: for support/* etc # env['CPPPATH'] += ['$TOP_SRCDIR/boost', '$BUILDDIR/common', '$TOP_SRCDIR/src'] +# for intl/config.h, intl/libintl.h and intl/libgnuintl.h +if env['nls'] and included_gettext: + env['CPPPATH'].append('$BUILDDIR/intl') # # QT_INC_PATH is not needed for *every* source file env['CPPPATH'].remove(qt_inc_path) -# -# Customized builders -# -# install customized builders -env['BUILDERS']['substFile'] = Builder(action = utils.env_subst) - # # A Link script for cygwin see # http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html @@ -1257,6 +1388,11 @@ if logfile != '' or platform_name == 'win32': # -h will print out help info Help(opts.GenerateHelpText(env)) +# save environment settings (for fast_start option) +cache_file = open(env_cache_file, 'w') +cPickle.dump(env_cache, cache_file) +cache_file.close() + #---------------------------------------------------------- # Start building @@ -1366,124 +1502,6 @@ if build_intl: # intl # intlenv = env.Copy() - # - intl_config_h = os.path.join(intlenv.Dir('$BUILDDIR/intl').path, 'config.h') - if not os.path.isfile(intl_config_h) or not fast_start: - # - print "Creating %s..." % intl_config_h - # - # start another configuration session. - conf = Configure(intlenv, - custom_tests = { - 'CheckLC_MESSAGES' : utils.checkLC_MESSAGES, - 'CheckIconvConst' : utils.checkIconvConst, - } - ) - # create config.h - result = utils.createConfigFile(conf, - config_file = intl_config_h, - config_pre = '''/* intl/config.h. Generated by SCons. */ - -/* -*- C++ -*- */ -/* - * \file config.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * This is the compilation configuration file for LyX. - * It was generated by scon. - * You might want to change some of the defaults if something goes wrong - * during the compilation. - */ - -#ifndef _CONFIG_H -#define _CONFIG_H -''', - headers = [ - ('unistd.h', 'HAVE_UNISTD_H', 'c'), - ('inttypes.h', 'HAVE_INTTYPES_H', 'c'), - ('string.h', 'HAVE_STRING_H', 'c'), - ('strings.h', 'HAVE_STRINGS_H', 'c'), - ('argz.h', 'HAVE_ARGZ_H', 'c'), - ('limits.h', 'HAVE_LIMITS_H', 'c'), - ('alloca.h', 'HAVE_ALLOCA_H', 'c'), - ('stddef.h', 'HAVE_STDDEF_H', 'c'), - ('stdint.h', 'HAVE_STDINT_H', 'c'), - ('sys/param.h', 'HAVE_SYS_PARAM_H', 'c'), - ], - functions = [ - ('getcwd', 'HAVE_GETCWD', None), - ('stpcpy', 'HAVE_STPCPY', None), - ('strcasecmp', 'HAVE_STRCASECMP', None), - ('strdup', 'HAVE_STRDUP', None), - ('strtoul', 'HAVE_STRTOUL', None), - ('alloca', 'HAVE_ALLOCA', None), - ('__fsetlocking', 'HAVE___FSETLOCKING', None), - ('mempcpy', 'HAVE_MEMPCPY', None), - ('__argz_count', 'HAVE___ARGZ_COUNT', None), - ('__argz_next', 'HAVE___ARGZ_NEXT', None), - ('__argz_stringify', 'HAVE___ARGZ_STRINGIFY', None), - ('setlocale', 'HAVE_SETLOCALE', None), - ('tsearch', 'HAVE_TSEARCH', None), - ('getegid', 'HAVE_GETEGID', None), - ('getgid', 'HAVE_GETGID', None), - ('getuid', 'HAVE_GETUID', None), - ('wcslen', 'HAVE_WCSLEN', None), - ('asprintf', 'HAVE_ASPRINTF', None), - ('wprintf', 'HAVE_WPRINTF', None), - ('snprintf', 'HAVE_SNPRINTF', None), - ('printf', 'HAVE_POSIX_PRINTF', None), - ('fcntl', 'HAVE_FCNTL', None), - ], - types = [ - ('intmax_t', 'HAVE_INTMAX_T', None), - ('long double', 'HAVE_LONG_DOUBLE', None), - ('long long', 'HAVE_LONG_LONG', None), - ('wchar_t', 'HAVE_WCHAR_T', None), - ('wint_t', 'HAVE_WINT_T', None), - ('uintmax_t', 'HAVE_INTTYPES_H_WITH_UINTMAX', '#include '), - ('uintmax_t', 'HAVE_STDINT_H_WITH_UINTMAX', '#include '), - ], - libs = [ - (('iconv', 'libiconv'), 'HAVE_ICONV', 'ICONV_LIB'), - ('c', 'HAVE_LIBC'), - ], - custom_tests = [ - (conf.CheckLC_MESSAGES(), - 'HAVE_LC_MESSAGES', - 'Define if your file defines LC_MESSAGES.' - ), - (conf.CheckIconvConst(), - 'ICONV_CONST', - 'Define as const if the declaration of iconv() needs const.', - '#define ICONV_CONST', - '#define ICONV_CONST const', - ), - (conf.CheckType('intmax_t', includes='#include ') or \ - conf.CheckType('intmax_t', includes='#include '), - 'HAVE_INTMAX_T', - "Define to 1 if you have the `intmax_t' type." - ), - (env.has_key('nls') and env['nls'], - 'ENABLE_NLS', - "Define to 1 if translation of program messages to the user's native anguage is requested.", - ), - ], - config_post = '#endif' - ) - conf.Finish() - # these keys are needed in env - for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \ - 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']: - # USE_ASPELL etc does not go through result - if result.has_key(key): - env[key] = result[key] - env_cache[key] = env[key] - else: - # only a few variables need to be rescanned - for key in ['HAVE_ASPRINTF', 'HAVE_WPRINTF', 'HAVE_SNPRINTF', \ - 'HAVE_POSIX_PRINTF', 'HAVE_ICONV', 'HAVE_LIBC']: - env[key] = env_cache[key] print "Processing files in intl..." @@ -1513,11 +1531,6 @@ if build_intl: ] ) - # libgnuintl.h.in => libintl.h - env.substFile('$TOP_SRCDIR/intl/libintl.h', '$TOP_SRCDIR/intl/libgnuintl.h.in') - env.Command('$TOP_SRCDIR/intl/libgnuintl.h', '$TOP_SRCDIR/intl/libintl.h', - [Copy('$TARGET', '$SOURCE')]) - intl = intlenv.StaticLibrary( target = '$LOCALLIBPATH/included_intl', LIBS = ['c'], @@ -2206,9 +2219,12 @@ if build_po: if 'install' in targets: + # + # install to DESTDIR or prefix + dest_dir = env.Dir(env.get('DESTDIR', prefix)).abspath # if dest_dir is different from prefix. if env.has_key('exec_prefix'): - bin_dest_dir = env['exec_prefix'] + bin_dest_dir = Dir(env['exec_prefix']).abspath else: bin_dest_dir = os.path.join(dest_dir, 'bin') if add_suffix: @@ -2308,9 +2324,3 @@ if 'install' in targets: Default('lyx') Alias('all', ['lyx', 'client', 'tex2lyx']) - - -# save environment settings (for fast_start option) -cache_file = open(env_cache_file, 'w') -cPickle.dump(env_cache, cache_file) -cache_file.close()