I was going to wait to test this patch myself, but I did not manage to
get iconv installed. So, can anyone test the attached patch?

This patch tests for the existence of iconv (HAVE_ICONV) , test for
LC_MESSAGES (set HAVE_LC_MESSAGES) and ICONV_CONST. Lyx links to
libiconv correctly under linux.

I also try to set debug/release options to g++/msvc. Please comment on
the appropriate options. I remember that there are things like
-DNDEBUG.

Bo
Index: development/scons/SConstruct
===================================================================
--- development/scons/SConstruct	(revision 14051)
+++ development/scons/SConstruct	(working copy)
@@ -546,6 +546,8 @@
     'CheckBoostLibraries' : utils.checkBoostLibraries,
     'CheckCommand' : utils.checkCommand,
     'CheckCXXGlobalCstd' : utils.checkCXXGlobalCstd,
+    'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
+    'CheckIconvConst' : utils.checkIconvConst,
   }
 )
 
@@ -689,10 +691,6 @@
       # we do not need to set LIBPATH now.
       env['INCLUDED_GETTEXT'] = True
       env['INTL_LIBS'] = ['included_intl']
-    if platform_name == 'win32' and not use_vc:
-      # for functions AddFontResouceA, RemoveFontResourceA
-      # if use_vc, gdi32 will be added anyway later
-      env['INTL_LIBS'].append('gdi32')
   env_cache['INCLUDED_GETTEXT'] = env['INCLUDED_GETTEXT']
   env_cache['INTL_LIBS'] = env['INTL_LIBS']
 else:
@@ -873,12 +871,6 @@
     ('wcslen', 'HAVE_WCSLEN', None)
   ]
 
-  # HAVE_ASPRINTF
-  # HAVE_WPRINTF
-  # HAVE_SNPRINTF
-  # HAVE_POSIX_PRINTF
-  # HAVE_FCNTL
-  
   for func in functions:
     utils.addToConfig("/* Define to 1 if you have the `%s' function. */" % func[0], newline=1)
     if conf.CheckFunc(func[0], header=func[2]):
@@ -886,6 +878,13 @@
     else:
       utils.addToConfig('/* #undef %s */' % func[1])
 
