*** empty log message ***
[gnulib.git] / m4 / check-decl.m4
1 #serial 6
2
3 dnl This is just a wrapper function to encapsulate this kludge.
4 dnl Putting it in a separate file like this helps share it between
5 dnl different packages.
6 AC_DEFUN(jm_CHECK_DECLS,
7 [
8   AC_REQUIRE([_jm_DECL_HEADERS])
9   headers='
10 #include <stdio.h>
11 #if HAVE_STRING_H
12 # if !STDC_HEADERS && HAVE_MEMORY_H
13 #  include <memory.h>
14 # endif
15 # include <string.h>
16 #else
17 # if HAVE_STRINGS_H
18 #  include <strings.h>
19 # endif
20 #endif
21 #if HAVE_STDLIB_H
22 # include <stdlib.h>
23 #endif
24 #if HAVE_UNISTD_H
25 # include <unistd.h>
26 #endif
27 '
28
29   if test x = y; then
30     dnl This code is deliberately never run via ./configure.
31     dnl FIXME: this is a gross hack to make autoheader put entries
32     dnl for each of these symbols in the config.h.in.
33     dnl Otherwise, I'd have to update acconfig.h every time I change
34     dnl this list of functions.
35     AC_DEFINE(HAVE_DECL_FREE, 1, [Define if this function is declared.])
36     AC_DEFINE(HAVE_DECL_LSEEK, 1, [Define if this function is declared.])
37     AC_DEFINE(HAVE_DECL_MALLOC, 1, [Define if this function is declared.])
38     AC_DEFINE(HAVE_DECL_MEMCHR, 1, [Define if this function is declared.])
39     AC_DEFINE(HAVE_DECL_REALLOC, 1, [Define if this function is declared.])
40     AC_DEFINE(HAVE_DECL_STPCPY, 1, [Define if this function is declared.])
41     AC_DEFINE(HAVE_DECL_STRSTR, 1, [Define if this function is declared.])
42     AC_DEFINE(HAVE_DECL_STRTOUL, 1, [Define if this function is declared.])
43     AC_DEFINE(HAVE_DECL_STRTOULL, 1, [Define if this function is declared.])
44   fi
45
46   jm_CHECK_DECLARATIONS($headers, free lseek malloc \
47                         memchr realloc stpcpy strstr strtoul strtoull)
48 ])
49
50 dnl FIXME: when autoconf has support for it.
51 dnl This is a little helper so we can require these header checks.
52 AC_DEFUN(_jm_DECL_HEADERS,
53 [
54   AC_REQUIRE([AC_HEADER_STDC])
55   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h)
56 ])