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