]> arthur.barton.de Git - netatalk.git/blob - macros/gssapi-check.m4
User compiler flags were not used in GSSAPI check
[netatalk.git] / macros / gssapi-check.m4
1 dnl Autoconf macro to check for kerberos
2
3 AC_DEFUN([NETATALK_GSSAPI_CHECK], 
4 [
5     FOUND_GSSAPI=no
6     GSSAPI_LIBS=""
7     GSSAPI_CFLAGS=""
8     GSSAPI_LDFLAGS=""
9     save_CFLAGS="$CFLAGS"
10     save_LDFLAGS="$LDFLAGS"
11     save_LIBS="$LIBS"
12
13     AC_ARG_WITH(gssapi,
14         [  --with-gssapi[[=PATH]]    path to GSSAPI for Kerberos V UAM [[auto]]],
15         [compilegssapi=$withval],
16         [compilegssapi=auto]
17     )
18
19     if test x"$compilegssapi" != x"no" ; then
20         if test "x$compilegssapi" != "xyes" -a "x$compilegssapi" != "xauto" ; then
21             export CFLAGS="-I$withval/include"
22             export LDFLAGS="-L$withval/${atalk_libname}"
23             AC_MSG_NOTICE([checking for GSSAPI support in $compilegssapi])
24         fi
25
26         if test x"$compilegssapi" = x"yes" -o x"$compilegssapi" = x"auto" ; then
27             # check for krb5-config from recent MIT and Heimdal kerberos 5
28             AC_PATH_PROG(KRB5_CONFIG, krb5-config)
29             AC_MSG_CHECKING([for working krb5-config that takes --libs gssapi])
30
31             if test -x "$KRB5_CONFIG" ; then 
32                 TEMP="`$KRB5_CONFIG --libs gssapi`"
33                 if test $? -eq 0 ; then 
34                     GSSAPI_CFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
35                     GSSAPI_LIBS="$TEMP"
36                     FOUND_GSSAPI=yes
37                     AC_MSG_RESULT(yes)
38                 else
39                     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
40                 fi
41             else
42                 AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
43             fi
44         fi
45     fi
46
47     if test x"$compilegssapi" != x"no" -a x"$FOUND_GSSAPI" = x"no" ; then
48         # check for gssapi headers
49         gss_headers_found=no
50         AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_krb5.h,
51             [gss_headers_found=yes])
52         if test x"$gss_headers_found" = x"no" ; then
53             AC_MSG_ERROR([GSSAPI installation not found, headers missing])
54         fi
55         # check for libs
56         AC_SEARCH_LIBS(gss_display_status, [gss gssapi gssapi_krb5])
57         if test x"$ac_cv_search_gss_display_status" = x"no" ; then
58             AC_MSG_ERROR([GSSAPI installation not found, library missing])
59         fi
60         GSSAPI_CFLAGS="$CFLAGS"
61         GSSAPI_LIBS="$LIBS"
62         FOUND_GSSAPI=yes
63     fi
64
65     if test x"$FOUND_GSSAPI" = x"yes" ; then
66         # check for functions
67         export CFLAGS="$GSSAPI_CFLAGS"
68         export LIBS="$GSSAPI_LIBS"
69         AC_CHECK_FUNC(gss_acquire_cred, [], [AC_MSG_ERROR([GSSAPI: required function gss_acquire_cred missing])])
70
71         # Heimdal/MIT compatibility fix
72         if test "$ac_cv_header_gssapi_h" = "yes" ; then
73             AC_EGREP_HEADER(
74                 GSS_C_NT_HOSTBASED_SERVICE,
75                 gssapi.h,
76                 AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE, 1, [Wheter GSS_C_NT_HOSTBASED_SERVICE is in gssapi.h])
77             )
78         else
79             AC_EGREP_HEADER(
80                 GSS_C_NT_HOSTBASED_SERVICE,
81                 gssapi/gssapi.h,
82                 AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE, 1, [Wheter GSS_C_NT_HOSTBASED_SERVICE is in gssapi.h])
83             )
84         fi
85
86         AC_DEFINE(HAVE_GSSAPI, 1, [Whether to enable GSSAPI support])
87         if test x"$ac_cv_func_gss_acquire_cred" = x"yes" ; then
88                 ifelse([$1], , :, [$1])
89         else
90                 ifelse([$2], , :, [$2])
91         fi
92     fi
93
94     AC_SUBST(GSSAPI_LIBS)
95     AC_SUBST(GSSAPI_CFLAGS)
96     AC_SUBST(GSSAPI_LDFLAGS)
97
98     export LIBS="$save_LIBS"
99     export CFLAGS="$save_CFLAGS"
100     export LDFLAGS="$save_LDFLAGS"
101 ])