1dnl ######################################################################
2dnl check for external definition for a function (not external variables)
3dnl Usage AMU_CHECK_EXTERN(extern)
4dnl Checks for external definition for "extern" that is delimited on the
5dnl left and the right by a character that is not a valid symbol character.
6dnl
7dnl Note that $pattern below is very carefully crafted to match any system
8dnl external definition, with __P posix prototypes, with or without an extern
9dnl word, etc.  Think twice before changing this.
10AC_DEFUN([AMU_CHECK_EXTERN],
11[
12# store variable name for external definition
13ac_upcase_extern_name=`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
14ac_safe=HAVE_EXTERN_$ac_upcase_extern_name
15# check for cached value and set it if needed
16AMU_CACHE_CHECK_DYNAMIC(external function definition for $1,
17ac_cv_extern_$1,
18[
19# the old pattern assumed that the complete external definition is on one
20# line but on some systems it is split over several lines, so only match
21# beginning of the extern definition including the opening parenthesis.
22#pattern="(extern)?.*[^a-zA-Z0-9_]$1[^a-zA-Z0-9_]?.*\(.*\).*;"
23pattern="(extern)?.*[[^a-zA-Z0-9_]]$1[[^a-zA-Z0-9_]]?.*\("
24AC_EGREP_CPP(${pattern},
25[
26#ifdef HAVE_SYS_TYPES_H
27# include <sys/types.h>
28#endif /* HAVE_SYS_TYPES_H */
29#ifdef HAVE_SYS_WAIT_H
30# include <sys/wait.h>
31#endif /* HAVE_SYS_WAIT_H */
32#if TIME_WITH_SYS_TIME
33# include <sys/time.h>
34# include <time.h>
35#else /* not TIME_WITH_SYS_TIME */
36# if HAVE_SYS_TIME_H
37#  include <sys/time.h>
38# else /* not HAVE_SYS_TIME_H */
39#  include <time.h>
40# endif /* not HAVE_SYS_TIME_H */
41#endif /* not TIME_WITH_SYS_TIME */
42
43#if defined(_AIX) && defined(HAVE_SYS_VMOUNT_H)
44# include <sys/vmount.h>
45#endif /* defined(_AIX) && defined(HAVE_SYS_VMOUNT_H) */
46
47#ifdef HAVE_STDIO_H
48# include <stdio.h>
49#endif /* HAVE_STDIO_H */
50#ifdef HAVE_STDLIB_H
51# include <stdlib.h>
52#endif /* HAVE_STDLIB_H */
53#if HAVE_UNISTD_H
54# include <unistd.h>
55#endif /* HAVE_UNISTD_H */
56#if HAVE_STRING_H
57# include <string.h>
58#endif /* HAVE_STRING_H */
59#ifdef HAVE_STRINGS_H
60# include <strings.h>
61#endif /* HAVE_STRINGS_H */
62#ifdef HAVE_NETDB_H
63# include <netdb.h>
64#endif /* HAVE_NETDB_H */
65#ifdef HAVE_CLUSTER_H
66# include <cluster.h>
67#endif /* HAVE_CLUSTER_H */
68#ifdef HAVE_RPC_RPC_H
69/*
70 * Turn on PORTMAP, so that additional header files would get included
71 * and the important definition for UDPMSGSIZE is included too.
72 */
73# ifndef PORTMAP
74#  define PORTMAP
75# endif /* not PORTMAP */
76# include <rpc/rpc.h>
77# ifndef XDRPROC_T_TYPE
78typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...));
79# endif /* not XDRPROC_T_TYPE */
80#endif /* HAVE_RPC_RPC_H */
81
82#if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP)
83# include <tcpd.h>
84#endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */
85
86], eval "ac_cv_extern_$1=yes", eval "ac_cv_extern_$1=no")
87])
88# check if need to define variable
89if test "`eval echo '$''{ac_cv_extern_'$1'}'`" = yes
90then
91  AC_DEFINE_UNQUOTED($ac_safe)
92fi
93])
94dnl ======================================================================
95
96dnl ######################################################################
97dnl run AMU_CHECK_EXTERN on each argument given
98dnl Usage: AMU_CHECK_EXTERNS(arg arg arg ...)
99AC_DEFUN([AMU_CHECK_EXTERNS],
100[
101for ac_tmp_arg in $1
102do
103AMU_CHECK_EXTERN($ac_tmp_arg)
104done
105])
106dnl ======================================================================
107