10 dnl Look for function in any of the specified libraries
13 dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments)
14 AC_DEFUN(AC_FIND_FUNC_NO_LIBS, [
16 AC_MSG_CHECKING([for $1])
17 AC_CACHE_VAL(ac_cv_funclib_$1,
19 if eval "test \"\$ac_cv_func_$1\" != yes" ; then
21 for ac_lib in "" $2; do
22 if test -n "$ac_lib"; then
24 LIBS="$ac_lib $ac_save_LIBS"
26 AC_TRY_LINK([$3],[$1($4)],eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break)
28 eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}"
33 eval "ac_res=\$ac_cv_funclib_$1"
35 # autoheader tricks *sigh*
37 @@@funcs="$funcs $1"@@@
42 eval "ac_tr_func=HAVE_`echo $1 | tr '[a-z]' '[A-Z]'`"
43 eval "ac_tr_lib=HAVE_LIB`echo $ac_res | sed -e 's/-l//' | tr '[a-z]' '[A-Z]'`"
49 eval "ac_cv_func_$1=yes"
51 AC_DEFINE_UNQUOTED($ac_tr_func)
55 eval "ac_cv_func_$1=no"
60 eval "ac_cv_func_$1=yes"
61 eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
62 AC_DEFINE_UNQUOTED($ac_tr_func)
63 AC_DEFINE_UNQUOTED($ac_tr_lib)
64 AC_MSG_RESULT([yes, in $ac_res])
70 dnl AC_FIND_FUNC(func, libraries, includes, arguments)
71 AC_DEFUN(AC_FIND_FUNC, [
72 AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4])
73 if test -n "$LIB_$1"; then
82 dnl undefine(AC_REPLACE_FUNCS)
83 dnl define(AC_BROKEN,AC_REPLACE_FUNCS)
86 dnl Same as AC _REPLACE_FUNCS, just define HAVE_func if found in normal
92 AC_CHECK_FUNC($ac_func, [
94 ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'`
96 AC_DEFINE_UNQUOTED($ac_tr_func)],[LIBOBJS[]="$LIBOBJS ${ac_func}.o"])
97 # autoheader tricks *sigh*
99 @@@funcs="$funcs $1"@@@
106 dnl Mix between AC_FIND_FUNC and AC_BROKEN
109 AC_DEFUN(AC_FIND_IF_NOT_BROKEN,
110 [AC_FIND_FUNC([$1], [$2], [$3], [$4])
111 if eval "test \"$ac_cv_func_$1\" != yes"; then
112 LIBOBJS[]="$LIBOBJS $1.o"
121 dnl AC_TEST_PACKAGE(package,header,lib,linkline)
122 AC_DEFUN(AC_TEST_PACKAGE,
124 AC_MSG_CHECKING(for $1)
126 [ --with-$1=dir use $1 in dir],
127 [if test "$with_$1" = "no"; then
132 [ --with-$1-lib=dir use $1-lib in dir],
133 [if test "$withval" = "yes" -o "$withval" = "no"; then
134 AC_MSG_ERROR([No argument for --with-$1-lib])
135 elif test "X$with_$1" = "X"; then
139 AC_ARG_WITH($1-include,
140 [ --with-$1-include=dir use $1-include in dir],
141 [if test "$withval" = "yes" -o "$withval" = "no"; then
142 AC_MSG_ERROR([No argument for --with-$1-include])
143 elif test "X$with_$1" = "X"; then
148 define([foo], translit($1, [a-z], [A-Z]))
150 @@@syms="$syms foo"@@@
153 if test -n "$with_$1"; then
155 if test "$with_$1" != "yes"; then
158 dnl Try to find include
159 if test -n "$with_$1_include"; then
160 trydir=$with_$1_include
161 elif test "$with_$1" != "yes"; then
162 trydir="$with_$1 $with_$1/include"
167 for i in $trydir ""; do
168 if test -n "$i"; then
169 if test -f $i/$2; then
170 found=yes; res=$i; break
173 AC_TRY_CPP([#include <$2>], [found=yes; res=$i; break])
176 if test -n "$found"; then
179 AC_MSG_ERROR(Cannot find $2)
182 if test -n "$with_$1_lib"; then
184 elif test "$with_$1" != "yes"; then
185 trydir="$with_$1 $with_$1/lib"
190 for i in $trydir ""; do
191 if test -n "$i"; then
192 if test -f $i/$3; then
193 found=yes; res=$i; break
198 AC_TRY_LINK([], [], [found=yes; res=$i; LIBS=$old_LIBS; break])
202 if test -n "$found"; then
205 AC_MSG_ERROR(Cannot find $3)
207 AC_MSG_RESULT([headers $$1_include, libraries $$1_lib])
208 AC_DEFINE_UNQUOTED(foo)
209 if test -n "$$1_include"; then
210 foo[INCLUDE]="-I$$1_include"
212 AC_SUBST(foo[INCLUDE])
213 if test -n "$$1_lib"; then
216 foo[LIB]="$foo[LIB] $4"
225 dnl Check if we need the declaration of a variable
228 AC_DEFUN(AC_NEED_DECLARATION, [
229 AC_MSG_CHECKING([if $3 needs a declaration])
230 AC_CACHE_VAL(ac_cv_var_$3_declaration, [
233 eval "ac_cv_var_$3_declaration=no",
234 eval "ac_cv_var_$3_declaration=yes")
238 eval "ac_tr_var=NEED_`echo $3 | tr '[a-z]' '[A-Z]'`_DECLARATION"
241 define([foo], [NEED_]translit($3, [a-z], [A-Z])[_DECLARATION])
243 @@@syms="$syms foo"@@@
247 AC_MSG_RESULT($ac_cv_var_$3_declaration)
248 if eval "test \"\$ac_cv_var_$3_declaration\" = yes"; then
249 AC_DEFINE_UNQUOTED($ac_tr_var)
257 dnl AC_CHECK_VAR(includes, variable)
258 AC_DEFUN(AC_CHECK_VAR, [
259 AC_MSG_CHECKING(for $2)
260 AC_CACHE_VAL(ac_cv_var_$2, [
261 AC_TRY_LINK([extern int $2;
262 int foo() { return $2; }],
264 ac_cv_var_$2=yes, ac_cv_var_$2=no)
266 eval "ac_tr_var=[HAVE_]translit($2,[a-z],[A-Z])"
268 define([foo], [HAVE_]translit($2, [a-z], [A-Z]))
270 @@@syms="$syms foo"@@@
274 AC_MSG_RESULT(`eval echo \\$ac_cv_var_$2`)
275 if test `eval echo \\$ac_cv_var_$2` = yes; then
276 AC_DEFINE_UNQUOTED($ac_tr_var)
277 AC_CHECK_DECLARATION([$1],[$2])
282 dnl Check if we need the prototype for a function
285 dnl AC_NEED_PROTO(includes, function)
287 AC_DEFUN(AC_NEED_PROTO, [
288 AC_CACHE_CHECK([if $2 needs a prototype], ac_cv_func_$2_noproto,
290 [struct foo { int foo; } xx;
291 extern int $2 (struct foo*);
294 eval "ac_cv_func_$2_noproto=yes",
295 eval "ac_cv_func_$2_noproto=no"))
296 define([foo], [NEED_]translit($2, [a-z], [A-Z])[_PROTO])
297 if test "$ac_cv_func_$2_noproto" = yes; then
301 @@@syms="$syms foo"@@@
307 dnl Check if the prototype of a function is compatible with another one
310 dnl AC_PROTO_COMPAT(includes, function, prototype)
312 AC_DEFUN(AC_PROTO_COMPAT, [
313 AC_CACHE_CHECK([if $2 is compatible with system prototype],
314 ac_cv_func_$2_proto_compat,
317 eval "ac_cv_func_$2_proto_compat=yes",
318 eval "ac_cv_func_$2_proto_compat=no"))
319 define([foo], translit($2, [a-z], [A-Z])[_PROTO_COMPATIBLE])
320 if test "$ac_cv_func_$2_proto_compat" = yes; then
324 @@@syms="$syms foo"@@@
330 dnl Check if a particular struct has a particular field
333 dnl AC_HAVE_STRUCT_FIELD(includes, struct, type, field)
334 AC_DEFUN(AC_HAVE_STRUCT_FIELD, [
335 AC_MSG_CHECKING([if $2 has a field $4])
336 AC_CACHE_VAL(ac_cv_struct_$2_$4, [
338 [struct $2 foo; $3 bar = foo.$4; ],
339 eval "ac_cv_struct_$2_$4=yes",
340 eval "ac_cv_struct_$2_$4=no")
343 eval "ac_tr_var=HAVE_STRUCT_`echo $2 | tr '[a-z]' '[A-Z]'`_`echo $4 | tr '[a-z]' '[A-Z]'`"
346 define([foo], [[HAVE_STRUCT_]translit($2, [a-z], [A-Z])[_]translit($4, [a-z], [A-Z])])
348 @@@syms="$syms foo"@@@
352 AC_MSG_RESULT($ac_cv_struct_$2_$4)
353 if eval "test \"\$ac_cv_struct_$2_$4\" = yes"; then
354 AC_DEFINE_UNQUOTED($ac_tr_var)
359 dnl Check if we need the declaration of a variable
362 dnl AC_HAVE_DECLARATION(includes, variable)
363 AC_DEFUN(AC_CHECK_DECLARATION, [
364 AC_MSG_CHECKING([if $2 is properly declared])
365 AC_CACHE_VAL(ac_cv_var_$2_declaration, [
367 extern struct { int foo; } $2;],
369 eval "ac_cv_var_$2_declaration=no",
370 eval "ac_cv_var_$2_declaration=yes")
373 ac_tr_var=[HAVE_]translit($2, [a-z], [A-Z])[_DECLARATION]
375 define([foo], [HAVE_]translit($2, [a-z], [A-Z])[_DECLARATION])
377 @@@syms="$syms foo"@@@
381 AC_MSG_RESULT($ac_cv_var_$2_declaration)
382 if eval "test \"\$ac_cv_var_$2_declaration\" = yes"; then
383 AC_DEFINE_UNQUOTED($ac_tr_var)
392 dnl We prefer byacc or yacc because they do not use `alloca'
395 AC_DEFUN(AC_KRB_PROG_YACC,
396 [AC_CHECK_PROGS(YACC, byacc yacc 'bison -y')])
399 dnl NEXTSTEP is not posix compliant by default,
400 dnl you need a switch -posix to the compiler
403 AC_DEFUN(AC_KRB_SYS_NEXTSTEP, [
404 AC_MSG_CHECKING(for NEXTSTEP)
405 AC_CACHE_VAL(krb_cv_sys_nextstep,
410 ], krb_cv_sys_nextstep=yes, krb_cv_sys_nextstep=no) )
411 if test "$krb_cv_sys_nextstep" = "yes"; then
412 CFLAGS="$CFLAGS -posix"
415 AC_MSG_RESULT($krb_cv_sys_nextstep)
419 dnl AIX have a very different syscall convention
421 AC_DEFUN(AC_KRB_SYS_AIX, [
422 AC_MSG_CHECKING(for AIX)
423 AC_CACHE_VAL(krb_cv_sys_aix,
428 ], krb_cv_sys_aix=yes, krb_cv_sys_aix=no) )
429 AC_MSG_RESULT($krb_cv_sys_aix)
433 dnl test for broken getcwd in (SunOS braindamage)
436 AC_DEFUN(AC_KRB_FUNC_GETCWD_BROKEN, [
437 if test "$ac_cv_func_getcwd" = yes; then
438 AC_MSG_CHECKING(if getcwd is broken)
439 AC_CACHE_VAL(ac_cv_func_getcwd_broken, [
440 ac_cv_func_getcwd_broken=no
444 char *getcwd(char*, int);
446 void *popen(char *cmd, char *mode)
455 ret = getcwd(0, 1024);
456 if(ret == 0 && errno == ENOTTY)
460 ], ac_cv_func_getcwd_broken=yes,:,:)
462 if test "$ac_cv_func_getcwd_broken" = yes; then
463 AC_DEFINE(BROKEN_GETCWD, 1)dnl
464 LIBOBJS="$LIBOBJS getcwd.o"
466 AC_MSG_RESULT($ac_cv_func_getcwd_broken)
468 AC_MSG_RESULT([seems ok])
474 AC_DEFUN(AC_HAVE_PRAGMA_WEAK, [
475 if test "${with_shared}" = "yes"; then
476 AC_MSG_CHECKING(for pragma weak)
477 AC_CACHE_VAL(ac_have_pragma_weak, [
478 ac_have_pragma_weak=no
479 cat > conftest_foo.$ac_ext <<'EOF'
480 [#]line __oline__ "configure"
481 #include "confdefs.h"
482 #pragma weak foo = _foo
485 cat > conftest_bar.$ac_ext <<'EOF'
486 [#]line __oline__ "configure"
487 #include "confdefs.h"
498 if AC_TRY_EVAL('CC $CFLAGS $CPPFLAGS $LDFLAGS conftest_foo.$ac_ext conftest_bar.$ac_ext -o conftest'); then
499 ac_have_pragma_weak=yes
502 if test "$ac_have_pragma_weak" = "yes"; then
503 AC_DEFINE(HAVE_PRAGMA_WEAK, 1)dnl
505 AC_MSG_RESULT($ac_have_pragma_weak)
510 AC_DEFUN(AC_GROK_TYPE, [
511 AC_CACHE_VAL(ac_cv_type_$1,
513 #include "confdefs.h"
514 #ifdef HAVE_SYS_TYPES_H
515 #include <sys/types.h>
517 #ifdef HAVE_SYS_BITYPES_H
518 #include <sys/bitypes.h>
523 eval ac_cv_type_$1=yes,
524 eval ac_cv_type_$1=no))])
527 AC_DEFUN(AC_GROK_TYPES, [
529 AC_MSG_CHECKING(for $i)
531 eval ac_res=\$ac_cv_type_$i
532 if test "$ac_res" = yes; then
533 type=HAVE_`echo $i | tr '[a-z]' '[A-Z]'`
534 AC_DEFINE_UNQUOTED($type)
536 AC_MSG_RESULT($ac_res)
541 dnl Search for struct winsize
544 AC_DEFUN(AC_KRB_STRUCT_WINSIZE, [
545 AC_MSG_CHECKING(for struct winsize)
546 AC_CACHE_VAL(ac_cv_struct_winsize, [
547 ac_cv_struct_winsize=no
548 for i in sys/termios.h sys/ioctl.h; do
551 struct[ ]*winsize,dnl
553 $i, ac_cv_struct_winsize=yes; break)dnl
556 if test "$ac_cv_struct_winsize" = "yes"; then
557 AC_DEFINE(HAVE_STRUCT_WINSIZE, 1)dnl
559 AC_MSG_RESULT($ac_cv_struct_winsize)
560 AC_EGREP_HEADER(ws_xpixel, termios.h, AC_DEFINE(HAVE_WS_XPIXEL))
561 AC_EGREP_HEADER(ws_ypixel, termios.h, AC_DEFINE(HAVE_WS_YPIXEL))
565 dnl Check for sa_len in sys/socket.h
568 AC_DEFUN(AC_KRB_STRUCT_SOCKADDR_SA_LEN, [
569 AC_MSG_CHECKING(for sa_len in struct sockaddr)
570 AC_CACHE_VAL(ac_cv_struct_sockaddr_sa_len, [
572 [#include <sys/types.h>
573 #include <sys/socket.h>],
575 int foo = sa.sa_len;],
576 ac_cv_struct_sockaddr_sa_len=yes,
577 ac_cv_struct_sockaddr_sa_len=no)
579 if test "$ac_cv_struct_sockaddr_sa_len" = yes; then
580 AC_DEFINE(SOCKADDR_HAS_SA_LEN)dnl
582 AC_MSG_RESULT($ac_cv_struct_sockaddr_sa_len)
586 dnl Better test for ln -s, ln or cp
589 AC_DEFUN(AC_KRB_PROG_LN_S,
590 [AC_MSG_CHECKING(for ln -s or something else)
591 AC_CACHE_VAL(ac_cv_prog_LN_S,
593 if ln -s X conftestdata 2>/dev/null
596 ac_cv_prog_LN_S="ln -s"
599 if ln conftestdata1 conftestdata2; then
606 LN_S="$ac_cv_prog_LN_S"
607 AC_MSG_RESULT($ac_cv_prog_LN_S)
611 dnl test for sig_atomic_t
613 AC_DEFUN(AC_TYPE_SIG_ATOMIC_T,
614 [AC_MSG_CHECKING(for sig_atomic_t)
615 AC_CACHE_VAL(ac_cv_type_sig_atomic_t,
617 [#include <signal.h>],
618 [sig_atomic_t foo = 1;],
619 ac_cv_type_sig_atomic_t=yes,
620 ac_cv_type_sig_atomic_t=no))
621 if test "$ac_cv_type_sig_atomic_t" = no; then
622 AC_DEFINE(sig_atomic_t, int)dnl
624 AC_MSG_RESULT($ac_cv_type_sig_atomic_t)
629 AC_DEFUN(AC_TYPE_MODE_T,
630 [AC_MSG_CHECKING(for mode_t)
631 AC_CACHE_VAL(ac_cv_type_mode_t,
633 [#include <sys/types.h>],
635 ac_cv_type_mode_t=yes,
636 ac_cv_type_mode_t=no))
637 if test "$ac_cv_type_mode_t" = no; then
638 AC_DEFINE(mode_t, unsigned short)dnl
640 AC_MSG_RESULT($ac_cv_type_mode_t)
643 AC_DEFUN(AC_BROKEN_SNPRINTF, [
644 AC_CACHE_CHECK(for working snprintf,ac_cv_func_snprintf_working,
645 ac_cv_func_snprintf_working=yes
654 snprintf(foo, 2, "12");
655 return strcmp(foo, "1");
656 }],:,ac_cv_func_snprintf_working=no,:))
658 @@@funcs="$funcs snprintf"@@@
660 if test "$ac_cv_func_snprintf_working" = yes; then
662 AC_DEFINE_UNQUOTED($foo)
666 AC_DEFUN(AC_BROKEN_VSNPRINTF,[
667 AC_CACHE_CHECK(for working vsnprintf,ac_cv_func_vsnprintf_working,
668 ac_cv_func_vsnprintf_working=yes
674 int foo(int num, ...)
681 vsnprintf(bar, 2, "%s", arg);
683 return strcmp(bar, "1");
690 }],:,ac_cv_func_vsnprintf_working=no,:))
692 @@@funcs="$funcs vsnprintf"@@@
694 if test "$ac_cv_func_vsnprintf_working" = yes; then
696 AC_DEFINE_UNQUOTED($foo)
700 AC_DEFUN(AC_KRB_IPV6, [
701 AC_MSG_CHECKING(for IPv6)
703 AC_EGREP_HEADER(sockaddr_in6, netinet/in.h,
704 AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6) foo=yes)
705 AC_EGREP_HEADER(sockaddr_in6, netinet/in6.h,
706 AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6) foo=yes)