Dear Abdel and Enrico,

Attached patch is supposed to fix:

1. remove unnecessay rebuild, since I found that adding fast_start=yes
    can sometimes trigger rebuild.

   tested under linux

2. fix lyx2lyx_version.py (converted from lyx2lyx_version.py.in)

3. version_suffix  (version-suffix=-svn etc)

 tested under linux

4. find a way to pass CCFLAGS options to gcc.

 fixed for mingw

 5. Make the link to libintl (internal or external) and libiconv in order
 to support NLS.  (nls=no/yes gettext=included/system/auto)

seems to be done.

QUESTION:

 6. create multiple "config.h" in build directory not in the source (as
   is done with autotools):
    2.a. release/config.h for all general macro including
        BOOST_USER_CONFIG
    2.a. release/boost_config.h for all boost_specific macro except
        BOOST_USER_CONFIG
    2.c. release/support/config.h for all support specific macro (this
        will include the general one)

 I do not see where autotools are doing this.

 7. link tex2lyx and lyxclient to liblyxbase_pre.a instead of recompiling
   copied files.

 I can not do this. Some of the .C files include different .h file
with the same name.

Please test it. I am not in a hurry to apply.

Bo
Index: development/scons/SConscript
===================================================================
--- development/scons/SConscript	(revision 13864)
+++ development/scons/SConscript	(working copy)
@@ -90,6 +90,67 @@
 env.BuildDir('$BUILDDIR/common', '$TOP_SRC_DIR/src', duplicate = 0)
 
 
+if env['INCLUDED_GETTEXT'] or 'intl' in targets:
+  # 
+  # intl
+  # 
+  print "Processing files in intl"
+
+  env.BuildDir('$BUILDDIR/intl', '$TOP_SRC_DIR/intl', duplicate = 0)
+
+  intlenv = env.Copy()
+  # we need the original C compiler for these files
+  intlenv['CC'] = intlenv['C_COMPILER']
+  intlenv['CPPPATH'] += ['intl']
+  
+  intlenv.Append(CCFLAGS = [
+    r'-DLOCALEDIR=\"' + env['LOCALE_DIR'] + r'\"',
+    r'-DLOCALE_ALIAS_PATH=\"' + env['LOCALE_DIR'] + r'\"',
+    r'-DLIBDIR=\"' + env['TOP_SRC_DIR'] + r'/lib\"',
+    '-DIN_LIBINTL',
+    '-DENABLE_RELOCATABLE=1',
+    '-DIN_LIBRARY',
+    r'-DINSTALLDIR=\"' + env['PREFIX'] + r'/lib\"',
+    '-DNO_XMALLOC',
+    '-Dset_relocation_prefix=libintl_set_relocation_prefix',
+    '-Drelocate=libintl_relocate',
+    '-DDEPENDS_ON_LIBICONV=1',
+    '-DHAVE_CONFIG_H'
+    ]
+  )
+  
+  intl = intlenv.StaticLibrary(
+    target = '$LOCALLIBPATH/intl',
+    source = ["$BUILDDIR/intl/%s" % x for x in Split('''
+      bindtextdom.c
+      dcgettext.c
+      dgettext.c
+      gettext.c
+      finddomain.c
+      loadmsgcat.c
+      localealias.c
+      textdomain.c
+      l10nflist.c
+      explodename.c
+      dcigettext.c
+      dcngettext.c
+      dngettext.c
+      ngettext.c
+      plural.y
+      plural-exp.c
+      localcharset.c
+      relocatable.c
+      localename.c
+      log.c
+      printf.c
+      osdep.c
+      os2compat.c
+      intl-compat.c
+    ''')]
+  )
+  Alias('intl', intl)
+
+
 if build_lyx or True in [x in targets for x in ['supports', 'client', 'tex2lyx']]:
   #
   # src/support
