]> git.lyx.org Git - lyx.git/commitdiff
Scons: check HAVE_DECL_MKSTEMP to fix a configuration error with gcc4 on Linux
authorBo Peng <bpeng@lyx.org>
Thu, 31 May 2007 01:34:33 +0000 (01:34 +0000)
committerBo Peng <bpeng@lyx.org>
Thu, 31 May 2007 01:34:33 +0000 (01:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18587 a592a061-630c-0410-9148-cb99ea01b6c8

development/scons/SConstruct
development/scons/scons_utils.py

index 153e565993159407853792226a36fc46638ce409..7cf68eac9eae4518045063f7842c4f7e1b46afd0 100644 (file)
@@ -603,6 +603,7 @@ conf = Configure(env,
         'CheckLC_MESSAGES' : utils.checkLC_MESSAGES,
         'CheckIconvConst' : utils.checkIconvConst,
         'CheckSizeOfWChar' : utils.checkSizeOfWChar,
+        'CheckDeclaration' : utils.checkDeclaration,
     }
 )
 
@@ -933,6 +934,9 @@ return std::count(a, a+5, 'l');
         ('fcntl', 'HAVE_FCNTL', None),
         ('mkfifo', 'HAVE_MKFIFO', None),
     ],
+    declarations = [
+        ('mkstemp', 'HAVE_DECL_MKSTEMP', ['unistd.h', 'stdlib.h']),
+    ],
     types = [
         ('std::istreambuf_iterator<std::istream>', 'HAVE_DECL_ISTREAMBUF_ITERATOR',
             '#include <streambuf>\n#include <istream>'),
index 1e3d6acaefabd28b2b9344312acb74bb55018737..2baa5eef40d778a40a2b6f343b56a9d607e33316 100644 (file)
@@ -432,9 +432,26 @@ int main()
     return ret
 
 
+def checkDeclaration(conf, func, headers):
+    ''' check if a function is declared in given headers '''
+    check_decl = '''
+#include <%%s>
+int main()
+{
+#ifndef %s
+    char *p = (char *) %s;
+#endif
+}
+''' % (func, func)
+    conf.Message('Checking for the declaration of function %s... ' % func)
+    ret = True in [conf.TryLink(check_decl % header, '.c') for header in headers]
+    conf.Result(ret)
+    return ret
+
+    
 def createConfigFile(conf, config_file,
     config_pre = '', config_post = '',
-    headers = [], functions = [], types = [], libs = [],
+    headers = [], functions = [], declarations = [], types = [], libs = [],
     custom_tests = [], extra_items = []):
     ''' create a configuration file, with options
         config_file: which file to create
@@ -444,6 +461,8 @@ def createConfigFile(conf, config_file,
             ('file', 'HAVE_FILE', 'c'/'c++')
         functions: functions to check, in the form of a list of
             ('func', 'HAVE_func', 'include lines'/None)
+        declarations: function declarations to check, in the form of a list of
+            ('func', 'HAVE_DECL_func', header_files)
         types: types to check, in the form of a list of
             ('type', 'HAVE_TYPE', 'includelines'/None)
         libs: libraries to check, in the form of a list of
@@ -492,6 +511,14 @@ def createConfigFile(conf, config_file,
         else:
             result[func[1]] = 0
             cont += configString('/* #undef %s */' % func[1], desc = description)
+    for decl in declarations:
+        description = "Define to 1 if you have the declaration of `%s', and to 0 if you don't." % decl[0]
+        if conf.CheckDeclaration(decl[0], decl[2]):
+            result[decl[1]] = 1
+            cont += configString('#define %s 1' % decl[1], desc = description)
+        else:
+            result[decl[1]] = 0
+            cont += configString('/* #undef %s */' % decl[1], desc = description)
     # types
     for t in types:
         description = "Define to 1 if you have the `%s' type." % t[0]