875251f9364d3005fbf12d408a0d4eead3327e34
[ircu2.10.12-pk.git] / config / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4a
2
3 dnl Copyright (C) 1994, 1995-8, 1999 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_CHECK_LIB_RESOLV
39 dnl
40 dnl   Check for res_mkquery in -lresolv and add that to LIBS when needed.
41 dnl
42 AC_DEFUN(unet_CHECK_LIB_RESOLV,
43 [AC_CACHE_CHECK([for res_mkquery in -lresolv], unet_cv_lib_resolv,
44 [AC_TRY_LINK([struct rrec;
45 extern int res_mkquery(int, const char *, int, int, const char *,
46     int, struct rrec *, unsigned char *, int);],
47 [int op;
48 const char *dname;
49 int class, type;
50 const char *data;
51 int datalen;
52 struct rrec *newrr;
53 unsigned char *buf;
54 int buflen;
55 res_mkquery(op,dname,class,type,data,datalen,newrr,buf,buflen)],
56 unet_cv_lib_resolv=no, [OLD_LIBS="$LIBS"
57 LIBS="$LIBS -lresolv"
58 AC_TRY_LINK([extern char *_res;], [*_res=0],
59 unet_cv_lib_resolv=yes, unet_cv_lib_resolv=no)
60 LIBS="$OLD_LIBS"])])
61 if test $unet_cv_lib_resolv = yes; then
62   AC_DEFINE(HAVE_LIB_RESOLV)
63   LIBS="$LIBS -lresolv"
64 fi])
65
66 dnl
67 dnl Macro: unet_NONBLOCKING
68 dnl
69 dnl   Check whether we have posix, bsd or sysv non-blocking sockets and
70 dnl   define respectively NBLOCK_POSIX, NBLOCK_BSD or NBLOCK_SYSV.
71 dnl
72 AC_DEFUN(unet_NONBLOCKING,
73 [dnl Do we have posix, bsd or sysv non-blocking stuff ?
74 AC_CACHE_CHECK([for posix non-blocking], unet_cv_sys_nonblocking_posix,
75 [AC_TRY_RUN([#include <sys/types.h>
76 #include <sys/socket.h>
77 #include <fcntl.h>
78 #include <sys/ioctl.h>
79 #include <sys/file.h>
80 #include <signal.h>
81 $ac_cv_type_signal alarmed() { exit(1); }
82 int main(void)
83 {
84   char b[12];
85   struct sockaddr x;
86   size_t l = sizeof(x);
87   int f = socket(AF_INET, SOCK_DGRAM, 0);
88   if (f >= 0 && !(fcntl(f, F_SETFL, O_NONBLOCK)))
89   {
90     signal(SIGALRM, alarmed);
91     alarm(2);
92     recvfrom(f, b, 12, 0, &x, &l);
93     alarm(0);
94     exit(0);
95   }
96   exit(1);
97 }], unet_cv_sys_nonblocking_posix=yes, unet_cv_sys_nonblocking_posix=no)])
98 if test $unet_cv_sys_nonblocking_posix = yes; then
99   AC_DEFINE(NBLOCK_POSIX)
100 else
101 AC_CACHE_CHECK([for bsd non-blocking], unet_cv_sys_nonblocking_bsd,
102 [AC_TRY_RUN([#include <sys/types.h>
103 #include <sys/socket.h>
104 #include <fcntl.h>
105 #include <sys/ioctl.h>
106 #include <sys/file.h>
107 #include <signal.h>
108 $ac_cv_type_signal alarmed() { exit(1); }
109 int main(void)
110 {
111   char b[12];
112   struct sockaddr x;
113   size_t l = sizeof(x);
114   int f = socket(AF_INET, SOCK_DGRAM, 0);
115   if (f >= 0 && !(fcntl(f, F_SETFL, O_NDELAY)))
116   {
117     signal(SIGALRM, alarmed);
118     alarm(2);
119     recvfrom(f, b, 12, 0, &x, &l);
120     alarm(0);
121     exit(0);
122   }
123   exit(1);
124 }], unet_cv_sys_nonblocking_bsd=yes, unet_cv_sys_nonblocking_bsd=no)])
125 if test $unet_cv_sys_nonblocking_bsd = yes; then
126   AC_DEFINE(NBLOCK_BSD)
127 else
128   AC_DEFINE(NBLOCK_SYSV)
129 fi
130 fi])
131
132 dnl
133 dnl Macro: unet_SIGNALS
134 dnl
135 dnl   Check if we have posix signals, reliable bsd signals or
136 dnl   unreliable sysv signals and define respectively POSIX_SIGNALS,
137 dnl   BSD_RELIABLE_SIGNALS or SYSV_UNRELIABLE_SIGNALS.
138 dnl
139 AC_DEFUN(unet_SIGNALS,
140 [dnl Do we have posix signals, reliable bsd signals or unreliable sysv signals ?
141 AC_CACHE_CHECK([for posix signals], unet_cv_sys_signal_posix,
142 [AC_TRY_COMPILE([#include <signal.h>],
143 [sigaction(SIGTERM, (struct sigaction *)0L, (struct sigaction *)0L)],
144 unet_cv_sys_signal_posix=yes, unet_cv_sys_signal_posix=no)])
145 if test $unet_cv_sys_signal_posix = yes; then
146   AC_DEFINE(POSIX_SIGNALS)
147 else
148 AC_CACHE_CHECK([for bsd reliable signals], unet_cv_sys_signal_bsd,
149 [AC_TRY_RUN([#include <signal.h>
150 int calls = 0;
151 $ac_cv_type_signal handler()
152 {
153   if (calls) return;
154   calls++;
155   kill(getpid(), SIGTERM);
156   sleep(1);
157 }
158 int main(void)
159 {
160   signal(SIGTERM, handler);
161   kill(getpid(), SIGTERM);
162   exit (0);
163 }], unet_cv_sys_signal_bsd=yes, unet_cv_sys_signal_bsd=no)])
164 if test $unet_cv_sys_signal_bsd = yes; then
165   AC_DEFINE(BSD_RELIABLE_SIGNALS)
166 else
167   AC_DEFINE(SYSV_UNRELIABLE_SIGNALS)
168 fi
169 fi])
170
171 dnl
172 dnl Macro: unet_DEFINE_SIZE_T_FMT
173 dnl
174 dnl Define SIZE_T_FMT to be "%u" or "%lu", whichever seems more appropriate.
175 dnl
176 AC_DEFUN(unet_DEFINE_SIZE_T_FMT,
177 [dnl Make educated guess :/, if size_t is a long or not
178 AC_CHECK_SIZEOF(size_t)dnl
179 AC_MSG_CHECKING(printf format of size_t)
180 if test "$ac_cv_sizeof_size_t" = 4 ; then
181   AC_MSG_RESULT("%u")
182   AC_DEFINE(SIZE_T_FMT, "%u")
183 else
184   AC_MSG_RESULT("%lu")
185   AC_DEFINE(SIZE_T_FMT, "%lu")
186 fi])
187
188 dnl
189 dnl Macro: unet_DEFINE_TIME_T_FMT
190 dnl
191 dnl Try to figure out if time_t is an int or not, and if so define
192 dnl TIME_T_FMT to be "%u", otherwise define it to be "%lu".
193 dnl Likewise define STIME_T_FMT for the signed format.
194 dnl
195 AC_DEFUN(unet_DEFINE_TIME_T_FMT,
196 [dnl Make educated guess :/, if time_t is a long or not
197 AC_MSG_CHECKING(size of time_t)
198 AC_CACHE_VAL(unet_cv_sizeof_time_t,
199 [AC_TRY_RUN([#include <stdio.h>
200 #include <sys/types.h>
201 main()
202 {
203   FILE *f=fopen("conftestval", "w");
204   if (!f) exit(1);
205   fprintf(f, "%d\n", sizeof(time_t));
206   exit(0);
207 }], unet_cv_sizeof_time_t=`cat conftestval`,
208 unet_cv_sizeof_time_t=0, unet_cv_sizeof_time_t=0)])
209 if test "$unet_cv_sizeof_time_t" = 0 ; then
210   AC_MSG_RESULT(unknown)
211   AC_DEFINE(TIME_T_FMT, "%lu")
212   AC_DEFINE(STIME_T_FMT, "%ld")
213 else
214   AC_MSG_RESULT([$unet_cv_sizeof_time_t])
215   AC_MSG_CHECKING(printf format of time_t)
216   if test "$unet_cv_sizeof_time_t" = "$ac_cv_sizeof_long" ; then
217     AC_MSG_RESULT("%lu")
218     AC_DEFINE(TIME_T_FMT, "%lu")
219     AC_DEFINE(STIME_T_FMT, "%ld")
220   else
221     AC_MSG_RESULT("%u")
222     AC_DEFINE(TIME_T_FMT, "%u")
223     AC_DEFINE(STIME_T_FMT, "%d")
224   fi
225 fi])
226
227 dnl
228 dnl Macro: unet_CHECK_TYPE_SIZES
229 dnl
230 dnl Check the size of several types and define a valid int16_t and int32_t.
231 dnl
232 AC_DEFUN(unet_CHECK_TYPE_SIZES,
233 [dnl Check type sizes
234 AC_CHECK_SIZEOF(short)
235 AC_CHECK_SIZEOF(int)
236 AC_CHECK_SIZEOF(long)
237 AC_CHECK_SIZEOF(void *)
238 if test "$ac_cv_sizeof_int" = 2 ; then
239   AC_CHECK_TYPE(int16_t, int)
240   AC_CHECK_TYPE(u_int16_t, unsigned int)
241 elif test "$ac_cv_sizeof_short" = 2 ; then
242   AC_CHECK_TYPE(int16_t, short)
243   AC_CHECK_TYPE(u_int16_t, unsigned short)
244 else
245   AC_MSG_ERROR([Cannot find a type with size of 16 bits])
246 fi
247 if test "$ac_cv_sizeof_int" = 4 ; then
248   AC_CHECK_TYPE(int32_t, int)
249   AC_CHECK_TYPE(u_int32_t, unsigned int)
250 elif test "$ac_cv_sizeof_short" = 4 ; then
251   AC_CHECK_TYPE(int32_t, short)
252   AC_CHECK_TYPE(u_int32_t, unsigned short)
253 elif test "$ac_cv_sizeof_long" = 4 ; then
254   AC_CHECK_TYPE(int32_t, long)
255   AC_CHECK_TYPE(u_int32_t, unsigned long)
256 else
257   AC_MSG_ERROR([Cannot find a type with size of 32 bits])
258 fi])
259
260 dnl
261 dnl Macro: unet_FUNC_POLL_SYSCALL
262 dnl
263 dnl Try to figure out if we have a system call poll (not if it is emulated).
264 dnl Manical laughter...
265 dnl
266 AC_DEFUN(unet_FUNC_POLL_SYSCALL,
267 [AC_CHECK_HEADERS(poll.h)dnl
268 if test -z "$unet_cv_func_poll_syscall" ; then
269   AC_MSG_CHECKING([if poll is a system call (please wait)])
270 else
271   AC_MSG_CHECKING([if poll is a system call])
272 fi
273 AC_CACHE_VAL(unet_cv_func_poll_syscall,
274 [unet_cv_func_poll_syscall=no
275 dnl No need to go through the trouble when we don't have poll.h:
276 changequote(, )dnl
277 if test "$ac_cv_header_poll_h" = yes; then
278   unet_dirs=`find /usr/include/sys -type f -name '*.h' -exec egrep '^#include <[^/]*/.*>' {} \; | sed -e 's/^.*<//' -e 's%/.*$%%' | sort | uniq`
279   for i in $unet_dirs ; do
280     if test "$unet_cv_func_poll_syscall" = no ; then
281       unet_files=`ls /usr/include/$i/*.h 2> /dev/null`
282       if test -n "$unet_files" ; then
283         for j in $unet_files ; do
284           if test "$unet_cv_func_poll_syscall" = no ; then
285             unet_line=`egrep '^#define[[:space:]]+[[:alnum:]_]*[Pp][Oo][Ll][Ll]' $j`
286             if test -n "$unet_line" ; then
287               unet_sig=`echo "$unet_line" | sed -e 's/poll/fork/g' -e 's/POLL/FORK/g' -e 's/[[:space:]]//g' -e 's%/\*.*\*/%%g' -e 's/[0-9]//g'`
288               unet_set=`for k in "$unet_sig" ; do echo $k; done | sed -e 's% %|%g'`
289               unet_match=`sed -e 's/[[:space:]]//g' -e 's%/\*.*\*/%%g' -e 's/[0-9]//g' $j | egrep "$unet_set"`
290               if test -n "$unet_match" ; then
291                 unet_cv_func_poll_syscall=yes
292               fi
293             fi
294           fi
295         done
296       fi
297     fi
298   done
299 fi
300 changequote([, ])dnl
301 ])
302 AC_MSG_RESULT([$unet_cv_func_poll_syscall])
303 ])
304
305
306 # serial 1
307
308 # @defmac AC_PROG_CC_STDC
309 # @maindex PROG_CC_STDC
310 # @ovindex CC
311 # If the C compiler in not in ANSI C mode by default, try to add an option
312 # to output variable @code{CC} to make it so.  This macro tries various
313 # options that select ANSI C on some system or another.  It considers the
314 # compiler to be in ANSI C mode if it handles function prototypes correctly.
315 #
316 # If you use this macro, you should check after calling it whether the C
317 # compiler has been set to accept ANSI C; if not, the shell variable
318 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
319 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
320 # program @code{ansi2knr}, which comes with Ghostscript.
321 # @end defmac
322
323 AC_DEFUN(AM_PROG_CC_STDC,
324 [AC_REQUIRE([AC_PROG_CC])
325 AC_BEFORE([$0], [AC_C_INLINE])
326 AC_BEFORE([$0], [AC_C_CONST])
327 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
328 dnl a magic option to avoid problems with ANSI preprocessor commands
329 dnl like #elif.
330 dnl FIXME: can't do this because then AC_AIX won't work due to a
331 dnl circular dependency.
332 dnl AC_BEFORE([$0], [AC_PROG_CPP])
333 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
334 AC_CACHE_VAL(am_cv_prog_cc_stdc,
335 [am_cv_prog_cc_stdc=no
336 ac_save_CC="$CC"
337 # Don't try gcc -ansi; that turns off useful extensions and
338 # breaks some systems' header files.
339 # AIX                   -qlanglvl=ansi
340 # Ultrix and OSF/1      -std1
341 # HP-UX                 -Aa -D_HPUX_SOURCE
342 # SVR4                  -Xc -D__EXTENSIONS__
343 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
344 do
345   CC="$ac_save_CC $ac_arg"
346   AC_TRY_COMPILE(
347 [#include <stdarg.h>
348 #include <stdio.h>
349 #include <sys/types.h>
350 #include <sys/stat.h>
351 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
352 struct buf { int x; };
353 FILE * (*rcsopen) (struct buf *, struct stat *, int);
354 static char *e (p, i)
355      char **p;
356      int i;
357 {
358   return p[i];
359 }
360 static char *f (char * (*g) (char **, int), char **p, ...)
361 {
362   char *s;
363   va_list v;
364   va_start (v,p);
365   s = g (p, va_arg (v,int));
366   va_end (v);
367   return s;
368 }
369 int test (int i, double x);
370 struct s1 {int (*f) (int a);};
371 struct s2 {int (*f) (double a);};
372 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
373 int argc;
374 char **argv;
375 ], [
376 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
377 ],
378 [am_cv_prog_cc_stdc="$ac_arg"; break])
379 done
380 CC="$ac_save_CC"
381 ])
382 if test -z "$am_cv_prog_cc_stdc"; then
383   AC_MSG_RESULT([none needed])
384 else
385   AC_MSG_RESULT($am_cv_prog_cc_stdc)
386 fi
387 case "x$am_cv_prog_cc_stdc" in
388   x|xno) ;;
389   *) CC="$CC $am_cv_prog_cc_stdc" ;;
390 esac
391 ])
392