*** empty log message ***
[gnulib.git] / m4 / check-decl.m4
1 #serial 7
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   AC_REQUIRE([AC_HEADER_TIME])
10   headers='
11 #include <stdio.h>
12 #if HAVE_STRING_H
13 # if !STDC_HEADERS && HAVE_MEMORY_H
14 #  include <memory.h>
15 # endif
16 # include <string.h>
17 #else
18 # if HAVE_STRINGS_H
19 #  include <strings.h>
20 # endif
21 #endif
22 #if HAVE_STDLIB_H
23 # include <stdlib.h>
24 #endif
25 #if HAVE_UNISTD_H
26 # include <unistd.h>
27 #endif
28
29 #include <sys/types.h>
30 #if TIME_WITH_SYS_TIME
31 # include <sys/time.h>
32 # include <time.h>
33 #else
34 # if HAVE_SYS_TIME_H
35 #  include <sys/time.h>
36 # else
37 #  include <time.h>
38 # endif
39 #endif
40 '
41
42   if test x = y; then
43     dnl This code is deliberately never run via ./configure.
44     dnl FIXME: this is a gross hack to make autoheader put entries
45     dnl for each of these symbols in the config.h.in.
46     dnl Otherwise, I'd have to update acconfig.h every time I change
47     dnl this list of functions.
48     AC_DEFINE(HAVE_DECL_FREE, 1, [Define if this function is declared.])
49     AC_DEFINE(HAVE_DECL_LSEEK, 1, [Define if this function is declared.])
50     AC_DEFINE(HAVE_DECL_MALLOC, 1, [Define if this function is declared.])
51     AC_DEFINE(HAVE_DECL_MEMCHR, 1, [Define if this function is declared.])
52     AC_DEFINE(HAVE_DECL_REALLOC, 1, [Define if this function is declared.])
53     AC_DEFINE(HAVE_DECL_STPCPY, 1, [Define if this function is declared.])
54     AC_DEFINE(HAVE_DECL_STRSTR, 1, [Define if this function is declared.])
55     AC_DEFINE(HAVE_DECL_STRTOUL, 1, [Define if this function is declared.])
56     AC_DEFINE(HAVE_DECL_STRTOULL, 1, [Define if this function is declared.])
57     AC_DEFINE(HAVE_DECL_NANOSLEEP, 1, [Define if this function is declared.])
58   fi
59
60   jm_CHECK_DECLARATIONS($headers, free lseek malloc \
61                         memchr nanosleep realloc stpcpy strstr strtoul strtoull)
62 ])
63
64 dnl FIXME: when autoconf has support for it.
65 dnl This is a little helper so we can require these header checks.
66 AC_DEFUN(_jm_DECL_HEADERS,
67 [
68   AC_REQUIRE([AC_HEADER_STDC])
69   AC_CHECK_HEADERS(memory.h string.h strings.h stdlib.h unistd.h sys/time.h)
70 ])