xref: /openbsd/gnu/usr.bin/cvs/acinclude.m4 (revision 09467b48)
1/* This program is free software; you can redistribute it and/or modify
2   it under the terms of the GNU General Public License as published by
3   the Free Software Foundation; either version 2, or (at your option)
4   any later version.
5
6   This program is distributed in the hope that it will be useful,
7   but WITHOUT ANY WARRANTY; without even the implied warranty of
8   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9   GNU General Public License for more details.  */
10
11AC_DEFUN(ACX_WITH_GSSAPI,[
12#
13# Use --with-gssapi[=DIR] to enable GSSAPI support.
14#
15# defaults to enabled with DIR in default list below
16#
17# Search for /SUNHEA/ and read the comments about this default below.
18#
19AC_ARG_WITH([gssapi],
20	    [  --with-gssapi=value     GSSAPI directory],
21	    [acx_gssapi_withgssapi=$withval], [acx_gssapi_withgssapi=yes])dnl
22
23dnl
24dnl FIXME - cache withval and obliterate later cache values when options change
25dnl
26#
27# Try to locate a GSSAPI installation if no location was specified, assuming
28# GSSAPI was enabled (the default).
29#
30if test -n "$acx_gssapi_cv_gssapi"; then
31  # Granted, this is a slightly ugly way to print this info, but the
32  # AC_CHECK_HEADER used in the search for a GSSAPI installation makes using
33  # AC_CACHE_CHECK worse
34  AC_MSG_CHECKING([for GSSAPI])
35else :; fi
36AC_CACHE_VAL([acx_gssapi_cv_gssapi], [
37if test x$acx_gssapi_withgssapi = xyes; then
38  # --with but no location specified
39  # assume a gssapi.h or gssapi/gssapi.h locates our install.
40  #
41  # This isn't always strictly true.  For instance Solaris 7's SUNHEA (header)
42  # package installs gssapi.h whether or not the necessary libraries are
43  # installed.  I'm still not sure whether to consider this a bug.  The long
44  # way around is to not consider GSSPAI installed unless gss_import_name is
45  # found, but that brings up a lot of other hassles, like continuing to let
46  # gcc & ld generate the error messages when the user uses --with-gssapi=dir
47  # as a debugging aid.  The short way around is to disable GSSAPI by default,
48  # but I think Sun users have been faced with this for awhile and I haven't
49  # heard many complaints.
50  acx_gssapi_save_CPPFLAGS=$CPPFLAGS
51  for acx_gssapi_cv_gssapi in yes /usr/kerberos /usr/cygnus/kerbnet no; do
52    if test x$acx_gssapi_cv_gssapi = xno; then
53      break
54    fi
55    if test x$acx_gssapi_cv_gssapi = xyes; then
56      AC_CHECKING([for GSSAPI])
57    else
58      CPPFLAGS="$acx_gssapi_save_CPPFLAGS -I$acx_gssapi_cv_gssapi/include"
59      AC_CHECKING([for GSSAPI in $acx_gssapi_cv_gssapi])
60    fi
61    unset ac_cv_header_gssapi_h
62    unset ac_cv_header_gssapi_gssapi_h
63    AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
64    if test "$ac_cv_header_gssapi_h" = "yes" ||
65        test "$ac_cv_header_gssapi_gssapi_h" = "yes"; then
66      break
67    fi
68  done
69  CPPFLAGS=$acx_gssapi_save_CPPFLAGS
70else
71  acx_gssapi_cv_gssapi=$acx_gssapi_withgssapi
72fi
73AC_MSG_CHECKING([for GSSAPI])
74])dnl
75AC_MSG_RESULT([$acx_gssapi_cv_gssapi])
76
77#
78# Set up GSSAPI includes for later use.  We don't bother to check for
79# $acx_gssapi_cv_gssapi=no here since that will be caught later.
80#
81if test x$acx_gssapi_cv_gssapi = yes; then
82  # no special includes necessary
83  GSSAPI_INCLUDES=""
84else
85  # GSSAPI at $acx_gssapi_cv_gssapi (could be 'no')
86  GSSAPI_INCLUDES=" -I$acx_gssapi_cv_gssapi/include"
87fi
88
89#
90# Get the rest of the information CVS needs to compile with GSSAPI support
91#
92if test x$acx_gssapi_cv_gssapi != xno; then
93  # define HAVE_GSSAPI and set up the includes
94  AC_DEFINE([HAVE_GSSAPI],, [Define if you have GSSAPI with Kerberos version 5 available.])
95  includeopt=$includeopt$GSSAPI_INCLUDES
96
97  # locate any other headers
98  acx_gssapi_save_CPPFLAGS=$CPPFLAGS
99  CPPFLAGS=$CPPFLAGS$GSSAPI_INCLUDES
100  dnl We don't use HAVE_KRB5_H anywhere, but including it here might make it
101  dnl easier to spot errors by reading configure output
102  AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h krb5.h])
103  # And look through them for GSS_C_NT_HOSTBASED_SERVICE or its alternatives
104  AC_CACHE_CHECK([for GSS_C_NT_HOSTBASED_SERVICE], [acx_gssapi_cv_gss_c_nt_hostbased_service],
105   [acx_gssapi_cv_gss_c_nt_hostbased_service=no
106    if test "$ac_cv_header_gssapi_h" = "yes"; then
107      AC_EGREP_HEADER([GSS_C_NT_HOSTBASED_SERVICE], [gssapi.h],
108		      [acx_gssapi_cv_gss_c_nt_hostbased_service=yes],
109		      AC_EGREP_HEADER([gss_nt_service_name], [gssapi.h],
110				      [acx_gssapi_cv_gss_c_nt_hostbased_service=gss_nt_service_name]))
111    fi
112    if test $acx_gssapi_cv_gss_c_nt_hostbased_service = no &&
113        test "$ac_cv_header_gssapi_gssapi_h" = "yes"; then
114      AC_EGREP_HEADER([GSS_C_NT_HOSTBASED_SERVICE], [gssapi/gssapi.h],
115		      [acx_gssapi_cv_gss_c_nt_hostbased_service],
116		      AC_EGREP_HEADER([gss_nt_service_name], [gssapi/gssapi.h],
117				      [acx_gssapi_cv_gss_c_nt_hostbased_service=gss_nt_service_name]))
118    fi
119    if test $acx_gssapi_cv_gss_c_nt_hostbased_service = no &&
120        test "$ac_cv_header_gssapi_gssapi_generic_h" = "yes"; then
121      AC_EGREP_HEADER([GSS_C_NT_HOSTBASED_SERVICE], [gssapi/gssapi_generic.h],
122		      [acx_gssapi_cv_gss_c_nt_hostbased_service],
123		      AC_EGREP_HEADER([gss_nt_service_name], [gssapi/gssapi_generic.h],
124				      [acx_gssapi_cv_gss_c_nt_hostbased_service=gss_nt_service_name]))
125    fi])
126  if test $acx_gssapi_cv_gss_c_nt_hostbased_service != yes &&
127      test $acx_gssapi_cv_gss_c_nt_hostbased_service != no; then
128    # don't define for yes since that means it already means something and
129    # don't define for no since we'd rather the compiler catch the error
130    AC_DEFINE_UNQUOTED([GSS_C_NT_HOSTBASED_SERVICE], [$acx_gssapi_cv_gss_c_nt_hostbased_service],
131[Define to an alternative value if GSS_C_NT_HOSTBASED_SERVICE isn't defined
132in the gssapi.h header file.  MIT Kerberos 1.2.1 requires this.  Only relevant
133when using GSSAPI.])
134  fi
135  CPPFLAGS=$acx_gssapi_save_CPPFLAGS
136
137  # Expect the libs to be installed parallel to the headers
138  #
139  # We could try once with and once without, but I'm not sure it's worth the
140  # trouble.
141  if test x$acx_gssapi_cv_gssapi != xyes; then
142    if test -z "$LIBS"; then
143      LIBS="-L$acx_gssapi_cv_gssapi/lib"
144    else
145      LIBS="-L$acx_gssapi_cv_gssapi/lib $LIBS"
146    fi
147  else :; fi
148
149  dnl What happens if we want to enable, say, krb5 and some other GSSAPI
150  dnl authentication method at the same time?
151  #
152  # Some of the order below is particular due to library dependencies
153  #
154
155  #
156  # des			Heimdal K 0.3d, but Heimdal seems to be set up such
157  #			that it could have been installed from elsewhere.
158  #
159  AC_SEARCH_LIBS([des_set_odd_parity], [des])
160
161  #
162  # com_err		Heimdal K 0.3d
163  #
164  # com_err		MIT K5 v1.2.2-beta1
165  #
166  AC_SEARCH_LIBS([com_err], [com_err])
167
168  #
169  # asn1		Heimdal K 0.3d		-lcom_err
170  #
171  AC_SEARCH_LIBS([initialize_asn1_error_table_r], [asn1])
172
173  #
174  # resolv		required, but not installed by Heimdal K 0.3d
175  #
176  # resolv		MIT K5 1.2.2-beta1
177  # 			Linux 2.2.17
178  #
179  AC_SEARCH_LIBS([__dn_expand], [resolv])
180
181  #
182  # roken		Heimdal K 0.3d		-lresolv
183  #
184  AC_SEARCH_LIBS([roken_gethostbyaddr], [roken])
185
186  #
187  # k5crypto		MIT K5 v1.2.2-beta1
188  #
189  AC_SEARCH_LIBS([valid_enctype], [k5crypto])
190
191  #
192  # gen			? ? ?			Needed on Irix 5.3 with some
193  #			Irix 5.3		version of Kerberos.  I'm not
194  #						sure which since Irix didn't
195  #						get any testing this time
196  #						around.  Original comment:
197  #
198  # This is necessary on Irix 5.3, in order to link against libkrb5 --
199  # there, an_to_ln.o refers to things defined only in -lgen.
200  #
201  AC_SEARCH_LIBS([compile], [gen])
202
203  #
204  # krb5		? ? ?			-lgen -l???
205  #			Irix 5.3
206  #
207  # krb5		MIT K5 v1.1.1
208  #
209  # krb5		MIT K5 v1.2.2-beta1	-lcrypto -lcom_err
210  # 			Linux 2.2.17
211  #
212  # krb5		MIT K5 v1.2.2-beta1	-lcrypto -lcom_err -lresolv
213  #
214  # krb5		Heimdal K 0.3d		-lasn1 -lroken -ldes
215  #
216  AC_SEARCH_LIBS([krb5_free_context], [krb5])
217
218  #
219  # gssapi_krb5		Only lib needed with MIT K5 v1.2.1, so find it first in
220  #			order to prefer MIT Kerberos.  If both MIT & Heimdal
221  #			Kerberos are installed and in the path, this will leave
222  #			some of the libraries above in LIBS unnecessarily, but
223  #			noone would ever do that, right?
224  #
225  # gssapi_krb5		MIT K5 v1.2.2-beta1	-lkrb5
226  #
227  # gssapi		Heimdal K 0.3d		-lkrb5
228  #
229  AC_SEARCH_LIBS([gss_import_name], [gssapi_krb5 gssapi])
230fi
231])dnl
232