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