1 | dnl @(#) $Header: /afs/dev.mit.edu/source/repository/third/traceroute/aclocal.m4,v 1.2 2000-04-11 22:47:47 ghudson Exp $ (LBL) |
---|
2 | dnl |
---|
3 | dnl Copyright (c) 1995, 1996, 1997 |
---|
4 | dnl The Regents of the University of California. All rights reserved. |
---|
5 | dnl |
---|
6 | dnl Redistribution and use in source and binary forms, with or without |
---|
7 | dnl modification, are permitted provided that: (1) source code distributions |
---|
8 | dnl retain the above copyright notice and this paragraph in its entirety, (2) |
---|
9 | dnl distributions including binary code include the above copyright notice and |
---|
10 | dnl this paragraph in its entirety in the documentation or other materials |
---|
11 | dnl provided with the distribution, and (3) all advertising materials mentioning |
---|
12 | dnl features or use of this software display the following acknowledgement: |
---|
13 | dnl ``This product includes software developed by the University of California, |
---|
14 | dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
---|
15 | dnl the University nor the names of its contributors may be used to endorse |
---|
16 | dnl or promote products derived from this software without specific prior |
---|
17 | dnl written permission. |
---|
18 | dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
---|
19 | dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
---|
20 | dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
21 | dnl |
---|
22 | dnl LBL autoconf macros |
---|
23 | dnl |
---|
24 | |
---|
25 | dnl |
---|
26 | dnl Determine which compiler we're using (cc or gcc) |
---|
27 | dnl If using gcc, determine the version number |
---|
28 | dnl If using cc, require that it support ansi prototypes |
---|
29 | dnl If using gcc, use -O2 (otherwise use -O) |
---|
30 | dnl If using cc, explicitly specify /usr/local/include |
---|
31 | dnl |
---|
32 | dnl usage: |
---|
33 | dnl |
---|
34 | dnl AC_LBL_C_INIT(copt, incls) |
---|
35 | dnl |
---|
36 | dnl results: |
---|
37 | dnl |
---|
38 | dnl $1 (copt set) |
---|
39 | dnl $2 (incls set) |
---|
40 | dnl CC |
---|
41 | dnl ac_cv_lbl_gcc_vers |
---|
42 | dnl LBL_CFLAGS |
---|
43 | dnl |
---|
44 | AC_DEFUN(AC_LBL_C_INIT, |
---|
45 | [AC_PREREQ(2.12) |
---|
46 | AC_BEFORE([$0], [AC_PROG_CC]) |
---|
47 | AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) |
---|
48 | AC_BEFORE([$0], [AC_LBL_DEVEL]) |
---|
49 | AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) |
---|
50 | $1="-O" |
---|
51 | $2="" |
---|
52 | if test "${CFLAGS+set}" = set; then |
---|
53 | LBL_CFLAGS="$CFLAGS" |
---|
54 | fi |
---|
55 | if test -z "$CC" ; then |
---|
56 | case "$target_os" in |
---|
57 | |
---|
58 | bsdi*) |
---|
59 | AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) |
---|
60 | if test $SHLICC2 = yes ; then |
---|
61 | CC=shlicc2 |
---|
62 | export CC |
---|
63 | fi |
---|
64 | ;; |
---|
65 | esac |
---|
66 | fi |
---|
67 | if test -z "$CC" -a "$with_gcc" = no ; then |
---|
68 | CC=cc |
---|
69 | export CC |
---|
70 | fi |
---|
71 | AC_PROG_CC |
---|
72 | if test "$GCC" = yes ; then |
---|
73 | if test "$SHLICC2" = yes ; then |
---|
74 | ac_cv_lbl_gcc_vers=2 |
---|
75 | $1="-O2" |
---|
76 | else |
---|
77 | AC_MSG_CHECKING(gcc version) |
---|
78 | AC_CACHE_VAL(ac_cv_lbl_gcc_vers, |
---|
79 | ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ |
---|
80 | sed -n -e '$s/\..*//' -e '$s/.* //p'`) |
---|
81 | AC_MSG_RESULT($ac_cv_lbl_gcc_vers) |
---|
82 | if test $ac_cv_lbl_gcc_vers -gt 1 ; then |
---|
83 | $1="-O2" |
---|
84 | fi |
---|
85 | fi |
---|
86 | else |
---|
87 | AC_MSG_CHECKING(that $CC handles ansi prototypes) |
---|
88 | AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, |
---|
89 | AC_TRY_COMPILE( |
---|
90 | [#include <sys/types.h>], |
---|
91 | [int frob(int, char *)], |
---|
92 | ac_cv_lbl_cc_ansi_prototypes=yes, |
---|
93 | ac_cv_lbl_cc_ansi_prototypes=no)) |
---|
94 | AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) |
---|
95 | if test $ac_cv_lbl_cc_ansi_prototypes = no ; then |
---|
96 | case "$target_os" in |
---|
97 | |
---|
98 | hpux*) |
---|
99 | AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) |
---|
100 | savedcflags="$CFLAGS" |
---|
101 | CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" |
---|
102 | AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, |
---|
103 | AC_TRY_COMPILE( |
---|
104 | [#include <sys/types.h>], |
---|
105 | [int frob(int, char *)], |
---|
106 | ac_cv_lbl_cc_hpux_cc_aa=yes, |
---|
107 | ac_cv_lbl_cc_hpux_cc_aa=no)) |
---|
108 | AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) |
---|
109 | if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then |
---|
110 | AC_MSG_ERROR(see the INSTALL doc for more info) |
---|
111 | fi |
---|
112 | CFLAGS="$savedcflags" |
---|
113 | V_CCOPT="-Aa $V_CCOPT" |
---|
114 | AC_DEFINE(_HPUX_SOURCE) |
---|
115 | ;; |
---|
116 | |
---|
117 | *) |
---|
118 | AC_MSG_ERROR(see the INSTALL doc for more info) |
---|
119 | ;; |
---|
120 | esac |
---|
121 | fi |
---|
122 | $2="-I/usr/local/include" |
---|
123 | |
---|
124 | case "$target_os" in |
---|
125 | |
---|
126 | irix*) |
---|
127 | V_CCOPT="$V_CCOPT -xansi -signed -g3" |
---|
128 | ;; |
---|
129 | |
---|
130 | osf*) |
---|
131 | V_CCOPT="$V_CCOPT -g3" |
---|
132 | ;; |
---|
133 | |
---|
134 | ultrix*) |
---|
135 | AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) |
---|
136 | AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, |
---|
137 | AC_TRY_COMPILE( |
---|
138 | [#include <sys/types.h>], |
---|
139 | [struct a { int b; }; |
---|
140 | void c(const struct a *)], |
---|
141 | ac_cv_lbl_cc_const_proto=yes, |
---|
142 | ac_cv_lbl_cc_const_proto=no)) |
---|
143 | AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) |
---|
144 | if test $ac_cv_lbl_cc_const_proto = no ; then |
---|
145 | AC_DEFINE(const,) |
---|
146 | fi |
---|
147 | ;; |
---|
148 | esac |
---|
149 | fi |
---|
150 | ]) |
---|
151 | |
---|
152 | dnl |
---|
153 | dnl Use pfopen.c if available and pfopen() not in standard libraries |
---|
154 | dnl Require libpcap |
---|
155 | dnl Look for libpcap in .. |
---|
156 | dnl Use the installed libpcap if there is no local version |
---|
157 | dnl |
---|
158 | dnl usage: |
---|
159 | dnl |
---|
160 | dnl AC_LBL_LIBPCAP(pcapdep, incls) |
---|
161 | dnl |
---|
162 | dnl results: |
---|
163 | dnl |
---|
164 | dnl $1 (pcapdep set) |
---|
165 | dnl $2 (incls appended) |
---|
166 | dnl LIBS |
---|
167 | dnl LBL_LIBS |
---|
168 | dnl |
---|
169 | AC_DEFUN(AC_LBL_LIBPCAP, |
---|
170 | [AC_REQUIRE([AC_LBL_LIBRARY_NET]) |
---|
171 | dnl |
---|
172 | dnl save a copy before locating libpcap.a |
---|
173 | dnl |
---|
174 | LBL_LIBS="$LIBS" |
---|
175 | pfopen=/usr/examples/packetfilter/pfopen.c |
---|
176 | if test -f $pfopen ; then |
---|
177 | AC_CHECK_FUNCS(pfopen) |
---|
178 | if test $ac_cv_func_pfopen = "no" ; then |
---|
179 | AC_MSG_RESULT(Using $pfopen) |
---|
180 | LIBS="$LIBS $pfopen" |
---|
181 | fi |
---|
182 | fi |
---|
183 | AC_MSG_CHECKING(for local pcap library) |
---|
184 | libpcap=FAIL |
---|
185 | lastdir=FAIL |
---|
186 | places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ |
---|
187 | egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'` |
---|
188 | for dir in $places ../libpcap libpcap ; do |
---|
189 | basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'` |
---|
190 | if test $lastdir = $basedir ; then |
---|
191 | dnl skip alphas when an actual release is present |
---|
192 | continue; |
---|
193 | fi |
---|
194 | lastdir=$dir |
---|
195 | if test -r $dir/pcap.c ; then |
---|
196 | libpcap=$dir/libpcap.a |
---|
197 | d=$dir |
---|
198 | dnl continue and select the last one that exists |
---|
199 | fi |
---|
200 | done |
---|
201 | if test $libpcap = FAIL ; then |
---|
202 | AC_MSG_RESULT(not found) |
---|
203 | AC_CHECK_LIB(pcap, main, libpcap="-lpcap") |
---|
204 | if test $libpcap = FAIL ; then |
---|
205 | AC_MSG_ERROR(see the INSTALL doc for more info) |
---|
206 | fi |
---|
207 | else |
---|
208 | $1=$libpcap |
---|
209 | $2="-I$d $$2" |
---|
210 | AC_MSG_RESULT($libpcap) |
---|
211 | fi |
---|
212 | LIBS="$libpcap $LIBS"]) |
---|
213 | |
---|
214 | dnl |
---|
215 | dnl Define RETSIGTYPE and RETSIGVAL |
---|
216 | dnl |
---|
217 | dnl usage: |
---|
218 | dnl |
---|
219 | dnl AC_LBL_TYPE_SIGNAL |
---|
220 | dnl |
---|
221 | dnl results: |
---|
222 | dnl |
---|
223 | dnl RETSIGTYPE (defined) |
---|
224 | dnl RETSIGVAL (defined) |
---|
225 | dnl |
---|
226 | AC_DEFUN(AC_LBL_TYPE_SIGNAL, |
---|
227 | [AC_BEFORE([$0], [AC_LBL_LIBPCAP]) |
---|
228 | AC_TYPE_SIGNAL |
---|
229 | if test "$ac_cv_type_signal" = void ; then |
---|
230 | AC_DEFINE(RETSIGVAL,) |
---|
231 | else |
---|
232 | AC_DEFINE(RETSIGVAL,(0)) |
---|
233 | fi |
---|
234 | case "$target_os" in |
---|
235 | |
---|
236 | irix*) |
---|
237 | AC_DEFINE(_BSD_SIGNALS) |
---|
238 | ;; |
---|
239 | |
---|
240 | *) |
---|
241 | dnl prefer sigset() to sigaction() |
---|
242 | AC_CHECK_FUNCS(sigset) |
---|
243 | if test $ac_cv_func_sigset = no ; then |
---|
244 | AC_CHECK_FUNCS(sigaction) |
---|
245 | fi |
---|
246 | ;; |
---|
247 | esac]) |
---|
248 | |
---|
249 | dnl |
---|
250 | dnl If using gcc, make sure we have ANSI ioctl definitions |
---|
251 | dnl |
---|
252 | dnl usage: |
---|
253 | dnl |
---|
254 | dnl AC_LBL_FIXINCLUDES |
---|
255 | dnl |
---|
256 | AC_DEFUN(AC_LBL_FIXINCLUDES, |
---|
257 | [if test "$GCC" = yes ; then |
---|
258 | AC_MSG_CHECKING(for ANSI ioctl definitions) |
---|
259 | AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, |
---|
260 | AC_TRY_COMPILE( |
---|
261 | [/* |
---|
262 | * This generates a "duplicate case value" when fixincludes |
---|
263 | * has not be run. |
---|
264 | */ |
---|
265 | # include <sys/types.h> |
---|
266 | # include <sys/time.h> |
---|
267 | # include <sys/ioctl.h> |
---|
268 | # ifdef HAVE_SYS_IOCCOM_H |
---|
269 | # include <sys/ioccom.h> |
---|
270 | # endif], |
---|
271 | [switch (0) { |
---|
272 | case _IO('A', 1):; |
---|
273 | case _IO('B', 1):; |
---|
274 | }], |
---|
275 | ac_cv_lbl_gcc_fixincludes=yes, |
---|
276 | ac_cv_lbl_gcc_fixincludes=no)) |
---|
277 | AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) |
---|
278 | if test $ac_cv_lbl_gcc_fixincludes = no ; then |
---|
279 | # Don't cache failure |
---|
280 | unset ac_cv_lbl_gcc_fixincludes |
---|
281 | AC_MSG_ERROR(see the INSTALL for more info) |
---|
282 | fi |
---|
283 | fi]) |
---|
284 | |
---|
285 | dnl |
---|
286 | dnl Check for flex, default to lex |
---|
287 | dnl Require flex 2.4 or higher |
---|
288 | dnl Check for bison, default to yacc |
---|
289 | dnl Default to lex/yacc if both flex and bison are not available |
---|
290 | dnl Define the yy prefix string if using flex and bison |
---|
291 | dnl |
---|
292 | dnl usage: |
---|
293 | dnl |
---|
294 | dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) |
---|
295 | dnl |
---|
296 | dnl results: |
---|
297 | dnl |
---|
298 | dnl $1 (lex set) |
---|
299 | dnl $2 (yacc appended) |
---|
300 | dnl $3 (optional flex and bison -P prefix) |
---|
301 | dnl |
---|
302 | AC_DEFUN(AC_LBL_LEX_AND_YACC, |
---|
303 | [AC_ARG_WITH(flex, [ --without-flex don't use flex]) |
---|
304 | AC_ARG_WITH(bison, [ --without-bison don't use bison]) |
---|
305 | if test "$with_flex" = no ; then |
---|
306 | $1=lex |
---|
307 | else |
---|
308 | AC_CHECK_PROGS($1, flex, lex) |
---|
309 | fi |
---|
310 | if test "$$1" = flex ; then |
---|
311 | # The -V flag was added in 2.4 |
---|
312 | AC_MSG_CHECKING(for flex 2.4 or higher) |
---|
313 | AC_CACHE_VAL(ac_cv_lbl_flex_v24, |
---|
314 | if flex -V >/dev/null 2>&1; then |
---|
315 | ac_cv_lbl_flex_v24=yes |
---|
316 | else |
---|
317 | ac_cv_lbl_flex_v24=no |
---|
318 | fi) |
---|
319 | AC_MSG_RESULT($ac_cv_lbl_flex_v24) |
---|
320 | if test $ac_cv_lbl_flex_v24 = no ; then |
---|
321 | s="2.4 or higher required" |
---|
322 | AC_MSG_WARN(ignoring obsolete flex executable ($s)) |
---|
323 | $1=lex |
---|
324 | fi |
---|
325 | fi |
---|
326 | if test "$with_bison" = no ; then |
---|
327 | $2=yacc |
---|
328 | else |
---|
329 | AC_CHECK_PROGS($2, bison, yacc) |
---|
330 | fi |
---|
331 | if test "$$2" = bison ; then |
---|
332 | $2="$$2 -y" |
---|
333 | fi |
---|
334 | if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then |
---|
335 | AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) |
---|
336 | $1=lex |
---|
337 | $2=yacc |
---|
338 | fi |
---|
339 | if test "$$1" = flex -a -n "$3" ; then |
---|
340 | $1="$$1 -P$3" |
---|
341 | $2="$$2 -p $3" |
---|
342 | fi]) |
---|
343 | |
---|
344 | dnl |
---|
345 | dnl Checks to see if union wait is used with WEXITSTATUS() |
---|
346 | dnl |
---|
347 | dnl usage: |
---|
348 | dnl |
---|
349 | dnl AC_LBL_UNION_WAIT |
---|
350 | dnl |
---|
351 | dnl results: |
---|
352 | dnl |
---|
353 | dnl DECLWAITSTATUS (defined) |
---|
354 | dnl |
---|
355 | AC_DEFUN(AC_LBL_UNION_WAIT, |
---|
356 | [AC_MSG_CHECKING(if union wait is used) |
---|
357 | AC_CACHE_VAL(ac_cv_lbl_union_wait, |
---|
358 | AC_TRY_COMPILE([ |
---|
359 | # include <sys/types.h> |
---|
360 | # include <sys/wait.h>], |
---|
361 | [int status; |
---|
362 | u_int i = WEXITSTATUS(status); |
---|
363 | u_int j = waitpid(0, &status, 0);], |
---|
364 | ac_cv_lbl_union_wait=no, |
---|
365 | ac_cv_lbl_union_wait=yes)) |
---|
366 | AC_MSG_RESULT($ac_cv_lbl_union_wait) |
---|
367 | if test $ac_cv_lbl_union_wait = yes ; then |
---|
368 | AC_DEFINE(DECLWAITSTATUS,union wait) |
---|
369 | else |
---|
370 | AC_DEFINE(DECLWAITSTATUS,int) |
---|
371 | fi]) |
---|
372 | |
---|
373 | dnl |
---|
374 | dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member |
---|
375 | dnl |
---|
376 | dnl usage: |
---|
377 | dnl |
---|
378 | dnl AC_LBL_SOCKADDR_SA_LEN |
---|
379 | dnl |
---|
380 | dnl results: |
---|
381 | dnl |
---|
382 | dnl HAVE_SOCKADDR_SA_LEN (defined) |
---|
383 | dnl |
---|
384 | AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, |
---|
385 | [AC_MSG_CHECKING(if sockaddr struct has sa_len member) |
---|
386 | AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, |
---|
387 | AC_TRY_COMPILE([ |
---|
388 | # include <sys/types.h> |
---|
389 | # include <sys/socket.h>], |
---|
390 | [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], |
---|
391 | ac_cv_lbl_sockaddr_has_sa_len=yes, |
---|
392 | ac_cv_lbl_sockaddr_has_sa_len=no)) |
---|
393 | AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) |
---|
394 | if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then |
---|
395 | AC_DEFINE(HAVE_SOCKADDR_SA_LEN) |
---|
396 | fi]) |
---|
397 | |
---|
398 | dnl |
---|
399 | dnl Checks to see if -R is used |
---|
400 | dnl |
---|
401 | dnl usage: |
---|
402 | dnl |
---|
403 | dnl AC_LBL_HAVE_RUN_PATH |
---|
404 | dnl |
---|
405 | dnl results: |
---|
406 | dnl |
---|
407 | dnl ac_cv_lbl_have_run_path (yes or no) |
---|
408 | dnl |
---|
409 | AC_DEFUN(AC_LBL_HAVE_RUN_PATH, |
---|
410 | [AC_MSG_CHECKING(for ${CC-cc} -R) |
---|
411 | AC_CACHE_VAL(ac_cv_lbl_have_run_path, |
---|
412 | [echo 'main(){}' > conftest.c |
---|
413 | ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 |
---|
414 | if test ! -s conftest.out ; then |
---|
415 | ac_cv_lbl_have_run_path=yes |
---|
416 | else |
---|
417 | ac_cv_lbl_have_run_path=no |
---|
418 | fi |
---|
419 | rm -f conftest*]) |
---|
420 | AC_MSG_RESULT($ac_cv_lbl_have_run_path) |
---|
421 | ]) |
---|
422 | |
---|
423 | dnl |
---|
424 | dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless. |
---|
425 | dnl |
---|
426 | dnl usage: |
---|
427 | dnl |
---|
428 | dnl AC_LBL_CHECK_TYPE |
---|
429 | dnl |
---|
430 | dnl results: |
---|
431 | dnl |
---|
432 | dnl int32_t (defined) |
---|
433 | dnl u_int32_t (defined) |
---|
434 | dnl |
---|
435 | AC_DEFUN(AC_LBL_CHECK_TYPE, |
---|
436 | [AC_MSG_CHECKING(for $1 using $CC) |
---|
437 | AC_CACHE_VAL(ac_cv_lbl_have_$1, |
---|
438 | AC_TRY_COMPILE([ |
---|
439 | # include "confdefs.h" |
---|
440 | # include <sys/types.h> |
---|
441 | # if STDC_HEADERS |
---|
442 | # include <stdlib.h> |
---|
443 | # include <stddef.h> |
---|
444 | # endif], |
---|
445 | [$1 i], |
---|
446 | ac_cv_lbl_have_$1=yes, |
---|
447 | ac_cv_lbl_have_$1=no)) |
---|
448 | AC_MSG_RESULT($ac_cv_lbl_have_$1) |
---|
449 | if test $ac_cv_lbl_have_$1 = no ; then |
---|
450 | AC_DEFINE($1, $2) |
---|
451 | fi]) |
---|
452 | |
---|
453 | dnl |
---|
454 | dnl Checks to see if unaligned memory accesses fail |
---|
455 | dnl |
---|
456 | dnl usage: |
---|
457 | dnl |
---|
458 | dnl AC_LBL_UNALIGNED_ACCESS |
---|
459 | dnl |
---|
460 | dnl results: |
---|
461 | dnl |
---|
462 | dnl LBL_ALIGN (DEFINED) |
---|
463 | dnl |
---|
464 | AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, |
---|
465 | [AC_MSG_CHECKING(if unaligned accesses fail) |
---|
466 | AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, |
---|
467 | [case "$target_cpu" in |
---|
468 | |
---|
469 | alpha|hp*|mips|sparc) |
---|
470 | ac_cv_lbl_unaligned_fail=yes |
---|
471 | ;; |
---|
472 | |
---|
473 | *) |
---|
474 | cat >conftest.c <<EOF |
---|
475 | # include <sys/types.h> |
---|
476 | # include <sys/wait.h> |
---|
477 | # include <stdio.h> |
---|
478 | unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; |
---|
479 | main() { |
---|
480 | unsigned int i; |
---|
481 | pid_t pid; |
---|
482 | int status; |
---|
483 | /* avoid "core dumped" message */ |
---|
484 | pid = fork(); |
---|
485 | if (pid < 0) |
---|
486 | exit(2); |
---|
487 | if (pid > 0) { |
---|
488 | /* parent */ |
---|
489 | pid = waitpid(pid, &status, 0); |
---|
490 | if (pid < 0) |
---|
491 | exit(3); |
---|
492 | exit(!WIFEXITED(status)); |
---|
493 | } |
---|
494 | /* child */ |
---|
495 | i = *(unsigned int *)&a[[1]]; |
---|
496 | printf("%d\n", i); |
---|
497 | exit(0); |
---|
498 | } |
---|
499 | EOF |
---|
500 | ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ |
---|
501 | conftest.c $LIBS >/dev/null 2>&1 |
---|
502 | if test ! -x conftest ; then |
---|
503 | dnl failed to compile for some reason |
---|
504 | ac_cv_lbl_unaligned_fail=yes |
---|
505 | else |
---|
506 | ./conftest >conftest.out |
---|
507 | if test ! -s conftest.out ; then |
---|
508 | ac_cv_lbl_unaligned_fail=yes |
---|
509 | else |
---|
510 | ac_cv_lbl_unaligned_fail=no |
---|
511 | fi |
---|
512 | fi |
---|
513 | rm -f conftest* core core.conftest |
---|
514 | ;; |
---|
515 | esac]) |
---|
516 | AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) |
---|
517 | if test $ac_cv_lbl_unaligned_fail = yes ; then |
---|
518 | AC_DEFINE(LBL_ALIGN) |
---|
519 | fi]) |
---|
520 | |
---|
521 | dnl |
---|
522 | dnl If using gcc and the file .devel exists: |
---|
523 | dnl Compile with -g (if supported) and -Wall |
---|
524 | dnl If using gcc 2, do extra prototype checking |
---|
525 | dnl If an os prototype include exists, symlink os-proto.h to it |
---|
526 | dnl |
---|
527 | dnl usage: |
---|
528 | dnl |
---|
529 | dnl AC_LBL_DEVEL(copt) |
---|
530 | dnl |
---|
531 | dnl results: |
---|
532 | dnl |
---|
533 | dnl $1 (copt appended) |
---|
534 | dnl HAVE_OS_PROTO_H (defined) |
---|
535 | dnl os-proto.h (symlinked) |
---|
536 | dnl |
---|
537 | AC_DEFUN(AC_LBL_DEVEL, |
---|
538 | [rm -f os-proto.h |
---|
539 | if test "${LBL_CFLAGS+set}" = set; then |
---|
540 | $1="$$1 ${LBL_CFLAGS}" |
---|
541 | fi |
---|
542 | if test -f .devel ; then |
---|
543 | if test "$GCC" = yes ; then |
---|
544 | if test "${LBL_CFLAGS+set}" != set; then |
---|
545 | if test "$ac_cv_prog_cc_g" = yes ; then |
---|
546 | $1="-g $$1" |
---|
547 | fi |
---|
548 | $1="$$1 -Wall" |
---|
549 | if test $ac_cv_lbl_gcc_vers -gt 1 ; then |
---|
550 | $1="$$1 -Wmissing-prototypes -Wstrict-prototypes" |
---|
551 | fi |
---|
552 | fi |
---|
553 | else |
---|
554 | case "$target_os" in |
---|
555 | |
---|
556 | irix6*) |
---|
557 | V_CCOPT="$V_CCOPT -n32" |
---|
558 | ;; |
---|
559 | |
---|
560 | *) |
---|
561 | ;; |
---|
562 | esac |
---|
563 | fi |
---|
564 | os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'` |
---|
565 | name="lbl/os-$os.h" |
---|
566 | if test -f $name ; then |
---|
567 | ln -s $name os-proto.h |
---|
568 | AC_DEFINE(HAVE_OS_PROTO_H) |
---|
569 | else |
---|
570 | AC_MSG_WARN(can't find $name) |
---|
571 | fi |
---|
572 | fi]) |
---|
573 | |
---|
574 | dnl |
---|
575 | dnl Attempt to determine additional libraries needed for network programs |
---|
576 | dnl |
---|
577 | dnl Thanks to John Hawkinson (jhawk@mit.edu) |
---|
578 | dnl |
---|
579 | dnl usage: |
---|
580 | dnl |
---|
581 | dnl AC_LBL_LIBRARY_NET |
---|
582 | dnl |
---|
583 | dnl results: |
---|
584 | dnl |
---|
585 | dnl LIBS |
---|
586 | dnl |
---|
587 | |
---|
588 | define(AC_LBL_CHECK_LIB, |
---|
589 | [AC_MSG_CHECKING([for $2 in -l$1]) |
---|
590 | dnl Use a cache variable name containing both the library and function name, |
---|
591 | dnl because the test really is for library $1 defining function $2, not |
---|
592 | dnl just for library $1. Separate tests with the same $1 and different $2s |
---|
593 | dnl may have different results. |
---|
594 | ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` |
---|
595 | AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, |
---|
596 | [ac_save_LIBS="$LIBS" |
---|
597 | LIBS="-l$1 $5 $LIBS" |
---|
598 | AC_TRY_LINK(dnl |
---|
599 | ifelse([$2], [main], , dnl Avoid conflicting decl of main. |
---|
600 | [/* Override any gcc2 internal prototype to avoid an error. */ |
---|
601 | ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus |
---|
602 | extern "C" |
---|
603 | #endif |
---|
604 | ])dnl |
---|
605 | [/* We use char because int might match the return type of a gcc2 |
---|
606 | builtin and then its argument prototype would still apply. */ |
---|
607 | char $2(); |
---|
608 | ]), |
---|
609 | [$2()], |
---|
610 | eval "ac_cv_lbl_lib_$ac_lib_var=yes", |
---|
611 | eval "ac_cv_lbl_lib_$ac_lib_var=no") |
---|
612 | LIBS="$ac_save_LIBS" |
---|
613 | ])dnl |
---|
614 | if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then |
---|
615 | AC_MSG_RESULT(yes) |
---|
616 | ifelse([$3], , |
---|
617 | [changequote(, )dnl |
---|
618 | ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ |
---|
619 | -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` |
---|
620 | changequote([, ])dnl |
---|
621 | AC_DEFINE_UNQUOTED($ac_tr_lib) |
---|
622 | LIBS="-l$1 $LIBS" |
---|
623 | ], [$3]) |
---|
624 | else |
---|
625 | AC_MSG_RESULT(no) |
---|
626 | ifelse([$4], , , [$4 |
---|
627 | ])dnl |
---|
628 | fi |
---|
629 | ]) |
---|
630 | |
---|
631 | dnl |
---|
632 | dnl AC_LBL_LIBRARY_NET |
---|
633 | dnl |
---|
634 | dnl This test is for network applications that need socket() and |
---|
635 | dnl gethostbyname() -ish functions. Under Solaris, those applications |
---|
636 | dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link |
---|
637 | dnl with "-lnsl" but should *not* link with "-lsocket" because |
---|
638 | dnl libsocket.a breaks a number of things (for instance: |
---|
639 | dnl gethostbyname() under IRIX 5.2, and snoop sockets under most |
---|
640 | dnl versions of IRIX). |
---|
641 | dnl |
---|
642 | dnl Unfortunately, many application developers are not aware of this, |
---|
643 | dnl and mistakenly write tests that cause -lsocket to be used under |
---|
644 | dnl IRIX. It is also easy to write tests that cause -lnsl to be used |
---|
645 | dnl under operating systems where neither are necessary (or useful), |
---|
646 | dnl such as SunOS 4.1.4, which uses -lnsl for TLI. |
---|
647 | dnl |
---|
648 | dnl This test exists so that every application developer does not test |
---|
649 | dnl this in a different, and subtly broken fashion. |
---|
650 | |
---|
651 | dnl It has been argued that this test should be broken up into two |
---|
652 | dnl seperate tests, one for the resolver libraries, and one for the |
---|
653 | dnl libraries necessary for using Sockets API. Unfortunately, the two |
---|
654 | dnl are carefully intertwined and allowing the autoconf user to use |
---|
655 | dnl them independantly potentially results in unfortunate ordering |
---|
656 | dnl dependancies -- as such, such component macros would have to |
---|
657 | dnl carefully use indirection and be aware if the other components were |
---|
658 | dnl executed. Since other autoconf macros do not go to this trouble, |
---|
659 | dnl and almost no applications use sockets without the resolver, this |
---|
660 | dnl complexity has not been implemented. |
---|
661 | dnl |
---|
662 | dnl The check for libresolv is in case you are attempting to link |
---|
663 | dnl statically and happen to have a libresolv.a lying around (and no |
---|
664 | dnl libnsl.a). |
---|
665 | dnl |
---|
666 | AC_DEFUN(AC_LBL_LIBRARY_NET, [ |
---|
667 | # Most operating systems have gethostbyname() in the default searched |
---|
668 | # libraries (i.e. libc): |
---|
669 | AC_CHECK_FUNC(gethostbyname, , |
---|
670 | # Some OSes (eg. Solaris) place it in libnsl: |
---|
671 | AC_LBL_CHECK_LIB(nsl, gethostbyname, , |
---|
672 | # Some strange OSes (SINIX) have it in libsocket: |
---|
673 | AC_LBL_CHECK_LIB(socket, gethostbyname, , |
---|
674 | # Unfortunately libsocket sometimes depends on libnsl. |
---|
675 | # AC_CHECK_LIB's API is essentially broken so the |
---|
676 | # following ugliness is necessary: |
---|
677 | AC_LBL_CHECK_LIB(socket, gethostbyname, |
---|
678 | LIBS="-lsocket -lnsl $LIBS", |
---|
679 | AC_CHECK_LIB(resolv, gethostbyname), |
---|
680 | -lnsl)))) |
---|
681 | AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, , |
---|
682 | AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , |
---|
683 | -lnsl))) |
---|
684 | # DLPI needs putmsg under HPUX so test for -lstr while we're at it |
---|
685 | AC_CHECK_LIB(str, putmsg) |
---|
686 | ]) |
---|