1 dnl Find the compiler and linker flags for GSS-API.
3 dnl Finds the compiler and linker flags for linking with GSS-API libraries.
4 dnl Provides the --with-gssapi, --with-gssapi-include, and --with-gssapi-lib
5 dnl configure option to specify a non-standard path to the GSS-API libraries.
6 dnl Uses krb5-config where available unless reduced dependencies is requested
7 dnl or --with-gssapi-include or --with-gssapi-lib are given.
9 dnl Provides the macro RRA_LIB_GSSAPI and sets the substitution variables
10 dnl GSSAPI_CPPFLAGS, GSSAPI_LDFLAGS, and GSSAPI_LIBS. Also provides
11 dnl RRA_LIB_GSSAPI_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
12 dnl GSS-API libraries, saving the ecurrent values, and RRA_LIB_GSSAPI_RESTORE
13 dnl to restore those settings to before the last RRA_LIB_GSSAPI_SWITCH.
15 dnl Also provides RRA_INCLUDES_KRB5, which are the headers to include when
16 dnl probing the Kerberos library properties.
18 dnl Depends on RRA_KRB5_CONFIG, RRA_ENABLE_REDUCED_DEPENDS, and
21 dnl The canonical version of this file is maintained in the rra-c-util
22 dnl package, available at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
24 dnl Written by Russ Allbery <rra@stanford.edu>
25 dnl Copyright 2005, 2006, 2007, 2008, 2009, 2011, 2012
26 dnl The Board of Trustees of the Leland Stanford Junior University
28 dnl This file is free software; the authors give unlimited permission to copy
29 dnl and/or distribute it, with or without modifications, as long as this
30 dnl notice is preserved.
32 dnl Headers to include when probing for Kerberos library properties.
33 AC_DEFUN([RRA_INCLUDES_GSSAPI], [[
34 #ifdef HAVE_GSSAPI_GSSAPI_H
35 # include <gssapi/gssapi.h>
39 #ifdef HAVE_GSSAPI_GSSAPI_KRB5_H
40 # include <gssapi/gssapi_krb5.h>
44 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
45 dnl versions that include the GSS-API flags. Used as a wrapper, with
46 dnl RRA_LIB_GSSAPI_RESTORE, around tests.
47 AC_DEFUN([RRA_LIB_GSSAPI_SWITCH],
48 [rra_gssapi_save_CPPFLAGS="$CPPFLAGS"
49 rra_gssapi_save_LDFLAGS="$LDFLAGS"
50 rra_gssapi_save_LIBS="$LIBS"
51 CPPFLAGS="$GSSAPI_CPPFLAGS $CPPFLAGS"
52 LDFLAGS="$GSSAPI_LDFLAGS $LDFLAGS"
53 LIBS="$GSSAPI_LIBS $LIBS"])
55 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
56 dnl RRA_LIB_GSSAPI_SWITCH was called).
57 AC_DEFUN([RRA_LIB_GSSAPI_RESTORE],
58 [CPPFLAGS="$rra_gssapi_save_CPPFLAGS"
59 LDFLAGS="$rra_gssapi_save_LDFLAGS"
60 LIBS="$rra_gssapi_save_LIBS"])
62 dnl Set GSSAPI_CPPFLAGS and GSSAPI_LDFLAGS based on rra_gssapi_root,
63 dnl rra_gssapi_libdir, and rra_gssapi_includedir.
64 AC_DEFUN([_RRA_LIB_GSSAPI_PATHS],
65 [AS_IF([test x"$rra_gssapi_libdir" != x],
66 [GSSAPI_LDFLAGS="-L$rra_gssapi_libdir"],
67 [AS_IF([test x"$rra_gssapi_root" != x],
68 [RRA_SET_LDFLAGS([GSSAPI_LDFLAGS], [$rra_gssapi_root])])])
69 AS_IF([test x"$rra_gssapi_includedir" != x],
70 [GSSAPI_CPPFLAGS="-I$rra_gssapi_includedir"],
71 [AS_IF([test x"$rra_gssapi_root" != x],
72 [AS_IF([test x"$rra_gssapi_root" != x/usr],
73 [GSSAPI_CPPFLAGS="-I${rra_gssapi_root}/include"])])])])
75 dnl Does the appropriate library checks for reduced-dependency GSS-API
77 AC_DEFUN([_RRA_LIB_GSSAPI_REDUCED],
78 [RRA_LIB_GSSAPI_SWITCH
79 AC_CHECK_LIB([gssapi_krb5], [gss_import_name], [GSSAPI_LIBS="-lgssapi_krb5"],
80 [AC_CHECK_LIB([gssapi], [gss_import_name], [GSSAPI_LIBS="-lgssapi"],
81 [AC_CHECK_LIB([gss], [gss_import_name], [GSSAPI_LIBS="-lgss"],
82 [AC_MSG_ERROR([cannot find usable GSS-API library])])])])
83 RRA_LIB_GSSAPI_RESTORE])
85 dnl Does the appropriate library checks for GSS-API linkage when we don't
86 dnl have krb5-config or reduced dependencies. libgss is used as a last
87 dnl resort, since it may be a non-functional mech-independent wrapper, but
88 dnl it's the right choice on Solaris 10.
89 AC_DEFUN([_RRA_LIB_GSSAPI_MANUAL],
90 [RRA_LIB_GSSAPI_SWITCH
93 AC_SEARCH_LIBS([res_search], [resolv], [],
94 [AC_SEARCH_LIBS([__res_search], [resolv])])
95 AC_SEARCH_LIBS([gethostbyname], [nsl])
96 AC_SEARCH_LIBS([socket], [socket], [],
97 [AC_CHECK_LIB([nsl], [socket], [LIBS="-lnsl -lsocket $LIBS"], [],
99 AC_SEARCH_LIBS([crypt], [crypt])
100 AC_SEARCH_LIBS([rk_simple_execve], [roken])
101 rra_gssapi_extra="$LIBS"
102 LIBS="$rra_gssapi_save_LIBS"
103 AC_CHECK_LIB([gssapi], [gss_import_name],
104 [GSSAPI_LIBS="-lgssapi -lkrb5 -lasn1 -lcrypto -lcom_err $rra_gssapi_extra"],
105 [AC_CHECK_LIB([krb5support], [krb5int_getspecific],
106 [rra_gssapi_extra="-lkrb5support $rra_gssapi_extra"],
107 [AC_CHECK_LIB([pthreads], [pthread_setspecific],
108 [rra_gssapi_pthread="-lpthreads"],
109 [AC_CHECK_LIB([pthread], [pthread_setspecific],
110 [rra_gssapi_pthread="-lpthread"])])
111 AC_CHECK_LIB([krb5support], [krb5int_setspecific],
112 [rra_gssapi_extra="-lkrb5support $rra_gssapi_extra"
113 rra_gssapi_extra="$rra_gssapi_extra $rra_gssapi_pthread"], [],
114 [$rra_gssapi_pthread])])
115 AC_CHECK_LIB([com_err], [error_message],
116 [rra_gssapi_extra="-lcom_err $rra_gssapi_extra"])
117 AC_CHECK_LIB([k5crypto], [krb5int_hash_md5],
118 [rra_gssapi_extra="-lk5crypto $rra_gssapi_extra"])
119 rra_gssapi_extra="-lkrb5 $rra_gssapi_extra"
120 AC_CHECK_LIB([gssapi_krb5], [gss_import_name],
121 [GSSAPI_LIBS="-lgssapi_krb5 $rra_gssapi_extra"],
122 [AC_CHECK_LIB([gss], [gss_import_name],
123 [GSSAPI_LIBS="-lgss"],
124 [AC_MSG_ERROR([cannot find usable GSS-API library])])],
125 [$rra_gssapi_extra])],
126 [-lkrb5 -lasn1 -lcrypto -lcom_err $rra_gssapi_extra])
127 RRA_LIB_GSSAPI_RESTORE])
129 dnl Sanity-check the results of krb5-config and be sure we can really link a
130 dnl GSS-API program. If not, fall back on the manual check.
131 AC_DEFUN([_RRA_LIB_GSSAPI_CHECK],
132 [RRA_LIB_GSSAPI_SWITCH
133 AC_CHECK_FUNC([gss_import_name],
134 [RRA_LIB_GSSAPI_RESTORE],
135 [RRA_LIB_GSSAPI_RESTORE
138 _RRA_LIB_GSSAPI_PATHS
139 _RRA_LIB_GSSAPI_MANUAL])])
141 dnl Determine GSS-API compiler and linker flags from krb5-config.
142 AC_DEFUN([_RRA_LIB_GSSAPI_CONFIG],
143 [RRA_KRB5_CONFIG([${rra_gssapi_root}], [gssapi], [GSSAPI],
144 [_RRA_LIB_GSSAPI_CHECK],
145 [_RRA_LIB_GSSAPI_PATHS
146 _RRA_LIB_GSSAPI_MANUAL])])
148 dnl Check for a header using a file existence check rather than using
149 dnl AC_CHECK_HEADERS. This is used if there were arguments to configure
150 dnl specifying the GSS-API library path, since we may have one header in the
151 dnl default include path and another under our explicitly-configured GSS-API
153 AC_DEFUN([_RRA_LIB_GSSAPI_CHECK_HEADER],
154 [AC_MSG_CHECKING([for $1])
155 AS_IF([test -f "${rra_gssapi_incroot}/$1"],
156 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
157 [Define to 1 if you have the <$1> header file.])
158 AC_MSG_RESULT([yes])],
159 [AC_MSG_RESULT([no])])])
161 dnl Determine the GSS-API header location and probe for some other
162 dnl characteristics of the libraries. We use a file existence check rather
163 dnl than letting the compiler probe for the right header location
164 AC_DEFUN([_RRA_LIB_GSSAPI_EXTRA],
166 AS_IF([test x"$rra_gssapi_includedir" != x],
167 [rra_gssapi_incroot="$rra_gssapi_includedir"],
168 [AS_IF([test x"$rra_gssapi_root" != x],
169 [rra_gssapi_incroot="${rra_gssapi_root}/include"])])
170 AS_IF([test x"$rra_gssapi_incroot" = x],
171 [AC_CHECK_HEADERS([gssapi/gssapi.h gssapi/gssapi_krb5.h])],
172 [_RRA_LIB_GSSAPI_CHECK_HEADER([gssapi/gssapi.h])
173 _RRA_LIB_GSSAPI_CHECK_HEADER([gssapi/gssapi_krb5.h])])
174 AC_CHECK_DECL([GSS_C_NT_USER_NAME],
175 [AC_DEFINE([HAVE_GSS_RFC_OIDS], 1,
176 [Define to 1 if the GSS-API library uses RFC-compliant OIDs.])], [],
177 [RRA_INCLUDES_GSSAPI])])
180 AC_DEFUN([RRA_LIB_GSSAPI],
181 [AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS])
184 rra_gssapi_includedir=
188 AC_SUBST([GSSAPI_CPPFLAGS])
189 AC_SUBST([GSSAPI_LDFLAGS])
190 AC_SUBST([GSSAPI_LIBS])
192 AC_ARG_WITH([gssapi],
193 [AS_HELP_STRING([--with-gssapi=DIR],
194 [Location of GSS-API headers and libraries])],
195 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
196 [rra_gssapi_root="$withval"])])
197 AC_ARG_WITH([gssapi-include],
198 [AS_HELP_STRING([--with-gssapi-include=DIR],
199 [Location of GSS-API headers])],
200 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
201 [rra_gssapi_includedir="$withval"])])
202 AC_ARG_WITH([gssapi-lib],
203 [AS_HELP_STRING([--with-gssapi-lib=DIR],
204 [Location of GSS-API libraries])],
205 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
206 [rra_gssapi_libdir="$withval"])])
208 AS_IF([test x"$rra_reduced_depends" = xtrue],
209 [_RRA_LIB_GSSAPI_PATHS
210 _RRA_LIB_GSSAPI_REDUCED],
211 [AS_IF([test x"$rra_gssapi_includedir" = x \
212 && test x"$rra_gssapi_libdir" = x],
213 [_RRA_LIB_GSSAPI_CONFIG],
214 [_RRA_LIB_GSSAPI_PATHS
215 _RRA_LIB_GSSAPI_MANUAL])])
217 RRA_LIB_GSSAPI_SWITCH
218 _RRA_LIB_GSSAPI_EXTRA
219 RRA_LIB_GSSAPI_RESTORE])