Author: hikari <hikari@undernet.org>
[ircu2.10.12-pk.git] / aclocal.m4
1 dnl aclocal.m4t generated automatically by aclocal 1.4-p6
2
3 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl
14 dnl Macro: unet_PIPE_CFLAGS
15 dnl
16 dnl   If the compiler understands -pipe, add it to CFLAGS if not already
17 dnl   there.
18 dnl
19 AC_DEFUN(unet_PIPE_CFLAGS,
20 [AC_MSG_CHECKING([if the compiler understands -pipe])
21 unet_cv_pipe_flags="$ac_cv_prog_gcc"
22 if test "$ac_cv_prog_gcc" = no; then
23   OLDCFLAGS="$CFLAGS"
24   CFLAGS="$CFLAGS -pipe"
25   AC_TRY_COMPILE(,,unet_cv_pipe_flags=yes,)
26   CFLAGS="$OLDCFLAGS"
27 fi
28 AC_MSG_RESULT($unet_cv_pipe_flags)
29 if test "$unet_cv_pipe_flags" = yes ; then
30   x=`echo $CFLAGS | grep 'pipe' 2>/dev/null`
31   if test "$x" = "" ; then
32     CFLAGS="$CFLAGS -pipe"
33   fi
34 fi
35 ])
36
37 dnl
38 dnl Macro: unet_NONBLOCKING
39 dnl
40 dnl   Check whether we have posix, bsd or sysv non-blocking sockets and
41 dnl   define respectively NBLOCK_POSIX, NBLOCK_BSD or NBLOCK_SYSV.
42 dnl
43 AC_DEFUN(unet_NONBLOCKING,
44 [dnl Do we have posix, bsd or sysv non-blocking stuff ?
45 AC_CACHE_CHECK([for posix non-blocking], unet_cv_sys_nonblocking_posix,
46 [AC_TRY_RUN([#include <sys/types.h>
47 #include <sys/socket.h>
48 #include <fcntl.h>
49 #include <sys/ioctl.h>
50 #include <sys/file.h>
51 #include <signal.h>
52 $ac_cv_type_signal alarmed() { exit(1); }
53 int main(void)
54 {
55   char b[12];
56   struct sockaddr x;
57   size_t l = sizeof(x);
58   int f = socket(AF_INET, SOCK_DGRAM, 0);
59   if (f >= 0 && !(fcntl(f, F_SETFL, O_NONBLOCK)))
60   {
61     signal(SIGALRM, alarmed);
62     alarm(2);
63     recvfrom(f, b, 12, 0, &x, &l);
64     alarm(0);
65     exit(0);
66   }
67   exit(1);
68 }], unet_cv_sys_nonblocking_posix=yes, unet_cv_sys_nonblocking_posix=no)])
69 if test $unet_cv_sys_nonblocking_posix = yes; then
70   AC_DEFINE(NBLOCK_POSIX)
71 else
72 AC_CACHE_CHECK([for bsd non-blocking], unet_cv_sys_nonblocking_bsd,
73 [AC_TRY_RUN([#include <sys/types.h>
74 #include <sys/socket.h>
75 #include <fcntl.h>
76 #include <sys/ioctl.h>
77 #include <sys/file.h>
78 #include <signal.h>
79 $ac_cv_type_signal alarmed() { exit(1); }
80 int main(void)
81 {
82   char b[12];
83   struct sockaddr x;
84   size_t l = sizeof(x);
85   int f = socket(AF_INET, SOCK_DGRAM, 0);
86   if (f >= 0 && !(fcntl(f, F_SETFL, O_NDELAY)))
87   {
88     signal(SIGALRM, alarmed);
89     alarm(2);
90     recvfrom(f, b, 12, 0, &x, &l);
91     alarm(0);
92     exit(0);
93   }
94   exit(1);
95 }], unet_cv_sys_nonblocking_bsd=yes, unet_cv_sys_nonblocking_bsd=no)])
96 if test $unet_cv_sys_nonblocking_bsd = yes; then
97   AC_DEFINE(NBLOCK_BSD)
98 else
99   AC_DEFINE(NBLOCK_SYSV)
100 fi
101 fi])
102
103 dnl
104 dnl Macro: unet_SIGNALS
105 dnl
106 dnl   Check if we have posix signals, reliable bsd signals or
107 dnl   unreliable sysv signals and define respectively POSIX_SIGNALS,
108 dnl   BSD_RELIABLE_SIGNALS or SYSV_UNRELIABLE_SIGNALS.
109 dnl
110 AC_DEFUN(unet_SIGNALS,
111 [dnl Do we have posix signals, reliable bsd signals or unreliable sysv signals ?
112 AC_CACHE_CHECK([for posix signals], unet_cv_sys_signal_posix,
113 [AC_TRY_COMPILE([#include <signal.h>],
114 [sigaction(SIGTERM, (struct sigaction *)0L, (struct sigaction *)0L)],
115 unet_cv_sys_signal_posix=yes, unet_cv_sys_signal_posix=no)])
116 if test $unet_cv_sys_signal_posix = yes; then
117   AC_DEFINE(POSIX_SIGNALS)
118 else
119 AC_CACHE_CHECK([for bsd reliable signals], unet_cv_sys_signal_bsd,
120 [AC_TRY_RUN([#include <signal.h>
121 int calls = 0;
122 $ac_cv_type_signal handler()
123 {
124   if (calls) return;
125   calls++;
126   kill(getpid(), SIGTERM);
127   sleep(1);
128 }
129 int main(void)
130 {
131   signal(SIGTERM, handler);
132   kill(getpid(), SIGTERM);
133   exit (0);
134 }], unet_cv_sys_signal_bsd=yes, unet_cv_sys_signal_bsd=no)])
135 if test $unet_cv_sys_signal_bsd = yes; then
136   AC_DEFINE(BSD_RELIABLE_SIGNALS)
137 else
138   AC_DEFINE(SYSV_UNRELIABLE_SIGNALS)
139 fi
140 fi])
141
142 dnl
143 dnl Macro: unet_CHECK_TYPE_SIZES
144 dnl
145 dnl Check the size of several types and define a valid int16_t and int32_t.
146 dnl
147 AC_DEFUN(unet_CHECK_TYPE_SIZES,
148 [dnl Check type sizes
149 AC_CHECK_SIZEOF(short)
150 AC_CHECK_SIZEOF(int)
151 AC_CHECK_SIZEOF(long)
152 AC_CHECK_SIZEOF(void *)
153 if test "$ac_cv_sizeof_int" = 2 ; then
154   AC_CHECK_TYPE(int16_t, int)
155   AC_CHECK_TYPE(u_int16_t, unsigned int)
156 elif test "$ac_cv_sizeof_short" = 2 ; then
157   AC_CHECK_TYPE(int16_t, short)
158   AC_CHECK_TYPE(u_int16_t, unsigned short)
159 else
160   AC_MSG_ERROR([Cannot find a type with size of 16 bits])
161 fi
162 if test "$ac_cv_sizeof_int" = 4 ; then
163   AC_CHECK_TYPE(int32_t, int)
164   AC_CHECK_TYPE(u_int32_t, unsigned int)
165 elif test "$ac_cv_sizeof_short" = 4 ; then
166   AC_CHECK_TYPE(int32_t, short)
167   AC_CHECK_TYPE(u_int32_t, unsigned short)
168 elif test "$ac_cv_sizeof_long" = 4 ; then
169   AC_CHECK_TYPE(int32_t, long)
170   AC_CHECK_TYPE(u_int32_t, unsigned long)
171 else
172   AC_MSG_ERROR([Cannot find a type with size of 32 bits])
173 fi])
174
175 dnl Written by John Hawkinson <jhawk@mit.edu>. This code is in the Public
176 dnl Domain.
177 dnl
178 dnl This test is for network applications that need socket() and
179 dnl gethostbyname() -ish functions.  Under Solaris, those applications need to
180 dnl link with "-lsocket -lnsl".  Under IRIX, they should *not* link with
181 dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
182 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
183 dnl IRIX).
184 dnl 
185 dnl Unfortunately, many application developers are not aware of this, and
186 dnl mistakenly write tests that cause -lsocket to be used under IRIX.  It is
187 dnl also easy to write tests that cause -lnsl to be used under operating
188 dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
189 dnl uses -lnsl for TLI.
190 dnl 
191 dnl This test exists so that every application developer does not test this in
192 dnl a different, and subtly broken fashion.
193 dnl 
194 dnl It has been argued that this test should be broken up into two seperate
195 dnl tests, one for the resolver libraries, and one for the libraries necessary
196 dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
197 dnl allowing the autoconf user to use them independantly potentially results in
198 dnl unfortunate ordering dependancies -- as such, such component macros would
199 dnl have to carefully use indirection and be aware if the other components were
200 dnl executed. Since other autoconf macros do not go to this trouble, and almost
201 dnl no applications use sockets without the resolver, this complexity has not
202 dnl been implemented.
203 dnl
204 dnl The check for libresolv is in case you are attempting to link statically
205 dnl and happen to have a libresolv.a lying around (and no libnsl.a).
206 dnl
207 AC_DEFUN(AC_LIBRARY_NET, [
208    # Most operating systems have gethostbyname() in the default searched
209    # libraries (i.e. libc):
210    AC_CHECK_FUNC(gethostbyname, ,
211      # Some OSes (eg. Solaris) place it in libnsl:
212      AC_CHECK_LIB(nsl, gethostbyname, , 
213        # Some strange OSes (SINIX) have it in libsocket:
214        AC_CHECK_LIB(socket, gethostbyname, ,
215           # Unfortunately libsocket sometimes depends on libnsl.
216           # AC_CHECK_LIB's API is essentially broken so the following
217           # ugliness is necessary:
218           AC_CHECK_LIB(socket, gethostbyname,
219              LIBS="-lsocket -lnsl $LIBS",
220                AC_CHECK_LIB(resolv, gethostbyname),
221              -lnsl)
222        )
223      )
224    )
225   AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
226     AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
227   ])
228
229
230 # serial 1
231
232 # @defmac AC_PROG_CC_STDC
233 # @maindex PROG_CC_STDC
234 # @ovindex CC
235 # If the C compiler in not in ANSI C mode by default, try to add an option
236 # to output variable @code{CC} to make it so.  This macro tries various
237 # options that select ANSI C on some system or another.  It considers the
238 # compiler to be in ANSI C mode if it handles function prototypes correctly.
239 #
240 # If you use this macro, you should check after calling it whether the C
241 # compiler has been set to accept ANSI C; if not, the shell variable
242 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
243 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
244 # program @code{ansi2knr}, which comes with Ghostscript.
245 # @end defmac
246
247 AC_DEFUN([AM_PROG_CC_STDC],
248 [AC_REQUIRE([AC_PROG_CC])
249 AC_BEFORE([$0], [AC_C_INLINE])
250 AC_BEFORE([$0], [AC_C_CONST])
251 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
252 dnl a magic option to avoid problems with ANSI preprocessor commands
253 dnl like #elif.
254 dnl FIXME: can't do this because then AC_AIX won't work due to a
255 dnl circular dependency.
256 dnl AC_BEFORE([$0], [AC_PROG_CPP])
257 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
258 AC_CACHE_VAL(am_cv_prog_cc_stdc,
259 [am_cv_prog_cc_stdc=no
260 ac_save_CC="$CC"
261 # Don't try gcc -ansi; that turns off useful extensions and
262 # breaks some systems' header files.
263 # AIX                   -qlanglvl=ansi
264 # Ultrix and OSF/1      -std1
265 # HP-UX                 -Aa -D_HPUX_SOURCE
266 # SVR4                  -Xc -D__EXTENSIONS__
267 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
268 do
269   CC="$ac_save_CC $ac_arg"
270   AC_TRY_COMPILE(
271 [#include <stdarg.h>
272 #include <stdio.h>
273 #include <sys/types.h>
274 #include <sys/stat.h>
275 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
276 struct buf { int x; };
277 FILE * (*rcsopen) (struct buf *, struct stat *, int);
278 static char *e (p, i)
279      char **p;
280      int i;
281 {
282   return p[i];
283 }
284 static char *f (char * (*g) (char **, int), char **p, ...)
285 {
286   char *s;
287   va_list v;
288   va_start (v,p);
289   s = g (p, va_arg (v,int));
290   va_end (v);
291   return s;
292 }
293 int test (int i, double x);
294 struct s1 {int (*f) (int a);};
295 struct s2 {int (*f) (double a);};
296 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
297 int argc;
298 char **argv;
299 ], [
300 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
301 ],
302 [am_cv_prog_cc_stdc="$ac_arg"; break])
303 done
304 CC="$ac_save_CC"
305 ])
306 if test -z "$am_cv_prog_cc_stdc"; then
307   AC_MSG_RESULT([none needed])
308 else
309   AC_MSG_RESULT($am_cv_prog_cc_stdc)
310 fi
311 case "x$am_cv_prog_cc_stdc" in
312   x|xno) ;;
313   *) CC="$CC $am_cv_prog_cc_stdc" ;;
314 esac
315 ])
316