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