e482169dfcf76291001bf7f921e69353a4c31ca1
[gnulib.git] / m4 / check-decl.m4
1 #serial 5
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   headers='
9 #include <stdio.h>
10 #ifdef HAVE_STRING_H
11 # if !STDC_HEADERS && HAVE_MEMORY_H
12 #  include <memory.h>
13 # endif
14 # include <string.h>
15 #else
16 # ifdef HAVE_STRINGS_H
17 #  include <strings.h>
18 # endif
19 #endif
20 #ifdef HAVE_STDLIB_H
21 # include <stdlib.h>
22 #endif
23 #ifdef HAVE_UNISTD_H
24 # include <unistd.h>
25 #endif
26 '
27
28   if test x = y; then
29     dnl This code is deliberately never run via ./configure.
30     dnl FIXME: this is a gross hack to make autoheader put entries
31     dnl for each of these symbols in the config.h.in.
32     dnl Otherwise, I'd have to update acconfig.h every time I change
33     dnl this list of functions.
34     AC_DEFINE(HAVE_DECL_FREE, 1, [Define if this function is declared.])
35     AC_DEFINE(HAVE_DECL_LSEEK, 1, [Define if this function is declared.])
36     AC_DEFINE(HAVE_DECL_MALLOC, 1, [Define if this function is declared.])
37     AC_DEFINE(HAVE_DECL_MEMCHR, 1, [Define if this function is declared.])
38     AC_DEFINE(HAVE_DECL_REALLOC, 1, [Define if this function is declared.])
39     AC_DEFINE(HAVE_DECL_STPCPY, 1, [Define if this function is declared.])
40     AC_DEFINE(HAVE_DECL_STRSTR, 1, [Define if this function is declared.])
41   fi
42
43   jm_CHECK_DECLARATIONS($headers, free lseek malloc \
44                         memchr realloc stpcpy strstr)
45 ])