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"@@@
306 dnl AC_HAVE_STRUCT_FIELD(includes, struct, type, field)
307 AC_DEFUN(AC_HAVE_STRUCT_FIELD, [
308 AC_MSG_CHECKING([if $2 has a field $4])
309 AC_CACHE_VAL(ac_cv_struct_$2_$4, [
311 [struct $2 foo; $3 bar = foo.$4; ],
312 eval "ac_cv_struct_$2_$4=yes",
313 eval "ac_cv_struct_$2_$4=no")
316 eval "ac_tr_var=HAVE_STRUCT_`echo $2 | tr '[a-z]' '[A-Z]'`_`echo $4 | tr '[a-z]' '[A-Z]'`"
319 define([foo], [[HAVE_STRUCT_]translit($2, [a-z], [A-Z])[_]translit($4, [a-z], [A-Z])])
321 @@@syms="$syms foo"@@@
325 AC_MSG_RESULT($ac_cv_struct_$2_$4)
326 if eval "test \"\$ac_cv_struct_$2_$4\" = yes"; then
327 AC_DEFINE_UNQUOTED($ac_tr_var)
332 dnl Check if we need the declaration of a variable
335 dnl AC_HAVE_DECLARATION(includes, variable)
336 AC_DEFUN(AC_CHECK_DECLARATION, [
337 AC_MSG_CHECKING([if $2 is properly declared])
338 AC_CACHE_VAL(ac_cv_var_$2_declaration, [
340 extern struct { int foo; } $2;],
342 eval "ac_cv_var_$2_declaration=no",
343 eval "ac_cv_var_$2_declaration=yes")
346 ac_tr_var=[HAVE_]translit($2, [a-z], [A-Z])[_DECLARATION]
348 define([foo], [HAVE_]translit($2, [a-z], [A-Z])[_DECLARATION])
350 @@@syms="$syms foo"@@@
354 AC_MSG_RESULT($ac_cv_var_$2_declaration)
355 if eval "test \"\$ac_cv_var_$2_declaration\" = yes"; then
356 AC_DEFINE_UNQUOTED($ac_tr_var)
365 dnl We prefer byacc or yacc because they do not use `alloca'
368 AC_DEFUN(AC_KRB_PROG_YACC,
369 [AC_CHECK_PROGS(YACC, byacc yacc 'bison -y')])
372 dnl NEXTSTEP is not posix compliant by default,
373 dnl you need a switch -posix to the compiler
376 AC_DEFUN(AC_KRB_SYS_NEXTSTEP, [
377 AC_MSG_CHECKING(for NEXTSTEP)
378 AC_CACHE_VAL(krb_cv_sys_nextstep,
383 ], krb_cv_sys_nextstep=yes, krb_cv_sys_nextstep=no) )
384 if test "$krb_cv_sys_nextstep" = "yes"; then
385 CFLAGS="$CFLAGS -posix"
388 AC_MSG_RESULT($krb_cv_sys_nextstep)
392 dnl AIX have a very different syscall convention
394 AC_DEFUN(AC_KRB_SYS_AIX, [
395 AC_MSG_CHECKING(for AIX)
396 AC_CACHE_VAL(krb_cv_sys_aix,
401 ], krb_cv_sys_aix=yes, krb_cv_sys_aix=no) )
402 AC_MSG_RESULT($krb_cv_sys_aix)
406 dnl test for broken getcwd in (SunOS braindamage)
409 AC_DEFUN(AC_KRB_FUNC_GETCWD_BROKEN, [
410 if test "$ac_cv_func_getcwd" = yes; then
411 AC_MSG_CHECKING(if getcwd is broken)
412 AC_CACHE_VAL(ac_cv_func_getcwd_broken, [
413 ac_cv_func_getcwd_broken=no
417 char *getcwd(char*, int);
419 void *popen(char *cmd, char *mode)
428 ret = getcwd(0, 1024);
429 if(ret == 0 && errno == ENOTTY)
433 ], ac_cv_func_getcwd_broken=yes,:,:)
435 if test "$ac_cv_func_getcwd_broken" = yes; then
436 AC_DEFINE(BROKEN_GETCWD, 1)dnl
437 LIBOBJS="$LIBOBJS getcwd.o"
439 AC_MSG_RESULT($ac_cv_func_getcwd_broken)
441 AC_MSG_RESULT([seems ok])
447 AC_DEFUN(AC_HAVE_PRAGMA_WEAK, [
448 if test "${with_shared}" = "yes"; then
449 AC_MSG_CHECKING(for pragma weak)
450 AC_CACHE_VAL(ac_have_pragma_weak, [
451 ac_have_pragma_weak=no
452 cat > conftest_foo.$ac_ext <<'EOF'
453 [#]line __oline__ "configure"
454 #include "confdefs.h"
455 #pragma weak foo = _foo
458 cat > conftest_bar.$ac_ext <<'EOF'
459 [#]line __oline__ "configure"
460 #include "confdefs.h"
471 if AC_TRY_EVAL('CC $CFLAGS $CPPFLAGS $LDFLAGS conftest_foo.$ac_ext conftest_bar.$ac_ext -o conftest'); then
472 ac_have_pragma_weak=yes
475 if test "$ac_have_pragma_weak" = "yes"; then
476 AC_DEFINE(HAVE_PRAGMA_WEAK, 1)dnl
478 AC_MSG_RESULT($ac_have_pragma_weak)
483 AC_DEFUN(AC_GROK_TYPE, [
484 AC_CACHE_VAL(ac_cv_type_$1,
486 #include "confdefs.h"
487 #ifdef HAVE_SYS_TYPES_H
488 #include <sys/types.h>
490 #ifdef HAVE_SYS_BITYPES_H
491 #include <sys/bitypes.h>
496 eval ac_cv_type_$1=yes,
497 eval ac_cv_type_$1=no))])
500 AC_DEFUN(AC_GROK_TYPES, [
502 AC_MSG_CHECKING(for $i)
504 eval ac_res=\$ac_cv_type_$i
505 if test "$ac_res" = yes; then
506 type=HAVE_`echo $i | tr '[a-z]' '[A-Z]'`
507 AC_DEFINE_UNQUOTED($type)
509 AC_MSG_RESULT($ac_res)
514 dnl Search for struct winsize
517 AC_DEFUN(AC_KRB_STRUCT_WINSIZE, [
518 AC_MSG_CHECKING(for struct winsize)
519 AC_CACHE_VAL(ac_cv_struct_winsize, [
520 ac_cv_struct_winsize=no
521 for i in sys/termios.h sys/ioctl.h; do
524 struct[ ]*winsize,dnl
526 $i, ac_cv_struct_winsize=yes; break)dnl
529 if test "$ac_cv_struct_winsize" = "yes"; then
530 AC_DEFINE(HAVE_STRUCT_WINSIZE, 1)dnl
532 AC_MSG_RESULT($ac_cv_struct_winsize)
533 AC_EGREP_HEADER(ws_xpixel, termios.h, AC_DEFINE(HAVE_WS_XPIXEL))
534 AC_EGREP_HEADER(ws_ypixel, termios.h, AC_DEFINE(HAVE_WS_YPIXEL))
538 dnl Check for sa_len in sys/socket.h
541 AC_DEFUN(AC_KRB_STRUCT_SOCKADDR_SA_LEN, [
542 AC_MSG_CHECKING(for sa_len in struct sockaddr)
543 AC_CACHE_VAL(ac_cv_struct_sockaddr_sa_len, [
545 [#include <sys/types.h>
546 #include <sys/socket.h>],
548 int foo = sa.sa_len;],
549 ac_cv_struct_sockaddr_sa_len=yes,
550 ac_cv_struct_sockaddr_sa_len=no)
552 if test "$ac_cv_struct_sockaddr_sa_len" = yes; then
553 AC_DEFINE(SOCKADDR_HAS_SA_LEN)dnl
555 AC_MSG_RESULT($ac_cv_struct_sockaddr_sa_len)
559 dnl Better test for ln -s, ln or cp
562 AC_DEFUN(AC_KRB_PROG_LN_S,
563 [AC_MSG_CHECKING(for ln -s or something else)
564 AC_CACHE_VAL(ac_cv_prog_LN_S,
566 if ln -s X conftestdata 2>/dev/null
569 ac_cv_prog_LN_S="ln -s"
572 if ln conftestdata1 conftestdata2; then
579 LN_S="$ac_cv_prog_LN_S"
580 AC_MSG_RESULT($ac_cv_prog_LN_S)
584 dnl test for sig_atomic_t
586 AC_DEFUN(AC_TYPE_SIG_ATOMIC_T,
587 [AC_MSG_CHECKING(for sig_atomic_t)
588 AC_CACHE_VAL(ac_cv_type_sig_atomic_t,
590 [#include <signal.h>],
591 [sig_atomic_t foo = 1;],
592 ac_cv_type_sig_atomic_t=yes,
593 ac_cv_type_sig_atomic_t=no))
594 if test "$ac_cv_type_sig_atomic_t" = no; then
595 AC_DEFINE(sig_atomic_t, int)dnl
597 AC_MSG_RESULT($ac_cv_type_sig_atomic_t)
602 AC_DEFUN(AC_TYPE_MODE_T,
603 [AC_MSG_CHECKING(for mode_t)
604 AC_CACHE_VAL(ac_cv_type_mode_t,
606 [#include <sys/types.h>],
608 ac_cv_type_mode_t=yes,
609 ac_cv_type_mode_t=no))
610 if test "$ac_cv_type_mode_t" = no; then
611 AC_DEFINE(mode_t, unsigned short)dnl
613 AC_MSG_RESULT($ac_cv_type_mode_t)
616 AC_DEFUN(AC_BROKEN_SNPRINTF, [
617 AC_CACHE_CHECK(for working snprintf,ac_cv_func_snprintf_working,
618 ac_cv_func_snprintf_working=yes
627 snprintf(foo, 2, "12");
628 return strcmp(foo, "1");
629 }],:,ac_cv_func_snprintf_working=no,:))
631 @@@funcs="$funcs snprintf"@@@
633 if test "$ac_cv_func_snprintf_working" = yes; then
635 AC_DEFINE_UNQUOTED($foo)
639 AC_DEFUN(AC_BROKEN_VSNPRINTF,[
640 AC_CACHE_CHECK(for working vsnprintf,ac_cv_func_vsnprintf_working,
641 ac_cv_func_vsnprintf_working=yes
647 int foo(int num, ...)
654 vsnprintf(bar, 2, "%s", arg);
656 return strcmp(bar, "1");
663 }],:,ac_cv_func_vsnprintf_working=no,:))
665 @@@funcs="$funcs vsnprintf"@@@
667 if test "$ac_cv_func_vsnprintf_working" = yes; then
669 AC_DEFINE_UNQUOTED($foo)