+
+  # HAVE_ASPRINTF
+  # HAVE_WPRINTF
+  # HAVE_SNPRINTF
+  # HAVE_POSIX_PRINTF
+  # HAVE_FCNTL
+  
   env_functions = [
     ('asprintf', 'HAVE_ASPRINTF'),
     ('wprintf', 'HAVE_WPRINTF'),
@@ -949,6 +948,36 @@
   else:
     utils.addToConfig('/* #undef CXX_GLOBAL_CSTD */')
 
+  # HAVE_LIBGDI32
+  # HAVE_ICONV
+  # HAVE_LIBC
+  libs = [
+    ('gdi32', 'HAVE_LIBGDI32'),
+    ('iconv', 'HAVE_ICONV'),
+    ('c', 'HAVE_LIBC')
+  ]
+  for lib in libs:
+    if conf.CheckLib(lib[0]):
+      utils.addToConfig('#define %s 1' % lib[1])
+      env[lib[1]] = True
+      env_cache[lib[1]] = env[lib[1]]
+    else:
+      utils.addToConfig('/* #undef %s */' % lib[1])
+      env[lib[1]] = False
+      env_cache[lib[1]] = env[lib[1]]
+  
+  # HAVE_LC_MESSAGES
+  if conf.CheckLC_MESSAGES():
+    utils.addToConfig('#define HAVE_LC_MESSAGES 1')
+  else:
+    utils.addToConfig('/* #undef HAVE_LC_MESSAGES */')
+
+  # ICONV_CONST
+  if conf.CheckIconvConst():
+    utils.addToConfig('#define ICONV_CONST')
+  else:
+    utils.addToConfig('/* #undef ICONV_CONST */')
+  
   # PACKAGE
   # PACKAGE_VERSION
   # DEVEL_VERSION
@@ -1102,6 +1131,9 @@
   env['HAVE_SNPRINTF'] = env_cache['HAVE_SNPRINTF']
   env['HAVE_POSIX_PRINTF'] = env_cache['HAVE_POSIX_PRINTF']
   env['HAVE_FCNTL'] = env_cache['HAVE_FCNTL']
+  env['HAVE_ICONV'] = env_cache['HAVE_ICONV']
+  env['HAVE_LIBGDI32'] = env_cache['HAVE_LIBGDI32']
+  env['HAVE_LIBC'] = env_cache['HAVE_LIBC']
 
 #
 # Finish auto-configuration
@@ -1142,12 +1174,17 @@
   # the final link step needs stdc++ to succeed under mingw
   # FIXME: shouldn't g++ automatically link to stdc++?
   if use_vc:
-    env['SYSTEM_LIBS'] = ['shlwapi', 'gdi32', 'shell32', 'advapi32', 'zdll']
+    env['SYSTEM_LIBS'] = ['shlwapi', 'shell32', 'advapi32', 'zdll']
   else:
     env['SYSTEM_LIBS'] = ['shlwapi', 'stdc++', 'z']
 else:
   env['SYSTEM_LIBS'] = ['z']
 
+if env['HAVE_ICONV']:
+  env['SYSTEM_LIBS'].append('iconv')
+if env['HAVE_LIBGDI32']:
+  env['SYSTEM_LIBS'].append('gdi32')
+
 #
 # Build parameters CPPPATH etc
 #
@@ -1157,12 +1194,18 @@
 env['CPPPATH'].remove(env['QT_INC_PATH'])
 env['CPPPATH'] += ['$TOP_SRC_DIR/boost', '$TOP_SRC_DIR/src']
 
-# TODO: add (more) appropriate compiling options (-DNDEBUG etc)
+# add appropriate compiling options (-DNDEBUG etc)
 # for debug/release mode
 if ARGUMENTS.get('mode', default_build_mode) == 'debug':
-  env.AppendUnique(CCFLAGS = [])
+  if use_vc:
+    env.AppendUnique(CCFLAGS = [])
+  else:
+    env.AppendUnique(CCFLAGS = ['-Wall', '-g'])
 else:
-  env.AppendUnique(CCFLAGS = [])
+  if use_vc:
+    env.AppendUnique(CCFLAGS = ['/O2'])
+  else:
+    env.AppendUnique(CCFLAGS = ['-Wall', '-O2'])
 
 #
 # Customized builders
Index: development/scons/scons_utils.py
===================================================================
--- development/scons/scons_utils.py	(revision 14051)
+++ development/scons/scons_utils.py	(working copy)
@@ -280,7 +280,47 @@
   conf.Result(res is not None)
   return res
 
+def checkLC_MESSAGES(conf):
+  ''' check the definition of LC_MESSAGES '''
+  check_LC_MESSAGES = '''
+#include <locale.h>
+int main()
+{
+  return LC_MESSAGES;
+}
+'''
+  conf.Message('Check for LC_MESSAGES in locale.h... ')
+  ret = conf.TryLink(check_LC_MESSAGES, '.c')
+  conf.Result(ret)
+  return ret
 
+# FIXME: not quite sure about this part.
+def checkIconvConst(conf):
+  ''' check the declaration of iconv '''
+  check_iconv_const = '''
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+extern size_t iconv(iconv_t cd, const char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+int main()
+{
+  return 1;
+}
+'''
+  conf.Message('Check if the declaration of iconv needs const... ')
+  ret = conf.TryLink(check_iconv_const, '.c')
+  conf.Result(ret)
+  return ret
+
+
 def installCygwinLDScript(path):
   ''' Install i386pe.x-no-rdata '''
   ld_script = os.path.join(path, 'i386pe.x-no-rdata')

Reply via email to