This commit was generated by cvs2svn to compensate for changes in r2,
[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 if test "$ac_cv_sizeof_int" = 2 ; then
238   AC_CHECK_TYPE(int16_t, int)
239   AC_CHECK_TYPE(u_int16_t, unsigned int)
240 elif test "$ac_cv_sizeof_short" = 2 ; then
241   AC_CHECK_TYPE(int16_t, short)
242   AC_CHECK_TYPE(u_int16_t, unsigned short)
243 else
244   AC_MSG_ERROR([Cannot find a type with size of 16 bits])
245 fi
246 if test "$ac_cv_sizeof_int" = 4 ; then
247   AC_CHECK_TYPE(int32_t, int)
248   AC_CHECK_TYPE(u_int32_t, unsigned int)
249 elif test "$ac_cv_sizeof_short" = 4 ; then
250   AC_CHECK_TYPE(int32_t, short)
251   AC_CHECK_TYPE(u_int32_t, unsigned short)
252 elif test "$ac_cv_sizeof_long" = 4 ; then
253   AC_CHECK_TYPE(int32_t, long)
254   AC_CHECK_TYPE(u_int32_t, unsigned long)
255 else
256   AC_MSG_ERROR([Cannot find a type with size of 32 bits])
257 fi])
258
259 dnl
260 dnl Macro: unet_FUNC_POLL_SYSCALL
261 dnl
262 dnl Try to figure out if we have a system call poll (not if it is emulated).
263 dnl Manical laughter...
264 dnl
265 AC_DEFUN(unet_FUNC_POLL_SYSCALL,
266 [AC_CHECK_HEADERS(poll.h)dnl
267 if test -z "$unet_cv_func_poll_syscall" ; then
268   AC_MSG_CHECKING([if poll is a system call (please wait)])
269 else
270   AC_MSG_CHECKING([if poll is a system call])
271 fi
272 AC_CACHE_VAL(unet_cv_func_poll_syscall,
273 [unet_cv_func_poll_syscall=no
274 dnl No need to go through the trouble when we don't have poll.h:
275 changequote(, )dnl
276 if test "$ac_cv_header_poll_h" = yes; then
277   unet_dirs=`find /usr/include/sys -type f -name '*.h' -exec egrep '^#include <[^/]*/.*>' {} \; | sed -e 's/^.*<//' -e 's%/.*$%%' | sort | uniq`
278   for i in $unet_dirs ; do
279     if test "$unet_cv_func_poll_syscall" = no ; then
280       unet_files=`ls /usr/include/$i/*.h 2> /dev/null`
281       if test -n "$unet_files" ; then
282         for j in $unet_files ; do
283           if test "$unet_cv_func_poll_syscall" = no ; then
284             unet_line=`egrep '^#define[[:space:]]+[[:alnum:]_]*[Pp][Oo][Ll][Ll]' $j`
285             if test -n "$unet_line" ; then
286               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'`
287               unet_set=`for k in "$unet_sig" ; do echo $k; done | sed -e 's% %|%g'`
288               unet_match=`sed -e 's/[[:space:]]//g' -e 's%/\*.*\*/%%g' -e 's/[0-9]//g' $j | egrep "$unet_set"`
289               if test -n "$unet_match" ; then
290                 unet_cv_func_poll_syscall=yes
291               fi
292             fi
293           fi
294         done
295       fi
296     fi
297   done
298 fi
299 changequote([, ])dnl
300 ])
301 AC_MSG_RESULT([$unet_cv_func_poll_syscall])
302 ])
303
304
305 # serial 1
306
307 # @defmac AC_PROG_CC_STDC
308 # @maindex PROG_CC_STDC
309 # @ovindex CC
310 # If the C compiler in not in ANSI C mode by default, try to add an option
311 # to output variable @code{CC} to make it so.  This macro tries various
312 # options that select ANSI C on some system or another.  It considers the
313 # compiler to be in ANSI C mode if it handles function prototypes correctly.
314 #
315 # If you use this macro, you should check after calling it whether the C
316 # compiler has been set to accept ANSI C; if not, the shell variable
317 # @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
318 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
319 # program @code{ansi2knr}, which comes with Ghostscript.
320 # @end defmac
321
322 AC_DEFUN(AM_PROG_CC_STDC,
323 [AC_REQUIRE([AC_PROG_CC])
324 AC_BEFORE([$0], [AC_C_INLINE])
325 AC_BEFORE([$0], [AC_C_CONST])
326 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
327 dnl a magic option to avoid problems with ANSI preprocessor commands
328 dnl like #elif.
329 dnl FIXME: can't do this because then AC_AIX won't work due to a
330 dnl circular dependency.
331 dnl AC_BEFORE([$0], [AC_PROG_CPP])
332 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
333 AC_CACHE_VAL(am_cv_prog_cc_stdc,
334 [am_cv_prog_cc_stdc=no
335 ac_save_CC="$CC"
336 # Don't try gcc -ansi; that turns off useful extensions and
337 # breaks some systems' header files.
338 # AIX                   -qlanglvl=ansi
339 # Ultrix and OSF/1      -std1
340 # HP-UX                 -Aa -D_HPUX_SOURCE
341 # SVR4                  -Xc -D__EXTENSIONS__
342 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
343 do
344   CC="$ac_save_CC $ac_arg"
345   AC_TRY_COMPILE(
346 [#include <stdarg.h>
347 #include <stdio.h>
348 #include <sys/types.h>
349 #include <sys/stat.h>
350 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
351 struct buf { int x; };
352 FILE * (*rcsopen) (struct buf *, struct stat *, int);
353 static char *e (p, i)
354      char **p;
355      int i;
356 {
357   return p[i];
358 }
359 static char *f (char * (*g) (char **, int), char **p, ...)
360 {
361   char *s;
362   va_list v;
363   va_start (v,p);
364   s = g (p, va_arg (v,int));
365   va_end (v);
366   return s;
367 }
368 int test (int i, double x);
369 struct s1 {int (*f) (int a);};
370 struct s2 {int (*f) (double a);};
371 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
372 int argc;
373 char **argv;
374 ], [
375 return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
376 ],
377 [am_cv_prog_cc_stdc="$ac_arg"; break])
378 done
379 CC="$ac_save_CC"
380 ])
381 if test -z "$am_cv_prog_cc_stdc"; then
382   AC_MSG_RESULT([none needed])
383 else
384   AC_MSG_RESULT($am_cv_prog_cc_stdc)
385 fi
386 case "x$am_cv_prog_cc_stdc" in
387   x|xno) ;;
388   *) CC="$CC $am_cv_prog_cc_stdc" ;;
389 esac
390 ])
391