Angus Leeming wrote:
So, really, truly, the header files aren't helping any. Hence the need for a configure test to see whether the function is present in the standard library.

I asked on the autoconf list "autoconf test for dllimport-ed function?" http://news.gmane.org/gmane.comp.sysutils.autoconf.general

The reply just back is that no test currently exists but I should consider submitting one :)

<quote>
| Any suggestions?

You should be able to use AC_TRY_COMPILE or AC_COMPILE_IFELSE to create a macro, say AC_CHECK_WINDOWS_FUNCS, which does something like
AC_CHECK_FUNCS for MSYS.


Obviously, such a thing will not be very portable. But if it turns out to be useful, the autoconf archive might want to include it.
</quote>


Looking at the autoconf macro archive, wouldn't this fit the bill?
http://autoconf-archive.cryp.to/ac_check_func_in.html

AC_CHECK_FUNC_IN(windows.h, GetLongPathName)

However, when I come to run autogen.sh on it, I get:
configure.ac:257: error: AC_LANG: unknown language:
autoconf/lang.m4:123: _AC_LANG_SET is expanded from...
autoconf/lang.m4:132: AC_LANG is expanded from...
autoconf/general.m4:1799: AC_CACHE_VAL is expanded from...
acinclude.m4:800: AC_CHECK_FUNC_IN is expanded from...
configure.ac:257: the top level
autom4te: /bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1

Patch attached. Any clues? Wrapping it in AC_LANG_PUSH(C)... POP doesn't have any effect.

Angus

Index: config/configure.ac
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/Attic/configure.ac,v
retrieving revision 1.24.2.31
diff -u -a -u -r1.24.2.31 configure.ac
--- config/configure.ac 30 Mar 2005 14:50:53 -0000      1.24.2.31
+++ config/configure.ac 19 Apr 2005 09:11:58 -0000
@@ -254,6 +254,7 @@
 AC_TYPE_UID_T
 
 AC_CHECK_FUNCS(snprintf vsnprintf strerror)
+AC_CHECK_FUNC_IN(windows.h, GetLongPathName)
 LYX_CHECK_DECL(snprintf, stdio.h)
 LYX_CHECK_DECL(vsnprintf, stdio.h)
 LYX_CHECK_DECL(istreambuf_iterator, iterator)
Index: config/lyxinclude.m4
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/config/lyxinclude.m4,v
retrieving revision 1.81.2.7
diff -u -a -u -r1.81.2.7 lyxinclude.m4
--- config/lyxinclude.m4        4 Feb 2005 09:14:24 -0000       1.81.2.7
+++ config/lyxinclude.m4        19 Apr 2005 09:13:38 -0000
@@ -750,3 +750,51 @@
             [Define if mkdir takes only one argument.])
 fi
 ])
+
+dnl Checking for library functions in a given header file
+dnl
+dnl @category Misc
+dnl @author Guido Draheim <[EMAIL PROTECTED]>
+dnl @version 2001-05-03
+dnl @license GPLWithACException
+dnl http://autoconf-archive.cryp.to/ac_check_func_in.html
+
+dnl AC_CHECK_FUNC_IN(HEADER, FUNCTION, [ACTION-IF-FOUND [, 
ACTION-IF-NOT-FOUND]])
+AC_DEFUN([AC_CHECK_FUNC_IN],
+[AC_MSG_CHECKING([for $2 in $1])
+AC_CACHE_VAL(ac_cv_func_$2,
+[AC_TRY_LINK(
+dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
+dnl which includes <sys/select.h> which contains a prototype for
+dnl select.  Similarly for bzero.
+[/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2(); below.  */
+#include <assert.h>
+#include <$1>
+/* Override any gcc2 internal prototype to avoid an error.  */
+]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
+extern "C"
+#endif
+])dnl
+[/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $2();
+], [
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$2) || defined (__stub___$2)
+choke me
+#else
+$2();
+#endif
+], eval "ac_cv_func_$2=yes", eval "ac_cv_func_$2=no")])
+if eval "test \"`echo '$ac_cv_func_'$2`\" = yes"; then
+  AC_MSG_RESULT(yes)
+  ifelse([$3], , :, [$3])
+else
+  AC_MSG_RESULT(no)
+ifelse([$4], , , [$4
+])dnl
+fi
+])

Reply via email to