@@ -883,8 +944,6 @@
   #
   qt4_moced_files = [qt4env.Moc4(x.replace('.C', '_moc.cpp'), x.replace('.C', '.h')) for x in qt4_moc_files]
 
-  # if the moced files are included in the .C file
-  # the Flatten(...) part will not be needed
   qt4 = qt4env.StaticLibrary(
     target = '$LOCALLIBPATH/qt4',
     LIBS = qt4env['QT_LIB'],
@@ -931,16 +990,10 @@
   tex2lyx_env.Prepend(CPPPATH = ['$BUILDDIR/common/tex2lyx'])
   tex2lyx_env.AppendUnique(LIBPATH = ['#$LOCALLIBPATH'])
 
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/FloatList.C', '$TOP_SRC_DIR/src/FloatList.C')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/Floating.C', '$TOP_SRC_DIR/src/Floating.C')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/counters.C', '$TOP_SRC_DIR/src/counters.C')
-  # for some reason I do not know, I have to copy the header files as well.
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlayout.h', '$TOP_SRC_DIR/src/lyxlayout.h')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlayout.C', '$TOP_SRC_DIR/src/lyxlayout.C')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxtextclass.h', '$TOP_SRC_DIR/src/lyxtextclass.h')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxtextclass.C', '$TOP_SRC_DIR/src/lyxtextclass.C')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlex.C', '$TOP_SRC_DIR/src/lyxlex.C')
-  tex2lyx_env.fileCopy('$BUILDDIR/common/tex2lyx/lyxlex_pimpl.C', '$TOP_SRC_DIR/src/lyxlex_pimpl.C')
+  for file in ['FloatList.C', 'Floating.C', 'counters.C', 'lyxlayout.h', 'lyxlayout.C', 
+    'lyxtextclass.h', 'lyxtextclass.C', 'lyxlex.C', 'lyxlex_pimpl.C']:
+    env.Command('$BUILDDIR/common/tex2lyx/'+file, '$TOP_SRC_DIR/src/'+file,
+      [Copy('$TARGET', '$SOURCE')])
 
   tex2lyx = tex2lyx_env.Program(
     target = '$BUILDDIR/common/tex2lyx/tex2lyx',
@@ -1133,6 +1186,7 @@
       ] +
       env['BOOST_LIBRARIES'] +
       env['EXTRA_LIBS'] +
+      env['INTL_LIB'] + 
       env['SOCKET_LIBS'] +
       env['SYSTEM_LIBS']
   )
@@ -1217,9 +1271,36 @@
     return ins_dir
   #
   # executables (some of them may be none)
-  env.Install(env['BIN_DIR'], filter(lambda x: x != None, [lyx, tex2lyx, client]))
-  Alias('install', env['BIN_DIR'])
   #
