Update kerberos directory in win-build
[mech_eap.git] / acinclude.m4
1 dnl Based on the one from the Boinc project by Reinhard
2
3 AC_DEFUN([AX_CHECK_WINDOWS],
4 [AC_MSG_CHECKING(for windows)
5 target_windows="no"
6 AC_CHECK_HEADER(windows.h,[target_windows="yes"],[target_windows="no"])
7 AC_MSG_RESULT($target_windows)
8 AM_CONDITIONAL(TARGET_WINDOWS,test "x$target_windows" = "xyes")
9 ])dnl
10
11 AC_DEFUN([AX_CHECK_KRB5],
12 [AC_MSG_CHECKING(for GSS-API and Kerberos implementation)
13 KRB5_DIR=
14 found_krb5="no"
15 AC_ARG_WITH(krb5,
16     AC_HELP_STRING([--with-krb5],
17        [Use krb5 (in specified installation directory)]),
18     [check_krb5_dir="$withval"],
19     [check_krb5_dir=])
20 for dir in $check_krb5_dir $prefix /usr/local /usr ; do
21    krb5dir="$dir"
22    if test "x$target_windows" = "xyes"; then
23       krb5includedir="$dir/include";
24       if test -e "$krb5includedir/krb5.h"; then
25         found_krb5="yes";
26         krb5libdir="$dir/lib/i386"
27         KRB5_CFLAGS=-I"$krb5includedir";
28         KRB5_LDFLAGS=-L"$krb5libdir";
29         KRB5_LIBS="$krb5libdir/krb5_32.lib $krb5libdir/gssapi32.lib $krb5libdir/comerr32.lib";
30         COMPILE_ET="$(pwd)/windows/compile_et";
31         AC_MSG_RESULT([yes])
32         break;
33      fi
34    else
35       if test -x "$dir/bin/krb5-config"; then
36         found_krb5="yes";
37         KRB5_CFLAGS=`$dir/bin/krb5-config gssapi --cflags`;
38         KRB5_LDFLAGS="-L$dir/lib";
39         KRB5_LIBS=`$dir/bin/krb5-config gssapi --libs`
40         AC_MSG_RESULT([yes])
41         AC_PATH_PROG(COMPILE_ET, [compile_et], [compile_et], [$dir/bin$PATH_SEPARATOr])
42         break;
43      fi
44    fi
45 done
46 if test x_$found_krb5 != x_yes; then
47    AC_MSG_RESULT($found_krb5)
48    AC_MSG_ERROR([
49 ----------------------------------------------------------------------
50   Cannot find GSS-API/Kerberos libraries.
51
52   Please install MIT or Heimdal or specify installation directory with
53   --with-krb5=(dir).
54 ----------------------------------------------------------------------
55 ])
56 else
57         printf "Kerberos found in $krb5dir\n";
58         AC_SUBST(KRB5_CFLAGS)
59         AC_SUBST(KRB5_LDFLAGS)
60         AC_SUBST(KRB5_LIBS)
61         AC_SUBST(COMPILE_ET)
62         AC_CHECK_LIB(krb5, GSS_C_NT_COMPOSITE_EXPORT, [AC_DEFINE_UNQUOTED([HAVE_GSS_C_NT_COMPOSITE_EXPORT], 1, [Define if GSS-API library supports recent naming extensions draft])], [], "$KRB5_LIBS")
63         AC_CHECK_LIB(krb5, gss_inquire_attrs_for_mech, [AC_DEFINE_UNQUOTED([HAVE_GSS_INQUIRE_ATTRS_FOR_MECH], 1, [Define if GSS-API library supports RFC 5587])], [], "$KRB5_LIBS")
64         AC_CHECK_LIB(krb5, gss_krb5_import_cred, [AC_DEFINE_UNQUOTED([HAVE_GSS_KRB5_IMPORT_CRED], 1, [Define if GSS-API library supports gss_krb5_import_cred])], [], "$KRB5_LIBS")
65         AC_CHECK_LIB(krb5, heimdal_version, [AC_DEFINE_UNQUOTED([HAVE_HEIMDAL_VERSION], 1, [Define if building against Heimdal Kerberos implementation]), heimdal=yes], [heimdal=no], "$KRB5_LIBS")
66         AM_CONDITIONAL(HEIMDAL, test "x$heimdal" != "xno")
67 fi
68 ])dnl
69
70 AC_DEFUN([AX_CHECK_EAP],
71 [AC_MSG_CHECKING(for EAP implementation)
72 EAP_DIR=
73 found_eap="no"
74 AC_ARG_WITH(eap,
75     AC_HELP_STRING([--with-eap],
76        [Use eap (in specified installation directory)]),
77     [check_eap_dir="$withval"],
78     [check_eap_dir=])
79 for dir in $check_eap_dir $prefix /usr /usr/local ../libeap ; do
80    eapdir="$dir"
81    if test -f "$dir/src/eap_peer/eap.h"; then
82      found_eap="yes";
83      EAP_DIR="${eapdir}"
84      EAP_CFLAGS="-I$eapdir/src/common -I$eapdir/src -I$eapdir/src/utils";
85      break;
86    fi
87 done
88 AC_MSG_RESULT($found_eap)
89 if test x_$found_eap != x_yes; then
90    AC_MSG_ERROR([
91 ----------------------------------------------------------------------
92   Cannot find EAP libraries.
93
94   Please install wpa_supplicant or specify installation directory with
95   --with-eap=(dir).
96 ----------------------------------------------------------------------
97 ])
98 else
99         printf "EAP found in $eapdir\n";
100         EAP_CFLAGS="$EAP_CFLAGS \
101 -DEAP_TLS \
102 -DEAP_PEAP \
103 -DEAP_TTLS \
104 -DEAP_MD5 \
105 -DEAP_MSCHAPv2 \
106 -DEAP_GTC \
107 -DEAP_OTP \
108 -DEAP_LEAP \
109 -DEAP_PSK \
110 -DEAP_PAX \
111 -DEAP_SAKE \
112 -DEAP_GPSK \
113 -DEAP_GPSK_SHA256 \
114 -DEAP_SERVER_IDENTITY \
115 -DEAP_SERVER_TLS \
116 -DEAP_SERVER_PEAP \
117 -DEAP_SERVER_TTLS \
118 -DEAP_SERVER_MD5 \
119 -DEAP_SERVER_MSCHAPV2 \
120 -DEAP_SERVER_GTC \
121 -DEAP_SERVER_PSK \
122 -DEAP_SERVER_PAX \
123 -DEAP_SERVER_SAKE \
124 -DEAP_SERVER_GPSK \
125 -DEAP_SERVER_GPSK_SHA256 \
126 -DIEEE8021X_EAPOL";
127         EAP_LIBS="-leap -lutils -lcrypto -ltls -lssl";
128         EAP_LDFLAGS="-L$eapdir/eap_example -L$eapdir/src/utils -L$eapdir/src/crypto -L$eapdir/src/tls";
129         AC_SUBST(EAP_CFLAGS)
130         AC_SUBST(EAP_LDFLAGS)
131         AC_SUBST(EAP_LIBS)
132 fi
133 ])dnl
134
135 AC_DEFUN([AX_CHECK_SHIBSP],
136 [AC_MSG_CHECKING(for Shibboleth implementation)
137 SHIBSP_DIR=
138 found_shibsp="no"
139 AC_ARG_WITH(shibsp,
140     AC_HELP_STRING([--with-shibsp],
141        [Use shibspboleth (in specified installation directory)]),
142     [check_shibsp_dir="$withval"],
143     [check_shibsp_dir=])
144 for dir in $check_shibsp_dir $prefix /usr /usr/local ; do
145    shibspdir="$dir"
146    if test -f "$dir/include/shibsp/SPConfig.h"; then
147      found_shibsp="yes";
148      SHIBSP_DIR="${shibspdir}"
149      SHIBSP_CXXFLAGS="-I$shibspdir/include";
150      break;
151    fi
152 done
153 AC_MSG_RESULT($found_shibsp)
154 if test x_$found_shibsp != x_yes; then
155    AC_MSG_ERROR([
156 ----------------------------------------------------------------------
157   Cannot find Shibboleth libraries.
158
159   Please install Shibboleth or specify installation directory with
160   --with-shibsp=(dir).
161 ----------------------------------------------------------------------
162 ])
163 else
164         printf "Shibboleth found in $shibspdir\n";
165         SHIBSP_LIBS="-lshibsp -lsaml -lxml-security-c -lxmltooling -lxerces-c";
166         SHIBSP_LDFLAGS="-L$shibspdir/lib";
167         AC_SUBST(SHIBSP_CXXFLAGS)
168         AC_SUBST(SHIBSP_LDFLAGS)
169         AC_SUBST(SHIBSP_LIBS)
170         AC_DEFINE_UNQUOTED([HAVE_SHIBSP], 1, [Define is Shibboleth SP is available])
171 fi
172 ])dnl
173
174 AC_DEFUN([AX_CHECK_SHIBRESOLVER],
175 [AC_MSG_CHECKING(for Shibboleth resolver implementation)
176 SHIBRESOLVER_DIR=
177 found_shibresolver="no"
178 AC_ARG_WITH(shibresolver,
179     AC_HELP_STRING([--with-shibresolver],
180        [Use Shibboleth resolver (in specified installation directory)]),
181     [check_shibresolver_dir="$withval"],
182     [check_shibresolver_dir=])
183 if test x_$check_shibresolver_dir != x_no; then
184 for dir in $check_shibresolver_dir $prefix /usr /usr/local ; do
185    shibresolverdir="$dir"
186    if test -f "$dir/include/shibresolver/resolver.h"; then
187      found_shibresolver="yes";
188      SHIBRESOLVER_DIR="${shibresolverdir}"
189      SHIBRESOLVER_CXXFLAGS="-I$shibresolverdir/include";
190      break;
191    fi
192 done
193 fi
194 AC_MSG_RESULT($found_shibresolver)
195 if test x_$check_shibresolver_dir != x_no; then
196 if test x_$found_shibresolver != x_yes; then
197    AC_MSG_WARN([
198 ----------------------------------------------------------------------
199   Cannot find Shibboleth resolver libraries, building without
200   Shibboleth support.
201
202   Please install Shibboleth or specify installation directory with
203   --with-shibresolver=(dir).
204 ----------------------------------------------------------------------
205 ])
206 else
207         printf "Shibboleth resolver found in $shibresolverdir\n";
208         SHIBRESOLVER_LIBS="-lshibresolver";
209         SHIBRESOLVER_LDFLAGS="-L$shibresolverdir/lib";
210         AC_SUBST(SHIBRESOLVER_CXXFLAGS)
211         AC_SUBST(SHIBRESOLVER_LDFLAGS)
212         AC_SUBST(SHIBRESOLVER_LIBS)
213         AC_DEFINE_UNQUOTED([HAVE_SHIBRESOLVER], 1, [Define is Shibboleth resolver is available])
214 fi
215 fi
216 ])dnl
217
218 AC_DEFUN([AX_CHECK_OPENSAML],
219 [AC_MSG_CHECKING(for OpenSAML implementation)
220 OPENSAML_DIR=
221 found_opensaml="no"
222 AC_ARG_WITH(opensaml,
223     AC_HELP_STRING([--with-opensaml],
224        [Use OpenSAML (in specified installation directory)]),
225     [check_opensaml_dir="$withval"],
226     [check_opensaml_dir=])
227 if test x_$check_opensaml_dir != x_no; then
228 for dir in $check_opensaml_dir $prefix /usr /usr/local ; do
229    opensamldir="$dir"
230    if test -f "$dir/include/saml/Assertion.h"; then
231      found_opensaml="yes";
232      OPENSAML_DIR="${opensamldir}"
233      OPENSAML_CXXFLAGS="-I$opensamldir/include";
234      break;
235    fi
236 done
237 fi
238 AC_MSG_RESULT($found_opensaml)
239 if test x_$check_opensaml_dir != x_no; then
240 if test x_$found_opensaml != x_yes; then
241    AC_MSG_WARN([
242 ----------------------------------------------------------------------
243   Cannot find OpenSAML libraries, building without OpenSAML support.
244
245   Please install OpenSAML or specify installation directory with
246   --with-opensaml=(dir).
247 ----------------------------------------------------------------------
248 ])
249 else
250         printf "OpenSAML found in $opensamldir\n";
251         OPENSAML_LIBS="-lsaml -lxml-security-c -lxmltooling -lxerces-c";
252         OPENSAML_LDFLAGS="-L$opensamldir/lib";
253         AC_SUBST(OPENSAML_CXXFLAGS)
254         AC_SUBST(OPENSAML_LDFLAGS)
255         AC_SUBST(OPENSAML_LIBS)
256         AC_DEFINE_UNQUOTED([HAVE_OPENSAML], 1, [Define is OpenSAML is available])
257 fi
258 fi
259 ])dnl
260
261 AC_DEFUN([AX_CHECK_OPENSSL],
262 [AC_MSG_CHECKING(for OpenSSL)
263 OPENSSL_DIR=
264 found_openssl="no"
265 AC_ARG_WITH(openssl,
266     AC_HELP_STRING([--with-openssl],
267        [Use OpenSSL (in specified installation directory)]),
268     [check_openssl_dir="$withval"],
269     [check_openssl_dir=])
270 for dir in $check_openssl_dir $prefix /usr /usr/local ; do
271    openssldir="$dir"
272    if test -f "$dir/include/openssl/opensslv.h"; then
273      found_openssl="yes";
274      OPENSSL_DIR="${openssldir}"
275      OPENSSL_CFLAGS="-I$openssldir/include";
276      break;
277    fi
278 done
279 AC_MSG_RESULT($found_openssl)
280 if test x_$found_openssl != x_yes; then
281    AC_MSG_ERROR([
282 ----------------------------------------------------------------------
283   Cannot find OpenSSL libraries.
284
285   Please install libssl or specify installation directory with
286   --with-openssl=(dir).
287 ----------------------------------------------------------------------
288 ])
289 else
290         printf "OpenSSL found in $openssldir\n";
291     if test "x$target_windows" = "xyes"; then
292       OPENSSL_LIBS="$openssldir/lib/libeay32.lib $openssldir/lib/ssleay32.lib";
293     else
294           OPENSSL_LIBS="-lssl -lcrypto";
295         fi
296         OPENSSL_LDFLAGS="-L$openssldir/lib";
297         AC_SUBST(OPENSSL_CFLAGS)
298         AC_SUBST(OPENSSL_LDFLAGS)
299         AC_SUBST(OPENSSL_LIBS)
300 fi
301 ])dnl
302
303 AC_DEFUN([AX_CHECK_RADSEC],
304 [AC_MSG_CHECKING(for radsec)
305 RADSEC_DIR=
306 found_radsec="no"
307 AC_ARG_WITH(radsec,
308     AC_HELP_STRING([--with-radsec],
309        [Use radsec (in specified installation directory)]),
310     [check_radsec_dir="$withval"],
311     [check_radsec_dir=])
312 for dir in $check_radsec_dir $prefix /usr /usr/local ; do
313    radsecdir="$dir"
314    if test -f "$dir/include/radsec/radsec.h"; then
315      found_radsec="yes";
316      RADSEC_DIR="${radsecdir}"
317      RADSEC_CFLAGS="-I$radsecdir/include";
318      break;
319    fi
320 done
321 AC_MSG_RESULT($found_radsec)
322 if test x_$found_radsec != x_yes; then
323    AC_MSG_ERROR([
324 ----------------------------------------------------------------------
325   Cannot find radsec libraries.
326
327   Please install libradsec or specify installation directory with
328   --with-radsec=(dir).
329 ----------------------------------------------------------------------
330 ])
331 else
332         printf "radsec found in $radsecdir\n";
333         RADSEC_LIBS="-lradsec";
334         RADSEC_LDFLAGS="-L$radsecdir/lib";
335         AC_SUBST(RADSEC_CFLAGS)
336         AC_SUBST(RADSEC_LDFLAGS)
337         AC_SUBST(RADSEC_LIBS)
338 fi
339 ])dnl
340
341 AC_DEFUN([AX_CHECK_JANSSON],
342 [AC_MSG_CHECKING(for jansson)
343 JANSSON_DIR=
344 found_jansson="no"
345 AC_ARG_WITH(jansson,
346     AC_HELP_STRING([--with-jansson],
347        [Use jansson (in specified installation directory)]),
348     [check_jansson_dir="$withval"],
349     [check_jansson_dir=])
350 for dir in $check_jansson_dir $prefix /usr /usr/local ; do
351    janssondir="$dir"
352    if test -f "$dir/include/jansson.h"; then
353      found_jansson="yes";
354      JANSSON_DIR="${janssondir}"
355      JANSSON_CFLAGS="-I$janssondir/include";
356      break;
357    fi
358 done
359 AC_MSG_RESULT($found_jansson)
360 if test x_$found_jansson != x_yes; then
361    AC_MSG_ERROR([
362 ----------------------------------------------------------------------
363   Cannot find jansson libraries.
364
365   Please install libjansson or specify installation directory with
366   --with-jansson=(dir).
367 ----------------------------------------------------------------------
368 ])
369 else
370         printf "jansson found in $janssondir\n";
371         JANSSON_LIBS="-ljansson";
372         JANSSON_LDFLAGS="-L$janssondir/lib";
373         AC_SUBST(JANSSON_CFLAGS)
374         AC_SUBST(JANSSON_LDFLAGS)
375         AC_SUBST(JANSSON_LIBS)
376 fi
377 ])dnl
378
379 AC_DEFUN([AX_CHECK_LIBMOONSHOT],
380 [AC_MSG_CHECKING(for Moonshot identity selector implementation)
381 LIBMOONSHOT_DIR=
382 LIBMOONSHOT_CFLAGS=
383 LIBMOONSHOT_LDFLAGS=
384 LIBMOONSHOT_LIBS=
385 found_libmoonshot="no"
386 AC_ARG_WITH(libmoonshot,
387     AC_HELP_STRING([--with-libmoonshot],
388        [Use libmoonshot (in specified installation directory)]),
389     [check_libmoonshot_dir="$withval"],
390     [check_libmoonshot_dir=])
391 for dir in $check_libmoonshot_dir $prefix /usr /usr/local ; do
392     libmoonshotdir="$dir"
393     if test -f "$dir/include/libmoonshot.h"; then
394         found_libmoonshot="yes";
395         LIBMOONSHOT_CFLAGS="-I$libmoonshotdir/include";
396         break;
397     fi
398 done
399 AC_MSG_RESULT($found_libmoonshot)
400 if test x_$found_libmoonshot = x_yes; then
401     printf "libmoonshot found in $libmoonshotdir\n";
402     LIBMOONSHOT_DIR="${libmoonshotdir}"
403     if test x_$target_windows = x_yes; then
404         LIBMOONSHOT_LIBS="$LIBMOONSHOT_DIR/lib/libmoonshot.lib"
405         AC_DEFINE_UNQUOTED([HAVE_MOONSHOT_GET_IDENTITY], 1, [Define if Moonshot identity selector is available])           
406     else
407         LIBMOONSHOT_LIBS="-lmoonshot";
408         LIBMOONSHOT_LDFLAGS="-L$libmoonshot/lib";
409         AC_CHECK_LIB(moonshot, moonshot_get_identity, [AC_DEFINE_UNQUOTED([HAVE_MOONSHOT_GET_IDENTITY], 1, [Define if Moonshot identity selector is available])], [], "$LIBMOONSHOT_LIBS")
410     fi
411 fi
412     AC_SUBST(LIBMOONSHOT_CFLAGS)
413     AC_SUBST(LIBMOONSHOT_LDFLAGS)
414     AC_SUBST(LIBMOONSHOT_LIBS)
415     AM_CONDITIONAL(LIBMOONSHOT, test "x$found_libmoonshot" != "xno")
416 ])dnl
417