xref: /freebsd/crypto/krb5/src/aclocal.m4 (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertAC_PREREQ(2.63)
2*7f2fe78bSCy SchubertAC_COPYRIGHT([Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
3*7f2fe78bSCy SchubertMassachusetts Institute of Technology.
4*7f2fe78bSCy Schubert])
5*7f2fe78bSCy Schubertdnl
6*7f2fe78bSCy Schubertdefine([K5_TOPDIR],[.])dnl
7*7f2fe78bSCy Schubertdnl
8*7f2fe78bSCy SchubertAC_DEFUN(V5_SET_TOPDIR,[dnl
9*7f2fe78bSCy Schubertac_reltopdir="K5_TOPDIR"
10*7f2fe78bSCy Schubertif test ! -r "$srcdir/K5_TOPDIR/aclocal.m4"; then
11*7f2fe78bSCy Schubert  AC_MSG_ERROR([Configure could not determine the relative topdir])
12*7f2fe78bSCy Schubertfi
13*7f2fe78bSCy Schubertac_topdir=$srcdir/$ac_reltopdir
14*7f2fe78bSCy Schubertac_config_fragdir=$ac_reltopdir/config
15*7f2fe78bSCy Schubert# echo "Looking for $srcdir/$ac_config_fragdir"
16*7f2fe78bSCy SchubertAC_CONFIG_AUX_DIR(K5_TOPDIR/config)
17*7f2fe78bSCy Schubert])dnl
18*7f2fe78bSCy Schubertdnl
19*7f2fe78bSCy Schubertdnl Version info.
20*7f2fe78bSCy Schubertdnl
21*7f2fe78bSCy Schubertpushdef([x],esyscmd([sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < ]K5_TOPDIR/patchlevel.h))
22*7f2fe78bSCy Schubertdefine([PL_KRB5_MAJOR_RELEASE],regexp(x,[KRB5_MAJOR_RELEASE=\(.*\)],[\1]))
23*7f2fe78bSCy Schubertifelse(PL_KRB5_MAJOR_RELEASE,,[errprint([Can't determine KRB5_MAJOR_RELEASE value from patchlevel.h.
24*7f2fe78bSCy Schubert]) m4exit(1) dnl sometimes that does not work?
25*7f2fe78bSCy Schubertbuiltin(m4exit,1)])
26*7f2fe78bSCy Schubertdefine([PL_KRB5_MINOR_RELEASE],regexp(x,[KRB5_MINOR_RELEASE=\(.*\)],[\1]))
27*7f2fe78bSCy Schubertifelse(PL_KRB5_MINOR_RELEASE,,[errprint([Can't determine KRB5_MINOR_RELEASE value from patchlevel.h.
28*7f2fe78bSCy Schubert]) m4exit(1) dnl sometimes that does not work?
29*7f2fe78bSCy Schubertbuiltin(m4exit,1)])
30*7f2fe78bSCy Schubertdefine([PL_KRB5_PATCHLEVEL],regexp(x,[KRB5_PATCHLEVEL=\(.*\)],[\1]))
31*7f2fe78bSCy Schubertifelse(PL_KRB5_PATCHLEVEL,,[errprint([Can't determine KRB5_PATCHLEVEL value from patchlevel.h.
32*7f2fe78bSCy Schubert]) m4exit(1) dnl sometimes that does not work?
33*7f2fe78bSCy Schubertbuiltin(m4exit,1)])
34*7f2fe78bSCy Schubertdefine([PL_KRB5_RELTAIL],regexp(x,[KRB5_RELTAIL="\(.*\)"],[\1]))
35*7f2fe78bSCy Schubertdnl RELTAIL is allowed to not be defined.
36*7f2fe78bSCy Schubertpopdef([x])
37*7f2fe78bSCy Schubertdefine([K5_VERSION],PL_KRB5_MAJOR_RELEASE.PL_KRB5_MINOR_RELEASE[]ifelse(PL_KRB5_PATCHLEVEL,0,,.PL_KRB5_PATCHLEVEL)ifelse(PL_KRB5_RELTAIL,,,-PL_KRB5_RELTAIL))
38*7f2fe78bSCy Schubertdefine([K5_BUGADDR],krb5-bugs@mit.edu)
39*7f2fe78bSCy Schubertdefine([K5_AC_INIT],[AC_INIT(Kerberos 5, K5_VERSION, K5_BUGADDR, krb5)
40*7f2fe78bSCy SchubertAC_CONFIG_SRCDIR($1)
41*7f2fe78bSCy Schubertbuild_dynobj=no])
42*7f2fe78bSCy Schubertdnl
43*7f2fe78bSCy Schubertdnl drop in standard rules for all configure files -- CONFIG_RULES
44*7f2fe78bSCy Schubertdnl
45*7f2fe78bSCy SchubertAC_DEFUN(CONFIG_RULES,[dnl
46*7f2fe78bSCy SchubertAC_REQUIRE([V5_SET_TOPDIR]) dnl
47*7f2fe78bSCy SchubertEXTRA_FILES=""
48*7f2fe78bSCy SchubertAC_SUBST(EXTRA_FILES)
49*7f2fe78bSCy Schubertdnl Consider using AC_USE_SYSTEM_EXTENSIONS when we require autoconf
50*7f2fe78bSCy Schubertdnl 2.59c or later, but be sure to test on Solaris first.
51*7f2fe78bSCy SchubertAC_DEFINE([_GNU_SOURCE], 1, [Define to enable extensions in glibc])
52*7f2fe78bSCy SchubertAC_DEFINE([__STDC_WANT_LIB_EXT1__], 1, [Define to enable C11 extensions])
53*7f2fe78bSCy Schubert
54*7f2fe78bSCy SchubertWITH_CC dnl
55*7f2fe78bSCy SchubertAC_REQUIRE_CPP
56*7f2fe78bSCy Schubertif test -z "$LD" ; then LD=$CC; fi
57*7f2fe78bSCy SchubertAC_ARG_VAR(LD,[linker command [CC]])
58*7f2fe78bSCy SchubertAC_SUBST(LDFLAGS) dnl
59*7f2fe78bSCy SchubertKRB5_AC_CHOOSE_ET dnl
60*7f2fe78bSCy SchubertKRB5_AC_CHOOSE_SS dnl
61*7f2fe78bSCy SchubertKRB5_AC_CHOOSE_DB dnl
62*7f2fe78bSCy Schubertdnl allow stuff in tree to access deprecated stuff for now
63*7f2fe78bSCy Schubertdnl AC_DEFINE([KRB5_DEPRECATED], 1, [Define only if building in-tree])
64*7f2fe78bSCy SchubertAC_C_CONST dnl
65*7f2fe78bSCy SchubertWITH_NETLIB dnl
66*7f2fe78bSCy SchubertWITH_HESIOD dnl
67*7f2fe78bSCy SchubertKRB5_AC_MAINTAINER_MODE dnl
68*7f2fe78bSCy SchubertAC_ARG_PROGRAM dnl
69*7f2fe78bSCy Schubertdnl
70*7f2fe78bSCy Schubertdnl This identifies the top of the source tree relative to the directory
71*7f2fe78bSCy Schubertdnl in which the configure file lives.
72*7f2fe78bSCy Schubertdnl
73*7f2fe78bSCy SchubertCONFIG_RELTOPDIR=$ac_reltopdir
74*7f2fe78bSCy SchubertAC_SUBST(CONFIG_RELTOPDIR)
75*7f2fe78bSCy Schubertlib_frag=$srcdir/$ac_config_fragdir/lib.in
76*7f2fe78bSCy SchubertAC_SUBST_FILE(lib_frag)
77*7f2fe78bSCy Schubertlibobj_frag=$srcdir/$ac_config_fragdir/libobj.in
78*7f2fe78bSCy SchubertAC_SUBST_FILE(libobj_frag)
79*7f2fe78bSCy Schubertlibnover_frag=$srcdir/$ac_config_fragdir/libnover.in
80*7f2fe78bSCy SchubertAC_SUBST_FILE(libnover_frag)
81*7f2fe78bSCy Schubertlibpriv_frag=$srcdir/$ac_config_fragdir/libpriv.in
82*7f2fe78bSCy SchubertAC_SUBST_FILE(libpriv_frag)
83*7f2fe78bSCy Schubertlibnodeps_frag=$srcdir/$ac_config_fragdir/libnodeps.in
84*7f2fe78bSCy SchubertAC_SUBST_FILE(libnodeps_frag)
85*7f2fe78bSCy Schubertdnl
86*7f2fe78bSCy SchubertKRB5_AC_PRAGMA_WEAK_REF
87*7f2fe78bSCy SchubertWITH_LDAP
88*7f2fe78bSCy SchubertKRB5_LIB_PARAMS
89*7f2fe78bSCy SchubertKRB5_AC_INITFINI
90*7f2fe78bSCy SchubertKRB5_AC_ENABLE_THREADS
91*7f2fe78bSCy SchubertKRB5_AC_FIND_DLOPEN
92*7f2fe78bSCy Schubert])dnl
93*7f2fe78bSCy Schubert
94*7f2fe78bSCy Schubertdnl Maintainer mode, akin to what automake provides, 'cept we don't
95*7f2fe78bSCy Schubertdnl want to use automake right now.
96*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_MAINTAINER_MODE],
97*7f2fe78bSCy Schubert[AC_ARG_ENABLE([maintainer-mode],
98*7f2fe78bSCy Schubert  [AS_HELP_STRING([--enable-maintainer-mode],
99*7f2fe78bSCy Schubert    [enable rebuilding of source files, Makefiles, etc])],
100*7f2fe78bSCy Schubert  [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=no])
101*7f2fe78bSCy Schubertif test "$USE_MAINTAINER_MODE" = yes; then
102*7f2fe78bSCy Schubert  MAINTAINER_MODE_TRUE=
103*7f2fe78bSCy Schubert  MAINTAINER_MODE_FALSE='#'
104*7f2fe78bSCy Schubert  AC_MSG_NOTICE(enabling maintainer mode)
105*7f2fe78bSCy Schubertelse
106*7f2fe78bSCy Schubert  MAINTAINER_MODE_TRUE='#'
107*7f2fe78bSCy Schubert  MAINTAINER_MODE_FALSE=
108*7f2fe78bSCy Schubertfi
109*7f2fe78bSCy SchubertMAINT=$MAINTAINER_MODE_TRUE
110*7f2fe78bSCy SchubertAC_SUBST(MAINTAINER_MODE_TRUE)
111*7f2fe78bSCy SchubertAC_SUBST(MAINTAINER_MODE_FALSE)
112*7f2fe78bSCy SchubertAC_SUBST(MAINT)
113*7f2fe78bSCy Schubert])
114*7f2fe78bSCy Schubert
115*7f2fe78bSCy Schubertdnl
116*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_INITFINI],[
117*7f2fe78bSCy Schubertdnl Do we want initialization at load time?
118*7f2fe78bSCy SchubertAC_ARG_ENABLE([delayed-initialization],
119*7f2fe78bSCy Schubert  [AS_HELP_STRING([--disable-delayed-initialization],
120*7f2fe78bSCy Schubert    [initialize library code when loaded @<:@delay until first use@:>@])],
121*7f2fe78bSCy Schubert  [], [enable_delayed_initialization=yes])
122*7f2fe78bSCy Schubertcase "$enable_delayed_initialization" in
123*7f2fe78bSCy Schubert  yes)
124*7f2fe78bSCy Schubert    AC_DEFINE(DELAY_INITIALIZER,1,[Define if library initialization should be delayed until first use]) ;;
125*7f2fe78bSCy Schubert  no) ;;
126*7f2fe78bSCy Schubert  *)  AC_MSG_ERROR(invalid option $enable_delayed_initialization for delayed-initialization) ;;
127*7f2fe78bSCy Schubertesac
128*7f2fe78bSCy Schubertdnl We always want finalization at unload time.
129*7f2fe78bSCy Schubertdnl
130*7f2fe78bSCy Schubertdnl Can we do things through gcc?
131*7f2fe78bSCy SchubertKRB5_AC_GCC_ATTRS
132*7f2fe78bSCy Schubertdnl How about with the linker?
133*7f2fe78bSCy Schubertif test -z "$use_linker_init_option" ; then
134*7f2fe78bSCy Schubert  AC_MSG_ERROR(ran INITFINI before checking shlib.conf?)
135*7f2fe78bSCy Schubertfi
136*7f2fe78bSCy Schubertif test "$use_linker_init_option" = yes; then
137*7f2fe78bSCy Schubert  AC_DEFINE(USE_LINKER_INIT_OPTION,1,[Define if link-time options for library initialization will be used])
138*7f2fe78bSCy Schubertfi
139*7f2fe78bSCy Schubertif test "$use_linker_fini_option" = yes; then
140*7f2fe78bSCy Schubert  AC_DEFINE(USE_LINKER_FINI_OPTION,1,[Define if link-time options for library finalization will be used])
141*7f2fe78bSCy Schubertfi
142*7f2fe78bSCy Schubert])
143*7f2fe78bSCy Schubert
144*7f2fe78bSCy Schubertdnl find dlopen
145*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_FIND_DLOPEN],[
146*7f2fe78bSCy Schubertold_LIBS="$LIBS"
147*7f2fe78bSCy SchubertDL_LIB=
148*7f2fe78bSCy SchubertAC_SEARCH_LIBS(dlopen, dl, [
149*7f2fe78bSCy Schubertif test "$ac_cv_search_dlopen" != "none required"; then
150*7f2fe78bSCy Schubert  DL_LIB=$ac_cv_search_dlopen
151*7f2fe78bSCy Schubertfi
152*7f2fe78bSCy SchubertLIBS="$old_LIBS"
153*7f2fe78bSCy SchubertAC_DEFINE(USE_DLOPEN,1,[Define if dlopen should be used])])
154*7f2fe78bSCy SchubertAC_SUBST(DL_LIB)
155*7f2fe78bSCy Schubert])
156*7f2fe78bSCy Schubert
157*7f2fe78bSCy Schubert
158*7f2fe78bSCy Schubertdnl Hack for now.
159*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_ENABLE_THREADS],[
160*7f2fe78bSCy SchubertAC_ARG_ENABLE([thread-support],
161*7f2fe78bSCy Schubert  [AS_HELP_STRING([--disable-thread-support],
162*7f2fe78bSCy Schubert    [don't enable thread support @<:@enabled@:>@])],
163*7f2fe78bSCy Schubert  [], [enable_thread_support=yes])
164*7f2fe78bSCy Schubertif test "$enable_thread_support" = yes ; then
165*7f2fe78bSCy Schubert  AC_MSG_NOTICE(enabling thread support)
166*7f2fe78bSCy Schubert  AC_DEFINE(ENABLE_THREADS,1,[Define if thread support enabled])
167*7f2fe78bSCy Schubertfi
168*7f2fe78bSCy Schubertdnl Maybe this should be inside the conditional above?  Doesn't cache....
169*7f2fe78bSCy Schubertif test "$enable_thread_support" = yes; then
170*7f2fe78bSCy Schubert  AX_PTHREAD(,[AC_MSG_ERROR([cannot determine options for enabling thread support; try --disable-thread-support])])
171*7f2fe78bSCy Schubert  AC_MSG_NOTICE(PTHREAD_CC = $PTHREAD_CC)
172*7f2fe78bSCy Schubert  AC_MSG_NOTICE(PTHREAD_CFLAGS = $PTHREAD_CFLAGS)
173*7f2fe78bSCy Schubert  AC_MSG_NOTICE(PTHREAD_LIBS = $PTHREAD_LIBS)
174*7f2fe78bSCy Schubert  dnl Not really needed -- if pthread.h isn't found, ACX_PTHREAD will fail.
175*7f2fe78bSCy Schubert  dnl AC_CHECK_HEADERS(pthread.h)
176*7f2fe78bSCy Schubert  # AIX and Tru64 don't support weak references, and don't have
177*7f2fe78bSCy Schubert  # stub versions of the pthread code in libc.
178*7f2fe78bSCy Schubert  case "${host_os}" in
179*7f2fe78bSCy Schubert    aix* | osf*)
180*7f2fe78bSCy Schubert      # On these platforms, we'll always pull in the thread support.
181*7f2fe78bSCy Schubert      LIBS="$LIBS $PTHREAD_LIBS"
182*7f2fe78bSCy Schubert      CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
183*7f2fe78bSCy Schubert      # We don't need to sometimes add the flags we've just folded in...
184*7f2fe78bSCy Schubert      PTHREAD_LIBS=
185*7f2fe78bSCy Schubert      PTHREAD_CFLAGS=
186*7f2fe78bSCy Schubert      ;;
187*7f2fe78bSCy Schubert    hpux*)
188*7f2fe78bSCy Schubert      # These are the flags that "gcc -pthread" adds.  But we don't
189*7f2fe78bSCy Schubert      # want "-pthread" because that has link-time effects, and we
190*7f2fe78bSCy Schubert      # don't exclude CFLAGS when linking.  *sigh*
191*7f2fe78bSCy Schubert      PTHREAD_CFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L"
192*7f2fe78bSCy Schubert      ;;
193*7f2fe78bSCy Schubert    solaris2.[[1-9]])
194*7f2fe78bSCy Schubert      # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
195*7f2fe78bSCy Schubert      # get the right result.   XXX What about Solaris 9 and earlier?
196*7f2fe78bSCy Schubert      if test "$GCC" = yes ; then
197*7f2fe78bSCy Schubert        PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
198*7f2fe78bSCy Schubert      fi
199*7f2fe78bSCy Schubert      ;;
200*7f2fe78bSCy Schubert    solaris*)
201*7f2fe78bSCy Schubert      # On Solaris 10 with gcc 3.4.3, the autoconf archive macro doesn't
202*7f2fe78bSCy Schubert      # get the right result.
203*7f2fe78bSCy Schubert      if test "$GCC" = yes ; then
204*7f2fe78bSCy Schubert        PTHREAD_CFLAGS="-D_REENTRANT -pthreads"
205*7f2fe78bSCy Schubert      fi
206*7f2fe78bSCy Schubert      # On Solaris 10, the thread support is always available in libc.
207*7f2fe78bSCy Schubert      AC_DEFINE(NO_WEAK_PTHREADS,1,[Define if references to pthread routines should be non-weak.])
208*7f2fe78bSCy Schubert      ;;
209*7f2fe78bSCy Schubert  esac
210*7f2fe78bSCy Schubert  THREAD_SUPPORT=1
211*7f2fe78bSCy Schubertelse
212*7f2fe78bSCy Schubert  PTHREAD_CC="$CC"
213*7f2fe78bSCy Schubert  PTHREAD_CFLAGS=""
214*7f2fe78bSCy Schubert  PTHREAD_LIBS=""
215*7f2fe78bSCy Schubert  THREAD_SUPPORT=0
216*7f2fe78bSCy Schubertfi
217*7f2fe78bSCy SchubertAC_SUBST(THREAD_SUPPORT)
218*7f2fe78bSCy Schubertdnl We want to know where these routines live, so on systems with weak
219*7f2fe78bSCy Schubertdnl reference support we can figure out whether or not the pthread library
220*7f2fe78bSCy Schubertdnl has been linked in.
221*7f2fe78bSCy Schubertdnl If we don't add any libraries for thread support, don't bother.
222*7f2fe78bSCy SchubertAC_CHECK_FUNCS(pthread_once pthread_rwlock_init)
223*7f2fe78bSCy Schubertold_CC="$CC"
224*7f2fe78bSCy Schuberttest "$PTHREAD_CC" != "" && test "$ac_cv_c_compiler_gnu" = no && CC=$PTHREAD_CC
225*7f2fe78bSCy Schubertold_CFLAGS="$CFLAGS"
226*7f2fe78bSCy Schubert# On Solaris, -pthreads is added to CFLAGS, no extra explicit libraries.
227*7f2fe78bSCy SchubertCFLAGS="$CFLAGS $PTHREAD_CFLAGS"
228*7f2fe78bSCy SchubertAC_SUBST(PTHREAD_CFLAGS)
229*7f2fe78bSCy Schubertold_LIBS="$LIBS"
230*7f2fe78bSCy SchubertLIBS="$PTHREAD_LIBS $LIBS"
231*7f2fe78bSCy SchubertAC_MSG_NOTICE(rechecking with PTHREAD_... options)
232*7f2fe78bSCy SchubertAC_CHECK_LIB(c, pthread_rwlock_init,
233*7f2fe78bSCy Schubert  [AC_DEFINE(HAVE_PTHREAD_RWLOCK_INIT_IN_THREAD_LIB,1,[Define if pthread_rwlock_init is provided in the thread library.])])
234*7f2fe78bSCy SchubertLIBS="$old_LIBS"
235*7f2fe78bSCy SchubertCC="$old_CC"
236*7f2fe78bSCy SchubertCFLAGS="$old_CFLAGS"
237*7f2fe78bSCy Schubert])
238*7f2fe78bSCy Schubert
239*7f2fe78bSCy Schubertdnl This is somewhat gross and should go away when the build system
240*7f2fe78bSCy Schubertdnl is revamped. -- tlyu
241*7f2fe78bSCy Schubertdnl DECLARE_SYS_ERRLIST - check for sys_errlist in libc
242*7f2fe78bSCy Schubertdnl
243*7f2fe78bSCy SchubertAC_DEFUN([DECLARE_SYS_ERRLIST],
244*7f2fe78bSCy Schubert[AC_CACHE_CHECK([for sys_errlist declaration], krb5_cv_decl_sys_errlist,
245*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
246*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
247*7f2fe78bSCy Schubert    [[#include <stdio.h>
248*7f2fe78bSCy Schubert      #include <errno.h>
249*7f2fe78bSCy Schubert    ]],
250*7f2fe78bSCy Schubert    [[1+sys_nerr;]])],
251*7f2fe78bSCy Schubert  [krb5_cv_decl_sys_errlist=yes], [krb5_cv_decl_sys_errlist=no])])
252*7f2fe78bSCy Schubert# assume sys_nerr won't be declared w/o being in libc
253*7f2fe78bSCy Schubertif test $krb5_cv_decl_sys_errlist = yes; then
254*7f2fe78bSCy Schubert  AC_DEFINE(SYS_ERRLIST_DECLARED,1,[Define if sys_errlist is defined in errno.h])
255*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
256*7f2fe78bSCy Schubertelse
257*7f2fe78bSCy Schubert  # This means that sys_errlist is not declared in errno.h, but may still
258*7f2fe78bSCy Schubert  # be in libc.
259*7f2fe78bSCy Schubert  AC_CACHE_CHECK([for sys_errlist in libc], krb5_cv_var_sys_errlist,
260*7f2fe78bSCy Schubert  [AC_LINK_IFELSE(
261*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM(
262*7f2fe78bSCy Schubert      [[extern int sys_nerr;]],
263*7f2fe78bSCy Schubert      [[if (1+sys_nerr < 0) return 1;]])],
264*7f2fe78bSCy Schubert    [krb5_cv_var_sys_errlist=yes], [krb5_cv_var_sys_errlist=no])])
265*7f2fe78bSCy Schubert  if test $krb5_cv_var_sys_errlist = yes; then
266*7f2fe78bSCy Schubert    AC_DEFINE(HAVE_SYS_ERRLIST,1,[Define if sys_errlist in libc])
267*7f2fe78bSCy Schubert    # Do this cruft for backwards compatibility for now.
268*7f2fe78bSCy Schubert    AC_DEFINE(NEED_SYS_ERRLIST,1,[Define if need to declare sys_errlist])
269*7f2fe78bSCy Schubert  else
270*7f2fe78bSCy Schubert    AC_MSG_WARN([sys_errlist is neither in errno.h nor in libc])
271*7f2fe78bSCy Schubert  fi
272*7f2fe78bSCy Schubertfi])
273*7f2fe78bSCy Schubert
274*7f2fe78bSCy Schubertdnl
275*7f2fe78bSCy Schubertdnl check for sigmask/sigprocmask -- CHECK_SIGPROCMASK
276*7f2fe78bSCy Schubertdnl
277*7f2fe78bSCy SchubertAC_DEFUN(CHECK_SIGPROCMASK,[
278*7f2fe78bSCy SchubertAC_MSG_CHECKING([for use of sigprocmask])
279*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_func_sigprocmask_use,
280*7f2fe78bSCy Schubert[AC_LINK_IFELSE(
281*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
282*7f2fe78bSCy Schubert    [[#include <signal.h>
283*7f2fe78bSCy Schubert    ]],
284*7f2fe78bSCy Schubert    [[sigprocmask(SIG_SETMASK, 0, 0);]])],
285*7f2fe78bSCy Schubert  [krb5_cv_func_sigprocmask_use=yes],
286*7f2fe78bSCy Schubert  [AC_LINK_IFELSE(
287*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM(
288*7f2fe78bSCy Schubert      [[#include <signal.h>
289*7f2fe78bSCy Schubert      ]],
290*7f2fe78bSCy Schubert      [[sigmask(1);]])],
291*7f2fe78bSCy Schubert    [krb5_cv_func_sigprocmask_use=no], [krb5_cv_func_sigprocmask_use=yes])])])
292*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_func_sigprocmask_use)
293*7f2fe78bSCy Schubertif test $krb5_cv_func_sigprocmask_use = yes; then
294*7f2fe78bSCy Schubert AC_DEFINE(USE_SIGPROCMASK,1,[Define if sigprocmask should be used])
295*7f2fe78bSCy Schubertfi
296*7f2fe78bSCy Schubert])dnl
297*7f2fe78bSCy Schubertdnl
298*7f2fe78bSCy Schubertdnl
299*7f2fe78bSCy Schubertdnl check for <dirent.h> -- CHECK_DIRENT
300*7f2fe78bSCy Schubertdnl (may need to be more complex later)
301*7f2fe78bSCy Schubertdnl
302*7f2fe78bSCy SchubertAC_DEFUN(CHECK_DIRENT,[
303*7f2fe78bSCy SchubertAC_CHECK_HEADER(dirent.h,AC_DEFINE(USE_DIRENT_H,1,[Define if you have dirent.h functionality]))])dnl
304*7f2fe78bSCy Schubertdnl
305*7f2fe78bSCy Schubertdnl check if union wait is defined, or if WAIT_USES_INT -- CHECK_WAIT_TYPE
306*7f2fe78bSCy Schubertdnl
307*7f2fe78bSCy SchubertAC_DEFUN(CHECK_WAIT_TYPE,[
308*7f2fe78bSCy SchubertAC_MSG_CHECKING([if argument to wait is int *])
309*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_struct_wait,
310*7f2fe78bSCy Schubertdnl Test for prototype clash - if there is none - then assume int * works
311*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
312*7f2fe78bSCy Schubert  [AC_LANG_SOURCE(
313*7f2fe78bSCy Schubert    [[#include <sys/types.h>
314*7f2fe78bSCy Schubert      #include <sys/wait.h>
315*7f2fe78bSCy Schubert      extern pid_t wait(int *);]])],
316*7f2fe78bSCy Schubert  [krb5_cv_struct_wait=no],
317*7f2fe78bSCy Schubert  dnl Else fallback on old stuff
318*7f2fe78bSCy Schubert  [AC_COMPILE_IFELSE(
319*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM(
320*7f2fe78bSCy Schubert      [[#include <sys/wait.h>
321*7f2fe78bSCy Schubert      ]],
322*7f2fe78bSCy Schubert      [[union wait i;
323*7f2fe78bSCy Schubert        #ifdef WEXITSTATUS
324*7f2fe78bSCy Schubert        WEXITSTATUS (i);
325*7f2fe78bSCy Schubert        #endif
326*7f2fe78bSCy Schubert      ]])],
327*7f2fe78bSCy Schubert    [krb5_cv_struct_wait=yes], [krb5_cv_struct_wait=no])])])
328*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_struct_wait)
329*7f2fe78bSCy Schubertif test $krb5_cv_struct_wait = no; then
330*7f2fe78bSCy Schubert	AC_DEFINE(WAIT_USES_INT,1,[Define if wait takes int as a argument])
331*7f2fe78bSCy Schubertfi
332*7f2fe78bSCy Schubert])dnl
333*7f2fe78bSCy Schubertdnl
334*7f2fe78bSCy Schubertdnl check for POSIX signal handling -- CHECK_SIGNALS
335*7f2fe78bSCy Schubertdnl
336*7f2fe78bSCy SchubertAC_DEFUN(CHECK_SIGNALS,[
337*7f2fe78bSCy SchubertAC_CHECK_FUNC(sigprocmask,
338*7f2fe78bSCy SchubertAC_MSG_CHECKING(for sigset_t and POSIX_SIGNALS)
339*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_type_sigset_t,
340*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
341*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
342*7f2fe78bSCy Schubert    [[#include <signal.h>
343*7f2fe78bSCy Schubert    ]],
344*7f2fe78bSCy Schubert    [[sigset_t x]])],
345*7f2fe78bSCy Schubert  [krb5_cv_type_sigset_t=yes], [krb5_cv_type_sigset_t=no])])
346*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_type_sigset_t)
347*7f2fe78bSCy Schubertif test $krb5_cv_type_sigset_t = yes; then
348*7f2fe78bSCy Schubert  AC_DEFINE(POSIX_SIGNALS,1,[Define if POSIX signal handling is used])
349*7f2fe78bSCy Schubertfi
350*7f2fe78bSCy Schubert)])dnl
351*7f2fe78bSCy Schubertdnl
352*7f2fe78bSCy Schubertdnl check for POSIX setjmp/longjmp -- CHECK_SETJMP
353*7f2fe78bSCy Schubertdnl
354*7f2fe78bSCy SchubertAC_DEFUN(CHECK_SETJMP,[
355*7f2fe78bSCy SchubertAC_CHECK_FUNC(sigsetjmp,
356*7f2fe78bSCy SchubertAC_MSG_CHECKING(for sigjmp_buf)
357*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_struct_sigjmp_buf,
358*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
359*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
360*7f2fe78bSCy Schubert    [[#include <setjmp.h>
361*7f2fe78bSCy Schubert    ]],
362*7f2fe78bSCy Schubert    [[sigjmp_buf x]])],
363*7f2fe78bSCy Schubert  [krb5_cv_struct_sigjmp_buf=yes], [krb5_cv_struct_sigjmp_buf=no])])
364*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_struct_sigjmp_buf)
365*7f2fe78bSCy Schubertif test $krb5_cv_struct_sigjmp_buf = yes; then
366*7f2fe78bSCy Schubert  AC_DEFINE(POSIX_SETJMP,1,[Define if setjmp indicates POSIX interface])
367*7f2fe78bSCy Schubertfi
368*7f2fe78bSCy Schubert)])dnl
369*7f2fe78bSCy Schubertdnl
370*7f2fe78bSCy Schubertdnl Check for IPv6 compile-time support.
371*7f2fe78bSCy Schubertdnl
372*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_INET6,[
373*7f2fe78bSCy SchubertAC_CHECK_HEADERS(sys/types.h sys/socket.h netinet/in.h netdb.h)
374*7f2fe78bSCy SchubertAC_CHECK_FUNCS(inet_ntop inet_pton getnameinfo)
375*7f2fe78bSCy Schubertdnl getaddrinfo test needs netdb.h, for proper compilation on alpha
376*7f2fe78bSCy Schubertdnl under OSF/1^H^H^H^H^HDigital^H^H^H^H^H^H^HTru64 UNIX, where it's
377*7f2fe78bSCy Schubertdnl a macro
378*7f2fe78bSCy SchubertAC_MSG_CHECKING(for getaddrinfo)
379*7f2fe78bSCy SchubertAC_CACHE_VAL(ac_cv_func_getaddrinfo,
380*7f2fe78bSCy Schubert[AC_LINK_IFELSE(
381*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
382*7f2fe78bSCy Schubert    [[#ifdef HAVE_NETDB_H
383*7f2fe78bSCy Schubert      #include <netdb.h>
384*7f2fe78bSCy Schubert      #endif
385*7f2fe78bSCy Schubert    ]],
386*7f2fe78bSCy Schubert    [[struct addrinfo *ai;
387*7f2fe78bSCy Schubert      getaddrinfo("kerberos.mit.edu", "echo", 0, &ai);]])],
388*7f2fe78bSCy Schubert  [ac_cv_func_getaddrinfo=yes], [ac_cv_func_getaddrinfo=no])])
389*7f2fe78bSCy SchubertAC_MSG_RESULT($ac_cv_func_getaddrinfo)
390*7f2fe78bSCy Schubertif test $ac_cv_func_getaddrinfo = yes; then
391*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
392*7f2fe78bSCy Schubertfi
393*7f2fe78bSCy Schubertdnl
394*7f2fe78bSCy SchubertAC_REQUIRE([KRB5_SOCKADDR_SA_LEN])dnl
395*7f2fe78bSCy SchubertAC_MSG_CHECKING(for IPv6 compile-time support without -DINET6)
396*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_inet6,[
397*7f2fe78bSCy Schubertif test "$ac_cv_func_inet_ntop" != "yes" ; then
398*7f2fe78bSCy Schubert  krb5_cv_inet6=no
399*7f2fe78bSCy Schubertelse
400*7f2fe78bSCy Schubert  AC_COMPILE_IFELSE(
401*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM(
402*7f2fe78bSCy Schubert      [[#ifdef HAVE_SYS_TYPES_H
403*7f2fe78bSCy Schubert        #include <sys/types.h>
404*7f2fe78bSCy Schubert        #endif
405*7f2fe78bSCy Schubert        #include <sys/socket.h>
406*7f2fe78bSCy Schubert        #include <netinet/in.h>
407*7f2fe78bSCy Schubert        #include <netdb.h>
408*7f2fe78bSCy Schubert      ]],
409*7f2fe78bSCy Schubert      [[struct sockaddr_in6 in;
410*7f2fe78bSCy Schubert        AF_INET6;
411*7f2fe78bSCy Schubert        IN6_IS_ADDR_LINKLOCAL(&in.sin6_addr);]])],
412*7f2fe78bSCy Schubert    [krb5_cv_inet6=yes], [krb5_cv_inet6=no])
413*7f2fe78bSCy Schubertfi])
414*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_inet6)
415*7f2fe78bSCy Schubertif test "$krb5_cv_inet6" = no && test "$ac_cv_func_inet_ntop" = yes; then
416*7f2fe78bSCy SchubertAC_MSG_CHECKING(for IPv6 compile-time support with -DINET6)
417*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_inet6_with_dinet6,[
418*7f2fe78bSCy Schubertold_CC="$CC"
419*7f2fe78bSCy SchubertCC="$CC -DINET6"
420*7f2fe78bSCy SchubertAC_COMPILE_IFELSE(
421*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
422*7f2fe78bSCy Schubert    [[#ifdef HAVE_SYS_TYPES_H
423*7f2fe78bSCy Schubert      #include <sys/types.h>
424*7f2fe78bSCy Schubert      #endif
425*7f2fe78bSCy Schubert      #include <sys/socket.h>
426*7f2fe78bSCy Schubert      #include <netinet/in.h>
427*7f2fe78bSCy Schubert      #include <netdb.h>
428*7f2fe78bSCy Schubert    ]],
429*7f2fe78bSCy Schubert    [[struct sockaddr_in6 in;
430*7f2fe78bSCy Schubert      AF_INET6;
431*7f2fe78bSCy Schubert      IN6_IS_ADDR_LINKLOCAL (&in.sin6_addr);]])],
432*7f2fe78bSCy Schubert  [krb5_cv_inet6_with_dinet6=yes], [krb5_cv_inet6_with_dinet6=no])
433*7f2fe78bSCy SchubertCC="$old_CC"])
434*7f2fe78bSCy SchubertAC_MSG_RESULT($krb5_cv_inet6_with_dinet6)
435*7f2fe78bSCy Schubertfi
436*7f2fe78bSCy Schubertif test $krb5_cv_inet6 = yes || test "$krb5_cv_inet6_with_dinet6" = yes; then
437*7f2fe78bSCy Schubert  if test "$krb5_cv_inet6_with_dinet6" = yes; then
438*7f2fe78bSCy Schubert    AC_DEFINE(INET6,1,[May need to be defined to enable IPv6 support, for example on IRIX])
439*7f2fe78bSCy Schubert  fi
440*7f2fe78bSCy Schubertfi
441*7f2fe78bSCy Schubert])dnl
442*7f2fe78bSCy Schubertdnl
443*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_CHECK_FOR_CFLAGS,[
444*7f2fe78bSCy SchubertAC_BEFORE([$0],[AC_PROG_CC])
445*7f2fe78bSCy SchubertAC_BEFORE([$0],[AC_PROG_CXX])
446*7f2fe78bSCy Schubertkrb5_ac_cflags_set=${CFLAGS+set}
447*7f2fe78bSCy Schubertkrb5_ac_cxxflags_set=${CXXFLAGS+set}
448*7f2fe78bSCy Schubertkrb5_ac_warn_cflags_set=${WARN_CFLAGS+set}
449*7f2fe78bSCy Schubertkrb5_ac_warn_cxxflags_set=${WARN_CXXFLAGS+set}
450*7f2fe78bSCy Schubert])
451*7f2fe78bSCy Schubertdnl
452*7f2fe78bSCy SchubertAC_DEFUN(TRY_WARN_CC_FLAG_1,[dnl
453*7f2fe78bSCy Schubert  cachevar=`echo "krb5_cv_cc_flag_$1" | sed -e s/=/_eq_/g -e s/-/_dash_/g -e s/[[^a-zA-Z0-9_]]/_/g`
454*7f2fe78bSCy Schubert  AC_CACHE_CHECK([if C compiler supports $1], [$cachevar],
455*7f2fe78bSCy Schubert  [# first try without, then with
456*7f2fe78bSCy Schubert  AC_COMPILE_IFELSE(
457*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM([], [1;])],
458*7f2fe78bSCy Schubert    [old_cflags="$CFLAGS"
459*7f2fe78bSCy Schubert     CFLAGS="$CFLAGS $cflags_warning_test_flags $1"
460*7f2fe78bSCy Schubert     AC_COMPILE_IFELSE(
461*7f2fe78bSCy Schubert       [AC_LANG_PROGRAM([], [1;])],
462*7f2fe78bSCy Schubert       [eval $cachevar=yes], [eval $cachevar=no])
463*7f2fe78bSCy Schubert     CFLAGS="$old_cflags"],
464*7f2fe78bSCy Schubert    [AC_MSG_ERROR(compiling simple test program with $CFLAGS failed)])])
465*7f2fe78bSCy Schubert  if eval test '"${'$cachevar'}"' = yes; then
466*7f2fe78bSCy Schubert    WARN_CFLAGS="$WARN_CFLAGS $1"
467*7f2fe78bSCy Schubert  fi
468*7f2fe78bSCy Schubert  eval flag_supported='${'$cachevar'}'
469*7f2fe78bSCy Schubert])dnl
470*7f2fe78bSCy Schubertdnl
471*7f2fe78bSCy Schubertdnl Are additional flags needed to make unsupported warning options
472*7f2fe78bSCy Schubertdnl get reported as errors?
473*7f2fe78bSCy SchubertAC_DEFUN(CHECK_CC_WARNING_TEST_FLAGS,[dnl
474*7f2fe78bSCy Schubert  cflags_warning_test_flags=
475*7f2fe78bSCy Schubert  TRY_WARN_CC_FLAG_1(-Werror=unknown-warning-option)
476*7f2fe78bSCy Schubert  if test $flag_supported = yes; then
477*7f2fe78bSCy Schubert    cflags_warning_test_flags=-Werror=unknown-warning-option
478*7f2fe78bSCy Schubert  fi
479*7f2fe78bSCy Schubert])dnl
480*7f2fe78bSCy Schubertdnl
481*7f2fe78bSCy SchubertAC_DEFUN(TRY_WARN_CC_FLAG,[dnl
482*7f2fe78bSCy SchubertAC_REQUIRE([CHECK_CC_WARNING_TEST_FLAGS])dnl
483*7f2fe78bSCy SchubertTRY_WARN_CC_FLAG_1($1)dnl
484*7f2fe78bSCy Schubert])dnl
485*7f2fe78bSCy Schubertdnl
486*7f2fe78bSCy SchubertAC_DEFUN(WITH_CC,[dnl
487*7f2fe78bSCy SchubertAC_REQUIRE([KRB5_AC_CHECK_FOR_CFLAGS])dnl
488*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_CC])dnl
489*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_CXX])dnl
490*7f2fe78bSCy Schubertif test $ac_cv_c_compiler_gnu = yes ; then
491*7f2fe78bSCy Schubert     HAVE_GCC=yes
492*7f2fe78bSCy Schubert     else HAVE_GCC=
493*7f2fe78bSCy Schubertfi
494*7f2fe78bSCy SchubertAC_SUBST(HAVE_GCC)
495*7f2fe78bSCy SchubertAC_CACHE_CHECK([for GNU linker], krb5_cv_prog_gnu_ld,
496*7f2fe78bSCy Schubert[krb5_cv_prog_gnu_ld=no
497*7f2fe78bSCy Schubertif test "$GCC" = yes; then
498*7f2fe78bSCy Schubert  if AC_TRY_COMMAND([$CC -Wl,-v 2>&1 dnl
499*7f2fe78bSCy Schubert			| grep "GNU ld" > /dev/null]); then
500*7f2fe78bSCy Schubert    krb5_cv_prog_gnu_ld=yes
501*7f2fe78bSCy Schubert  fi
502*7f2fe78bSCy Schubertfi])
503*7f2fe78bSCy SchubertAC_ARG_WITH([size-optimizations],
504*7f2fe78bSCy Schubert[  --with-size-optimizations enable a few optimizations to reduce code size
505*7f2fe78bSCy Schubert                          possibly at some run-time cost],
506*7f2fe78bSCy Schubert,
507*7f2fe78bSCy Schubertwithval=no)
508*7f2fe78bSCy Schubertif test "$withval" = yes; then
509*7f2fe78bSCy Schubert  AC_DEFINE(CONFIG_SMALL,1,[Define to reduce code size even if it means more cpu usage])
510*7f2fe78bSCy Schubertfi
511*7f2fe78bSCy Schubert# -Wno-long-long, if needed, for k5-platform.h without inttypes.h etc.
512*7f2fe78bSCy Schubertextra_gcc_warn_opts="-Wall -Wcast-align -Wshadow"
513*7f2fe78bSCy Schubert# -Wmissing-prototypes
514*7f2fe78bSCy Schubertif test "$GCC" = yes ; then
515*7f2fe78bSCy Schubert  # Putting this here means we get -Os after -O2, which works.
516*7f2fe78bSCy Schubert  if test "$with_size_optimizations" = yes && test "x$krb5_ac_cflags_set" != xset; then
517*7f2fe78bSCy Schubert    AC_MSG_NOTICE(adding -Os optimization option)
518*7f2fe78bSCy Schubert    case "$CFLAGS" in
519*7f2fe78bSCy Schubert      "-g -O2") CFLAGS="-g -Os" ;;
520*7f2fe78bSCy Schubert      "-O2")    CFLAGS="-Os" ;;
521*7f2fe78bSCy Schubert      *)        CFLAGS="$CFLAGS -Os" ;;
522*7f2fe78bSCy Schubert    esac
523*7f2fe78bSCy Schubert  fi
524*7f2fe78bSCy Schubert  if test "x$krb5_ac_warn_cflags_set" = xset ; then
525*7f2fe78bSCy Schubert    AC_MSG_NOTICE(not adding extra gcc warning flags because WARN_CFLAGS was set)
526*7f2fe78bSCy Schubert  else
527*7f2fe78bSCy Schubert    AC_MSG_NOTICE(adding extra warning flags for gcc)
528*7f2fe78bSCy Schubert    WARN_CFLAGS="$WARN_CFLAGS $extra_gcc_warn_opts -Wmissing-prototypes"
529*7f2fe78bSCy Schubert    if test "`uname -s`" = Darwin ; then
530*7f2fe78bSCy Schubert      AC_MSG_NOTICE(skipping pedantic warnings on Darwin)
531*7f2fe78bSCy Schubert    elif test "`uname -s`" = Linux ; then
532*7f2fe78bSCy Schubert      AC_MSG_NOTICE(skipping pedantic warnings on Linux)
533*7f2fe78bSCy Schubert    else
534*7f2fe78bSCy Schubert      WARN_CFLAGS="$WARN_CFLAGS -pedantic"
535*7f2fe78bSCy Schubert    fi
536*7f2fe78bSCy Schubert    if test "$ac_cv_cxx_compiler_gnu" = yes; then
537*7f2fe78bSCy Schubert      if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
538*7f2fe78bSCy Schubert        AC_MSG_NOTICE(not adding extra g++ warnings because WARN_CXXFLAGS was set)
539*7f2fe78bSCy Schubert      else
540*7f2fe78bSCy Schubert        AC_MSG_NOTICE(adding extra warning flags for g++)
541*7f2fe78bSCy Schubert        WARN_CXXFLAGS="$WARN_CXXFLAGS $extra_gcc_warn_opts"
542*7f2fe78bSCy Schubert      fi
543*7f2fe78bSCy Schubert    fi
544*7f2fe78bSCy Schubert    # Currently, G++ does not support -Wno-format-zero-length.
545*7f2fe78bSCy Schubert    TRY_WARN_CC_FLAG(-Wno-format-zero-length)
546*7f2fe78bSCy Schubert    # Other flags here may not be supported on some versions of
547*7f2fe78bSCy Schubert    # gcc that people want to use.
548*7f2fe78bSCy Schubert    for flag in overflow strict-overflow missing-format-attribute missing-prototypes return-type missing-braces parentheses switch unused-function unused-label unused-variable unused-value unknown-pragmas sign-compare newline-eof error=uninitialized no-maybe-uninitialized error=pointer-arith error=int-conversion error=incompatible-pointer-types error=discarded-qualifiers error=implicit-int ; do
549*7f2fe78bSCy Schubert      TRY_WARN_CC_FLAG(-W$flag)
550*7f2fe78bSCy Schubert    done
551*7f2fe78bSCy Schubert    #  old-style-definition? generates many, many warnings
552*7f2fe78bSCy Schubert    #
553*7f2fe78bSCy Schubert    # Warnings that we'd like to turn into errors on versions of gcc
554*7f2fe78bSCy Schubert    # that support promoting only specific warnings to errors, but
555*7f2fe78bSCy Schubert    # we'll take as warnings on older compilers.  (If such a warning
556*7f2fe78bSCy Schubert    # is added after the -Werror=foo feature, you can just put
557*7f2fe78bSCy Schubert    # error=foo in the above list, and skip the test for the
558*7f2fe78bSCy Schubert    # warning-only form.)  At least in some versions, -Werror= doesn't
559*7f2fe78bSCy Schubert    # seem to make the conditions actual errors, but still issues
560*7f2fe78bSCy Schubert    # warnings; I guess we'll take what we can get.
561*7f2fe78bSCy Schubert    #
562*7f2fe78bSCy Schubert    # We're currently targeting C89+, not C99, so disallow some
563*7f2fe78bSCy Schubert    # constructs.
564*7f2fe78bSCy Schubert    for flag in declaration-after-statement ; do
565*7f2fe78bSCy Schubert      TRY_WARN_CC_FLAG(-Werror=$flag)
566*7f2fe78bSCy Schubert      if test "$flag_supported" = no; then
567*7f2fe78bSCy Schubert        TRY_WARN_CC_FLAG(-W$flag)
568*7f2fe78bSCy Schubert      fi
569*7f2fe78bSCy Schubert    done
570*7f2fe78bSCy Schubert    # We require function declarations now.
571*7f2fe78bSCy Schubert    #
572*7f2fe78bSCy Schubert    # In some compiler versions -- e.g., "gcc version 4.2.1 (Apple
573*7f2fe78bSCy Schubert    # Inc. build 5664)" -- the -Werror- option works, but the -Werror=
574*7f2fe78bSCy Schubert    # version doesn't cause implicitly declared functions to be
575*7f2fe78bSCy Schubert    # flagged as errors.  If neither works, -Wall implies
576*7f2fe78bSCy Schubert    # -Wimplicit-function-declaration so don't bother.
577*7f2fe78bSCy Schubert    TRY_WARN_CC_FLAG(-Werror-implicit-function-declaration)
578*7f2fe78bSCy Schubert    if test "implicit-function-declaration_supported" = no; then
579*7f2fe78bSCy Schubert      TRY_WARN_CC_FLAG(-Werror=implicit-function-declaration)
580*7f2fe78bSCy Schubert    fi
581*7f2fe78bSCy Schubert    #
582*7f2fe78bSCy Schubert  fi
583*7f2fe78bSCy Schubert  if test "`uname -s`" = Darwin ; then
584*7f2fe78bSCy Schubert    # Someday this should be a feature test.
585*7f2fe78bSCy Schubert    # One current (Jaguar = OS 10.2) problem:
586*7f2fe78bSCy Schubert    # Archive library with foo.o undef sym X and bar.o common sym X,
587*7f2fe78bSCy Schubert    # if foo.o is pulled in at link time, bar.o may not be, causing
588*7f2fe78bSCy Schubert    # the linker to complain.
589*7f2fe78bSCy Schubert    # Dynamic library problems too?
590*7f2fe78bSCy Schubert    case "$CC $CFLAGS" in
591*7f2fe78bSCy Schubert    *-fcommon*) ;; # why someone would do this, I don't know
592*7f2fe78bSCy Schubert    *-fno-common*) ;; # okay, they're already doing the right thing
593*7f2fe78bSCy Schubert    *)
594*7f2fe78bSCy Schubert      AC_MSG_NOTICE(disabling the use of common storage on Darwin)
595*7f2fe78bSCy Schubert      CFLAGS="$CFLAGS -fno-common"
596*7f2fe78bSCy Schubert      ;;
597*7f2fe78bSCy Schubert    esac
598*7f2fe78bSCy Schubert  fi
599*7f2fe78bSCy Schubertelse
600*7f2fe78bSCy Schubert  if test "`uname -s`" = AIX ; then
601*7f2fe78bSCy Schubert    # Using AIX but not GCC, assume native compiler.
602*7f2fe78bSCy Schubert    # The native compiler appears not to give a nonzero exit
603*7f2fe78bSCy Schubert    # status for certain classes of errors, like missing arguments
604*7f2fe78bSCy Schubert    # in function calls.  Let's try to fix that with -qhalt=e.
605*7f2fe78bSCy Schubert    case "$CC $CFLAGS" in
606*7f2fe78bSCy Schubert      *-qhalt=*) ;;
607*7f2fe78bSCy Schubert      *)
608*7f2fe78bSCy Schubert	CFLAGS="$CFLAGS -qhalt=e"
609*7f2fe78bSCy Schubert	AC_MSG_NOTICE(adding -qhalt=e for better error reporting)
610*7f2fe78bSCy Schubert	;;
611*7f2fe78bSCy Schubert    esac
612*7f2fe78bSCy Schubert    # Also, the optimizer isn't turned on by default, which means
613*7f2fe78bSCy Schubert    # the static inline functions get left in random object files,
614*7f2fe78bSCy Schubert    # leading to references to pthread_mutex_lock from anything that
615*7f2fe78bSCy Schubert    # includes k5-int.h whether it uses threads or not.
616*7f2fe78bSCy Schubert    case "$CC $CFLAGS" in
617*7f2fe78bSCy Schubert      *-O*) ;;
618*7f2fe78bSCy Schubert      *)
619*7f2fe78bSCy Schubert	CFLAGS="$CFLAGS -O"
620*7f2fe78bSCy Schubert	AC_MSG_NOTICE(adding -O for inline thread-support function elimination)
621*7f2fe78bSCy Schubert	;;
622*7f2fe78bSCy Schubert    esac
623*7f2fe78bSCy Schubert  fi
624*7f2fe78bSCy Schubert  if test "`uname -s`" = SunOS ; then
625*7f2fe78bSCy Schubert    # Using Solaris but not GCC, assume Sunsoft compiler.
626*7f2fe78bSCy Schubert    # We have some error-out-on-warning options available.
627*7f2fe78bSCy Schubert    # Sunsoft 12 compiler defaults to -xc99=all, it appears, so "inline"
628*7f2fe78bSCy Schubert    # works, but it also means that declaration-in-code warnings won't
629*7f2fe78bSCy Schubert    # be issued.
630*7f2fe78bSCy Schubert    # -v -fd -errwarn=E_DECLARATION_IN_CODE ...
631*7f2fe78bSCy Schubert    if test "x$krb5_ac_warn_cflags_set" = xset ; then
632*7f2fe78bSCy Schubert      AC_MSG_NOTICE(not adding extra warning flags because WARN_CFLAGS was set)
633*7f2fe78bSCy Schubert    else
634*7f2fe78bSCy Schubert      WARN_CFLAGS="-errtags=yes -errwarn=E_BAD_PTR_INT_COMBINATION,E_BAD_PTR_INT_COMB_ARG,E_PTR_TO_VOID_IN_ARITHMETIC,E_NO_IMPLICIT_DECL_ALLOWED,E_ATTRIBUTE_PARAM_UNDEFINED"
635*7f2fe78bSCy Schubert    fi
636*7f2fe78bSCy Schubert    if test "x$krb5_ac_warn_cxxflags_set" = xset ; then
637*7f2fe78bSCy Schubert      AC_MSG_NOTICE(not adding extra warning flags because WARN_CXXFLAGS was set)
638*7f2fe78bSCy Schubert    else
639*7f2fe78bSCy Schubert      WARN_CXXFLAGS="-errtags=yes +w +w2 -xport64"
640*7f2fe78bSCy Schubert    fi
641*7f2fe78bSCy Schubert  fi
642*7f2fe78bSCy Schubertfi
643*7f2fe78bSCy SchubertAC_SUBST(WARN_CFLAGS)
644*7f2fe78bSCy SchubertAC_SUBST(WARN_CXXFLAGS)
645*7f2fe78bSCy Schubert])dnl
646*7f2fe78bSCy Schubertdnl
647*7f2fe78bSCy Schubertdnl K5_GEN_MAKEFILE([dir, [frags]])
648*7f2fe78bSCy Schubertdnl
649*7f2fe78bSCy SchubertAC_DEFUN(K5_GEN_MAKEFILE,[dnl
650*7f2fe78bSCy Schubertifelse($1, ,[_K5_GEN_MAKEFILE(.,$2)],[_K5_GEN_MAKEFILE($1,$2)])
651*7f2fe78bSCy Schubert])
652*7f2fe78bSCy Schubertdnl
653*7f2fe78bSCy Schubertdnl _K5_GEN_MAKEFILE(dir, [frags])
654*7f2fe78bSCy Schubertdnl  dir must be present in this case
655*7f2fe78bSCy Schubertdnl  Note: Be careful in quoting.
656*7f2fe78bSCy Schubertdnl        The m4_foreach_w generates the list of fragments to include
657*7f2fe78bSCy Schubertdnl        or "" if $2 is empty
658*7f2fe78bSCy SchubertAC_DEFUN(_K5_GEN_MAKEFILE,[dnl
659*7f2fe78bSCy SchubertAC_CONFIG_FILES([$1/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:$1/Makefile.in:$1/deps:$srcdir/]K5_TOPDIR[/config/post.in])
660*7f2fe78bSCy Schubert])
661*7f2fe78bSCy Schubertdnl
662*7f2fe78bSCy Schubertdnl K5_GEN_FILE( <ac_output arguments> )
663*7f2fe78bSCy Schubertdnl
664*7f2fe78bSCy SchubertAC_DEFUN(K5_GEN_FILE,[AC_CONFIG_FILES($1)])dnl
665*7f2fe78bSCy Schubertdnl
666*7f2fe78bSCy Schubertdnl K5_AC_OUTPUT
667*7f2fe78bSCy Schubertdnl    Note: Adds the variables to config.status for individual
668*7f2fe78bSCy Schubertdnl          Makefile generation from config.status
669*7f2fe78bSCy SchubertAC_DEFUN(K5_AC_OUTPUT,[AC_OUTPUT])dnl
670*7f2fe78bSCy Schubertdnl
671*7f2fe78bSCy Schubertdnl V5_AC_OUTPUT_MAKEFILE
672*7f2fe78bSCy Schubertdnl
673*7f2fe78bSCy SchubertAC_DEFUN(V5_AC_OUTPUT_MAKEFILE,
674*7f2fe78bSCy Schubert[ifelse($1, , [_V5_AC_OUTPUT_MAKEFILE(.,$2)],[_V5_AC_OUTPUT_MAKEFILE($1,$2)])])
675*7f2fe78bSCy Schubertdnl
676*7f2fe78bSCy Schubertdefine(_V5_AC_OUTPUT_MAKEFILE,
677*7f2fe78bSCy Schubert[ifelse($2, , ,AC_CONFIG_FILES($2))
678*7f2fe78bSCy Schubertm4_foreach_w([DIR], [$1],dnl
679*7f2fe78bSCy Schubert [AC_CONFIG_FILES(DIR[/Makefile:$srcdir/]K5_TOPDIR[/config/pre.in:]DIR[/Makefile.in:]DIR[/deps:$srcdir/]K5_TOPDIR[/config/post.in])])
680*7f2fe78bSCy SchubertK5_AC_OUTPUT])dnl
681*7f2fe78bSCy Schubertdnl
682*7f2fe78bSCy Schubertdnl
683*7f2fe78bSCy Schubertdnl KRB5_SOCKADDR_SA_LEN: define HAVE_SA_LEN if sockaddr contains the sa_len
684*7f2fe78bSCy Schubertdnl component
685*7f2fe78bSCy Schubertdnl
686*7f2fe78bSCy SchubertAC_DEFUN([KRB5_SOCKADDR_SA_LEN],[ dnl
687*7f2fe78bSCy SchubertAC_CHECK_MEMBER(struct sockaddr.sa_len,
688*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len])
689*7f2fe78bSCy Schubert,,[#include <sys/types.h>
690*7f2fe78bSCy Schubert#include <sys/socket.h>])])
691*7f2fe78bSCy Schubertdnl
692*7f2fe78bSCy Schubertdnl WITH_NETLIB
693*7f2fe78bSCy Schubertdnl
694*7f2fe78bSCy Schubertdnl
695*7f2fe78bSCy SchubertAC_DEFUN(WITH_NETLIB,[
696*7f2fe78bSCy SchubertAC_ARG_WITH([netlib],
697*7f2fe78bSCy Schubert  [AS_HELP_STRING([--with-netlib=LIBS], [use user defined resolver library])],
698*7f2fe78bSCy Schubert[  if test "$withval" = yes -o "$withval" = no ; then
699*7f2fe78bSCy Schubert	AC_MSG_RESULT("netlib will link with C library resolver only")
700*7f2fe78bSCy Schubert  else
701*7f2fe78bSCy Schubert	LIBS="$LIBS $withval"
702*7f2fe78bSCy Schubert	AC_MSG_RESULT("netlib will use \'$withval\'")
703*7f2fe78bSCy Schubert  fi
704*7f2fe78bSCy Schubert],dnl
705*7f2fe78bSCy Schubert[AC_LIBRARY_NET]
706*7f2fe78bSCy Schubert)])dnl
707*7f2fe78bSCy Schubertdnl
708*7f2fe78bSCy Schubertdnl
709*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_NEED_DAEMON, [
710*7f2fe78bSCy SchubertKRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
711*7f2fe78bSCy Schubert#include <unistd.h>
712*7f2fe78bSCy Schubert#endif],daemon,1)])dnl
713*7f2fe78bSCy Schubert
714*7f2fe78bSCy Schubertdnl
715*7f2fe78bSCy Schubertdnl KRB5_AC_NEED_LIBGEN --- check if libgen needs to be linked in for
716*7f2fe78bSCy Schubertdnl 				compile/step
717*7f2fe78bSCy Schubertdnl
718*7f2fe78bSCy Schubertdnl
719*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_NEED_LIBGEN,[
720*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_CC])dnl
721*7f2fe78bSCy Schubertdnl
722*7f2fe78bSCy Schubertdnl regcomp is present but non-functional on Solaris 2.4
723*7f2fe78bSCy Schubertdnl
724*7f2fe78bSCy SchubertAC_MSG_CHECKING(for working regcomp)
725*7f2fe78bSCy SchubertAC_CACHE_VAL(ac_cv_func_regcomp,
726*7f2fe78bSCy Schubert[AC_RUN_IFELSE(
727*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
728*7f2fe78bSCy Schubert    [[#include <sys/types.h>
729*7f2fe78bSCy Schubert      #include <regex.h>
730*7f2fe78bSCy Schubert      regex_t x; regmatch_t m;]],
731*7f2fe78bSCy Schubert    [[return regcomp(&x,"pat.*",0) || regexec(&x,"pattern",1,&m,0);]])],
732*7f2fe78bSCy Schubert  [ac_cv_func_regcomp=yes], [ac_cv_func_regcomp=no],
733*7f2fe78bSCy Schubert  [AC_MSG_ERROR([Cannot test regcomp when cross compiling])])])
734*7f2fe78bSCy SchubertAC_MSG_RESULT($ac_cv_func_regcomp)
735*7f2fe78bSCy Schuberttest $ac_cv_func_regcomp = yes && AC_DEFINE(HAVE_REGCOMP,1,[Define if regcomp exists and functions])
736*7f2fe78bSCy Schubertdnl
737*7f2fe78bSCy Schubertdnl Check for the compile and step functions - only if regcomp is not available
738*7f2fe78bSCy Schubertdnl
739*7f2fe78bSCy Schubertif test $ac_cv_func_regcomp = no; then
740*7f2fe78bSCy Schubert save_LIBS="$LIBS"
741*7f2fe78bSCy Schubert LIBS=-lgen
742*7f2fe78bSCy Schubertdnl this will fail if there's no compile/step in -lgen, or if there's
743*7f2fe78bSCy Schubertdnl no -lgen.  This is fine.
744*7f2fe78bSCy Schubert AC_CHECK_FUNCS(compile step)
745*7f2fe78bSCy Schubert LIBS="$save_LIBS"
746*7f2fe78bSCy Schubertdnl
747*7f2fe78bSCy Schubertdnl Set GEN_LIB if necessary
748*7f2fe78bSCy Schubertdnl
749*7f2fe78bSCy Schubert AC_CHECK_LIB(gen, compile, GEN_LIB=-lgen, GEN_LIB=)
750*7f2fe78bSCy Schubert AC_SUBST(GEN_LIB)
751*7f2fe78bSCy Schubertfi
752*7f2fe78bSCy Schubert])
753*7f2fe78bSCy Schubertdnl
754*7f2fe78bSCy Schubertdnl KRB5_AC_REGEX_FUNCS --- check for different regular expression
755*7f2fe78bSCy Schubertdnl				support functions
756*7f2fe78bSCy Schubertdnl
757*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_REGEX_FUNCS,[
758*7f2fe78bSCy SchubertAC_CHECK_FUNCS(re_comp re_exec regexec)
759*7f2fe78bSCy SchubertAC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
760*7f2fe78bSCy Schubert])dnl
761*7f2fe78bSCy Schubertdnl
762*7f2fe78bSCy Schubertdnl WITH_HESIOD
763*7f2fe78bSCy Schubertdnl
764*7f2fe78bSCy SchubertAC_DEFUN(WITH_HESIOD,
765*7f2fe78bSCy Schubert[AC_ARG_WITH(hesiod,
766*7f2fe78bSCy Schubert  [AS_HELP_STRING([--with-hesiod[=path]],
767*7f2fe78bSCy Schubert    [compile with hesiod support @<:@omitted@:>@])],
768*7f2fe78bSCy Schubert  [hesiod=$with_hesiod], [with_hesiod=no])
769*7f2fe78bSCy Schubertif test "$with_hesiod" != "no"; then
770*7f2fe78bSCy Schubert	HESIOD_DEFS=-DHESIOD
771*7f2fe78bSCy Schubert	AC_CHECK_LIB(resolv, res_send, res_lib=-lresolv)
772*7f2fe78bSCy Schubert	if test "$hesiod" != "yes"; then
773*7f2fe78bSCy Schubert		HESIOD_LIBS="-L${hesiod}/lib -lhesiod $res_lib"
774*7f2fe78bSCy Schubert	else
775*7f2fe78bSCy Schubert		HESIOD_LIBS="-lhesiod $res_lib"
776*7f2fe78bSCy Schubert	fi
777*7f2fe78bSCy Schubertelse
778*7f2fe78bSCy Schubert	HESIOD_DEFS=
779*7f2fe78bSCy Schubert	HESIOD_LIBS=
780*7f2fe78bSCy Schubertfi
781*7f2fe78bSCy SchubertAC_SUBST(HESIOD_DEFS)
782*7f2fe78bSCy SchubertAC_SUBST(HESIOD_LIBS)])
783*7f2fe78bSCy Schubert
784*7f2fe78bSCy Schubert
785*7f2fe78bSCy Schubertdnl
786*7f2fe78bSCy Schubertdnl KRB5_BUILD_LIBRARY
787*7f2fe78bSCy Schubertdnl
788*7f2fe78bSCy Schubertdnl Pull in the necessary stuff to create the libraries.
789*7f2fe78bSCy Schubert
790*7f2fe78bSCy SchubertAC_DEFUN(KRB5_BUILD_LIBRARY,
791*7f2fe78bSCy Schubert[AC_REQUIRE([KRB5_LIB_AUX])dnl
792*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_LN_S])dnl
793*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_RANLIB])dnl
794*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_INSTALL])dnl
795*7f2fe78bSCy SchubertAC_CHECK_TOOL(AR, ar, false)
796*7f2fe78bSCy Schubertif test "$AR" = "false"; then
797*7f2fe78bSCy Schubert  AC_MSG_ERROR([ar not found in PATH])
798*7f2fe78bSCy Schubertfi
799*7f2fe78bSCy SchubertAC_CHECK_PROG(PERL, perl, perl, false)
800*7f2fe78bSCy Schubertif test "$ac_cv_prog_PERL" = "false"; then
801*7f2fe78bSCy Schubert  AC_MSG_ERROR(Perl is now required for Kerberos builds.)
802*7f2fe78bSCy Schubertfi
803*7f2fe78bSCy SchubertAC_SUBST(LIBLIST)
804*7f2fe78bSCy SchubertAC_SUBST(LIBLINKS)
805*7f2fe78bSCy SchubertAC_SUBST(PLUGIN)
806*7f2fe78bSCy SchubertAC_SUBST(PLUGINLINK)
807*7f2fe78bSCy SchubertAC_SUBST(PLUGININST)
808*7f2fe78bSCy SchubertAC_SUBST(KDB5_PLUGIN_DEPLIBS)
809*7f2fe78bSCy SchubertAC_SUBST(KDB5_PLUGIN_LIBS)
810*7f2fe78bSCy SchubertAC_SUBST(MAKE_SHLIB_COMMAND)
811*7f2fe78bSCy SchubertAC_SUBST(SHLIB_RPATH_FLAGS)
812*7f2fe78bSCy SchubertAC_SUBST(SHLIB_EXPFLAGS)
813*7f2fe78bSCy SchubertAC_SUBST(SHLIB_EXPORT_FILE_DEP)
814*7f2fe78bSCy SchubertAC_SUBST(DYNOBJ_EXPDEPS)
815*7f2fe78bSCy SchubertAC_SUBST(DYNOBJ_EXPFLAGS)
816*7f2fe78bSCy SchubertAC_SUBST(INSTALL_SHLIB)
817*7f2fe78bSCy SchubertAC_SUBST(STLIBEXT)
818*7f2fe78bSCy SchubertAC_SUBST(SHLIBEXT)
819*7f2fe78bSCy SchubertAC_SUBST(SHLIBVEXT)
820*7f2fe78bSCy SchubertAC_SUBST(SHLIBSEXT)
821*7f2fe78bSCy SchubertAC_SUBST(DEPLIBEXT)
822*7f2fe78bSCy SchubertAC_SUBST(PFLIBEXT)
823*7f2fe78bSCy SchubertAC_SUBST(LIBINSTLIST)
824*7f2fe78bSCy SchubertAC_SUBST(DYNOBJEXT)
825*7f2fe78bSCy SchubertAC_SUBST(MAKE_DYNOBJ_COMMAND)
826*7f2fe78bSCy SchubertAC_SUBST(UNDEF_CHECK)
827*7f2fe78bSCy Schubert])
828*7f2fe78bSCy Schubert
829*7f2fe78bSCy Schubertdnl
830*7f2fe78bSCy Schubertdnl KRB5_BUILD_LIBOBJS
831*7f2fe78bSCy Schubertdnl
832*7f2fe78bSCy Schubertdnl Pull in the necessary stuff to build library objects.
833*7f2fe78bSCy Schubert
834*7f2fe78bSCy SchubertAC_DEFUN(KRB5_BUILD_LIBOBJS,
835*7f2fe78bSCy Schubert[AC_REQUIRE([KRB5_LIB_AUX])dnl
836*7f2fe78bSCy SchubertAC_SUBST(OBJLISTS)
837*7f2fe78bSCy SchubertAC_SUBST(STOBJEXT)
838*7f2fe78bSCy SchubertAC_SUBST(SHOBJEXT)
839*7f2fe78bSCy SchubertAC_SUBST(PFOBJEXT)
840*7f2fe78bSCy SchubertAC_SUBST(PICFLAGS)
841*7f2fe78bSCy SchubertAC_SUBST(PROFFLAGS)])
842*7f2fe78bSCy Schubert
843*7f2fe78bSCy Schubertdnl
844*7f2fe78bSCy Schubertdnl KRB5_BUILD_PROGRAM
845*7f2fe78bSCy Schubertdnl
846*7f2fe78bSCy Schubertdnl Set variables to build a program.
847*7f2fe78bSCy Schubert
848*7f2fe78bSCy SchubertAC_DEFUN(KRB5_BUILD_PROGRAM,
849*7f2fe78bSCy Schubert[AC_REQUIRE([KRB5_LIB_AUX])dnl
850*7f2fe78bSCy SchubertAC_REQUIRE([KRB5_AC_NEED_LIBGEN])dnl
851*7f2fe78bSCy SchubertAC_SUBST(CC_LINK)
852*7f2fe78bSCy SchubertAC_SUBST(CXX_LINK)
853*7f2fe78bSCy SchubertAC_SUBST(RPATH_FLAG)
854*7f2fe78bSCy SchubertAC_SUBST(PROG_RPATH_FLAGS)
855*7f2fe78bSCy SchubertAC_SUBST(DEPLIBEXT)])
856*7f2fe78bSCy Schubert
857*7f2fe78bSCy Schubertdnl
858*7f2fe78bSCy Schubertdnl KRB5_RUN_FLAGS
859*7f2fe78bSCy Schubertdnl
860*7f2fe78bSCy Schubertdnl Set up environment for running dynamic executables out of build tree
861*7f2fe78bSCy Schubert
862*7f2fe78bSCy SchubertAC_DEFUN(KRB5_RUN_FLAGS,
863*7f2fe78bSCy Schubert[AC_REQUIRE([KRB5_LIB_AUX])dnl
864*7f2fe78bSCy SchubertKRB5_RUN_ENV="$RUN_ENV"
865*7f2fe78bSCy SchubertKRB5_RUN_VARS="$RUN_VARS"
866*7f2fe78bSCy SchubertAC_SUBST(KRB5_RUN_ENV)
867*7f2fe78bSCy SchubertAC_SUBST(KRB5_RUN_VARS)])
868*7f2fe78bSCy Schubert
869*7f2fe78bSCy Schubertdnl
870*7f2fe78bSCy Schubertdnl KRB5_LIB_AUX
871*7f2fe78bSCy Schubertdnl
872*7f2fe78bSCy Schubertdnl Parse configure options related to library building.
873*7f2fe78bSCy Schubert
874*7f2fe78bSCy SchubertAC_DEFUN(KRB5_LIB_AUX,
875*7f2fe78bSCy Schubert[AC_REQUIRE([KRB5_LIB_PARAMS])dnl
876*7f2fe78bSCy Schubert
877*7f2fe78bSCy SchubertAC_ARG_ENABLE([static],,, [enable_static=no])
878*7f2fe78bSCy SchubertAC_ARG_ENABLE([shared],,, [enable_shared=yes])
879*7f2fe78bSCy Schubert
880*7f2fe78bSCy Schubertif test "x$enable_static" = "x$enable_shared"; then
881*7f2fe78bSCy Schubert  AC_MSG_ERROR([--enable-static must be specified with --disable-shared])
882*7f2fe78bSCy Schubertfi
883*7f2fe78bSCy Schubert
884*7f2fe78bSCy SchubertAC_ARG_ENABLE([rpath],
885*7f2fe78bSCy Schubert  [AS_HELP_STRING([--disable-rpath],[suppress run path flags in link lines])],
886*7f2fe78bSCy Schubert  [], [enable_rpath=yes])
887*7f2fe78bSCy Schubert
888*7f2fe78bSCy Schubertif test "x$enable_rpath" != xyes ; then
889*7f2fe78bSCy Schubert	# Unset the rpath flag values set by shlib.conf
890*7f2fe78bSCy Schubert	SHLIB_RPATH_FLAGS=
891*7f2fe78bSCy Schubert	RPATH_FLAG=
892*7f2fe78bSCy Schubert	PROG_RPATH_FLAGS=
893*7f2fe78bSCy Schubertfi
894*7f2fe78bSCy Schubert
895*7f2fe78bSCy Schubertif test "$SHLIBEXT" = ".so-nobuild"; then
896*7f2fe78bSCy Schubert   AC_MSG_ERROR([Shared libraries are not yet supported on this platform.])
897*7f2fe78bSCy Schubertfi
898*7f2fe78bSCy Schubert
899*7f2fe78bSCy SchubertDEPLIBEXT=$SHLIBEXT
900*7f2fe78bSCy Schubert
901*7f2fe78bSCy Schubertif test "x$enable_static" = xyes; then
902*7f2fe78bSCy Schubert	AC_MSG_NOTICE([using static libraries])
903*7f2fe78bSCy Schubert	LIBLIST='lib$(LIBBASE)$(STLIBEXT)'
904*7f2fe78bSCy Schubert	LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(STLIBEXT)'
905*7f2fe78bSCy Schubert	PLUGIN='libkrb5_$(LIBBASE)$(STLIBEXT)'
906*7f2fe78bSCy Schubert	PLUGINLINK='$(TOPLIBD)/libkrb5_$(LIBBASE)$(STLIBEXT)'
907*7f2fe78bSCy Schubert	PLUGININST=install-static
908*7f2fe78bSCy Schubert	OBJLISTS=OBJS.ST
909*7f2fe78bSCy Schubert	LIBINSTLIST=install-static
910*7f2fe78bSCy Schubert	DEPLIBEXT=$STLIBEXT
911*7f2fe78bSCy Schubert	AC_DEFINE([STATIC_PLUGINS], 1, [Define for static plugin linkage])
912*7f2fe78bSCy Schubert
913*7f2fe78bSCy Schubert	KDB5_PLUGIN_DEPLIBS='$(TOPLIBD)/libkrb5_db2$(DEPLIBEXT)'
914*7f2fe78bSCy Schubert	KDB5_PLUGIN_LIBS='-lkrb5_db2'
915*7f2fe78bSCy Schubert	if test "x$OPENLDAP_PLUGIN" = xyes; then
916*7f2fe78bSCy Schubert		KDB5_PLUGIN_DEBLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkrb5_ldap$(DEPLIBEXT) $(TOPLIBD)/libkdb_ldap$(DEPLIBEXT)'
917*7f2fe78bSCy Schubert		KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkrb5_kldap -lkdb_ldap $(LDAP_LIBS)'
918*7f2fe78bSCy Schubert	fi
919*7f2fe78bSCy Schubert	# kadm5srv_mit normally comes before kdb on the link line.  Add it
920*7f2fe78bSCy Schubert	# again after the KDB plugins, since they depend on it for XDR stuff.
921*7f2fe78bSCy Schubert	KDB5_PLUGIN_DEPLIBS=$KDB5_PLUGIN_DEPLIBS' $(TOPLIBD)/libkadm5srv_mit$(DEPLIBEXT)'
922*7f2fe78bSCy Schubert	KDB5_PLUGIN_LIBS=$KDB5_PLUGIN_LIBS' -lkadm5srv_mit'
923*7f2fe78bSCy Schubert
924*7f2fe78bSCy Schubert	# avoid duplicate rules generation for AIX and such
925*7f2fe78bSCy Schubert	SHLIBEXT=.so-nobuild
926*7f2fe78bSCy Schubert	SHLIBVEXT=.so.v-nobuild
927*7f2fe78bSCy Schubert	SHLIBSEXT=.so.s-nobuild
928*7f2fe78bSCy Schubertelse
929*7f2fe78bSCy Schubert	AC_MSG_NOTICE([using shared libraries])
930*7f2fe78bSCy Schubert
931*7f2fe78bSCy Schubert	# Clear some stuff in case of AIX, etc.
932*7f2fe78bSCy Schubert	if test "$STLIBEXT" = "$SHLIBEXT" ; then
933*7f2fe78bSCy Schubert		STLIBEXT=.a-nobuild
934*7f2fe78bSCy Schubert	fi
935*7f2fe78bSCy Schubert	case "$SHLIBSEXT" in
936*7f2fe78bSCy Schubert	.so.s-nobuild)
937*7f2fe78bSCy Schubert		LIBLIST='lib$(LIBBASE)$(SHLIBEXT)'
938*7f2fe78bSCy Schubert		LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT)'
939*7f2fe78bSCy Schubert		LIBINSTLIST="install-shared"
940*7f2fe78bSCy Schubert		;;
941*7f2fe78bSCy Schubert	*)
942*7f2fe78bSCy Schubert		LIBLIST='lib$(LIBBASE)$(SHLIBEXT) lib$(LIBBASE)$(SHLIBSEXT)'
943*7f2fe78bSCy Schubert		LIBLINKS='$(TOPLIBD)/lib$(LIBBASE)$(SHLIBEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBVEXT) $(TOPLIBD)/lib$(LIBBASE)$(SHLIBSEXT)'
944*7f2fe78bSCy Schubert		LIBINSTLIST="install-shlib-soname"
945*7f2fe78bSCy Schubert		;;
946*7f2fe78bSCy Schubert	esac
947*7f2fe78bSCy Schubert	OBJLISTS="OBJS.SH"
948*7f2fe78bSCy Schubert	PLUGIN='$(LIBBASE)$(DYNOBJEXT)'
949*7f2fe78bSCy Schubert	PLUGINLINK='../$(PLUGIN)'
950*7f2fe78bSCy Schubert	PLUGININST=install-plugin
951*7f2fe78bSCy Schubert	KDB5_PLUGIN_DEPLIBS=
952*7f2fe78bSCy Schubert	KDB5_PLUGIN_LIBS=
953*7f2fe78bSCy Schubertfi
954*7f2fe78bSCy SchubertCC_LINK="$CC_LINK_SHARED"
955*7f2fe78bSCy SchubertCXX_LINK="$CXX_LINK_SHARED"
956*7f2fe78bSCy Schubert
957*7f2fe78bSCy Schubertif test -z "$LIBLIST"; then
958*7f2fe78bSCy Schubert	AC_MSG_ERROR([must enable one of shared or static libraries])
959*7f2fe78bSCy Schubertfi
960*7f2fe78bSCy Schubert
961*7f2fe78bSCy Schubert# Check whether to build profiled libraries.
962*7f2fe78bSCy SchubertAC_ARG_ENABLE([profiled],
963*7f2fe78bSCy Schubertdnl [  --enable-profiled       build profiled libraries @<:@disabled@:>@]
964*7f2fe78bSCy Schubert,
965*7f2fe78bSCy Schubert[if test "$enableval" = yes; then
966*7f2fe78bSCy Schubert  AC_MSG_ERROR([Sorry, profiled libraries do not work in this release.])
967*7f2fe78bSCy Schubertfi])])
968*7f2fe78bSCy Schubert
969*7f2fe78bSCy Schubertdnl
970*7f2fe78bSCy Schubertdnl KRB5_LIB_PARAMS
971*7f2fe78bSCy Schubertdnl
972*7f2fe78bSCy Schubertdnl Determine parameters related to libraries, e.g. various extensions.
973*7f2fe78bSCy Schubert
974*7f2fe78bSCy SchubertAC_DEFUN(KRB5_LIB_PARAMS,
975*7f2fe78bSCy Schubert[AC_REQUIRE([AC_CANONICAL_HOST])dnl
976*7f2fe78bSCy Schubertkrb5_cv_host=$host
977*7f2fe78bSCy SchubertAC_SUBST(krb5_cv_host)
978*7f2fe78bSCy SchubertAC_REQUIRE([AC_PROG_CC])dnl
979*7f2fe78bSCy SchubertAC_REQUIRE([V5_SET_TOPDIR])dnl
980*7f2fe78bSCy Schubert. $ac_topdir/config/shlib.conf])
981*7f2fe78bSCy Schubertdnl
982*7f2fe78bSCy Schubertdnl The following was written by jhawk@mit.edu
983*7f2fe78bSCy Schubertdnl
984*7f2fe78bSCy Schubertdnl AC_LIBRARY_NET: Id: net.m4,v 1.4 1997/10/25 20:49:53 jhawk Exp
985*7f2fe78bSCy Schubertdnl
986*7f2fe78bSCy Schubertdnl This test is for network applications that need socket() and
987*7f2fe78bSCy Schubertdnl gethostbyname() -ish functions.  Under Solaris, those applications need to
988*7f2fe78bSCy Schubertdnl link with "-lsocket -lnsl".  Under IRIX, they should *not* link with
989*7f2fe78bSCy Schubertdnl "-lsocket" because libsocket.a breaks a number of things (for instance:
990*7f2fe78bSCy Schubertdnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
991*7f2fe78bSCy Schubertdnl IRIX).
992*7f2fe78bSCy Schubertdnl
993*7f2fe78bSCy Schubertdnl Unfortunately, many application developers are not aware of this, and
994*7f2fe78bSCy Schubertdnl mistakenly write tests that cause -lsocket to be used under IRIX.  It is
995*7f2fe78bSCy Schubertdnl also easy to write tests that cause -lnsl to be used under operating
996*7f2fe78bSCy Schubertdnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
997*7f2fe78bSCy Schubertdnl uses -lnsl for TLI.
998*7f2fe78bSCy Schubertdnl
999*7f2fe78bSCy Schubertdnl This test exists so that every application developer does not test this in
1000*7f2fe78bSCy Schubertdnl a different, and subtly broken fashion.
1001*7f2fe78bSCy Schubertdnl
1002*7f2fe78bSCy Schubertdnl It has been argued that this test should be broken up into two separate
1003*7f2fe78bSCy Schubertdnl tests, one for the resolver libraries, and one for the libraries necessary
1004*7f2fe78bSCy Schubertdnl for using Sockets API. Unfortunately, the two are carefully intertwined and
1005*7f2fe78bSCy Schubertdnl allowing the autoconf user to use them independantly potentially results in
1006*7f2fe78bSCy Schubertdnl unfortunate ordering dependencies -- as such, such component macros would
1007*7f2fe78bSCy Schubertdnl have to carefully use indirection and be aware if the other components were
1008*7f2fe78bSCy Schubertdnl executed. Since other autoconf macros do not go to this trouble, and almost
1009*7f2fe78bSCy Schubertdnl no applications use sockets without the resolver, this complexity has not
1010*7f2fe78bSCy Schubertdnl been implemented.
1011*7f2fe78bSCy Schubertdnl
1012*7f2fe78bSCy Schubertdnl The check for libresolv is in case you are attempting to link statically
1013*7f2fe78bSCy Schubertdnl and happen to have a libresolv.a lying around (and no libnsl.a).
1014*7f2fe78bSCy Schubertdnl
1015*7f2fe78bSCy SchubertAC_DEFUN(AC_LIBRARY_NET, [
1016*7f2fe78bSCy Schubert   # Most operating systems have gethostbyname() in the default searched
1017*7f2fe78bSCy Schubert   # libraries (i.e. libc):
1018*7f2fe78bSCy Schubert   AC_CHECK_FUNC(gethostbyname, , [
1019*7f2fe78bSCy Schubert     # Some OSes (eg. Solaris) place it in libnsl:
1020*7f2fe78bSCy Schubert     AC_CHECK_LIB(nsl, gethostbyname, , [
1021*7f2fe78bSCy Schubert       # Some strange OSes (SINIX) have it in libsocket:
1022*7f2fe78bSCy Schubert       AC_CHECK_LIB(socket, gethostbyname, , [
1023*7f2fe78bSCy Schubert          # Unfortunately libsocket sometimes depends on libnsl.
1024*7f2fe78bSCy Schubert          # AC_CHECK_LIB's API is essentially broken so the following
1025*7f2fe78bSCy Schubert          # ugliness is necessary:
1026*7f2fe78bSCy Schubert          AC_CHECK_LIB(socket, gethostbyname,
1027*7f2fe78bSCy Schubert             LIBS="-lsocket -lnsl $LIBS",
1028*7f2fe78bSCy Schubert               [AC_CHECK_LIB(resolv, gethostbyname,
1029*7f2fe78bSCy Schubert			     LIBS="-lresolv $LIBS" )],
1030*7f2fe78bSCy Schubert             -lnsl)
1031*7f2fe78bSCy Schubert       ])
1032*7f2fe78bSCy Schubert     ])
1033*7f2fe78bSCy Schubert   ])
1034*7f2fe78bSCy Schubert  AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
1035*7f2fe78bSCy Schubert    AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
1036*7f2fe78bSCy Schubert  KRB5_AC_ENABLE_DNS
1037*7f2fe78bSCy Schubert  if test "$enable_dns" = yes ; then
1038*7f2fe78bSCy Schubert    # We assume that if libresolv exists we can link against it.
1039*7f2fe78bSCy Schubert    # This may get us a gethostby* that doesn't respect nsswitch.
1040*7f2fe78bSCy Schubert    AC_CHECK_LIB(resolv, main)
1041*7f2fe78bSCy Schubert
1042*7f2fe78bSCy Schubert_KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl
1043*7f2fe78bSCy Schubertns_initparse ns_name_uncompress dn_skipname res_search)
1044*7f2fe78bSCy Schubert    if test $krb5_cv_func_res_nsearch = no \
1045*7f2fe78bSCy Schubert      && test $krb5_cv_func_res_search = no; then
1046*7f2fe78bSCy Schubert	# Attempt to link with res_search(), in case it's not prototyped.
1047*7f2fe78bSCy Schubert	AC_CHECK_FUNC(res_search,
1048*7f2fe78bSCy Schubert	  [AC_DEFINE(HAVE_RES_SEARCH, 1,
1049*7f2fe78bSCy Schubert	    [Define to 1 if you have the `res_search' function])],
1050*7f2fe78bSCy Schubert          [AC_MSG_ERROR([cannot find res_nsearch or res_search])])
1051*7f2fe78bSCy Schubert    fi
1052*7f2fe78bSCy Schubert  fi
1053*7f2fe78bSCy Schubert])
1054*7f2fe78bSCy SchubertAC_DEFUN([_KRB5_AC_CHECK_RES_FUNCS],
1055*7f2fe78bSCy Schubert[m4_foreach_w([AC_Func], [$1],
1056*7f2fe78bSCy Schubert  [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
1057*7f2fe78bSCy Schubert               [Define to 1 if you have the `]AC_Func[' function.])])dnl
1058*7f2fe78bSCy Schubertfor krb5_func in $1; do
1059*7f2fe78bSCy Schubert_KRB5_AC_CHECK_RES_FUNC($krb5_func)
1060*7f2fe78bSCy Schubertdone
1061*7f2fe78bSCy Schubert])
1062*7f2fe78bSCy SchubertAC_DEFUN([_KRB5_AC_CHECK_RES_FUNC], [
1063*7f2fe78bSCy Schubert# Solaris 9 prototypes ns_name_uncompress() in arpa/nameser.h, but
1064*7f2fe78bSCy Schubert# doesn't export it from libresolv.so, so we use extreme paranoia here
1065*7f2fe78bSCy Schubert# and check both for the declaration and that we can link against the
1066*7f2fe78bSCy Schubert# function.
1067*7f2fe78bSCy SchubertAC_CACHE_CHECK([for $1], [krb5_cv_func_$1],
1068*7f2fe78bSCy Schubert[AC_LINK_IFELSE(
1069*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
1070*7f2fe78bSCy Schubert    [[#include <sys/types.h>
1071*7f2fe78bSCy Schubert      #include <netinet/in.h>
1072*7f2fe78bSCy Schubert      #include <arpa/nameser.h>
1073*7f2fe78bSCy Schubert      #include <resolv.h>
1074*7f2fe78bSCy Schubert    ]],
1075*7f2fe78bSCy Schubert    [[/*
1076*7f2fe78bSCy Schubert       * Use volatile, or else optimization can cause false positives.
1077*7f2fe78bSCy Schubert       */
1078*7f2fe78bSCy Schubert      void (* volatile p)() = (void (*)())$1;]])],
1079*7f2fe78bSCy Schubert    [AS_VAR_SET(krb5_cv_func_$1, yes)],
1080*7f2fe78bSCy Schubert    [AS_VAR_SET(krb5_cv_func_$1, no)])])
1081*7f2fe78bSCy SchubertAS_IF([test AS_VAR_GET(krb5_cv_func_$1) = yes],
1082*7f2fe78bSCy Schubert      [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), 1,
1083*7f2fe78bSCy Schubert			  [Define to 1 if you have the `$1' function])])[]dnl
1084*7f2fe78bSCy Schubert])
1085*7f2fe78bSCy Schubertdnl
1086*7f2fe78bSCy Schubertdnl
1087*7f2fe78bSCy Schubertdnl KRB5_AC_ENABLE_DNS
1088*7f2fe78bSCy Schubertdnl
1089*7f2fe78bSCy SchubertAC_DEFUN(KRB5_AC_ENABLE_DNS, [
1090*7f2fe78bSCy Schubertenable_dns=yes
1091*7f2fe78bSCy Schubert  AC_ARG_ENABLE([dns-for-realm],
1092*7f2fe78bSCy Schubert[  --enable-dns-for-realm  enable DNS lookups of Kerberos realm names], ,
1093*7f2fe78bSCy Schubert[enable_dns_for_realm=no])
1094*7f2fe78bSCy Schubert  if test "$enable_dns_for_realm" = yes; then
1095*7f2fe78bSCy Schubert    AC_DEFINE(KRB5_DNS_LOOKUP_REALM,1,[Define to enable DNS lookups of Kerberos realm names])
1096*7f2fe78bSCy Schubert  fi
1097*7f2fe78bSCy Schubert
1098*7f2fe78bSCy SchubertAC_DEFINE(KRB5_DNS_LOOKUP, 1,[Define for DNS support of locating realms and KDCs])
1099*7f2fe78bSCy Schubert
1100*7f2fe78bSCy Schubert])
1101*7f2fe78bSCy Schubertdnl
1102*7f2fe78bSCy Schubertdnl
1103*7f2fe78bSCy Schubertdnl Check if we need the prototype for a function - we give it a bogus
1104*7f2fe78bSCy Schubertdnl prototype and if it complains - then a valid prototype exists on the
1105*7f2fe78bSCy Schubertdnl system.
1106*7f2fe78bSCy Schubertdnl
1107*7f2fe78bSCy Schubertdnl KRB5_NEED_PROTO(includes, function, [bypass])
1108*7f2fe78bSCy Schubertdnl if $3 set, don't see if library defined.
1109*7f2fe78bSCy Schubertdnl Useful for case where we will define in libkrb5 the function if need be
1110*7f2fe78bSCy Schubertdnl but want to know if a prototype exists in either case on system.
1111*7f2fe78bSCy Schubertdnl
1112*7f2fe78bSCy SchubertAC_DEFUN([KRB5_NEED_PROTO], [
1113*7f2fe78bSCy Schubertifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
1114*7f2fe78bSCy SchubertAC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
1115*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
1116*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
1117*7f2fe78bSCy Schubert    [[$1]],
1118*7f2fe78bSCy Schubert    [[#undef $2
1119*7f2fe78bSCy Schubert      struct k5foo {int foo; } xx;
1120*7f2fe78bSCy Schubert      extern int $2 (struct k5foo*);
1121*7f2fe78bSCy Schubert      $2(&xx);]])],
1122*7f2fe78bSCy Schubert  [krb5_cv_func_$2_noproto=yes], [krb5_cv_func_$2_noproto=no])])
1123*7f2fe78bSCy Schubertif test $krb5_cv_func_$2_noproto = yes; then
1124*7f2fe78bSCy Schubert	AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl
1125*7f2fe78bSCy Schubert[define if the system header files are missing prototype for $2()])
1126*7f2fe78bSCy Schubertfi
1127*7f2fe78bSCy Schubertifelse([$3], ,[fi])
1128*7f2fe78bSCy Schubert])
1129*7f2fe78bSCy Schubertdnl
1130*7f2fe78bSCy Schubertdnl =============================================================
1131*7f2fe78bSCy Schubertdnl Internal function for testing for getpeername prototype
1132*7f2fe78bSCy Schubertdnl
1133*7f2fe78bSCy SchubertAC_DEFUN([KRB5_GETPEERNAME_ARGS],[
1134*7f2fe78bSCy SchubertAC_DEFINE([GETPEERNAME_ARG3_TYPE],GETSOCKNAME_ARG3_TYPE,[Type of getpeername second argument.])
1135*7f2fe78bSCy Schubert])
1136*7f2fe78bSCy Schubertdnl
1137*7f2fe78bSCy Schubertdnl =============================================================
1138*7f2fe78bSCy Schubertdnl Internal function for testing for getsockname arguments
1139*7f2fe78bSCy Schubertdnl
1140*7f2fe78bSCy SchubertAC_DEFUN([TRY_GETSOCK_INT],[
1141*7f2fe78bSCy Schubertkrb5_lib_var=`echo "$1 $2" | sed 'y% ./+-*%___p_p%'`
1142*7f2fe78bSCy SchubertAC_MSG_CHECKING([if getsockname() takes arguments $1 and $2])
1143*7f2fe78bSCy SchubertAC_CACHE_VAL(krb5_cv_getsockname_proto_$krb5_lib_var,
1144*7f2fe78bSCy Schubert[AC_COMPILE_IFELSE(
1145*7f2fe78bSCy Schubert  [AC_LANG_SOURCE(
1146*7f2fe78bSCy Schubert    [[#include <sys/types.h>
1147*7f2fe78bSCy Schubert      #include <sys/socket.h>
1148*7f2fe78bSCy Schubert      extern int getsockname(int, $1, $2);]])],
1149*7f2fe78bSCy Schubert  [eval "krb5_cv_getsockname_proto_$krb5_lib_var=yes"],
1150*7f2fe78bSCy Schubert  [eval "krb5_cv_getsockname_proto_$krb5_lib_var=no"])])
1151*7f2fe78bSCy Schubertif eval "test \"`echo '$krb5_cv_getsockname_proto_'$krb5_lib_var`\" = yes"; then
1152*7f2fe78bSCy Schubert	AC_MSG_RESULT(yes)
1153*7f2fe78bSCy Schubert	sock_set=yes; res1="$1"; res2="$2"
1154*7f2fe78bSCy Schubertelse
1155*7f2fe78bSCy Schubert	AC_MSG_RESULT(no)
1156*7f2fe78bSCy Schubertfi
1157*7f2fe78bSCy Schubert])
1158*7f2fe78bSCy Schubertdnl
1159*7f2fe78bSCy Schubertdnl Determines the types of the second and third arguments to getsockname().
1160*7f2fe78bSCy Schubertdnl
1161*7f2fe78bSCy SchubertAC_DEFUN([KRB5_GETSOCKNAME_ARGS],[
1162*7f2fe78bSCy Schubertsock_set=no
1163*7f2fe78bSCy Schubertfor sock_arg1 in "struct sockaddr *" "void *"
1164*7f2fe78bSCy Schubertdo
1165*7f2fe78bSCy Schubert  for sock_arg2 in "size_t *" "int *" "socklen_t *"
1166*7f2fe78bSCy Schubert  do
1167*7f2fe78bSCy Schubert	if test $sock_set = no; then
1168*7f2fe78bSCy Schubert	  TRY_GETSOCK_INT($sock_arg1, $sock_arg2)
1169*7f2fe78bSCy Schubert	fi
1170*7f2fe78bSCy Schubert  done
1171*7f2fe78bSCy Schubertdone
1172*7f2fe78bSCy Schubertif test "$sock_set" = no; then
1173*7f2fe78bSCy Schubert  AC_MSG_NOTICE(assuming struct sockaddr and socklen_t for getsockname args)
1174*7f2fe78bSCy Schubert  res1="struct sockaddr *"
1175*7f2fe78bSCy Schubert  res2="socklen_t *"
1176*7f2fe78bSCy Schubertfi
1177*7f2fe78bSCy Schubertres1=`echo "$res1" | tr -d '*' | sed -e 's/ *$//'`
1178*7f2fe78bSCy Schubertres2=`echo "$res2" | tr -d '*' | sed -e 's/ *$//'`
1179*7f2fe78bSCy SchubertAC_DEFINE_UNQUOTED([GETSOCKNAME_ARG3_TYPE],$res2,[Type of pointer target for argument 3 to getsockname])
1180*7f2fe78bSCy Schubert])
1181*7f2fe78bSCy Schubertdnl
1182*7f2fe78bSCy Schubertdnl
1183*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_CHOOSE_ET],[
1184*7f2fe78bSCy SchubertAC_ARG_WITH([system-et],
1185*7f2fe78bSCy Schubert  [AS_HELP_STRING([--with-system-et],
1186*7f2fe78bSCy Schubert    [use system compile_et and -lcom_err @<:@default: build and install a local version@:>@])])
1187*7f2fe78bSCy SchubertAC_MSG_CHECKING(which version of com_err to use)
1188*7f2fe78bSCy Schubertif test "x$with_system_et" = xyes ; then
1189*7f2fe78bSCy Schubert  # This will be changed to "intlsys" if textdomain support is present.
1190*7f2fe78bSCy Schubert  COM_ERR_VERSION=sys
1191*7f2fe78bSCy Schubert  AC_MSG_RESULT(system)
1192*7f2fe78bSCy Schubertelse
1193*7f2fe78bSCy Schubert  COM_ERR_VERSION=k5
1194*7f2fe78bSCy Schubert  AC_MSG_RESULT(krb5)
1195*7f2fe78bSCy Schubertfi
1196*7f2fe78bSCy SchubertOLDLIBS="$LIBS"
1197*7f2fe78bSCy SchubertCOM_ERR_LIB=-lcom_err
1198*7f2fe78bSCy Schubertif test $COM_ERR_VERSION = sys; then
1199*7f2fe78bSCy Schubert  PKG_CHECK_MODULES(COM_ERR, com_err, [have_com_err=yes], [have_com_err=no])
1200*7f2fe78bSCy Schubert  if test "x$have_com_err = xyes"; then
1201*7f2fe78bSCy Schubert    COM_ERR_LIB="$COM_ERR_LIBS"
1202*7f2fe78bSCy Schubert  fi
1203*7f2fe78bSCy Schubert  LIBS="$LIBS $COM_ERR_LIB"
1204*7f2fe78bSCy Schubert  # check for various functions we need
1205*7f2fe78bSCy Schubert  AC_CHECK_LIB(com_err, add_error_table, :, AC_MSG_ERROR(cannot find add_error_table in com_err library))
1206*7f2fe78bSCy Schubert  AC_CHECK_LIB(com_err, remove_error_table, :, AC_MSG_ERROR(cannot find remove_error_table in com_err library))
1207*7f2fe78bSCy Schubert  # make sure compile_et provides "et_foo" name
1208*7f2fe78bSCy Schubert  cat >> conf$$e.et <<EOF
1209*7f2fe78bSCy Schuberterror_table foo
1210*7f2fe78bSCy Schuberterror_code ERR_FOO, "foo"
1211*7f2fe78bSCy Schubertend
1212*7f2fe78bSCy SchubertEOF
1213*7f2fe78bSCy Schubert  AC_CHECK_PROGS(compile_et,compile_et,false)
1214*7f2fe78bSCy Schubert  if test "$compile_et" = false; then
1215*7f2fe78bSCy Schubert    AC_MSG_ERROR(cannot find compile_et)
1216*7f2fe78bSCy Schubert  fi
1217*7f2fe78bSCy Schubert  AC_CACHE_CHECK(whether compile_et is useful,krb5_cv_compile_et_useful,[
1218*7f2fe78bSCy Schubert  if compile_et conf$$e.et >/dev/null 2>&1 ; then true ; else
1219*7f2fe78bSCy Schubert    AC_MSG_ERROR(execution failed)
1220*7f2fe78bSCy Schubert  fi
1221*7f2fe78bSCy Schubert  AC_COMPILE_IFELSE(
1222*7f2fe78bSCy Schubert    [AC_LANG_PROGRAM(
1223*7f2fe78bSCy Schubert      [[#include "conf$$e.h"
1224*7f2fe78bSCy Schubert      ]],
1225*7f2fe78bSCy Schubert      [[&et_foo_error_table;]])],
1226*7f2fe78bSCy Schubert    [], [AC_MSG_ERROR(cannot use et_foo_error_table)])
1227*7f2fe78bSCy Schubert  # Anything else we need to test for?
1228*7f2fe78bSCy Schubert  rm -f conf$$e.c conf$$e.h
1229*7f2fe78bSCy Schubert  krb5_cv_compile_et_useful=yes
1230*7f2fe78bSCy Schubert  ])
1231*7f2fe78bSCy Schubert  AC_CACHE_CHECK(whether compile_et supports --textdomain,
1232*7f2fe78bSCy Schubert                 krb5_cv_compile_et_textdomain,[
1233*7f2fe78bSCy Schubert  krb5_cv_compile_et_textdomain=no
1234*7f2fe78bSCy Schubert  if compile_et --textdomain=xyzw conf$$e.et >/dev/null 2>&1 ; then
1235*7f2fe78bSCy Schubert    if grep -q xyzw conf$$e.c; then
1236*7f2fe78bSCy Schubert      krb5_cv_compile_et_textdomain=yes
1237*7f2fe78bSCy Schubert    fi
1238*7f2fe78bSCy Schubert  fi
1239*7f2fe78bSCy Schubert  rm -f conf$$e.c conf$$e.h
1240*7f2fe78bSCy Schubert  ])
1241*7f2fe78bSCy Schubert  if test "$krb5_cv_compile_et_textdomain" = yes; then
1242*7f2fe78bSCy Schubert    COM_ERR_VERSION=intlsys
1243*7f2fe78bSCy Schubert  fi
1244*7f2fe78bSCy Schubert  rm -f conf$$e.et
1245*7f2fe78bSCy Schubertfi
1246*7f2fe78bSCy SchubertAC_SUBST(COM_ERR_VERSION)
1247*7f2fe78bSCy SchubertAC_SUBST(COM_ERR_LIB)
1248*7f2fe78bSCy SchubertLIBS="$OLDLIBS"
1249*7f2fe78bSCy Schubertif test "$COM_ERR_VERSION" = k5 -o "$COM_ERR_VERSION" = intlsys; then
1250*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_COM_ERR_INTL,1,
1251*7f2fe78bSCy Schubert            [Define if com_err has compatible gettext support])
1252*7f2fe78bSCy Schubertfi
1253*7f2fe78bSCy Schubert])
1254*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_CHOOSE_SS],[
1255*7f2fe78bSCy SchubertAC_ARG_WITH(system-ss,
1256*7f2fe78bSCy Schubert  [AS_HELP_STRING([--with-system-ss],
1257*7f2fe78bSCy Schubert    [use system -lss and mk_cmds @<:@private version@:>@])])
1258*7f2fe78bSCy SchubertAC_ARG_VAR(SS_LIB,[system libraries for 'ss' package [-lss]])
1259*7f2fe78bSCy SchubertAC_MSG_CHECKING(which version of subsystem package to use)
1260*7f2fe78bSCy Schubertif test "x$with_system_ss" = xyes ; then
1261*7f2fe78bSCy Schubert  SS_VERSION=sys
1262*7f2fe78bSCy Schubert  AC_MSG_RESULT(system)
1263*7f2fe78bSCy Schubert  # todo: check for various libraries we might need
1264*7f2fe78bSCy Schubert  # in the meantime...
1265*7f2fe78bSCy Schubert  test "x${SS_LIB+set}" = xset || SS_LIB=-lss
1266*7f2fe78bSCy Schubert  old_LIBS="$LIBS"
1267*7f2fe78bSCy Schubert  LIBS="$LIBS $SS_LIB"
1268*7f2fe78bSCy Schubert  AC_CACHE_CHECK(whether system ss package works, krb5_cv_system_ss_okay,
1269*7f2fe78bSCy Schubert  [AC_RUN_IFELSE(
1270*7f2fe78bSCy Schubert    [AC_LANG_SOURCE(
1271*7f2fe78bSCy Schubert      [[#include <ss/ss.h>
1272*7f2fe78bSCy Schubert        int main(int argc, char *argv[]) {
1273*7f2fe78bSCy Schubert            if (argc == 42) {
1274*7f2fe78bSCy Schubert                int i, err;
1275*7f2fe78bSCy Schubert                i = ss_create_invocation("foo","foo","",0,&err);
1276*7f2fe78bSCy Schubert                ss_listen(i);
1277*7f2fe78bSCy Schubert            }
1278*7f2fe78bSCy Schubert            return 0;
1279*7f2fe78bSCy Schubert        }]])],
1280*7f2fe78bSCy Schubert    [krb5_cv_system_ss_okay=yes], [AC_MSG_ERROR(cannot run test program)],
1281*7f2fe78bSCy Schubert    [krb5_cv_system_ss_okay=assumed])])
1282*7f2fe78bSCy Schubert  LIBS="$old_LIBS"
1283*7f2fe78bSCy Schubert  KRB5_NEED_PROTO([#include <ss/ss.h>],ss_execute_command,1)
1284*7f2fe78bSCy Schubertelse
1285*7f2fe78bSCy Schubert  SS_VERSION=k5
1286*7f2fe78bSCy Schubert  AC_MSG_RESULT(krb5)
1287*7f2fe78bSCy Schubertfi
1288*7f2fe78bSCy SchubertAC_SUBST(SS_LIB)
1289*7f2fe78bSCy SchubertAC_SUBST(SS_VERSION)
1290*7f2fe78bSCy Schubert])
1291*7f2fe78bSCy Schubertdnl
1292*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_CHOOSE_DB],[
1293*7f2fe78bSCy SchubertAC_ARG_WITH(system-db,
1294*7f2fe78bSCy Schubert  [AS_HELP_STRING([--with-system-db],
1295*7f2fe78bSCy Schubert    [use system Berkeley db @<:@private version@:>@])])
1296*7f2fe78bSCy SchubertAC_ARG_VAR(DB_HEADER,[header file for system Berkeley db package [db.h]])
1297*7f2fe78bSCy SchubertAC_ARG_VAR(DB_LIB,[library for system Berkeley db package [-ldb]])
1298*7f2fe78bSCy Schubertif test "x$with_system_db" = xyes ; then
1299*7f2fe78bSCy Schubert  DB_VERSION=sys
1300*7f2fe78bSCy Schubert  # TODO: Do we have specific routines we should check for?
1301*7f2fe78bSCy Schubert  # How about known, easily recognizable bugs?
1302*7f2fe78bSCy Schubert  # We want to use bt_rseq in some cases, but no other version but
1303*7f2fe78bSCy Schubert  # ours has it right now.
1304*7f2fe78bSCy Schubert  #
1305*7f2fe78bSCy Schubert  # Okay, check the variables.
1306*7f2fe78bSCy Schubert  test "x${DB_HEADER+set}" = xset || DB_HEADER=db.h
1307*7f2fe78bSCy Schubert  test "x${DB_LIB+set}" = xset || DB_LIB=-ldb
1308*7f2fe78bSCy Schubert  #
1309*7f2fe78bSCy Schubert  if test "x${DB_HEADER}" = xdb.h ; then
1310*7f2fe78bSCy Schubert    DB_HEADER_VERSION=sys
1311*7f2fe78bSCy Schubert  else
1312*7f2fe78bSCy Schubert    DB_HEADER_VERSION=redirect
1313*7f2fe78bSCy Schubert  fi
1314*7f2fe78bSCy Schubert  KDB5_DB_LIB="$DB_LIB"
1315*7f2fe78bSCy Schubertelse
1316*7f2fe78bSCy Schubert  DB_VERSION=k5
1317*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_BT_RSEQ,1,[Define if bt_rseq is available, for recursive btree traversal.])
1318*7f2fe78bSCy Schubert  DB_HEADER=db.h
1319*7f2fe78bSCy Schubert  DB_HEADER_VERSION=k5
1320*7f2fe78bSCy Schubert  # libdb gets sucked into libkdb
1321*7f2fe78bSCy Schubert  KDB5_DB_LIB=
1322*7f2fe78bSCy Schubert  # needed for a couple of things that need libdb for its own sake
1323*7f2fe78bSCy Schubert  DB_LIB=-ldb
1324*7f2fe78bSCy Schubertfi
1325*7f2fe78bSCy SchubertAC_SUBST(DB_VERSION)
1326*7f2fe78bSCy SchubertAC_SUBST(DB_HEADER)
1327*7f2fe78bSCy SchubertAC_SUBST(DB_HEADER_VERSION)
1328*7f2fe78bSCy SchubertAC_SUBST(DB_LIB)
1329*7f2fe78bSCy SchubertAC_SUBST(KDB5_DB_LIB)
1330*7f2fe78bSCy Schubert])
1331*7f2fe78bSCy Schubertdnl
1332*7f2fe78bSCy Schubertdnl KRB5_AC_PRIOCNTL_HACK
1333*7f2fe78bSCy Schubertdnl
1334*7f2fe78bSCy Schubertdnl
1335*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_PRIOCNTL_HACK],
1336*7f2fe78bSCy Schubert[AC_REQUIRE([AC_PROG_AWK])dnl
1337*7f2fe78bSCy SchubertAC_REQUIRE([AC_LANG_COMPILER_REQUIRE])dnl
1338*7f2fe78bSCy SchubertAC_CACHE_CHECK([whether to use priocntl hack], [krb5_cv_priocntl_hack],
1339*7f2fe78bSCy Schubert[case $krb5_cv_host in
1340*7f2fe78bSCy Schubert*-*-solaris2.9*)
1341*7f2fe78bSCy Schubert	if test "$cross_compiling" = yes; then
1342*7f2fe78bSCy Schubert		krb5_cv_priocntl_hack=yes
1343*7f2fe78bSCy Schubert	else
1344*7f2fe78bSCy Schubert		# Solaris patch 117171-11 (sparc) or 117172-11 (x86)
1345*7f2fe78bSCy Schubert		# fixes the Solaris 9 bug where final pty output
1346*7f2fe78bSCy Schubert		# gets lost on close.
1347*7f2fe78bSCy Schubert		if showrev -p | $AWK 'BEGIN { e = 1 }
1348*7f2fe78bSCy Schubert/Patch: 11717[[12]]/ { x = index[]([$]2, "-");
1349*7f2fe78bSCy Schubertif (substr[]([$]2, x + 1, length([$]2) - x) >= 11)
1350*7f2fe78bSCy Schubert{ e = 0 } else { e = 1 } }
1351*7f2fe78bSCy SchubertEND { exit e; }'; then
1352*7f2fe78bSCy Schubert			krb5_cv_priocntl_hack=no
1353*7f2fe78bSCy Schubert		else
1354*7f2fe78bSCy Schubert			krb5_cv_priocntl_hack=yes
1355*7f2fe78bSCy Schubert		fi
1356*7f2fe78bSCy Schubert	fi
1357*7f2fe78bSCy Schubert	;;
1358*7f2fe78bSCy Schubert*)
1359*7f2fe78bSCy Schubert	krb5_cv_priocntl_hack=no
1360*7f2fe78bSCy Schubert	;;
1361*7f2fe78bSCy Schubertesac])
1362*7f2fe78bSCy Schubertif test "$krb5_cv_priocntl_hack" = yes; then
1363*7f2fe78bSCy Schubert	PRIOCNTL_HACK=1
1364*7f2fe78bSCy Schubertelse
1365*7f2fe78bSCy Schubert	PRIOCNTL_HACK=0
1366*7f2fe78bSCy Schubertfi
1367*7f2fe78bSCy SchubertAC_SUBST(PRIOCNTL_HACK)])
1368*7f2fe78bSCy Schubertdnl
1369*7f2fe78bSCy Schubertdnl
1370*7f2fe78bSCy Schubertdnl KRB5_AC_GCC_ATTRS
1371*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_GCC_ATTRS],
1372*7f2fe78bSCy Schubert[AC_CACHE_CHECK([for constructor/destructor attribute support],krb5_cv_attr_constructor_destructor,
1373*7f2fe78bSCy Schubert[rm -f conftest.1 conftest.2
1374*7f2fe78bSCy Schubertif test -r conftest.1 || test -r conftest.2 ; then
1375*7f2fe78bSCy Schubert  AC_MSG_ERROR(write error in local file system?)
1376*7f2fe78bSCy Schubertfi
1377*7f2fe78bSCy Schuberttrue > conftest.1
1378*7f2fe78bSCy Schuberttrue > conftest.2
1379*7f2fe78bSCy Schubertif test -r conftest.1 && test -r conftest.2 ; then true ; else
1380*7f2fe78bSCy Schubert  AC_MSG_ERROR(write error in local file system?)
1381*7f2fe78bSCy Schubertfi
1382*7f2fe78bSCy Schuberta=no
1383*7f2fe78bSCy Schubertb=no
1384*7f2fe78bSCy Schubert# blindly assume we have 'unlink' and unistd.h.
1385*7f2fe78bSCy SchubertAC_RUN_IFELSE(
1386*7f2fe78bSCy Schubert  [AC_LANG_SOURCE(
1387*7f2fe78bSCy Schubert    [[#include <unistd.h>
1388*7f2fe78bSCy Schubert      void foo1() __attribute__((constructor));
1389*7f2fe78bSCy Schubert      void foo1() { unlink("conftest.1"); }
1390*7f2fe78bSCy Schubert      void foo2() __attribute__((destructor));
1391*7f2fe78bSCy Schubert      void foo2() { unlink("conftest.2"); }
1392*7f2fe78bSCy Schubert      int main () { return 0; }]])],
1393*7f2fe78bSCy Schubert    [test -r conftest.1 || a=yes
1394*7f2fe78bSCy Schubert     test -r conftest.2 || b=yes],
1395*7f2fe78bSCy Schubert  [], [AC_MSG_ERROR(Cannot test for constructor/destructor support when cross compiling)])
1396*7f2fe78bSCy Schubertcase $krb5_cv_host in
1397*7f2fe78bSCy Schubert*-*-aix4.*)
1398*7f2fe78bSCy Schubert	# Under AIX 4.3.3, at least, shared library destructor functions
1399*7f2fe78bSCy Schubert	# appear to get executed in reverse link order (right to left),
1400*7f2fe78bSCy Schubert	# so that a library's destructor function may run after that of
1401*7f2fe78bSCy Schubert	# libraries it depends on, and may still have to access in the
1402*7f2fe78bSCy Schubert	# destructor.
1403*7f2fe78bSCy Schubert	#
1404*7f2fe78bSCy Schubert	# That counts as "not working", for me, but it's a much more
1405*7f2fe78bSCy Schubert	# complicated test case to set up.
1406*7f2fe78bSCy Schubert	b=no
1407*7f2fe78bSCy Schubert	;;
1408*7f2fe78bSCy Schubertesac
1409*7f2fe78bSCy Schubertkrb5_cv_attr_constructor_destructor="$a,$b"
1410*7f2fe78bSCy Schubert])
1411*7f2fe78bSCy Schubert# Okay, krb5_cv_... should be set now.
1412*7f2fe78bSCy Schubertcase $krb5_cv_attr_constructor_destructor in
1413*7f2fe78bSCy Schubert  yes,*)
1414*7f2fe78bSCy Schubert    AC_DEFINE(CONSTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((constructor)) works]) ;;
1415*7f2fe78bSCy Schubertesac
1416*7f2fe78bSCy Schubertcase $krb5_cv_attr_constructor_destructor in
1417*7f2fe78bSCy Schubert  *,yes)
1418*7f2fe78bSCy Schubert    AC_DEFINE(DESTRUCTOR_ATTR_WORKS,1,[Define if __attribute__((destructor)) works]) ;;
1419*7f2fe78bSCy Schubertesac
1420*7f2fe78bSCy Schubertdnl End of attributes we care about right now.
1421*7f2fe78bSCy Schubert])
1422*7f2fe78bSCy Schubertdnl
1423*7f2fe78bSCy Schubertdnl
1424*7f2fe78bSCy Schubertdnl KRB5_AC_PRAGMA_WEAK_REF
1425*7f2fe78bSCy SchubertAC_DEFUN([KRB5_AC_PRAGMA_WEAK_REF],
1426*7f2fe78bSCy Schubert[AC_CACHE_CHECK([whether pragma weak references are supported],
1427*7f2fe78bSCy Schubertkrb5_cv_pragma_weak_ref,
1428*7f2fe78bSCy Schubert[AC_LINK_IFELSE(
1429*7f2fe78bSCy Schubert  [AC_LANG_PROGRAM(
1430*7f2fe78bSCy Schubert    [[#pragma weak flurbl
1431*7f2fe78bSCy Schubert      extern int flurbl(void);]],
1432*7f2fe78bSCy Schubert    [[if (&flurbl != 0) return flurbl();]])],
1433*7f2fe78bSCy Schubert  [krb5_cv_pragma_weak_ref=yes], [krb5_cv_pragma_weak_ref=no])])
1434*7f2fe78bSCy Schubertif test $krb5_cv_pragma_weak_ref = yes ; then
1435*7f2fe78bSCy Schubert  AC_DEFINE(HAVE_PRAGMA_WEAK_REF,1,[Define if #pragma weak references work])
1436*7f2fe78bSCy Schubertfi])
1437*7f2fe78bSCy Schubertdnl
1438*7f2fe78bSCy Schubertdnl
1439*7f2fe78bSCy Schubertm4_include(config/ac-archive/ax_pthread.m4)
1440*7f2fe78bSCy Schubertm4_include(config/ac-archive/ax_recursive_eval.m4)
1441*7f2fe78bSCy Schubertm4_include(config/pkg.m4)
1442*7f2fe78bSCy Schubertdnl
1443*7f2fe78bSCy Schubertdnl
1444*7f2fe78bSCy Schubertdnl
1445*7f2fe78bSCy Schubertdnl --with-ldap=value
1446*7f2fe78bSCy Schubertdnl
1447*7f2fe78bSCy SchubertAC_DEFUN(WITH_LDAP,[
1448*7f2fe78bSCy SchubertAC_ARG_WITH([ldap],
1449*7f2fe78bSCy Schubert[AS_HELP_STRING([--with-ldap], [compile OpenLDAP database backend module])],
1450*7f2fe78bSCy Schubert[case "$withval" in
1451*7f2fe78bSCy Schubert    OPENLDAP) with_ldap=yes ;;
1452*7f2fe78bSCy Schubert    yes | no) ;;
1453*7f2fe78bSCy Schubert    *)  AC_MSG_ERROR(Invalid option value --with-ldap="$withval") ;;
1454*7f2fe78bSCy Schubertesac], with_ldap=no)dnl
1455*7f2fe78bSCy Schubert
1456*7f2fe78bSCy Schubertif test "$with_ldap" = yes; then
1457*7f2fe78bSCy Schubert  AC_MSG_NOTICE(enabling OpenLDAP database backend module support)
1458*7f2fe78bSCy Schubert  OPENLDAP_PLUGIN=yes
1459*7f2fe78bSCy Schubertfi
1460*7f2fe78bSCy Schubert])dnl
1461