1 | dnl gssapi.m4 -- Find the compiler and linker flags for GSS-API. |
---|
2 | dnl |
---|
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 |
---|
8 | dnl Provides the macro RRA_LIB_GSSAPI and sets the substitution variables |
---|
9 | dnl GSSAPI_CPPFLAGS, GSSAPI_LDFLAGS, and GSSAPI_LIBS. Also provides |
---|
10 | dnl RRA_LIB_GSSAPI_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the |
---|
11 | dnl GSS-API libraries, saving the ecurrent values, and RRA_LIB_GSSAPI_RESTORE |
---|
12 | dnl to restore those settings to before the last RRA_LIB_GSSAPI_SWITCH. |
---|
13 | dnl |
---|
14 | dnl Depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_SET_LDFLAGS. |
---|
15 | dnl |
---|
16 | dnl Written by Russ Allbery <rra@stanford.edu> |
---|
17 | dnl Copyright 2005, 2006, 2007, 2008, 2009 |
---|
18 | dnl Board of Trustees, Leland Stanford Jr. University |
---|
19 | dnl |
---|
20 | dnl See LICENSE for licensing terms. |
---|
21 | |
---|
22 | dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to |
---|
23 | dnl versions that include the GSS-API flags. Used as a wrapper, with |
---|
24 | dnl RRA_LIB_GSSAPI_RESTORE, around tests. |
---|
25 | AC_DEFUN([RRA_LIB_GSSAPI_SWITCH], |
---|
26 | [rra_gssapi_save_CPPFLAGS="$CPPFLAGS" |
---|
27 | rra_gssapi_save_LDFLAGS="$LDFLAGS" |
---|
28 | rra_gssapi_save_LIBS="$LIBS" |
---|
29 | CPPFLAGS="$GSSAPI_CPPFLAGS $CPPFLAGS" |
---|
30 | LDFLAGS="$GSSAPI_LDFLAGS $LDFLAGS" |
---|
31 | LIBS="$GSSAPI_LIBS $LIBS"]) |
---|
32 | |
---|
33 | dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before |
---|
34 | dnl RRA_LIB_GSSAPI_SWITCH was called). |
---|
35 | AC_DEFUN([RRA_LIB_GSSAPI_RESTORE], |
---|
36 | [CPPFLAGS="$rra_gssapi_save_CPPFLAGS" |
---|
37 | LDFLAGS="$rra_gssapi_save_LDFLAGS" |
---|
38 | LIBS="$rra_gssapi_save_LIBS"]) |
---|
39 | |
---|
40 | dnl Set GSSAPI_CPPFLAGS and GSSAPI_LDFLAGS based on rra_gssapi_root, |
---|
41 | dnl rra_gssapi_libdir, and rra_gssapi_includedir. |
---|
42 | AC_DEFUN([_RRA_LIB_GSSAPI_PATHS], |
---|
43 | [AS_IF([test x"$rra_gssapi_libdir" != x], |
---|
44 | [GSSAPI_LDFLAGS="-L$rra_gssapi_libdir"], |
---|
45 | [AS_IF([test x"$rra_gssapi_root" != x], |
---|
46 | [RRA_SET_LDFLAGS([GSSAPI_LDFLAGS], [$rra_gssapi_root])])]) |
---|
47 | AS_IF([test x"$rra_gssapi_includedir" != x], |
---|
48 | [GSSAPI_CPPFLAGS="-I$rra_gssapi_includedir"], |
---|
49 | [AS_IF([test x"$rra_gssapi_root" != x], |
---|
50 | [AS_IF([test x"$rra_gssapi_root" != x/usr], |
---|
51 | [GSSAPI_CPPFLAGS="-I${rra_gssapi_root}/include"])])])]) |
---|
52 | |
---|
53 | dnl Does the appropriate library checks for reduced-dependency GSS-API |
---|
54 | dnl linkage. |
---|
55 | AC_DEFUN([_RRA_LIB_GSSAPI_REDUCED], |
---|
56 | [RRA_LIB_GSSAPI_SWITCH |
---|
57 | AC_CHECK_LIB([gssapi_krb5], [gss_import_name], [GSSAPI_LIBS="-lgssapi_krb5"], |
---|
58 | [AC_CHECK_LIB([gssapi], [gss_import_name], [GSSAPI_LIBS="-lgssapi"], |
---|
59 | [AC_CHECK_LIB([gss], [gss_import_name], [GSSAPI_LIBS="-lgss"], |
---|
60 | [AC_MSG_ERROR([cannot find usable GSS-API library])])])])]) |
---|
61 | |
---|
62 | dnl Does the appropriate library checks for GSS-API linkage when we don't |
---|
63 | dnl have krb5-config or reduced dependencies. libgss is used as a last |
---|
64 | dnl resort, since it may be a non-functional mech-independent wrapper, but |
---|
65 | dnl it's the right choice on Solaris 10. |
---|
66 | AC_DEFUN([_RRA_LIB_GSSAPI_MANUAL], |
---|
67 | [RRA_LIB_GSSAPI_SWITCH |
---|
68 | rra_gssapi_extra= |
---|
69 | LIBS= |
---|
70 | AC_SEARCH_LIBS([res_search], [resolv], , |
---|
71 | [AC_SEARCH_LIBS([__res_search], [resolv])]) |
---|
72 | AC_SEARCH_LIBS([gethostbyname], [nsl]) |
---|
73 | AC_SEARCH_LIBS([socket], [socket], , |
---|
74 | [AC_CHECK_LIB([nsl], [socket], [LIBS="-lnsl -lsocket $LIBS"], , |
---|
75 | [-lsocket])]) |
---|
76 | AC_SEARCH_LIBS([crypt], [crypt]) |
---|
77 | rra_gssapi_extra="$LIBS" |
---|
78 | LIBS="$rra_gssapi_save_LIBS" |
---|
79 | AC_CHECK_LIB([gssapi], [gss_import_name], |
---|
80 | [GSSAPI_LIBS="-lgssapi -lkrb5 -lasn1 -lroken -lcrypto -lcom_err" |
---|
81 | GSSAPI_LIBS="$GSSAPI_LIBS $rra_gssapi_extra"], |
---|
82 | [AC_CHECK_LIB([krb5support], [krb5int_getspecific], |
---|
83 | [rra_gssapi_extra="-lkrb5support $rra_gssapi_extra"], |
---|
84 | [AC_CHECK_LIB([pthreads], [pthread_setspecific], |
---|
85 | [rra_gssapi_pthread="-lpthreads"], |
---|
86 | [AC_CHECK_LIB([pthread], [pthread_setspecific], |
---|
87 | [rra_gssapi_pthread="-lpthread"])]) |
---|
88 | AC_CHECK_LIB([krb5support], [krb5int_setspecific], |
---|
89 | [rra_gssapi_extra="-lkrb5support $rra_gssapi_extra" |
---|
90 | rra_gssapi_extra="$rra_gssapi_extra $rra_gssapi_pthread"], , |
---|
91 | [$rra_gssapi_pthread])]) |
---|
92 | AC_CHECK_LIB([com_err], [error_message], |
---|
93 | [rra_gssapi_extra="-lcom_err $rra_gssapi_extra"]) |
---|
94 | AC_CHECK_LIB([k5crypto], [krb5int_hash_md5], |
---|
95 | [rra_gssapi_extra="-lk5crypto $rra_gssapi_extra"]) |
---|
96 | rra_gssapi_extra="-lkrb5 $rra_gssapi_extra" |
---|
97 | AC_CHECK_LIB([gssapi_krb5], [gss_import_name], |
---|
98 | [GSSAPI_LIBS="-lgssapi_krb5 $rra_gssapi_extra"], |
---|
99 | [AC_CHECK_LIB([gss], [gss_import_name], |
---|
100 | [GSSAPI_LIBS="-lgss"], |
---|
101 | [AC_MSG_ERROR([cannot find usable GSS-API library])])], |
---|
102 | [$rra_gssapi_extra])], |
---|
103 | [-lkrb5 -lasn1 -lroken -lcrypto -lcom_err $rra_gssapi_extra]) |
---|
104 | RRA_LIB_GSSAPI_RESTORE]) |
---|
105 | |
---|
106 | dnl Sanity-check the results of krb5-config and be sure we can really link a |
---|
107 | dnl GSS-API program. |
---|
108 | AC_DEFUN([_RRA_LIB_GSSAPI_CHECK], |
---|
109 | [RRA_LIB_GSSAPI_SWITCH |
---|
110 | AC_CHECK_FUNC([gss_import_name], , |
---|
111 | [AC_MSG_FAILURE([krb5-config results fail for GSS-API])]) |
---|
112 | RRA_LIB_GSSAPI_RESTORE]) |
---|
113 | |
---|
114 | dnl The main macro. |
---|
115 | AC_DEFUN([RRA_LIB_GSSAPI], |
---|
116 | [AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS]) |
---|
117 | rra_gssapi_root= |
---|
118 | rra_gssapi_libdir= |
---|
119 | rra_gssapi_includedir= |
---|
120 | GSSAPI_CPPFLAGS= |
---|
121 | GSSAPI_LDFLAGS= |
---|
122 | GSSAPI_LIBS= |
---|
123 | AC_SUBST([GSSAPI_CPPFLAGS]) |
---|
124 | AC_SUBST([GSSAPI_LDFLAGS]) |
---|
125 | AC_SUBST([GSSAPI_LIBS]) |
---|
126 | |
---|
127 | AC_ARG_WITH([gssapi], |
---|
128 | [AC_HELP_STRING([--with-gssapi=DIR], |
---|
129 | [Location of GSS-API headers and libraries])], |
---|
130 | [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], |
---|
131 | [rra_gssapi_root="$withval"])]) |
---|
132 | AC_ARG_WITH([gssapi-include], |
---|
133 | [AC_HELP_STRING([--with-gssapi-include=DIR], |
---|
134 | [Location of GSS-API headers])], |
---|
135 | [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], |
---|
136 | [rra_gssapi_includedir="$withval"])]) |
---|
137 | AC_ARG_WITH([gssapi-lib], |
---|
138 | [AC_HELP_STRING([--with-gssapi-lib=DIR], |
---|
139 | [Location of GSS-API libraries])], |
---|
140 | [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], |
---|
141 | [rra_gssapi_libdir="$withval"])]) |
---|
142 | |
---|
143 | AS_IF([test x"$rra_reduced_depends" = xtrue], |
---|
144 | [_RRA_LIB_GSSAPI_PATHS |
---|
145 | _RRA_LIB_GSSAPI_REDUCED], |
---|
146 | [AC_ARG_VAR([KRB5_CONFIG], [Path to krb5-config]) |
---|
147 | AS_IF([test x"$rra_gssapi_root" != x], |
---|
148 | [AS_IF([test -x "${rra_gssapi_root}/bin/krb5-config"], |
---|
149 | [KRB5_CONFIG="${rra_gssapi_root}/bin/krb5-config"])], |
---|
150 | [AC_PATH_PROG([KRB5_CONFIG], [krb5-config])]) |
---|
151 | AS_IF([test x"$KRB5_CONFIG" != x], |
---|
152 | [AC_CACHE_CHECK([for gssapi support in krb5-config], |
---|
153 | [rra_cv_lib_gssapi_config], |
---|
154 | [AS_IF(["$KRB5_CONFIG" | grep gssapi > /dev/null 2>&1], |
---|
155 | [rra_cv_lib_gssapi_config=yes], |
---|
156 | [rra_cv_lib_gssapi_config=no])]) |
---|
157 | AS_IF([test "$rra_cv_lib_gssapi_config" = yes], |
---|
158 | [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags gssapi` |
---|
159 | GSSAPI_LIBS=`"$KRB5_CONFIG" --libs gssapi`], |
---|
160 | [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags` |
---|
161 | GSSAPI_LIBS=`"$KRB5_CONFIG" --libs`]) |
---|
162 | GSSAPI_CPPFLAGS=`echo "$GSSAPI_CPPFLAGS" \ |
---|
163 | | sed 's%-I/usr/include ?%%'` |
---|
164 | _RRA_LIB_GSSAPI_CHECK], |
---|
165 | [_RRA_LIB_GSSAPI_PATHS |
---|
166 | _RRA_LIB_GSSAPI_MANUAL])])]) |
---|