+  if env['ADD_SUFFIX_TO_EXECUTABLES']:
+    program_suffix = env['PROGRAM_SUFFIX']
+  else:
+    program_suffix = ''
+  #
+  # install lyx
+  target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx%s' % program_suffix)
+  target = os.path.join(env['BIN_DIR'], target_name)
+  env.InstallAs(target, lyx)
+  Alias('install', target)
+  # install lyx as lyx-qt3
+  target_name = os.path.split(str(lyx[0]))[1].replace('lyx', 'lyx-%s%s' % (frontend, program_suffix))
+  target = os.path.join(env['BIN_DIR'], target_name)
+  env.InstallAs(target, lyx)
+  Alias('install', target)
+  #
+  # install tex2lyx
+  target_name = os.path.split(str(tex2lyx[0]))[1].replace('tex2lyx', 'tex2lyx%s' % program_suffix)
+  target = os.path.join(env['BIN_DIR'], target_name)
+  env.InstallAs(target, tex2lyx)
+  Alias('install', target)
+  #
+  # install lyxclient, may not exist
+  if client != None:
+    target_name = os.path.split(str(client[0]))[1].replace('client', 'client%s' % program_suffix)
+    target = os.path.join(env['BIN_DIR'], target_name)
+    env.InstallAs(target, client)
+    Alias('install', target)
+  #
   # share/lyx
   dirs = install(env['SHARE_DIR'],
     [env.subst('$TOP_SRC_DIR/lib/') + file for file in ['configure.py', 'encodings',
@@ -1240,10 +1321,10 @@
   Alias('install', [os.path.join(env['MAN_DIR'], x) for
     x in ['lyx.1', 'tex2lyx.1', 'lyxclient.1']])
   # locale files?
-  # ru.gmo ==> ru/LC_MESSAGES/lyx.mo
+  # ru.gmo ==> ru/LC_MESSAGES/lyxSUFFIX.mo
   for gmo in gmo_files:
     lan = os.path.split(str(gmo))[1].split('.')[0]
-    dest_file = os.path.join(env['LOCALE_DIR'], lan, 'LC_MESSAGES', 'lyx.mo')
+    dest_file = os.path.join(env['LOCALE_DIR'], lan, 'LC_MESSAGES', 'lyx' + env['PROGRAM_SUFFIX'] + '.mo')
     env.InstallAs(dest_file, gmo)
     Alias('install', dest_file)
 
Index: development/scons/SConstruct
===================================================================
--- development/scons/SConstruct	(revision 13864)
+++ development/scons/SConstruct	(working copy)
@@ -133,6 +133,7 @@
   # If not specified, boost tries to figure out by itself, but it may fail.
   boost_posix = False
   packaging_method = 'windows'
+  add_suffix_to_executables = False
   default_prefix = 'c:/program files/lyx'
   share_dir = 'Resources'
   man_dir = 'Resources/man/man1'
@@ -147,6 +148,7 @@
   default_with_x = True
   boost_posix = True
   packaging_method = 'posix'
+  add_suffix_to_executables = True
   default_prefix = '/usr/local/'
   share_dir = 'share/lyx'
   man_dir = 'man/man1'
@@ -161,6 +163,7 @@
   default_with_x = True
   boost_posix = True
   packaging_method = 'posix'
+  add_suffix_to_executables = True
   default_prefix = '/usr/local/'
   share_dir = 'share/lyx'
   man_dir = 'man/man1'
@@ -175,6 +178,7 @@
   default_with_x = False
   boost_posix = True
   packaging_method = 'mac'
+  add_suffix_to_executables = True
   # FIXME: where to install?
   default_prefix = '/usr/local/'
   share_dir = 'Resources'
@@ -190,6 +194,7 @@
   default_with_x = True
   boost_posix = False
   packaging_method = 'posix'
+  add_suffix_to_executables = True
   default_prefix = '/usr/local/'
   share_dir = 'share/lyx'
   man_dir = 'man/man1'
@@ -243,16 +248,14 @@
   BoolOption('warnings', 'Use warnings', True),
   # enable glib, (config.h has _GLIBCXX_CONCEPT_CHECKS)
   BoolOption('concept_checks', 'Enable concept checks', True),
-  # FIXME: I do not know what is nls
-  BoolOption('nls', '(NA) Whether or not use native language support', False),
+  # 
+  BoolOption('nls', 'Whether or not use native language support', True),
   # FIXME: not implemented
   BoolOption('profile', '(NA) Whether or not enable profiling', False),
   # FIXME: not implemented
   BoolOption('std_debug', '(NA) Whether or not turn on stdlib debug', False),
   # using x11?
   BoolOption('X11', 'Use x11 windows system', default_with_x),
-  # FIXME: not implemented
-  BoolOption('libintl', '(NA) Use libintl library', False),
   # 
   PathOption('qt_dir', 'Path to qt directory', None),
   #
@@ -275,8 +278,6 @@
   ('version_suffix', 'install lyx as lyx-suffix', ''),
   #
   PathOption('exec_prefix', 'install architecture-independent executable files in PREFIX', None),
-  # FIXME: not implemented
-  PathOption('intl_prefix', '(NA) Path to intl library', None),
   # log file
   ('logfile', 'save commands (not outputs) to logfile', default_log_file),
   # Path to aikasurus
@@ -334,10 +335,25 @@
   env['BIN_DIR'] = env['exec_prefix']
 else:
   env['BIN_DIR'] = os.path.join(env['PREFIX'], 'bin')
-env['SHARE_DIR'] = os.path.join(env['PREFIX'], share_dir)
+# program suffix
+if env.has_key('version_suffix'):
+  env['PROGRAM_SUFFIX'] = env['version_suffix']
+else:
+  env['PROGRAM_SUFFIX'] = ''
+env['ADD_SUFFIX_TO_EXECUTABLES'] = add_suffix_to_executables
+env['SHARE_DIR'] = os.path.join(env['PREFIX'], share_dir + env['PROGRAM_SUFFIX'])
 env['MAN_DIR'] = os.path.join(env['PREFIX'], man_dir)
 env['LOCALE_DIR'] = os.path.join(env['PREFIX'], locale_dir)
 
+#
+# this is a bit out of place (after auto-configration) but 
+# it is required to do the tests. Since Tool('mingw') will 
+# reset CCFLAGS etc, this should be before getEnvVariable
+if platform_name == 'win32':
+  env.Tool('mingw')
+  env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
+
+
 # speed up source file processing
 #env['CPPSUFFIXES'] = ['.C', '.cc', '.cpp']
 #env['CXXSUFFIX'] = ['.C']
@@ -426,12 +442,6 @@
 if env.has_key('aikasurus_path') and env['aikasurus_path']:
   env.AppendUnique(LIBPATH = [env['aikasurus_path']])
 
-#
-# this is a bit out of place (after auto-configration)
-# but it is required to do the tests.
-if platform_name == 'win32':
-  env.AppendUnique(CPPPATH = ['#c:/MinGW/include'])
-  env.Tool('mingw')
 
 # under windows, scons is confused by .C/.c and uses gcc instead of
 # g++. I am forcing the use of g++ here. This is expected to change
@@ -440,6 +450,8 @@
 # Note that this step has to be after env.Tool('mingw') step
 # since env.Tool('mingw') will set env['CC'] etc.
 #
+# save the old c compiler
+env['C_COMPILER'] = env['CC']
 if env.has_key('CXX') and env['CXX']:
   env['CC'] = env['CXX']
   env['LINK'] = env['CXX']
@@ -570,6 +582,40 @@
   env['BOOST_LIBRARIES'] = env_cache['BOOST_LIBRARIES']
   env['INCLUDED_BOOST'] = env_cache['INCLUDED_BOOST']
 
+
+if not env.has_key('nls') or env['nls']:
+  env['ENABLE_NLS'] = True
+
+if not fast_start:
+  if env['ENABLE_NLS']:
+    env['INTL_LIB'] = []
+    env['INCLUDED_GETTEXT'] = False
+  else:
+    # check gettext libraries
+    gettext_opt = ARGUMENTS.get('gettext', default_gettext_opt)
+    # check for system gettext
+    succ = False
+    if gettext_opt in ['auto', 'system']:
+      if conf.CheckLib('intl'):
+        env['INCLUDED_GETTEXT'] = False
+        succ = True
+      else: # no found
+        if gettext_opt == 'system':
+          print "Can not find system gettext library"
+          print "Please supply a path through extra_lib_path and try again."
+          print "Or use gettext=included to use included gettext libraries."
+          Exit(2)
+    # now, auto and succ = false, or gettext=included
+    if not succ:
+      # we do not need to set LIBPATH now.
+      env['INCLUDED_GETTEXT'] = True
+    env['INTL_LIB'] = ['intl']
+    env_cache['INCLUDED_GETTEXT'] = env['INCLUDED_GETTEXT']
+else:
+  env['INTL_LIB'] = env_cache['INTL_LIB']
+  env['INCLUDED_GETTEXT'] = env_cache['INCLUDED_GETTEXT']
+
+
 #
 # check for msgfmt command
 if not fast_start:
@@ -621,6 +667,7 @@
     ('sys/utime.h', 'HAVE_SYS_UTIME_H', 'c'),
     ('sys/socket.h', 'HAVE_SYS_SOCKET_H', 'c'),
     ('unistd.h', 'HAVE_UNISTD_H', 'c'),
+    ('inttypes.h', 'HAVE_INTTYPES_H', 'c'),
     ('utime.h', 'HAVE_UTIME_H', 'c'),
     ('istream', 'HAVE_ISTREAM', 'cxx'),
     ('ostream', 'HAVE_OSTREAM', 'cxx'),
@@ -683,10 +730,21 @@
     utils.addToConfig('/* #undef HAVE_FCNTL */', TOP_SRC_DIR)
     env['HAVE_FCNTL'] = False
 
+  if conf.CheckType('intmax_t', includes='#include <stdint.h>') or \
+    conf.CheckType('intmax_t', includes='#include <inttypes.h>'):
+    utils.addToConfig('#define HAVE_INTMAX_T 1', TOP_SRC_DIR)
+  else:
+    utils.addToConfig('/* #undef HAVE_INTMAX_T */', TOP_SRC_DIR)
+
+  if conf.CheckType('uintmax_t', includes='#include <inttypes.h>'):
+    utils.addToConfig('#define HAVE_INTTYPES_H_WITH_UINTMAX  1', TOP_SRC_DIR)
+  else:
+    utils.addToConfig('/* #undef HAVE_INTTYPES_H_WITH_UINTMAX  */', TOP_SRC_DIR)
+    
   # PACKAGE
   # PACKAGE_VERSION
   # DEVEL_VERSION
-  utils.addToConfig('#define PACKAGE "%s"' % PACKAGE, TOP_SRC_DIR)
+  utils.addToConfig('#define PACKAGE "%s%s"' % (PACKAGE, env['PROGRAM_SUFFIX']), TOP_SRC_DIR)
   utils.addToConfig('#define PACKAGE_VERSION "%s"' % PACKAGE_VERSION, TOP_SRC_DIR)
   if DEVEL_VERSION:
     utils.addToConfig('#define DEVEL_VERSION 1', TOP_SRC_DIR)
@@ -905,8 +963,6 @@
 #
 # install customized builders
 env['BUILDERS']['substFile'] = Builder(action = utils.env_subst)
-# FIXME: there must be a better way.
-env['BUILDERS']['fileCopy'] = Builder(action = utils.env_filecopy)
 
 #
 # A Link script for cygwin see
@@ -929,11 +985,6 @@
 #  LYX_ABS_INSTALLED_LOCALEDIR
 env['LOCALEDIR'] = env['LOCALE_DIR']
 env['TOP_SRCDIR'] = env['TOP_SRC_DIR']
-# program suffix
-if env.has_key('version_suffix'):
-  env['PROGRAM_SUFFIX'] = env['version_suffix']
-else:
-  env['PROGRAM_SUFFIX'] = ''
 # needed by src/version.C.in => src/version.C
 env['PACKAGE_VERSION'] = PACKAGE_VERSION
 # fill in the version info
Index: development/scons/scons_utils.py
===================================================================
--- development/scons/scons_utils.py	(revision 13864)
+++ development/scons/scons_utils.py	(working copy)
@@ -72,11 +72,6 @@
   #os.chmod(str(target[0]), stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
 
 
-def env_filecopy(target, source, env):
-  ''' target can be a directory '''
-  shutil.copy(str(source[0]), str(target[0]))
-
-
 #
 # autoconf tests
 #

Reply via email to