Fix Coverity defects
[platform/upstream/xmlsec1.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT([xmlsec1],[1.2.22],[http://www.aleksey.com/xmlsec])
3
4 XMLSEC_PACKAGE=xmlsec1
5 XMLSEC_VERSION_MAJOR=1
6 XMLSEC_VERSION_MINOR=2
7 XMLSEC_VERSION_SUBMINOR=22
8 XMLSEC_VERSION="$XMLSEC_VERSION_MAJOR.$XMLSEC_VERSION_MINOR.$XMLSEC_VERSION_SUBMINOR"
9 XMLSEC_VERSION_INFO=`echo $XMLSEC_VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'`
10 XMLSEC_VERSION_SAFE=`echo $XMLSEC_VERSION | sed 's/\./_/g'`
11
12 AC_PREREQ([2.52g])
13 AC_CANONICAL_HOST
14
15 AC_SUBST(XMLSEC_VERSION)
16 AC_SUBST(XMLSEC_PACKAGE)
17 AC_SUBST(XMLSEC_VERSION_SAFE)
18 AC_SUBST(XMLSEC_VERSION_MAJOR)
19 AC_SUBST(XMLSEC_VERSION_MINOR)
20 AC_SUBST(XMLSEC_VERSION_SUBMINOR)
21 AC_SUBST(XMLSEC_VERSION_INFO)
22
23 AC_CONFIG_MACRO_DIR(m4)
24 AM_INIT_AUTOMAKE([1.7 tar-ustar subdir-objects -Wno-portability])
25 AC_CONFIG_HEADERS([config.h])
26 AM_MAINTAINER_MODE
27
28 # Support silent build rules, requires at least automake-1.11. Disable
29 # by either passing --disable-silent-rules to configure or passing V=1
30 # to make
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
32
33 dnl
34 dnl Check the environment
35 dnl
36 AC_PROG_CC
37 AC_PROG_INSTALL
38 AC_HEADER_STDC
39 AC_PROG_LIBTOOL
40
41 LT_INIT
42
43 dnl
44 dnl Find programs
45 dnl
46 if test "z$RM" == "z" ; then 
47     AC_PATH_PROG(RM, rm, /bin/rm)
48 fi
49 AC_PATH_PROG(CP, cp, /bin/cp)
50 AC_PATH_PROG(MV, mv, /bin/mv)
51 AC_PATH_PROG(TAR, tar, /bin/tar)
52 AC_PATH_PROG(PERL, perl)
53
54
55 dnl Checks for header files.
56 AC_HEADER_DIRENT
57 AC_HEADER_STDC
58 AC_CHECK_HEADERS([stdio.h])
59 AC_CHECK_HEADERS([stdlib.h])
60 AC_CHECK_HEADERS([string.h])
61 AC_CHECK_HEADERS([ctype.h])
62 AC_CHECK_HEADERS([errno.h])
63 AC_CHECK_HEADERS([ansidecl.h])
64 AC_CHECK_HEADERS([time.h])
65 AC_CHECK_FUNCS(strchr strrchr printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf timegm)
66
67 XMLSEC_DEFINES=""
68
69 dnl ==========================================================================
70 dnl Specific setup for Aleksey's development environment: 
71 dnl     - with debug
72 dnl - with pedantic compiler flags
73 dnl - with docs build
74 dnl     - with static binaries
75 dnl     - without dynamic xmlsec-crypto loading
76 dnl ==========================================================================
77 AC_MSG_CHECKING(for development environment) 
78 AC_ARG_ENABLE(development,   [  --enable-development    enable development environment (no)])
79 if test "z$enable_development" = "zyes" ; then
80     enable_debugging="yes"
81     enable_pedantic="yes"
82     enable_static_linking="yes"
83     enable_manpages_build="yes"
84     enable_docs_build="yes"
85     enable_crypto_dl="no"
86     AC_MSG_RESULT(yes)
87 else
88     AC_MSG_RESULT(no)
89 fi
90
91 dnl ==========================================================================
92 dnl Do we want to build manpages?
93 dnl ==========================================================================
94 AC_MSG_CHECKING(for man pages build) 
95 AC_ARG_ENABLE(manpages_build,[  --enable-manpages-build man pages build (no)])
96 if test "z$enable_manpages_build" = "zyes" ; then
97     AC_PATH_PROG(HELP2MAN, help2man)
98
99     AC_MSG_RESULT(yes)
100 else
101     AC_MSG_RESULT(no)
102 fi
103
104 AM_CONDITIONAL(HAS_HELP2MAN, [test x"$HELP2MAN" != x])
105 AM_CONDITIONAL(BUILD_MANPAGES, [test x"$HELP2MAN" != x])
106
107 dnl ==========================================================================
108 dnl Do we want to build docs?
109 dnl ==========================================================================
110 AC_MSG_CHECKING(for docs build) 
111 AC_ARG_ENABLE(docs_build,    [  --enable-docs-build     docs build (no)])
112 if test "z$enable_docs_build" = "zyes" ; then
113     AC_PATH_PROG(XSLTPROC, xsltproc)
114     AC_PATH_PROG(MAN2HTML, man2html)
115     AC_PATH_PROG(GTKDOC_MKHTML, gtkdoc-mkhtml)
116     AC_PATH_PROG(GTKDOC_MKTMPL, gtkdoc-mktmpl)
117     AC_PATH_PROG(GTKDOC_MKDB,   gtkdoc-mkdb)
118     AC_PATH_PROG(GTKDOC_SCAN,   gtkdoc-scan)
119
120     AC_MSG_RESULT(yes)
121 else
122     AC_MSG_RESULT(no)
123 fi
124
125 AM_CONDITIONAL(HAS_MAN2HTML, [test x"$MAN2HTML" != x])
126 AM_CONDITIONAL(HAS_XSLTPROC, [test x"$XSLTPROC" != x])
127
128 AM_CONDITIONAL(BUILD_MAN_DOCS, [test x"$PERL" != x && test x"$XSLTPROC" != x && test x"$MAN2HTML" != x])
129 AM_CONDITIONAL(BUILD_API_DOCS, [test x"$PERL" != x && test x"$XSLTPROC" != x && test x"$GTKDOC_MKHTML" != x && test x"$GTKDOC_MKTMPL" != x && test x"$GTKDOC_MKDB" != x && test x"$GTKDOC_SCAN" != x])
130
131 dnl ==========================================================================
132 dnl Perform host specific configuration
133 dnl ==========================================================================
134 XMLSEC_EXTRA_LDFLAGS=
135 XMLSEC_CRYPTO_EXTRA_LDFLAGS=
136 dnl should separate extra LDFLAGS for xmlsec and crypto libs ?
137 dnl should --enable-runtime-pseudo-reloc for mingw and cygwin ?
138
139 xmlsec_sharedlib_hack="no"
140 if test -n "$shrext"; then
141   XMLSEC_SHLIBSFX="$shrext"
142 else
143   dnl changed in libtool (between 1.5.2 and 1.5.14)
144   XMLSEC_SHLIBSFX="$shrext_cmds"
145 fi
146 case "${host}" in
147  *aix* )
148         CFLAGS="${CFLAGS} -D_ALL_SOURCE"
149         ;;
150  *-*-mingw*)
151         dnl use libtool flags "-avoid-version" to create shared
152         dnl libraries without version suffix, i.e. libxmlsec1.dll
153         dnl instead libxmlsec1-NN.dll, where NN is a number.
154         XMLSEC_EXTRA_LDFLAGS="-no-undefined -avoid-version"
155         XMLSEC_CRYPTO_EXTRA_LDFLAGS="-no-undefined -avoid-version"
156         XMLSEC_SHLIBSFX=".dll.a"
157         xmlsec_sharedlib_hack="yes"
158         ;;
159  *-*-cygwin*)
160         XMLSEC_EXTRA_LDFLAGS="-no-undefined"
161         XMLSEC_CRYPTO_EXTRA_LDFLAGS="-no-undefined"
162         ;;
163  *-*-darwin*)
164         XMLSEC_SHLIBSFX=".dylib"
165         ;;
166 esac
167
168 # To avoid problem with loading of a shared library (dlopen or equivalent)
169 # at run time on some platforms we need to link crypto modules with extra
170 # source. It's work without hack on 9x and under emulation.
171 # On nt 5.x (w2k,xp) the error is 998("Invalid access to memory location").
172 AM_CONDITIONAL(SHAREDLIB_HACK, [test "z$xmlsec_sharedlib_hack" = "zyes"])
173
174 dnl ==========================================================================
175 dnl Hack for autoconf version mismatch
176 dnl ==========================================================================
177 if test "z$shrext" == "z" ; then 
178     shrext=$shrext_cmds
179 fi
180
181 dnl ==========================================================================
182 dnl Check for __FUNCTION__ or __func__
183 dnl ==========================================================================
184 AC_MSG_CHECKING(for __FUNCTION__ or __func__)
185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
186         [[char *foo = __FUNCTION__;]])],
187         [ac_function_exists=yes],
188         [ac_function_exists=no])
189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
190         [[char *foo = __func__;]])],
191         [ac_func_exists=yes],
192         [ac_func_exists=no])
193 if test "z$ac_func_exists" = "zyes" ; then 
194         AC_MSG_RESULT(__func__)
195         XMLSEC_DEFINES="$XMLSEC_DEFINES -D__XMLSEC_FUNCTION__=__func__"
196 elif test "z$ac_function_exists" = "zyes" ; then
197     AC_MSG_RESULT(__FUNCTION__)
198     XMLSEC_DEFINES="$XMLSEC_DEFINES -D__XMLSEC_FUNCTION__=__FUNCTION__"
199 else 
200         AC_MSG_RESULT("no")
201 fi
202
203 dnl ==========================================================================
204 dnl check do we have size_t and its size, 
205 dnl TODO: will need to replace this and the xmlSecSize define with 
206 dnl typedef on next ABI refresh
207 dnl ==========================================================================
208 AC_CHECK_SIZEOF(size_t)
209 if test "$ac_cv_sizeof_size_t" -ne "4" ; then
210     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SIZE_T"
211 fi
212
213 dnl ==========================================================================
214 dnl Check if pkg-config enabled and installed
215 dnl ==========================================================================
216 PKG_CONFIG="pkg-config"
217 PKGCONFIG_FOUND="no"
218 AC_ARG_ENABLE(pkgconfig,   [  --enable-pkgconfig      enable pkgconfig for configuration (yes)])
219 if test "z$enable_pkgconfig" != "zno" ; then
220     AC_CHECK_PROG(PKGCONFIG_PRESENT, $PKG_CONFIG, yes, no)
221     if test "z$PKGCONFIG_PRESENT" = "zyes" ; then
222         if $PKG_CONFIG --atleast-pkgconfig-version 0.9 ; then
223             PKGCONFIG_FOUND="yes"
224         fi
225     fi
226 fi
227
228 dnl ==========================================================================
229 dnl find libxml
230 dnl ==========================================================================
231 LIBXML_MIN_VERSION="2.7.4"
232 LIBXML_CONFIG="xml2-config"
233 LIBXML_CFLAGS=""
234 LIBXML_LIBS=""
235 LIBXML_FOUND="no"
236 AC_ARG_WITH(libxml, 
237     [  --with-libxml=[PFX]       libxml2 location]
238 )
239 AC_ARG_WITH(libxml-src, 
240     [  --with-libxml-src=[PFX]   not installed yet libxml2 location]
241 )
242
243 if test "z$with_libxml" = "zno" -o "z$with_libxml_src" = "zno"; then 
244     AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_MIN_VERSION) 
245     AC_MSG_ERROR(libxml2 >= $LIBXML_MIN_VERSION is required for $XMLSEC_PACKAGE)
246 elif test "z$with_libxml_src" != "z" ; then
247     AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_MIN_VERSION) 
248     CWD=`pwd`
249     if cd "$with_libxml_src" ; then 
250         SRC_DIR=`pwd`
251         LIBXML_CONFIG=${SRC_DIR}/xml2-config
252         LIBXML_LIBS="-L${SRC_DIR}/.libs -lxml2"
253         LIBXML_CFLAGS="-I${SRC_DIR}/include"
254         LIBXML_FOUND="yes"
255         cd $CWD
256         AC_MSG_RESULT([yes (source)])    
257     else 
258         AC_MSG_ERROR([libxml source dir not found (${with_libxml_src}), typo?])
259     fi  
260 elif test "z$with_libxml" = "z" -a "z$PKGCONFIG_FOUND" = "zyes" ; then
261     PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_MIN_VERSION,
262         [LIBXML_FOUND=yes],
263         [LIBXML_FOUND=no])
264 fi
265 if test "z$LIBXML_FOUND" = "zno" ; then
266     if test "z$with_libxml" != "zyes" ; then
267         if test "z$with_libxml" != "z" ; then
268             AC_PATH_PROG([LIBXML_CONFIG], [$LIBXML_CONFIG], [],
269                      [$with_libxml/bin:$PATH])
270         else
271             AC_PATH_PROG([LIBXML_CONFIG], [$LIBXML_CONFIG], [],
272                      [$PATH])
273         fi
274     fi
275     AC_MSG_CHECKING([libxml2 $LIBXML_CONFIG ])
276     if ! LIBXML_VERSION=`$LIBXML_CONFIG --version 2>/dev/null`; then
277         AC_MSG_ERROR(Could not find libxml2 anywhere.)
278     fi
279     vers=`echo $LIBXML_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
280     minvers=`echo $LIBXML_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
281     if test "$vers" -ge "$minvers" ; then
282         LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
283         LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
284         LIBXML_FOUND="yes"
285         AC_MSG_RESULT([yes ('$LIBXML_VERSION')])
286     else
287         AC_MSG_ERROR(You need at least libxml2 $LIBXML_MIN_VERSION for this version of $XMLSEC_PACKAGE)
288     fi
289 fi
290
291 AC_SUBST(LIBXML_CFLAGS)
292 AC_SUBST(LIBXML_LIBS)
293 AC_SUBST(LIBXML_CONFIG)
294 AC_SUBST(LIBXML_MIN_VERSION)
295
296 dnl ==========================================================================
297 dnl find libxslt
298 dnl ==========================================================================
299 XMLSEC_NO_LIBXSLT="1"
300 LIBXSLT_MIN_VERSION=1.0.20
301 LIBXSLT_PC_FILE_COND="libxslt >= $LIBXSLT_MIN_VERSION"
302 LIBXSLT_CONFIG="xslt-config"
303 LIBXSLT_CFLAGS=""
304 LIBXSLT_LIBS=""
305 LIBXSLT_FOUND="no"
306 AC_ARG_WITH(libxslt, 
307     [  --with-libxslt=[PFX]      libxslt location]
308 )
309 AC_ARG_WITH(libxslt-src, 
310     [  --with-libxslt-src=[PFX]  not installed yet libxslt location]
311 )
312 if test "z$with_libxslt" = "zno" -o "z$with_libxslt_src" = "zno" ; then
313     AC_MSG_CHECKING(for libxslt libraries >= $LIBXSLT_MIN_VERSION) 
314     AC_MSG_RESULT(no)
315     LIBXSLT_FOUND="without"
316 elif test "z$with_libxslt_src" != "z" ; then
317     AC_MSG_CHECKING(for libxslt libraries >= $LIBXSLT_MIN_VERSION) 
318     CWD=`pwd`
319     if cd "$with_libxslt_src" ; then 
320         SRC_DIR=`pwd`
321         LIBXSLT_CONFIG=${SRC_DIR}/xslt-config
322         LIBXSLT_LIBS="-L${SRC_DIR}/libxslt/.libs -lxslt"
323         LIBXSLT_CFLAGS="-I${SRC_DIR}"
324         LIBXSLT_FOUND="yes"
325         cd $CWD
326         AC_MSG_RESULT([yes (source)])    
327     else 
328         AC_MSG_ERROR([libxslt source dir not found (${with_libxslt_src}), typo?])
329     fi  
330 elif test "z$with_libxslt" = "z" -a  "z$PKGCONFIG_FOUND" = "zyes" ; then
331     PKG_CHECK_MODULES(LIBXSLT, libxslt >= $LIBXSLT_MIN_VERSION,
332         [LIBXSLT_FOUND=yes],
333         [LIBXSLT_FOUND=no])
334 fi
335
336 if test "z$LIBXSLT_FOUND" = "zno" ; then
337     if test "z$with_libxslt" != "zyes" ; then
338         if test "z$with_libxslt" != "z" ; then
339             AC_PATH_PROG([LIBXSLT_CONFIG], [$LIBXSLT_CONFIG], [],
340                      [$with_libxslt/bin:$PATH])
341         else
342             AC_PATH_PROG([LIBXSLT_CONFIG], [$LIBXSLT_CONFIG], [],
343                      [$PATH])
344         fi
345     fi
346     AC_MSG_CHECKING(for libxslt libraries >= $LIBXSLT_MIN_VERSION) 
347     if ! LIBXSLT_VERSION=`$LIBXSLT_CONFIG --version 2>/dev/null`; then
348         if test "z$with_libxslt" != "zyes" ; then
349             AC_MSG_ERROR(Unable to find libxslt at '$with_libxslt')
350         else 
351             AC_MSG_RESULT(no)
352         fi
353     else
354         vers=`echo $LIBXSLT_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
355         minvers=`echo $LIBXSLT_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
356         if test "$vers" -ge "$minvers" ; then
357             LIBXSLT_LIBS="`$LIBXSLT_CONFIG --libs`"
358             LIBXSLT_CFLAGS="`$LIBXSLT_CONFIG --cflags`"
359             LIBXSLT_FOUND="yes"
360             AC_MSG_RESULT([yes ('$LIBXSLT_VERSION')])
361         else
362             AC_MSG_ERROR(You need at least libxslt $LIBXSLT_MIN_VERSION for this version of $XMLSEC_PACKAGE)
363         fi      
364     fi
365 fi
366
367 if test "z$LIBXSLT_FOUND" = "zyes" ; then
368     XMLSEC_NO_LIBXSLT="0"
369 else
370     LIBXSLT_PC_FILE_COND=""
371     LIBXSLT_MIN_VERSION=""
372     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_XSLT=1"
373 fi
374
375 AC_SUBST(XMLSEC_NO_LIBXSLT)
376 AC_SUBST(LIBXSLT_CFLAGS)
377 AC_SUBST(LIBXSLT_LIBS)
378 AC_SUBST(LIBXSLT_CONFIG)
379 AC_SUBST(LIBXSLT_MIN_VERSION)
380 AC_SUBST(LIBXSLT_PC_FILE_COND)
381
382 dnl ==========================================================================
383 dnl See if we can find a crypto library
384 dnl ==========================================================================
385 XMLSEC_CRYPTO_LIST=""
386 XMLSEC_CRYPTO_DISABLED_LIST=""
387
388 dnl ==========================================================================
389 dnl OpenSSL
390 dnl ==========================================================================
391 ac_openssl_lib_dir="/usr/local/lib /usr/lib /usr/lib64 /usr/local /usr/local/ssl /usr/local/ssl/lib /usr/pkg"
392 ac_openssl_inc_dir="/usr/local/include /usr/include /usr/local /usr/local/ssl /usr/pkg /usr/local/ssl/include"
393
394 XMLSEC_NO_OPENSSL="1"
395 OPENSSL_MIN_VERSION="0.9.8"
396 OPENSSL_VERSION=""
397 OPENSSL_CFLAGS=""
398 OPENSSL_LIBS=""
399 OPENSSL_CRYPTO_LIB="$XMLSEC_PACKAGE-openssl"
400 OPENSSL_FOUND=no
401 AC_ARG_WITH(openssl, [  --with-openssl=[PFX]      openssl location])
402 if test "z$with_openssl" = "zno" ; then
403     OPENSSL_FOUND=without
404     AC_MSG_CHECKING(for openssl libraries >= $OPENSSL_MIN_VERSION) 
405     AC_MSG_RESULT(no)
406 elif test "z$with_openssl" != "z" ; then
407     case $host in
408         *-*-mingw*) openssl_exlibs=;;
409         *-*-osf5*) openssl_exlibs=;;
410         *-*-openbsd*) openssl_exlibs=;;
411         *-*-netbsd*) openssl_exlibs=;;
412         #FIXME: check if lib "dl" is required
413         *)          openssl_exlibs=-ldl;;
414     esac
415     OPENSSL_CFLAGS="$OPENSSL_CFLAGS -I$with_openssl/include"
416     if test -f "$with_openssl/lib/libcrypto${XMLSEC_SHLIBSFX}" ; then
417         OPENSSL_LIBS="-L$with_openssl/lib -lcrypto $openssl_exlibs"
418     else
419         OPENSSL_LIBS="$with_openssl/lib/libcrypto.a $openssl_exlibs"
420     fi
421     OPENSSL_FOUND="yes"
422 elif test "z$PKGCONFIG_FOUND" = "zyes" ; then
423     if test "z$OPENSSL_VERSION" = "z" ; then
424         PKG_CHECK_MODULES(OPENSSL, openssl >= 1.1.0,
425             [OPENSSL_VERSION="1.1.0"],
426             [OPENSSL_VERSION=""])
427     fi
428
429     if test "z$OPENSSL_VERSION" = "z" ; then
430         PKG_CHECK_MODULES(OPENSSL, openssl >= 1.0.0,
431             [OPENSSL_VERSION="1.0.0"],
432             [OPENSSL_VERSION=""])
433     fi
434
435     if test "z$OPENSSL_VERSION" = "z" ; then
436         PKG_CHECK_MODULES(OPENSSL, openssl >= 0.9.8,
437             [OPENSSL_VERSION="0.9.8"],
438             [OPENSSL_VERSION=""])
439     fi
440
441     if test "z$OPENSSL_VERSION" = "z" ; then
442         PKG_CHECK_MODULES(OPENSSL, openssl >= $OPENSSL_MIN_VERSION,
443             [OPENSSL_VERSION="$OPENSSL_MIN_VERSION"],
444             [OPENSSL_VERSION=""])
445     fi
446
447     if test "z$OPENSSL_VERSION" != "z" ; then
448         OPENSSL_FOUND="yes"
449     fi
450 fi
451
452 if test "z$OPENSSL_FOUND" = "zno" ; then
453     OPENSSL_INCLUDES_FOUND="no"
454     OPENSSL_LIBS_FOUND="no"
455     
456     for dir in $ac_openssl_inc_dir ; do
457         if test -f $dir/openssl/ssl.h ; then
458             dnl do not add -I/usr/include because compiler does it anyway
459             if test "z$dir" = "z/usr/include" ; then
460                 OPENSSL_CFLAGS="$OPENSSL_CFLAGS "
461             else
462                 OPENSSL_CFLAGS="$OPENSSL_CFLAGS -I$dir"
463             fi
464             OPENSSL_INCLUDES_FOUND="yes"
465             break
466         fi
467     done
468
469     for dir in $ac_openssl_lib_dir ; do
470         if test -f $dir/libcrypto.a ; then
471             dnl do not add -L/usr/lib because compiler does it anyway
472             if test "z$dir" = "z/usr/lib" ; then
473                 OPENSSL_LIBS="-lcrypto -ldl"
474             else
475                 OPENSSL_LIBS="-L$dir -lcrypto -ldl"
476             fi
477             OPENSSL_LIBS_FOUND="yes"
478             ac_found_openssl_lib_dir=$dir
479             break;
480         fi
481     done
482     
483     if test "z$OPENSSL_INCLUDES_FOUND" = "zyes" -a "z$OPENSSL_LIBS_FOUND" = "zyes" ; then
484         OPENSSL_FOUND="yes"
485     fi
486 fi
487
488 if test "z$OPENSSL_FOUND" = "zyes" -a "z$OPENSSL_VERSION" = "z" ; then
489     AC_MSG_CHECKING(for openssl libraries >= $OPENSSL_MIN_VERSION) 
490
491     dnl Check the OpenSSL version    
492     OLD_CPPFLAGS=$CPPFLAGS
493     CPPFLAGS="$OPENSSL_CFLAGS"
494
495     if test "z$OPENSSL_VERSION" = "z" ; then
496         AC_EGREP_CPP(yes,[
497             #include <openssl/opensslv.h>
498         #if OPENSSL_VERSION_NUMBER >= 0x10100000L
499         yes
500         #endif
501     ],[
502         OPENSSL_VERSION="1.1.0"
503     ],[
504         OPENSSL_VERSION=""
505     ])
506     fi
507
508     if test "z$OPENSSL_VERSION" = "z" ; then
509         AC_EGREP_CPP(yes,[
510             #include <openssl/opensslv.h>
511             #if OPENSSL_VERSION_NUMBER >= 0x10000000L
512                 yes
513             #endif
514         ],[
515             OPENSSL_VERSION="1.0.0"
516         ],[
517             OPENSSL_VERSION=""
518         ])
519     fi
520
521     if test "z$OPENSSL_VERSION" = "z" ; then
522         AC_EGREP_CPP(yes,[
523             #include <openssl/opensslv.h>
524             #if OPENSSL_VERSION_NUMBER >= 0x00908000L
525                 yes
526             #endif
527         ],[
528             OPENSSL_VERSION="0.9.8"
529         ],[
530             OPENSSL_VERSION=""
531         ])
532     fi
533
534     if test "z$OPENSSL_VERSION" = "z" ; then
535         AC_MSG_RESULT(no)
536     else
537         AC_MSG_RESULT([yes ('$OPENSSL_VERSION')])
538     fi
539     
540     CPPFLAGS=$OLD_CPPFLAGS
541 fi    
542
543 if test "z$OPENSSL_FOUND" = "zyes" ; then
544     dnl Check availability of ECDSA
545     OLD_CPPFLAGS=$CPPFLAGS
546     CPPFLAGS="$OPENSSL_CFLAGS"
547
548     AC_EGREP_CPP(yes,[
549         #include <openssl/opensslconf.h>
550         #ifdef OPENSSL_NO_ECDSA
551             yes
552         #endif
553     ],[
554         OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_NO_ECDSA=1"
555     ]) 
556     CPPFLAGS=$OLD_CPPFLAGS
557 fi
558
559 if test "z$OPENSSL_FOUND" = "zyes" ; then
560     XMLSEC_NO_OPENSSL="0"
561     if test "z$OPENSSL_VERSION" = "z0.9.8" ; then
562         OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_OPENSSL_098=1 -DXMLSEC_NO_ECDSA=1 -DXMLSEC_NO_SHA256=1"
563     fi
564     if test "z$OPENSSL_VERSION" = "z1.0.0" ; then
565         OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_OPENSSL_100=1"
566     fi    
567     if test "z$OPENSSL_VERSION" = "z1.1.0" ; then
568         OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_OPENSSL_110=1"
569     fi    
570     OPENSSL_CFLAGS="$OPENSSL_CFLAGS -DXMLSEC_CRYPTO_OPENSSL=1"
571     XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST openssl"
572 else
573     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST openssl"
574 fi
575
576 AM_CONDITIONAL(XMLSEC_NO_OPENSSL, test "z$XMLSEC_NO_OPENSSL" == "z1")
577 AC_SUBST(XMLSEC_NO_OPENSSL)
578 AC_SUBST(OPENSSL_CFLAGS)
579 AC_SUBST(OPENSSL_LIBS)
580 AC_SUBST(OPENSSL_CRYPTO_LIB)
581 AC_SUBST(OPENSSL_MIN_VERSION)
582
583 dnl ==========================================================================
584 dnl See if we can find NSS and NSPR
585 dnl Allow the use of:
586 dnl   1.  Mozilla style distribution where all mozilla components (NSS, NSPR
587 dnl       are just 2 of over 100 components) are under one directory.
588 dnl       options: [--with-mozilla-ver=<VERSION>]
589 dnl
590 dnl       Using the version number, various directories are searched
591 dnl       for NSS & NSPR
592 dnl
593 dnl                      AND / OR
594 dnl
595 dnl   2.  separate NSS & NSPR distributions
596 dnl       options: [--with-nss=<PFX>] [--with-nspr=<PFX>]
597 dnl   
598 dnl   2 overrides 1
599 dnl
600 dnl ==========================================================================
601 XMLSEC_NO_NSS="1"
602 SEAMONKEY_MIN_VERSION="1.0"
603 MOZILLA_MIN_VERSION="1.4"
604 NSS_MIN_VERSION="3.9"
605 NSPR_MIN_VERSION="4.4.1"
606 NSS_CFLAGS=""
607 NSS_LIBS=""
608 NSS_LIBS_LIST="-lnss3 -lsmime3"
609 NSPR_LIBS_LIST="-lnspr4 -lplds4 -lplc4"
610 NSS_CRYPTO_LIB="$XMLSEC_PACKAGE-nss"
611 NSS_FOUND="no"
612 NSPR_PACKAGE=mozilla-nspr
613 NSS_PACKAGE=mozilla-nss
614
615
616 dnl if nss is disabled, bail out early
617 AC_ARG_WITH(nss,     [  --with-nss=[PFX]          nss location])
618 AC_ARG_WITH(nspr,    [  --with-nspr=[PFX]         nspr location (needed for NSS)])
619 AC_ARG_WITH(seamonkey_ver, [  --with-seamonkey-ver=[VER]  mozilla version (alt to --with-nss, --with-nspr)])
620 AC_ARG_WITH(mozilla_ver, [  --with-mozilla-ver=[VER]  mozilla version (alt to --with-nss, --with-nspr)])
621 if test "z$with_nss" = "zno" -o "z$with_nspr" = "zno" ; then
622     AC_MSG_CHECKING(for NSS libraries) 
623     AC_MSG_RESULT(no)
624     NSS_FOUND="without"
625 elif test "z$with_nss" = "z" -a "z$with_nspr" = "z" -a "z$with_mozilla_ver" = "z" -a "z$with_seamonkey_ver" = "z" -a "z$PKGCONFIG_FOUND" = "zyes" ; then
626     dnl
627     dnl Mozilla's NSS/NSPR are distributed under different names
628     dnl in different distribution:
629     dnl         seamonkey-nspr and seamonkey-nss
630     dnl         mozilla-nspr and mozilla-nss
631     dnl         xulrunner-nspr and xulrunner-nss
632     dnl         nspr and nss
633     dnl We are going to try all options
634     dnl
635     if test "z$NSS_FOUND" = "zno" ; then
636         PKG_CHECK_MODULES(NSS, seamonkey-nspr >= $NSPR_MIN_VERSION seamonkey-nss >= $SEAMONKEY_MIN_VERSION,
637             [NSS_FOUND=yes NSPR_PACKAGE=seamonkey-nspr NSS_PACKAGE=seamonkey-nss],
638             [NSS_FOUND=no])
639     fi
640     if test "z$NSS_FOUND" = "zno" ; then
641         PKG_CHECK_MODULES(NSS, mozilla-nspr >= $MOZILLA_MIN_VERSION mozilla-nss >= $MOZILLA_MIN_VERSION,
642             [NSS_FOUND=yes NSPR_PACKAGE=mozilla-nspr NSS_PACKAGE=mozilla-nss],
643             [NSS_FOUND=no])
644     fi
645     if test "z$NSS_FOUND" = "zno" ; then
646         PKG_CHECK_MODULES(NSS, xulrunner-nspr >= $NSPR_MIN_VERSION xulrunner-nss >= $NSS_MIN_VERSION,
647             [NSS_FOUND=yes NSPR_PACKAGE=xulrunner-nspr NSS_PACKAGE=xulrunner-nss],
648             [NSS_FOUND=no])
649     fi
650     if test "z$NSS_FOUND" = "zno" ; then
651         PKG_CHECK_MODULES(NSS, nspr >= $NSPR_MIN_VERSION nss >= $NSS_MIN_VERSION,
652             [NSS_FOUND=yes NSPR_PACKAGE=nspr NSS_PACKAGE=nss],
653             [NSS_FOUND=no])
654     fi
655 fi
656
657 if test "z$NSS_FOUND" = "zno" ; then 
658     dnl process the mozilla options if any
659     if test "z$with_seamonkey_ver" != "z" ; then
660         ac_mozilla_name=seamonkey-$with_seamonkey_ver
661     elif test "z$with_mozilla_ver" != "z" ; then
662         ac_mozilla_name=mozilla-$with_mozilla_ver
663     else
664         ac_mozilla_name=mozilla-$MOZILLA_MIN_VERSION
665     fi
666
667     ac_nss_lib_dir="/usr/lib /usr/lib64 /usr/local/lib /usr/lib/$ac_mozilla_name /usr/local/lib/$ac_mozilla_name"
668     ac_nss_inc_dir="/usr/include /usr/include/mozilla /usr/local/include /usr/local/include/mozilla /usr/include/$ac_mozilla_name /usr/local/include/$ac_mozilla_name"
669
670     AC_MSG_CHECKING(for nspr libraries >= $NSPR_MIN_VERSION)
671     NSPR_INCLUDES_FOUND="no"
672     NSPR_LIBS_FOUND="no"
673     NSPR_FOUND="no"
674     NSPR_PRINIT_H=""
675
676     if test "z$with_nspr" != "z" ; then
677         NSPR_PREFIX="$with_nspr"
678         NSPR_CFLAGS="-I$with_nspr/include -I$with_nspr/include/nspr"
679         if test "z$with_gnu_ld" = "zyes" ; then
680             NSPR_LIBS="-Wl,-rpath-link -Wl,$with_nspr/lib -L$with_nspr/lib $NSPR_LIBS_LIST"
681         else
682             NSPR_LIBS="-L$with_nspr/lib $NSPR_LIBS_LIST"
683         fi
684         NSPR_INCLUDES_FOUND="yes"
685         NSPR_LIBS_FOUND="yes"
686         NSPR_PRINIT_H="$with_nspr/include/prinit.h"
687     else
688         for dir in $ac_nss_inc_dir ; do
689             if test -f $dir/nspr/prinit.h ; then
690                 dnl do not add -I/usr/include because compiler does it anyway
691                 if test "z$dir" = "z/usr/include" ; then
692                     NSPR_CFLAGS=""
693                 else
694                     NSPR_CFLAGS="-I$dir/nspr"
695                 fi
696                 NSPR_INCLUDES_FOUND="yes"
697                 NSPR_PRINIT_H="$dir/nspr/prinit.h"
698                 break
699             fi
700         done
701         
702         for dir in $ac_nss_lib_dir ; do
703             if test -f $dir/libnspr4$shrext ; then
704                 dnl do not add -L/usr/lib because compiler does it anyway
705                 if test "z$dir" = "z/usr/lib" ; then
706                     NSPR_LIBS="$NSPR_LIBS_LIST"
707                 else
708                     if test "z$with_gnu_ld" = "zyes" ; then
709                         NSPR_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSPR_LIBS_LIST"
710                     else
711                         NSPR_LIBS="-L$dir $NSPR_LIBS_LIST"
712                     fi
713                 fi
714                 NSPR_LIBS_FOUND="yes"
715                 break
716             fi
717         done
718     fi
719
720     if test "z$NSPR_INCLUDES_FOUND" = "zyes" -a "z$NSPR_LIBS_FOUND" = "zyes" ; then
721         OLD_CPPFLAGS=$CPPFLAGS
722         CPPFLAGS="$NSPR_CFLAGS"
723         AC_EGREP_CPP(yes,[
724             #include <prinit.h>
725             #if PR_VMAJOR >= 4
726                yes
727             #endif
728         ],[
729             NSPR_FOUND=yes
730         ],[
731             NSPR_FOUND=no
732         ]) 
733         CPPFLAGS="$OLD_CPPFLAGS"
734     fi
735     
736     if test "z$NSPR_FOUND" = "zyes" ; then    
737         AC_MSG_RESULT(yes)      
738     else
739         AC_MSG_RESULT(no)
740     fi
741
742     dnl look for nss
743     AC_MSG_CHECKING(for nss libraries >= $NSS_MIN_VERSION)
744     NSS_INCLUDES_FOUND="no"
745     NSS_LIBS_FOUND="no"
746     NSS_NSS_H=""
747
748     if test "z$with_nss" != "z" ; then
749         NSS_CFLAGS="$NSS_CFLAGS -I$with_nss/include -I$with_nss/include/nss"
750         if test "z$with_gnu_ld" = "zyes" ; then
751             NSS_LIBS="$NSS_LIBS -Wl,-rpath-link -Wl,$with_nss/lib -L$with_nss/lib $NSS_LIBS_LIST"
752         else
753             NSS_LIBS="$NSS_LIBS -L$with_nss/lib $NSS_LIBS_LIST"
754         fi
755         NSS_INCLUDES_FOUND="yes"
756         NSS_LIBS_FOUND="yes"
757         NSS_NSS_H="$with_nss/include/nss.h"
758     else
759         for dir in $ac_nss_inc_dir ; do
760             if test -f $dir/nss/nss.h ; then
761                 dnl do not add -I/usr/include because compiler does it anyway
762                 if test "z$dir" = "z/usr/include" ; then
763                     NSS_CFLAGS="$NSS_CFLAGS"
764                 else
765                     NSS_CFLAGS="$NSS_CFLAGS -I$dir/nss"
766                 fi
767                 NSS_INCLUDES_FOUND="yes"
768                 NSS_NSS_H="$dir/nss/nss.h"
769                 break
770             fi
771         done
772        
773         for dir in $ac_nss_lib_dir ; do
774             if test -f $dir/libnss3$shrext ; then
775                 dnl do not add -L/usr/lib because compiler does it anyway
776                 if test "z$dir" = "z/usr/lib" ; then
777                     NSS_LIBS="$NSS_LIBS_LIST"
778                 else
779                     if test "z$with_gnu_ld" = "zyes" ; then
780                         NSS_LIBS="-Wl,-rpath-link -Wl,$dir -L$dir $NSS_LIBS_LIST"
781                     else
782                         NSS_LIBS="-L$dir $NSS_LIBS_LIST"
783                     fi
784                 fi
785                 NSS_LIBS_FOUND="yes"
786                 break
787             fi
788         done
789     fi
790
791     if test "z$NSS_INCLUDES_FOUND" = "zyes" -a "z$NSS_LIBS_FOUND" = "zyes" ; then
792        OLD_CPPFLAGS=$CPPFLAGS
793        CPPFLAGS="$NSPR_CFLAGS $NSS_CFLAGS"
794        AC_EGREP_CPP(yes,[
795           #include <nss.h>
796           #if NSS_VMAJOR >= 3 && NSS_VMINOR >= 2
797              yes
798           #endif
799         ],[
800             NSS_FOUND=yes
801         ],[
802             NSS_FOUND=no
803         ]) 
804         CPPFLAGS="$OLD_CPPFLAGS"
805     fi
806     
807     if test "z$NSS_FOUND" = "zyes" ; then    
808         AC_MSG_RESULT(yes)      
809     else
810         AC_MSG_RESULT(no)
811     fi
812
813     dnl check that we have found both NSS and NSPR
814     if test "z$NSPR_FOUND" = "zyes" -a "z$NSS_FOUND" = "zyes" ; then
815         NSS_CFLAGS="$NSS_CFLAGS $NSPR_CFLAGS"
816         NSS_LIBS="$NSS_LIBS $NSPR_LIBS"
817     elif test "z$NSPR_FOUND" != "zyes" -a "z$NSS_FOUND" = "zyes" ; then    
818         NSS_FOUND="no"
819         AC_MSG_RESULT(NSPR library is required for NSS, ignoring NSS library we have found)
820     fi
821 fi
822
823 if test "z$NSS_FOUND" = "zyes" ; then
824     XMLSEC_NO_NSS="0"
825     NSS_CFLAGS="$NSS_CFLAGS -DXMLSEC_CRYPTO_NSS=1"
826     XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST nss"
827 else
828     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST nss"
829 fi
830
831 AM_CONDITIONAL(XMLSEC_NO_NSS, test "z$XMLSEC_NO_NSS" = "z1")
832 AC_SUBST(XMLSEC_NO_NSS)
833 AC_SUBST(NSPR_PACKAGE)
834 AC_SUBST(NSS_PACKAGE)
835 AC_SUBST(NSS_CFLAGS)
836 AC_SUBST(NSS_LIBS)
837 AC_SUBST(NSS_CRYPTO_LIB)
838 AC_SUBST(NSS_MIN_VERSION)
839 AC_SUBST(NSPR_MIN_VERSION)
840 AC_SUBST(MOZILLA_MIN_VERSION)
841
842
843 dnl ==========================================================================
844 dnl See if we can find GCrypt
845 dnl ==========================================================================
846 GCRYPT_CONFIG="libgcrypt-config"
847 XMLSEC_NO_GCRYPT="1"
848 GCRYPT_MIN_VERSION="1.4.0"
849 GCRYPT_VERSION=""
850 GCRYPT_CFLAGS=""
851 GCRYPT_LIBS=""
852 GCRYPT_CRYPTO_LIB="$XMLSEC_PACKAGE-gcrypt"
853 GCRYPT_FOUND="no"
854 AC_ARG_WITH(gcrypt, [  --with-gcrypt=[PFX]       gcrypt location])
855 if test "z$with_gcrypt" = "zno" ; then
856     AC_MSG_CHECKING(for gcrypt libraries >= $GCRYPT_MIN_VERSION) 
857     AC_MSG_RESULT(no)
858     GCRYPT_FOUND="without"
859 elif test "z$with_gcrypt" = "z" -a "z$PKGCONFIG_FOUND" = "zyes" ; then
860     PKG_CHECK_MODULES(GCRYPT, gcrypt >= $GCRYPT_MIN_VERSION,
861         [GCRYPT_FOUND=yes],
862         [GCRYPT_FOUND=no])
863
864     if test "z$GCRYPT_FOUND" = "zno" ; then
865         PKG_CHECK_MODULES(GCRYPT, libgcrypt >= $GCRYPT_MIN_VERSION,
866             [GCRYPT_FOUND=yes],
867             [GCRYPT_FOUND=no])
868     fi
869
870     if test "z$GCRYPT_FOUND" = "zno" ; then
871         PKG_CHECK_MODULES(GCRYPT, libgcrypt11 >= $GCRYPT_MIN_VERSION,
872             [GCRYPT_FOUND=yes],
873             [GCRYPT_FOUND=no])
874     fi
875 fi
876
877 if test "z$GCRYPT_FOUND" = "zno" ; then
878     AC_MSG_CHECKING(for gcrypt libraries >= $GCRYPT_MIN_VERSION) 
879     if test "z$with_gcrypt" != "z" ; then
880         GCRYPT_CONFIG=$with_gcrypt/bin/$GCRYPT_CONFIG
881     fi
882     if ! $GCRYPT_CONFIG --version > /dev/null 2>&1 ; then
883         if test "z$with_gcrypt" != "z" ; then
884             AC_MSG_ERROR(Unable to find gcrypt at '$with_gcrypt')
885         else
886             AC_MSG_RESULT(no)
887         fi
888     else
889         vers=`$GCRYPT_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
890         minvers=`echo $GCRYPT_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
891         if test "$vers" -ge "$minvers" ; then
892             GCRYPT_CFLAGS="$GCRYPT_CFLAGS `$GCRYPT_CONFIG --cflags`"
893             GCRYPT_LIBS="$GCRYPT_LIBS `$GCRYPT_CONFIG --libs`"
894             GCRYPT_FOUND=yes
895         else
896             AC_MSG_ERROR(You need at least gcrypt $GCRYPT_MIN_VERSION for this version of $XMLSEC_PACKAGE)
897         fi      
898     fi
899 fi
900
901 if test "z$GCRYPT_FOUND" = "zyes" ; then 
902     XMLSEC_NO_GCRYPT="0"
903     GCRYPT_CFLAGS="$GCRYPT_CFLAGS -DXMLSEC_CRYPTO_GCRYPT=1"
904     XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST gcrypt"
905 else
906     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST gcrypt"
907 fi
908
909 AM_CONDITIONAL(XMLSEC_NO_GCRYPT, test "z$XMLSEC_NO_GCRYPT" = "z1")
910 AC_SUBST(XMLSEC_NO_GCRYPT)
911 AC_SUBST(GCRYPT_CFLAGS)
912 AC_SUBST(GCRYPT_LIBS)
913 AC_SUBST(GCRYPT_CRYPTO_LIB)
914 AC_SUBST(GCRYPT_MIN_VERSION)
915
916
917 dnl ==========================================================================
918 dnl See if we can find GnuTLS
919 dnl ==========================================================================
920 GNUTLS_CONFIG="libgnutls-config"
921 XMLSEC_NO_GNUTLS="1"
922 GNUTLS_MIN_VERSION="2.8.0"
923 GNUTLS_VERSION=""
924 GNUTLS_CFLAGS=""
925 GNUTLS_LIBS=""
926 GNUTLS_CRYPTO_LIB="$XMLSEC_PACKAGE-gnutls"
927 GNUTLS_FOUND="no"
928 AC_ARG_WITH(gnutls, [  --with-gnutls=[PFX]       gnutls location])
929 if test "z$with_gnutls" = "zno" ; then
930     AC_MSG_CHECKING(for gnutls libraries >= $GNUTLS_MIN_VERSION) 
931     AC_MSG_RESULT(no)
932     GNUTLS_FOUND="without"
933 elif test "z$with_gnutls" = "z" -a "z$PKGCONFIG_FOUND" = "zyes" ; then
934     PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_MIN_VERSION,
935         [GNUTLS_FOUND=yes],
936         [GNUTLS_FOUND=no])
937     if test "z$GNUTLS_FOUND" = "zno" ; then 
938         PKG_CHECK_MODULES(GNUTLS, libgnutls >= $GNUTLS_MIN_VERSION,
939             [GNUTLS_FOUND=yes],
940             [GNUTLS_FOUND=no])
941     fi
942 fi
943
944 if test "z$GNUTLS_FOUND" = "zno" ; then
945     AC_MSG_CHECKING(for gnutls libraries >= $GNUTLS_MIN_VERSION) 
946     if test "z$with_gnutls" != "z" ; then
947         GNUTLS_CONFIG=$with_gnutls/bin/$GNUTLS_CONFIG
948     fi
949     if ! $GNUTLS_CONFIG --version > /dev/null 2>&1 ; then
950         if test "z$with_gnutls" != "z" ; then
951             AC_MSG_ERROR(Unable to find gnutls at '$with_gnutls')
952         else
953             AC_MSG_RESULT(no)
954         fi
955     else
956         vers=`$GNUTLS_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
957         minvers=`echo $GNUTLS_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
958         if test "$vers" -ge "$minvers" ; then
959             GNUTLS_CFLAGS="$GNUTLS_CFLAGS `$GNUTLS_CONFIG --cflags`"
960             GNUTLS_LIBS="$GNUTLS_LIBS `$GNUTLS_CONFIG --libs`"
961             GNUTLS_FOUND=yes
962         else
963             AC_MSG_ERROR(You need at least gnutls $GNUTLS_MIN_VERSION for this version of $XMLSEC_PACKAGE)
964         fi      
965     fi
966 fi
967
968 if test "z$GNUTLS_FOUND" = "zyes" ; then 
969     XMLSEC_NO_GNUTLS="0"
970     GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DXMLSEC_CRYPTO_GNUTLS=1"
971     XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST gnutls"
972
973     dnl xmlsec-gnutls is using xmlsec-gcrypt
974     if test "z$GCRYPT_FOUND" != "zyes" ; then
975         AC_MSG_ERROR(xmlsec-gnutls library requires xmlsec-gcrypt library which is disabled or missing)
976     fi
977
978 else
979     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST gnutls"
980 fi
981
982 AM_CONDITIONAL(XMLSEC_NO_GNUTLS, test "z$XMLSEC_NO_GNUTLS" = "z1")
983 AC_SUBST(XMLSEC_NO_GNUTLS)
984 AC_SUBST(GNUTLS_CFLAGS)
985 AC_SUBST(GNUTLS_LIBS)
986 AC_SUBST(GNUTLS_CRYPTO_LIB)
987 AC_SUBST(GNUTLS_MIN_VERSION)
988
989
990 dnl ==========================================================================
991 dnl See if we can find MSCrypto
992 dnl ==========================================================================
993 XMLSEC_NO_MSCRYPTO="1"
994 MSCRYPTO_CFLAGS=""
995 MSCRYPTO_LIBS=""
996 MSCRYPTO_CRYPTO_LIB="$XMLSEC_PACKAGE-mscrypto"
997 MSCRYPTO_ENABLE='none'
998 AC_ARG_ENABLE(mscrypto,
999         [  --enable-mscrypto       enable mscrypto (no)],
1000         [MSCRYPTO_ENABLE=$enableval])
1001 if test "z$MSCRYPTO_ENABLE" != "zyes" ; then
1002     AC_MSG_CHECKING(for mscrypto libraries)
1003     AC_MSG_RESULT([$MSCRYPTO_ENABLE])
1004 else
1005 dnl cannot detect __stdcall functions
1006 dnl    AC_CHECK_LIB(crypt32, CertOpenStore, ....
1007     LIBS_SAVE="$LIBS"
1008     LIBS="$LIBS -lcrypt32"
1009     AC_MSG_CHECKING(for mscrypto libraries)
1010     AC_LINK_IFELSE([AC_LANG_PROGRAM([
1011         #include <windows.h>
1012         #include <wincrypt.h>],[
1013         int main () { CertOpenStore(0,0,0,0,0);; return(0); }
1014         ])],
1015         [],
1016         [MSCRYPTO_ENABLE="no"])
1017     AC_MSG_RESULT([$MSCRYPTO_ENABLE])
1018     LIBS="$LIBS_SAVE"
1019 fi
1020
1021 if test "z$MSCRYPTO_ENABLE" = "zyes" ; then
1022     XMLSEC_NO_MSCRYPTO="0"
1023
1024     MSCRYPTO_CFLAGS="$MSCRYPTO_CFLAGS -DXMLSEC_CRYPTO_MSCRYPTO=1"
1025     case $host in
1026         *-*-mingw*)
1027                 dnl since mingw crypt32 library is limited
1028                 dnl we use own def-file
1029                 MSCRYPTO_LIBS='-Wl,$(srcdir)/mingw-crypt32.def';;
1030         *)
1031                 MSCRYPTO_LIBS="-lcrypt32";;
1032     esac
1033
1034     XMLSEC_CRYPTO_LIST="$XMLSEC_CRYPTO_LIST mscrypto"
1035 else
1036     XMLSEC_CRYPTO_DISABLED_LIST="$XMLSEC_CRYPTO_DISABLED_LIST mscrypto"
1037 fi
1038
1039 AM_CONDITIONAL(XMLSEC_NO_MSCRYPTO, [test "z$XMLSEC_NO_MSCRYPTO" = "z1"])
1040 AC_SUBST(XMLSEC_NO_MSCRYPTO)
1041 AC_SUBST(MSCRYPTO_CFLAGS)
1042 AC_SUBST(MSCRYPTO_LIBS)
1043 AC_SUBST(MSCRYPTO_CRYPTO_LIB)
1044
1045
1046 dnl ==========================================================================
1047 dnl Figure out the default crypt - the first crypto library wins
1048 dnl ==========================================================================
1049 XMLSEC_DEFAULT_CRYPTO=""
1050 XMLSEC_CRYPTO_LIB=""
1051 XMLSEC_CRYPTO_CFLAGS=""
1052 XMLSEC_CRYPTO_LIBS=""
1053 AC_MSG_CHECKING(for default crypto library)
1054 AC_ARG_WITH(default_crypto, [  --with-default-crypto=name default crypto name])
1055
1056 # check the argument
1057 case "z$with_default_crypto" in
1058     'zmscrypto')
1059         if test "z$XMLSEC_NO_MSCRYPTO" != "z1" ; then
1060             XMLSEC_DEFAULT_CRYPTO="mscrypto"
1061         else
1062             AC_MSG_ERROR('$with_default_crypto' is specified as default crypto library but it is not configured or found)
1063         fi
1064         ;;
1065     'zopenssl')
1066         if test "z$XMLSEC_NO_OPENSSL" != "z1" ; then
1067             XMLSEC_DEFAULT_CRYPTO="openssl"
1068         else
1069             AC_MSG_ERROR('$with_default_crypto' is specified as default crypto library but it is not configured or found)
1070         fi
1071         ;;
1072     'znss')
1073         if test "z$XMLSEC_NO_NSS" != "z1" ; then
1074             XMLSEC_DEFAULT_CRYPTO="nss"
1075         else
1076             AC_MSG_ERROR('$with_default_crypto' is specified as default crypto library but it is not configured or found)
1077         fi
1078         ;;
1079     'zgnutls')
1080         if test "z$XMLSEC_NO_GNUTLS" != "z1" ; then
1081             XMLSEC_DEFAULT_CRYPTO="gnutls"
1082         else
1083             AC_MSG_ERROR('$with_default_crypto' is specified as default crypto library but it is not configured or found)
1084         fi
1085         ;;
1086     'zgcrypt')
1087         if test "z$XMLSEC_NO_GCRYPT" != "z1" ; then
1088             XMLSEC_DEFAULT_CRYPTO="gcrypt"
1089         else
1090             AC_MSG_ERROR('$with_default_crypto' is specified as default crypto library but it is not configured or found)
1091         fi
1092         ;;
1093     'z')
1094         dnl The first crypto library wins
1095         if test "z$XMLSEC_NO_MSCRYPTO" != "z1" ; then
1096             XMLSEC_DEFAULT_CRYPTO="mscrypto"
1097         elif test "z$XMLSEC_NO_OPENSSL" != "z1" ; then
1098             XMLSEC_DEFAULT_CRYPTO="openssl"
1099         elif test "z$XMLSEC_NO_NSS" != "z1" ; then
1100             XMLSEC_DEFAULT_CRYPTO="nss"
1101         elif test "z$XMLSEC_NO_GNUTLS" != "z1" ; then
1102             XMLSEC_DEFAULT_CRYPTO="gnutls"
1103         elif test "z$XMLSEC_NO_GCRYPT" != "z1" ; then
1104             XMLSEC_DEFAULT_CRYPTO="gcrypt"
1105         else
1106             AC_MSG_ERROR(At least one crypto library should exist for $XMLSEC_PACKAGE)
1107         fi
1108         ;;
1109     *)
1110         AC_MSG_ERROR(The value '$with_default_crypto' is not a recongnized crypto library name)
1111         ;;
1112 esac
1113
1114 dnl Set the flags for default crypto lib
1115 case "$XMLSEC_DEFAULT_CRYPTO" in
1116     'mscrypto')
1117         XMLSEC_CRYPTO_LIB="$MSCRYPTO_CRYPTO_LIB"
1118         XMLSEC_CRYPTO_CFLAGS="$MSCRYPTO_CFLAGS"
1119         XMLSEC_CRYPTO_LIBS="$MSCRYPTO_LIBS"
1120         ;;
1121     'openssl')
1122         XMLSEC_CRYPTO_LIB="$OPENSSL_CRYPTO_LIB"
1123         XMLSEC_CRYPTO_CFLAGS="$OPENSSL_CFLAGS"
1124         XMLSEC_CRYPTO_LIBS="$OPENSSL_LIBS"
1125         ;;
1126     'nss')
1127         XMLSEC_CRYPTO_LIB="$NSS_CRYPTO_LIB"
1128         XMLSEC_CRYPTO_CFLAGS="$NSS_CFLAGS"
1129         XMLSEC_CRYPTO_LIBS="$NSS_LIBS"
1130         ;;
1131     'gnutls')
1132         XMLSEC_CRYPTO_LIB="$GNUTLS_CRYPTO_LIB"
1133         XMLSEC_CRYPTO_CFLAGS="$GNUTLS_CFLAGS"
1134         XMLSEC_CRYPTO_LIBS="$GNUTLS_LIBS"
1135         ;;
1136     'gcrypt')
1137         XMLSEC_CRYPTO_LIB="$GCRYPT_CRYPTO_LIB"
1138         XMLSEC_CRYPTO_CFLAGS="$GCRYPT_CFLAGS"
1139         XMLSEC_CRYPTO_LIBS="$GCRYPT_LIBS"
1140         ;;
1141     *)
1142         AC_MSG_ERROR(The value \"$XMLSEC_DEFAULT_CRYPTO\" is not a recongnized crypto library name)
1143         ;;
1144 esac
1145 AC_MSG_RESULT(yes ('$XMLSEC_DEFAULT_CRYPTO'))
1146
1147 dnl ==========================================================================
1148 dnl See do we need MD5 support
1149 dnl ==========================================================================
1150 AC_MSG_CHECKING(for MD5 support) 
1151 AC_ARG_ENABLE(md5,   [  --enable-md5            enable MD5 support (yes)])
1152 if test "z$enable_md5" = "zno" ; then
1153     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_MD5=1"
1154     XMLSEC_NO_MD5="1"
1155     AC_MSG_RESULT(no)
1156 else
1157     XMLSEC_NO_MD5="0"
1158     AC_MSG_RESULT(yes)
1159 fi    
1160 AM_CONDITIONAL(XMLSEC_NO_MD5, test "z$XMLSEC_NO_MD5" = "z1")
1161 AC_SUBST(XMLSEC_NO_MD5)
1162
1163 dnl ==========================================================================
1164 dnl See do we need RIPEMD-160 support
1165 dnl ==========================================================================
1166 AC_MSG_CHECKING(for RIPEMD-160 support) 
1167 AC_ARG_ENABLE(ripemd160,   [  --enable-ripemd160      enable RIPEMD-160 support (yes)])
1168 if test "z$enable_ripemd160" = "zno" ; then
1169     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_RIPEMD160=1"
1170     XMLSEC_NO_RIPEMD160="1"
1171     AC_MSG_RESULT(no)
1172 else
1173     XMLSEC_NO_RIPEMD160="0"
1174     AC_MSG_RESULT(yes)
1175 fi    
1176 AM_CONDITIONAL(XMLSEC_NO_RIPEMD160, test "z$XMLSEC_NO_RIPEMD160" = "z1")
1177 AC_SUBST(XMLSEC_NO_RIPEMD160)
1178
1179 dnl ==========================================================================
1180 dnl See do we need SHA1 support
1181 dnl ==========================================================================
1182 AC_MSG_CHECKING(for SHA1 support) 
1183 AC_ARG_ENABLE(sha1,   [  --enable-sha1           enable SHA1 support (yes)])
1184 if test "z$enable_sha1" = "zno" ; then
1185     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SHA1=1"
1186     XMLSEC_NO_SHA1="1"
1187     AC_MSG_RESULT(no)
1188 else
1189     XMLSEC_NO_SHA1="0"
1190     AC_MSG_RESULT(yes)
1191 fi    
1192 AM_CONDITIONAL(XMLSEC_NO_SHA1, test "z$XMLSEC_NO_SHA1" = "z1")
1193 AC_SUBST(XMLSEC_NO_SHA1)
1194
1195 dnl ==========================================================================
1196 dnl See do we need SHA224 support
1197 dnl ==========================================================================
1198 AC_MSG_CHECKING(for SHA224 support) 
1199 AC_ARG_ENABLE(sha224,   [  --enable-sha224         enable SHA224 support (yes)])
1200 if test "z$enable_sha224" = "zno" ; then
1201     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SHA224=1"
1202     XMLSEC_NO_SHA224="1"
1203     AC_MSG_RESULT(no)
1204 else
1205     XMLSEC_NO_SHA224="0"
1206     AC_MSG_RESULT(yes)
1207 fi    
1208 AM_CONDITIONAL(XMLSEC_NO_SHA224, test "z$XMLSEC_NO_SHA224" = "z1")
1209 AC_SUBST(XMLSEC_NO_SHA224)
1210
1211 dnl ==========================================================================
1212 dnl See do we need SHA256 support
1213 dnl ==========================================================================
1214 AC_MSG_CHECKING(for SHA256 support) 
1215 AC_ARG_ENABLE(sha256,   [  --enable-sha256         enable SHA256 support (yes)])
1216 if test "z$enable_sha256" = "zno" ; then
1217     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SHA256=1"
1218     XMLSEC_NO_SHA256="1"
1219     AC_MSG_RESULT(no)
1220 else
1221     XMLSEC_NO_SHA256="0"
1222     AC_MSG_RESULT(yes)
1223 fi    
1224 AM_CONDITIONAL(XMLSEC_NO_SHA256, test "z$XMLSEC_NO_SHA256" = "z1")
1225 AC_SUBST(XMLSEC_NO_SHA256)
1226
1227 dnl ==========================================================================
1228 dnl See do we need SHA384 support
1229 dnl ==========================================================================
1230 AC_MSG_CHECKING(for SHA384 support) 
1231 AC_ARG_ENABLE(sha384,   [  --enable-sha384         enable SHA384 support (yes)])
1232 if test "z$enable_sha384" = "zno" ; then
1233     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SHA384=1"
1234     XMLSEC_NO_SHA384="1"
1235     AC_MSG_RESULT(no)
1236 else
1237     XMLSEC_NO_SHA384="0"
1238     AC_MSG_RESULT(yes)
1239 fi    
1240 AM_CONDITIONAL(XMLSEC_NO_SHA384, test "z$XMLSEC_NO_SHA384" = "z1")
1241 AC_SUBST(XMLSEC_NO_SHA384)
1242
1243 dnl ==========================================================================
1244 dnl See do we need SHA512 support
1245 dnl ==========================================================================
1246 AC_MSG_CHECKING(for SHA512 support) 
1247 AC_ARG_ENABLE(sha512,   [  --enable-sha512         enable SHA512 support (yes)])
1248 if test "z$enable_sha512" = "zno" ; then
1249     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SHA512=1"
1250     XMLSEC_NO_SHA512="1"
1251     AC_MSG_RESULT(no)
1252 else
1253     XMLSEC_NO_SHA512="0"
1254     AC_MSG_RESULT(yes)
1255 fi    
1256 AM_CONDITIONAL(XMLSEC_NO_SHA512, test "z$XMLSEC_NO_SHA512" = "z1")
1257 AC_SUBST(XMLSEC_NO_SHA512)
1258
1259
1260 dnl ==========================================================================
1261 dnl See do we need HMAC support
1262 dnl ==========================================================================
1263 AC_MSG_CHECKING(for HMAC support) 
1264 AC_ARG_ENABLE(hmac,   [  --enable-hmac           enable HMAC support (yes)])
1265 if test "z$enable_hmac" = "zno" ; then
1266     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_HMAC=1"
1267     XMLSEC_NO_HMAC="1"
1268     AC_MSG_RESULT(no)
1269 else
1270     XMLSEC_NO_HMAC="0"
1271     AC_MSG_RESULT(yes)
1272 fi    
1273 AM_CONDITIONAL(XMLSEC_NO_HMAC, test "z$XMLSEC_NO_HMAC" = "z1")
1274 AC_SUBST(XMLSEC_NO_HMAC)
1275
1276 dnl ==========================================================================
1277 dnl See do we need DSA support
1278 dnl ==========================================================================
1279 AC_MSG_CHECKING(for DSA support) 
1280 AC_ARG_ENABLE(dsa,   [  --enable-dsa            enable DSA support (yes)])
1281 if test "z$enable_dsa" = "zno" ; then
1282     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_DSA=1"
1283     XMLSEC_NO_DSA="1"
1284     AC_MSG_RESULT(no)
1285 else
1286     XMLSEC_NO_DSA="0"
1287     AC_MSG_RESULT(yes)
1288 fi    
1289 AM_CONDITIONAL(XMLSEC_NO_DSA, test "z$XMLSEC_NO_DSA" = "z1")
1290 AC_SUBST(XMLSEC_NO_DSA)
1291
1292 dnl ==========================================================================
1293 dnl See do we need RSA support
1294 dnl ==========================================================================
1295 AC_MSG_CHECKING(for RSA support) 
1296 AC_ARG_ENABLE(rsa,   [  --enable-rsa            enable RSA support (yes)])
1297 if test "z$enable_rsa" = "zno" ; then
1298     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_RSA=1"
1299     XMLSEC_NO_RSA="1"
1300     AC_MSG_RESULT(no)
1301 else
1302     XMLSEC_NO_RSA="0"
1303     AC_MSG_RESULT(yes)
1304 fi    
1305 AM_CONDITIONAL(XMLSEC_NO_RSA, test "z$XMLSEC_NO_RSA" = "z1")
1306 AC_SUBST(XMLSEC_NO_RSA)
1307
1308 dnl ==========================================================================
1309 dnl See do we need x509 support
1310 dnl ==========================================================================
1311 AC_MSG_CHECKING(for x509 support) 
1312 AC_ARG_ENABLE(x509,   [  --enable-x509           enable x509 support (yes)])
1313 if test "z$enable_x509" = "zno" ; then
1314     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_X509=1"
1315     XMLSEC_NO_X509="1"
1316     AC_MSG_RESULT(no)
1317 else
1318     XMLSEC_NO_X509="0"
1319     AC_MSG_RESULT(yes)
1320 fi    
1321 AM_CONDITIONAL(XMLSEC_NO_X509, test "z$XMLSEC_NO_X509" = "z1")
1322 AC_SUBST(XMLSEC_NO_X509)
1323
1324 dnl ==========================================================================
1325 dnl See do we need DES support
1326 dnl ==========================================================================
1327 AC_MSG_CHECKING(for DES support) 
1328 AC_ARG_ENABLE(des,   [  --enable-des            enable DES support (yes)])
1329 if test "z$enable_des" = "zno" ; then
1330     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_DES=1"
1331     XMLSEC_NO_DES="1"
1332     AC_MSG_RESULT(no)
1333 else
1334     XMLSEC_NO_DES="0"
1335     AC_MSG_RESULT(yes)
1336 fi    
1337 AM_CONDITIONAL(XMLSEC_NO_DES, test "z$XMLSEC_NO_DES" = "z1")
1338 AC_SUBST(XMLSEC_NO_DES)
1339
1340 dnl ==========================================================================
1341 dnl See do we need AES support
1342 dnl ==========================================================================
1343 AC_MSG_CHECKING(for AES support) 
1344 AC_ARG_ENABLE(aes,   [  --enable-aes            enable AES support])
1345 if test "z$enable_aes" = "zno" ; then
1346     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_AES=1"
1347     XMLSEC_NO_AES="1"
1348     AC_MSG_RESULT(no)
1349 else
1350     XMLSEC_NO_AES="0"
1351     AC_MSG_RESULT(yes)
1352 fi    
1353 AM_CONDITIONAL(XMLSEC_NO_AES, test "z$XMLSEC_NO_AES" = "z1")
1354 AC_SUBST(XMLSEC_NO_AES)
1355
1356 dnl ==========================================================================
1357 dnl See do we need GOST support
1358 dnl ==========================================================================
1359 AC_MSG_CHECKING(for GOST support)
1360 AC_ARG_ENABLE(gost,   [  --enable-gost           enable GOST support (no)])
1361 if test "z$enable_gost" != "zyes" ; then
1362     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_GOST=1"
1363     XMLSEC_NO_GOST="1"
1364     AC_MSG_RESULT(no)
1365 else
1366     XMLSEC_NO_GOST="0"
1367     AC_MSG_RESULT(yes)
1368 fi
1369 AM_CONDITIONAL(XMLSEC_NO_GOST, test "z$XMLSEC_NO_GOST" = "z1")
1370 AC_SUBST(XMLSEC_NO_GOST)
1371
1372
1373 dnl ==========================================================================
1374 dnl See do we need GOST2012 support
1375 dnl ==========================================================================
1376 AC_MSG_CHECKING(for EXPERMIENTAL GOST2012 support)
1377 AC_ARG_ENABLE(gost,   [  --enable-gost2012       enable EXPERMIENTAL GOST2012 support (no)])
1378 if test "z$enable_gost2012" != "zyes" ; then
1379     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_GOST2012=1"
1380     XMLSEC_NO_GOST2012="1"
1381     AC_MSG_RESULT(no)
1382 else
1383     XMLSEC_NO_GOST2012="0"
1384     AC_MSG_RESULT(yes)
1385 fi
1386 AM_CONDITIONAL(XMLSEC_NO_GOST2012, test "z$XMLSEC_NO_GOST2012" = "z1")
1387 AC_SUBST(XMLSEC_NO_GOST2012)
1388
1389
1390 dnl ==========================================================================
1391 dnl See do we need XMLDSig support
1392 dnl ==========================================================================
1393 AC_MSG_CHECKING(for XMLDSig support) 
1394 AC_ARG_ENABLE(xmldsig,   [  --enable-xmldsig        enable XMLDSig support (yes)])
1395 if test "z$enable_xmldsig" = "zno" ; then
1396     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_XMLDSIG=1"
1397     XMLSEC_NO_XMLDSIG="1"
1398     AC_MSG_RESULT(no)
1399 else
1400     XMLSEC_NO_XMLDSIG="0"
1401     AC_MSG_RESULT(yes)
1402 fi    
1403 AM_CONDITIONAL(XMLSEC_NO_XMLDSIG, test "z$XMLSEC_NO_XMLDSIG" = "z1")
1404 AC_SUBST(XMLSEC_NO_XMLDSIG)
1405
1406 dnl ==========================================================================
1407 dnl See do we need XMLEnc support
1408 dnl ==========================================================================
1409 AC_MSG_CHECKING(for XMLEnc support) 
1410 AC_ARG_ENABLE(xmlenc,   [  --enable-xmlenc         enable XMLEnc support (yes)])
1411 if test "z$enable_xmlenc" = "zno" ; then
1412     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_XMLENC=1"
1413     XMLSEC_NO_XMLENC="1"
1414     AC_MSG_RESULT(no)
1415 else
1416     XMLSEC_NO_XMLENC="0"
1417     AC_MSG_RESULT(yes)
1418 fi    
1419 AM_CONDITIONAL(XMLSEC_NO_XMLENC, test "z$XMLSEC_NO_XMLENC" = "z1")
1420 AC_SUBST(XMLSEC_NO_XMLENC)
1421
1422 dnl ==========================================================================
1423 dnl check if we need dynamic loading support
1424 dnl ==========================================================================
1425 XMLSEC_DL_INCLUDES=""
1426 XMLSEC_DL_LIBS=""
1427 AC_MSG_CHECKING(for xmlsec-crypto dynamic loading support) 
1428 AC_ARG_ENABLE(crypto_dl,   [  --enable-crypto-dl      enable dynamic loading support for xmlsec-crypto libraries (yes)])
1429 if test "z$enable_crypto_dl" = "zno" ; then
1430     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1"
1431     XMLSEC_NO_CRYPTO_DYNAMIC_LOADING="1"
1432     AC_MSG_RESULT(no)
1433 else
1434     AC_CHECK_HEADER([ltdl.h], 
1435         [
1436         XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_DL_LIBLTDL=1"
1437         AC_CHECK_LIB(
1438             [ltdl],
1439             [lt_dlopenext],
1440             [LIBLTDL=-lltdl],
1441             [LIBLTDL=]
1442         )],
1443         [LIBLTDL=]
1444     )
1445
1446     if test "z$LIBLTDL" != "z" ; then
1447         XMLSEC_DL_INCLUDES="$INCLTDL"
1448         XMLSEC_DL_LIBS="$LIBLTDL"
1449         XMLSEC_NO_CRYPTO_DYNAMIC_LOADING="0"
1450         AC_MSG_RESULT(yes)
1451     else
1452         AC_MSG_ERROR([libltdl is required for xmlsec-crypto dynamic loading])
1453     fi
1454 fi
1455 AM_CONDITIONAL(XMLSEC_NO_CRYPTO_DYNAMIC_LOADING, test "z$XMLSEC_NO_CRYPTO_DYNAMIC_LOADING" = "z1")
1456 AC_SUBST(XMLSEC_NO_CRYPTO_DYNAMIC_LOADING)
1457 AC_SUBST(XMLSEC_DL_INCLUDES)
1458 AC_SUBST(XMLSEC_DL_LIBS)
1459
1460 dnl ==========================================================================
1461 dnl check if we need dynamic loading in the xmlsec apps
1462 dnl ==========================================================================
1463 AC_MSG_CHECKING(for xmlsec-crypto dynamic loading support in command line tool) 
1464 AC_ARG_ENABLE(apps_crypto_dl,   [  --enable-apps-crypto-dl  enable dynamic loading support for xmlsec-crypto libraries in xmlsec command line tool (yes)])
1465 if test "z$enable_apps_crypto_dl" = "z" ; then
1466     enable_apps_crypto_dl="$enable_crypto_dl"
1467 fi
1468 if test "z$enable_apps_crypto_dl" = "zno" ; then
1469     XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING="1"
1470     AC_MSG_RESULT(no)
1471 elif test "z$enable_crypto_dl" = "zno" ; then
1472     AC_MSG_RESULT(no)
1473     AC_MSG_ERROR(xmlsec-crypto libraries dynamic loading support in xmlsec command line tool is requested but no dynamic loading in xmlsec itself is disabled)
1474 else
1475     XMLSEC_APP_DEFINES="$XMLSEC_APP_DEFINES -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1"
1476     XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING="0"
1477     AC_MSG_RESULT(yes)
1478 fi    
1479 AM_CONDITIONAL(XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING, 
1480     test "z$XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING" = "z1")
1481 AC_SUBST(XMLSEC_NO_APPS_CRYPTO_DYNAMIC_LOADING)
1482
1483 dnl ==========================================================================
1484 dnl Where do we want to install docs
1485 dnl ==========================================================================
1486 AC_MSG_CHECKING(for docs folder) 
1487 AC_ARG_WITH(html-dir,           [  --with-html-dir=PATH    path to installed docs ])
1488 if test "z$with_html_dir" != "z" ; then
1489     XMLSEC_DOCDIR=$with_html_dir
1490 else
1491     XMLSEC_DOCDIR='$(datadir)/doc/xmlsec1'
1492 fi
1493
1494 AC_MSG_RESULT($XMLSEC_DOCDIR)
1495 AC_SUBST(XMLSEC_DOCDIR)
1496
1497 dnl ==========================================================================
1498 dnl See do we need Simple Keys Manager 
1499 dnl ==========================================================================
1500 AC_MSG_CHECKING(for Simple Keys Manager testing) 
1501 AC_ARG_ENABLE(skm,   [  --enable-skm            enable Simple Keys Manager testing (yes)])
1502 if test "z$enable_skm" = "zno" ; then
1503     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_SKM_TEST=1"
1504     AC_MSG_RESULT(no)
1505 else
1506     AC_MSG_RESULT(yes)
1507 fi
1508
1509 dnl ==========================================================================
1510 dnl See do we need templates tests
1511 dnl ==========================================================================
1512 AC_MSG_CHECKING(for templates testing) 
1513 AC_ARG_ENABLE(tmpl_tests,   [  --enable-tmpl-tests     enable templates testing in xmlsec utility (yes)])
1514 if test "z$enable_tmpl_tests" = "zyes" ; then
1515     XMLSEC_DEFINES="$XMLSEC_DEFINES -DXMLSEC_NO_TMPL_TEST=1"
1516     AC_MSG_RESULT(no)
1517 else
1518     AC_MSG_RESULT(yes)
1519 fi    
1520
1521 dnl ==========================================================================
1522 dnl Debug 
1523 dnl ==========================================================================
1524 AC_MSG_CHECKING(for debugging)
1525 AC_ARG_ENABLE(debugging,   [  --enable-debugging      enable debugging compilation flags (no)])
1526 if test "z$enable_debugging" = "zyes" ; then
1527     CFLAGS="$CFLAGS -g"
1528     AC_MSG_RESULT(yes)
1529 else
1530     AC_MSG_RESULT(no)
1531 fi    
1532
1533 dnl ==========================================================================
1534 dnl Profiling 
1535 dnl ==========================================================================
1536 AC_MSG_CHECKING(for profiling) 
1537 AC_ARG_ENABLE(profiling,   [  --enable-profiling      enable profiling compilation flags (no)])
1538 if test "z$enable_profiling" = "zyes" ; then
1539     CFLAGS="$CFLAGS -pg"
1540     AC_MSG_RESULT(yes)
1541 else
1542     AC_MSG_RESULT(no)
1543 fi 
1544
1545 dnl ==========================================================================
1546 dnl Pedantic compilation
1547 dnl ==========================================================================
1548 AC_MSG_CHECKING(for pedantic) 
1549 AC_ARG_ENABLE(pedantic,   [  --enable-pedantic       enable pedantic compilation flags (no)])
1550 if test "z$enable_pedantic" = "zyes" ; then
1551     dnl CFLAGS="$CFLAGS -pedantic -Wall -std=c99 -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wredundant-decls"
1552     CFLAGS="$CFLAGS -O -pedantic -Wall -std=c99 -fno-inline -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wredundant-decls"
1553     AC_MSG_RESULT(yes)
1554 else
1555     AC_MSG_RESULT(no)
1556 fi    
1557
1558 dnl ==========================================================================
1559 dnl Static linking
1560 dnl ==========================================================================
1561 XMLSEC_STATIC_BINARIES=""
1562 AC_MSG_CHECKING(for static linking) 
1563 AC_ARG_ENABLE(static_linking,   [  --enable-static-linking enable static linking (no)])
1564 if test "z$enable_static_linking" = "zyes" ; then
1565     XMLSEC_STATIC_BINARIES="-static"
1566     AC_MSG_RESULT(yes)
1567 else
1568     AC_MSG_RESULT(no)
1569 fi    
1570 AC_SUBST(XMLSEC_STATIC_BINARIES)
1571
1572 dnl ==========================================================================
1573 dnl Final steps: xmlsec config
1574 dnl ==========================================================================
1575 XMLSEC_CORE_CFLAGS="$XMLSEC_DEFINES -I${includedir}/xmlsec1  $XMLSEC_DL_INCLUDES"
1576 XMLSEC_CORE_LIBS="-lxmlsec1 $XMLSEC_DL_LIBS "
1577 AC_SUBST(XMLSEC_CORE_CFLAGS)
1578 AC_SUBST(XMLSEC_CORE_LIBS)
1579
1580 dnl used in xmlsecConf.sh*
1581 XMLSEC_LIBDIR="${libdir}"
1582 AC_SUBST(XMLSEC_LIBDIR)
1583
1584 XMLSEC_OPENSSL_CFLAGS="$XMLSEC_CORE_CFLAGS $OPENSSL_CFLAGS"
1585 XMLSEC_OPENSSL_LIBS="-L${libdir} -l$OPENSSL_CRYPTO_LIB $XMLSEC_CORE_LIBS $OPENSSL_LIBS"
1586 AC_SUBST(XMLSEC_OPENSSL_CFLAGS)
1587 AC_SUBST(XMLSEC_OPENSSL_LIBS)
1588
1589 XMLSEC_GCRYPT_CFLAGS="$XMLSEC_CORE_CFLAGS $GCRYPT_CFLAGS"
1590 XMLSEC_GCRYPT_LIBS="-L${libdir} -l$GCRYPT_CRYPTO_LIB $XMLSEC_CORE_LIBS $GCRYPT_LIBS"
1591 AC_SUBST(XMLSEC_GCRYPT_CFLAGS)
1592 AC_SUBST(XMLSEC_GCRYPT_LIBS)
1593
1594 # xmlsec-gnutls is using xmlsec-gcrypt
1595 XMLSEC_GNUTLS_CFLAGS="$XMLSEC_CORE_CFLAGS $GNUTLS_CFLAGS"
1596 XMLSEC_GNUTLS_LIBS="-L${libdir} -l$GNUTLS_CRYPTO_LIB -l$GCRYPT_CRYPTO_LIB $XMLSEC_CORE_LIBS $GNUTLS_LIBS"
1597 AC_SUBST(XMLSEC_GNUTLS_CFLAGS)
1598 AC_SUBST(XMLSEC_GNUTLS_LIBS)
1599
1600 XMLSEC_NSS_CFLAGS="$XMLSEC_CORE_CFLAGS $NSS_CFLAGS"
1601 XMLSEC_NSS_LIBS="-L${libdir} -l$NSS_CRYPTO_LIB $XMLSEC_CORE_LIBS $NSS_LIBS"
1602 AC_SUBST(XMLSEC_NSS_CFLAGS)
1603 AC_SUBST(XMLSEC_NSS_LIBS)
1604
1605 dnl No we will not generate pkg-config file for mscrypto !
1606 dnl XMLSEC_MSCRYPTO_CFLAGS="$XMLSEC_CORE_CFLAGS $MSCRYPTO_CFLAGS"
1607 dnl XMLSEC_MSCRYPTO_LIBS="-L${libdir} -l$MSCRYPTO_CRYPTO_LIB $XMLSEC_CORE_LIBS $MSCRYPTO_LIBS";;
1608 dnl AC_SUBST(XMLSEC_MSCRYPTO_CFLAGS)
1609 dnl AC_SUBST(XMLSEC_MSCRYPTO_LIBS)
1610
1611 XMLSEC_CFLAGS="$XMLSEC_CORE_CFLAGS $LIBXML_CFLAGS $LIBXSLT_CFLAGS $XMLSEC_CRYPTO_CFLAGS"
1612 XMLSEC_LIBS="-L${libdir} -l$XMLSEC_CRYPTO_LIB $XMLSEC_CORE_LIBS $LIBXML_LIBS $LIBXSLT_LIBS $XMLSEC_CRYPTO_LIBS"
1613 AC_SUBST(XMLSEC_CFLAGS)
1614 AC_SUBST(XMLSEC_LIBS)
1615
1616 AC_SUBST(XMLSEC_DEFINES)
1617 AC_SUBST(XMLSEC_APP_DEFINES)
1618 AC_SUBST(CFLAGS)
1619 AC_SUBST(CPPFLAGS)
1620 AC_SUBST(LDFLAGS)
1621 AC_SUBST(XMLSEC_EXTRA_LDFLAGS)
1622 AC_SUBST(XMLSEC_CRYPTO_EXTRA_LDFLAGS)
1623
1624 AC_SUBST(XMLSEC_DEFAULT_CRYPTO)
1625 AC_SUBST(XMLSEC_CRYPTO_LIST)
1626 AC_SUBST(XMLSEC_CRYPTO_DISABLED_LIST)
1627 AC_SUBST(XMLSEC_CRYPTO_LIB)
1628 AC_SUBST(XMLSEC_CRYPTO_CFLAGS)
1629 AC_SUBST(XMLSEC_CRYPTO_LIBS)
1630
1631 XMLSEC_CRYPTO_PC_FILES_LIST=""
1632 for i in $XMLSEC_CRYPTO_LIST ; do
1633     dnl skip pkg-config file for mscrypto
1634     test x$i = xmscrypto && continue
1635     XMLSEC_CRYPTO_PC_FILES_LIST="$XMLSEC_CRYPTO_PC_FILES_LIST $XMLSEC_PACKAGE-$i.pc"
1636 done
1637 AC_SUBST(XMLSEC_CRYPTO_PC_FILES_LIST)
1638
1639 dnl ==========================================================================
1640 dnl Writing result files
1641 dnl ==========================================================================
1642 if test "z$XMLSEC_NO_OPENSSL" != "z1" ; then
1643 AC_CONFIG_FILES([include/xmlsec/openssl/Makefile src/openssl/Makefile])
1644 fi
1645
1646 if test "z$XMLSEC_NO_GNUTLS" != "z1" ; then
1647 AC_CONFIG_FILES([include/xmlsec/gnutls/Makefile src/gnutls/Makefile])
1648 fi
1649
1650 if test "z$XMLSEC_NO_GCRYPT" != "z1" ; then
1651 AC_CONFIG_FILES([include/xmlsec/gcrypt/Makefile src/gcrypt/Makefile])
1652 fi
1653
1654 if test "z$XMLSEC_NO_NSS" != "z1" ; then
1655 AC_CONFIG_FILES([include/xmlsec/nss/Makefile src/nss/Makefile])
1656 fi
1657
1658 if test "z$XMLSEC_NO_MSCRYPTO" != "z1" ; then
1659 AC_CONFIG_FILES([include/xmlsec/mscrypto/Makefile src/mscrypto/Makefile])
1660 fi
1661
1662 if test "z$XMLSEC_NO_CRYPTO_DYNAMIC_LOADING" = "z1" ; then
1663 (rm -f xmlsec1.pc && $LN_S xmlsec1-$XMLSEC_DEFAULT_CRYPTO.pc xmlsec1.pc)
1664 else
1665 AC_CONFIG_FILES([xmlsec1.pc:xmlsec.pc.in])
1666 fi
1667
1668 AC_CONFIG_FILES([
1669 include/xmlsec/version.h
1670 Makefile
1671 include/Makefile
1672 include/xmlsec/Makefile
1673 include/xmlsec/private/Makefile
1674 src/Makefile
1675 apps/Makefile
1676 docs/Makefile
1677 docs/api/Makefile
1678 man/Makefile
1679
1680 xmlsec1-openssl.pc:xmlsec-openssl.pc.in
1681 xmlsec1-gnutls.pc:xmlsec-gnutls.pc.in
1682 xmlsec1-gcrypt.pc:xmlsec-gcrypt.pc.in
1683 xmlsec1-nss.pc:xmlsec-nss.pc.in
1684 xmlsec1.spec:xmlsec.spec.in
1685 ])
1686 AC_CONFIG_FILES([xmlsec1Conf.sh:xmlsecConf.sh.in], [chmod +x xmlsec1Conf.sh])
1687 AC_CONFIG_FILES([xmlsec1-config:xmlsec-config.in], [chmod +x xmlsec1-config])
1688 AC_OUTPUT
1689