summaryrefslogtreecommitdiff
path: root/configure.in
blob: 2ad1964ed90d4305e70df5b2cfb4c71001f87477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
#    Free Software Foundation, Inc.
#
# Author: Nikos Mavrogiannopoulos
#
# This file is part of GNUTLS.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA

AC_PREREQ(2.61)
AC_INIT([GnuTLS], [2.7.0], [bug-gnutls@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])

AM_INIT_AUTOMAKE([1.10 dist-bzip2 -Wall -Werror -Wno-override])
AM_CONFIG_HEADER(config.h)

# Library code modified:                              REVISION++
# Interfaces changed/added/removed:   CURRENT++       REVISION=0
# Interfaces added:                             AGE++
# Interfaces removed:                           AGE=0
AC_SUBST(LT_CURRENT, 38)
AC_SUBST(LT_REVISION, 0)
AC_SUBST(LT_AGE, 12)

# Used when creating the Windows libgnutls-XX.def files.
SOVERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
AC_SUBST(SOVERSION)

# Compute numeric versions, used in includes/gnutls/gnutls.h.in.
AC_SUBST(MAJOR_VERSION, `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
AC_SUBST(MINOR_VERSION, `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
AC_SUBST(PATCH_VERSION, `echo $PACKAGE_VERSION | sed 's/.*\..*\.\(.*\)/\1/g'`)
AC_SUBST(NUMBER_VERSION, `printf "0x%02x%02x%02x" $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION`)

opt_dmalloc_mode=no
AC_MSG_CHECKING([whether in dmalloc mode])
AC_ARG_ENABLE(dmalloc-mode,
	AS_HELP_STRING([--enable-dmalloc-mode], [enable dmalloc mode]),
	opt_dmalloc_mode=$enableval)
AC_MSG_RESULT($opt_dmalloc_mode)

opt_efence_mode=no
AC_MSG_CHECKING([whether in electric fence mode])
AC_ARG_ENABLE(efence-mode,
	AS_HELP_STRING([--enable-efence-mode], [enable electric fence mode]),
opt_efence_mode=$enableval)
AC_MSG_RESULT($opt_efence_mode)

opt_developer_mode=no
AC_MSG_CHECKING([whether to enable compiler warnings])
AC_ARG_ENABLE(developer-mode,
	AS_HELP_STRING([--enable-developer-mode], [enable compiler warnings]),
opt_developer_mode=$enableval)
AC_MSG_RESULT($opt_developer_mode)

AC_MSG_RESULT([***
*** Checking for compilation programs...
])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LN_S
GTK_DOC_CHECK(1.1)
AC_PATH_PROG([GAA], [gaa])
if test "x$GAA" = "x"; then
   AC_MSG_WARN([[***
*** GAA was not found.  It is only needed if you wish to modify
*** the source code or command-line description files.  In this case,
*** you may want to get it from http://gaa.sourceforge.net/
***]])
fi
AM_CONDITIONAL(HAVE_GCC,   test "x$GCC" = "xyes")


AC_MSG_RESULT([***
*** Detecting compiler options...
])

gl_EARLY
lgl_EARLY
xgl_EARLY
AC_C_INLINE

AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.17])

AC_ARG_ENABLE(cxx,
       AS_HELP_STRING([--disable-cxx],
               [unconditionally disable the C++ library]),
       use_cxx=$enableval, use_cxx=yes)
if test "$use_cxx" != "no"; then
  AC_LANG_PUSH(C++)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], use_cxx=yes, use_cxx=no)
  AC_LANG_POP(C++)
fi

AC_MSG_CHECKING([whether C99 macros are supported])
AC_TRY_COMPILE(,[ 
#define test_mac(...) 
int z,y,x;
test_mac(x,y,z);
return 0;
], 
	dnl ***** OK
	AC_DEFINE(C99_MACROS, 1, [C99 macros are supported])
	AC_MSG_RESULT(yes),
	dnl ***** NOT FOUND
	AC_MSG_RESULT(no)
	AC_MSG_WARN([C99 macros not supported. This may affect compiling.]))

if test $ac_cv_c_compiler_gnu != no; then

	if test x$opt_developer_mode = xyes; then
	   AC_MSG_CHECKING([whether gcc supports various warning flags])
	   _gcc_cflags_save="$CFLAGS"
	   CFLAGS="${CFLAGS} -Wall -W -Wchar-subscripts -Wformat-security -Wnonnull -Winit-self -Wmissing-include-dirs -Wunused -Wno-unused-parameter -Wfloat-equal -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wvolatile-register-var -Wdisabled-optimization -Wstack-protector -Woverlength-strings"
	   #removed "-Wlogical-op" and "-Wvla" which are not supported by my gcc --nmav
	   # -Wtraditional: warns on #elif which we use often
	   # -Wundef: warns on '#if GNULIB_PORTCHECK' etc in gnulib headers
	   # -Wpadded: many of our structs are not optimized for padding
	   # -Wtraditional-conversion: we catch missing prototypes anyway
	   # -Wno-unused-parameter: added because -Wunused cause too many warns
	   # -Wunreachable-code: appears to return many false positives
	   # -Wconversion: too many warnings for now
	   # -Wswitch-default: too many warnings for now
	   # -Wswitch-enum: too many warnings for now
	   AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_warns=yes,_gcc_warns=no)
	   AC_MSG_RESULT($_gcc_warns)
	   if test x"$_gcc_warns" != xyes ; then
	      CFLAGS=$_gcc_cflags_save;
	   fi
	fi

	AC_MSG_CHECKING([whether gcc supports -Wno-pointer-sign])
	_gcc_cflags_save="$CFLAGS"
	CFLAGS="${CFLAGS} -Wno-pointer-sign"
	AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
	AC_MSG_RESULT($_gcc_psign)
	if test "$_gcc_psign" != "yes"; then
	  CFLAGS="$_gcc_cflags_save";
	fi

	AC_MSG_CHECKING([whether gcc supports -fgnu89-inline])
	_gcc_cflags_save="$CFLAGS"
	CFLAGS="${CFLAGS} -fgnu89-inline"
	AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
	  _gcc_gnu89_inline=yes, _gcc_gnu89_inline=no)
	AC_MSG_RESULT($_gcc_gnu89_inline)
	CFLAGS="$_gcc_cflags_save"

	AC_MSG_CHECKING([if gcc/ld supports -Wl,--output-def])
	if test "$enable_shared" = no; then
	  output_def=no
	  AC_MSG_RESULT([no need, since shared libraries are disabled])
	else
	  _gcc_ldflags_save=$LDFLAGS
	  LDFLAGS="-Wl,--output-def,foo.def"
	  AC_LINK_IFELSE(AC_LANG_PROGRAM([]),output_def=yes,output_def=no)
	  rm -f foo.def
	  AC_MSG_RESULT($output_def)
	  LDFLAGS="$_gcc_ldflags_save"
	fi

	if test x$opt_dmalloc_mode = xyes; then
	  AC_CHECK_LIB(dmalloc, main)
	  AC_DEFINE(USE_DMALLOC, 1, [enable the use of dmalloc])
	else
		if test x$opt_efence_mode = xyes; then
		  AC_CHECK_LIB(efence, main)
		  AC_DEFINE(USE_EFENCE, 1, [use electric fence])
		fi
	fi

	AC_MSG_CHECKING([whether we have GNU assembler])
	GAS=`as --version < /dev/null 2>/dev/null | grep GNU`
	if test "$GAS"; then
	  AM_CFLAGS="${AM_CFLAGS} -pipe"
	  AC_MSG_RESULT(yes)
	else
	  AC_MSG_RESULT(no)
	fi
fi

# Needs to be called outside of 'if' clause.
AM_CONDITIONAL(HAVE_LD_OUTPUT_DEF, test "$output_def" = "yes")
AM_CONDITIONAL([HAVE_GCC_GNU89_INLINE_OPTION],
               [test "$_gcc_gnu89_inline" = "yes"])

AC_MSG_RESULT([***
*** Detecting C library capabilities...
])

AC_HEADER_STDC
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_FUNCS(fork,,)
AC_DEFINE([HAVE_STRINGS_H], 1, [Hard-code for src/cfg/.])
AC_DEFINE([HAVE_FLOAT_H], 1, [Hard-code for src/cfg/.])
AC_DEFINE([HAVE_LIMITS_H], 1, [Hard-code for src/cfg/.])
AC_DEFINE([HAVE_MATH_H], 1, [Hard-code for src/cfg/.])
AC_DEFINE([HAVE_CTYPE_H], 1, [Hard-code for src/cfg/.])
AC_DEFINE([HAVE_ERRNO_H], 1, [Hard-code for src/cfg/.])

# No fork on MinGW, disable some self-tests until we fix them.
AM_CONDITIONAL(HAVE_FORK, test "$ac_cv_func_fork" != "no")

AC_MSG_RESULT([***
*** Detecting system's parameters...
])

# Run self-tests under valgrind?
if test "$cross_compiling" = no; then
  AC_CHECK_PROGS(VALGRIND, valgrind)
fi
if test -n "$VALGRIND" && $VALGRIND true > /dev/null 2>&1; then
  opt_valgrind_tests=yes
else
  opt_valgrind_tests=no
  VALGRIND=
fi 
AC_MSG_CHECKING([whether self tests are run under valgrind])
AC_ARG_ENABLE(valgrind-tests,
	AS_HELP_STRING([--enable-valgrind-tests],
                       [run self tests under valgrind]),
  opt_valgrind_tests=$enableval)
AC_MSG_RESULT($opt_valgrind_tests)

# For minitasn1.
AC_CHECK_SIZEOF(unsigned long int, 4)
AC_CHECK_SIZEOF(unsigned int, 4)

# For storing integers in pointers without warnings
# http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html#desc
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
case $ac_cv_sizeof_void_p in
  $ac_cv_sizeof_long)
    AC_DEFINE(GNUTLS_POINTER_TO_INT_CAST, [(long)],
              [Additional cast to bring void* to a type castable to int.])
    ;;
  *)
    AC_DEFINE(GNUTLS_POINTER_TO_INT_CAST, [])
    ;;
esac

# For some systems we know that we have ld_version scripts.
# Use it then as default.
have_ld_version_script=no
case "${host}" in
    *-*-linux*)
        have_ld_version_script=yes
        ;;
    *-*-gnu*)
        have_ld_version_script=yes
        ;;
esac
AC_ARG_ENABLE([ld-version-script],
              AC_HELP_STRING([--enable-ld-version-script],
                             [enable/disable use of linker version script.
                              (default is system dependent)]),
              [have_ld_version_script=$enableval],
              [ : ] )
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")

AC_CHECK_TYPES(uint,,, [
# include <sys/types.h>
])

# Check for and replace ssize_t.
AC_CHECK_TYPE(ssize_t,
	[DEFINE_SSIZE_T="#include <sys/types.h>"
	AC_SUBST(DEFINE_SSIZE_T)],
	[AC_DEFINE(NO_SSIZE_T, 1, [no ssize_t type was found])
	DEFINE_SSIZE_T="typedef int ssize_t;"
	AC_SUBST(DEFINE_SSIZE_T)],
	[#include <sys/types.h>])

AC_C_BIGENDIAN

AC_MSG_RESULT([***
*** Checking for external libraries...
])

# For Guile bindings.

opt_guile_bindings=yes
AC_MSG_CHECKING([whether building Guile bindings])
AC_ARG_ENABLE(guile,
	AS_HELP_STRING([--enable-guile], [build GNU Guile bindings]),
opt_guile_bindings=$enableval)
AC_MSG_RESULT($opt_guile_bindings)

AC_ARG_WITH([--with-guile-site-dir],
  [AS_HELP_STRING([--with-guile-site-dir],
     [use the given directory as the Guile site (use with care)])])

if test "x$opt_guile_bindings" = "xyes"; then
   AC_MSG_RESULT([***
*** Detecting GNU Guile...
])

   AC_PATH_PROG([guile_snarf], [guile-snarf])
   if test "x$guile_snarf" = "x"; then
      AC_MSG_WARN([`guile-snarf' from Guile 1.8 not found.  Guile bindings not built.])
      opt_guile_bindings=no
   else
      GUILE_PROGS
      GUILE_FLAGS

      save_CFLAGS="$CFLAGS"
      save_LIBS="$LIBS"
      CFLAGS="$CFLAGS $GUILE_CFLAGS"
      LIBS="$LIBS $GUILE_LDFLAGS"
      AC_MSG_CHECKING([whether GNU Guile is recent enough])
      AC_LINK_IFELSE(AC_LANG_CALL([], [scm_from_locale_string]),
        [], [opt_guile_bindings=no])
      CFLAGS="$save_CFLAGS"
      LIBS="$save_LIBS"

      if test "x$opt_guile_bindings" = "xyes"; then
        AC_MSG_RESULT([yes])
	case "x$with_guile_site_dir" in 
	     xno)
		# Use the default $(GUILE_SITE).
		GUILE_SITE_DIR
		;;
	     x|xyes)
		# Automatically derive $(GUILE_SITE) from $(pkgdatadir).  This
		# hack is used to allow `distcheck' to work (see
		# `DISTCHECK_CONFIGURE_FLAGS' in the top-level `Makefile.am').
		GUILE_SITE="\$(datadir)/guile/site"
		AC_SUBST(GUILE_SITE)
		;;
	     *)
		# Use the user-specified directory as $(GUILE_SITE).
		GUILE_SITE="$with_guile_site_dir"
		AC_SUBST(GUILE_SITE)
		;;
	esac
      else
        AC_MSG_RESULT([no])
        AC_MSG_WARN([A sufficiently recent GNU Guile not found.  Guile bindings not built.])
        opt_guile_bindings=no
      fi
   fi
fi
AM_CONDITIONAL(HAVE_GUILE, test "x$opt_guile_bindings" = "xyes")

# Check for libgcrypt
AC_LIB_HAVE_LINKFLAGS(gcrypt,, [#include <gcrypt.h>],
  [enum gcry_cipher_algos i = GCRY_CIPHER_CAMELLIA128])
if test "$ac_cv_libgcrypt" != yes; then
  AC_MSG_ERROR([[
***  
*** libgcrypt was not found. You may want to get it from
*** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
***
]])
fi

# If this ever changes to 0, the user disabled some officially enabled
# stuff so we will print a warning.
ac_full=1

AC_MSG_CHECKING([whether to enable Opaque PRF input support])
AC_ARG_ENABLE(opaque-prf-input,
	AS_HELP_STRING([--enable-opaque-prf-input=DD],
		[enable Opaque PRF input using DD as extension type]),
	ac_opaque_prf_input=$enableval, ac_opaque_prf_input=no)
if test "$ac_opaque_prf_input" != "no"; then
  if ! echo $ac_opaque_prf_input | egrep -q '^[[0-9]]+$'; then
    ac_opaque_prf_input=no
    AC_MSG_WARN([[
*** Could not parse Opaque PRF Input extension type.
*** Use --enable-opaque-prf-input=XX where XX is decimal, for example
*** to use extension value 42 use --enable-opqaue-prf-input=42]])
  fi
fi
if test "$ac_opaque_prf_input" != "no"; then
 AC_MSG_RESULT([yes (extension value $ac_opaque_prf_input)])
 AC_DEFINE_UNQUOTED(ENABLE_OPRFI, $ac_opaque_prf_input,
                    [enable Opaque PRF Input])
else
 AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(ENABLE_OPRFI, test "$ac_opaque_prf_input" != "no")

AC_MSG_CHECKING([whether to disable SRP authentication support])
AC_ARG_ENABLE(srp-authentication,
	AS_HELP_STRING([--disable-srp-authentication],
		[disable the SRP authentication support]),
	ac_enable_srp=no)
if test x$ac_enable_srp != xno; then
 AC_MSG_RESULT(no)
 AC_DEFINE(ENABLE_SRP, 1, [enable SRP authentication])
else
 ac_full=0
 AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL(ENABLE_SRP, test "$ac_enable_srp" != "no")

AC_MSG_CHECKING([whether to disable PSK authentication support])
AC_ARG_ENABLE(psk-authentication,
       AS_HELP_STRING([--disable-psk-authentication],
               [disable the PSK authentication support]),
       ac_enable_psk=no)
if test x$ac_enable_psk != xno; then
 AC_MSG_RESULT(no)
 AC_DEFINE(ENABLE_PSK, 1, [enable PSK authentication])
else
 ac_full=0
 AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL(ENABLE_PSK, test "$ac_enable_psk" != "no")

AC_MSG_CHECKING([whether to disable anonymous authentication support])
AC_ARG_ENABLE(anon-authentication,
	AS_HELP_STRING([--disable-anon-authentication],
		[disable the anonymous authentication support]),
	ac_enable_anon=no)
if test x$ac_enable_anon != xno; then
 AC_MSG_RESULT(no)
 AC_DEFINE(ENABLE_ANON, 1, [enable anonymous authentication])
else
 ac_full=0
 AC_MSG_RESULT(yes)
fi
AM_CONDITIONAL(ENABLE_ANON, test "$ac_enable_anon" != "no")

# Allow disabling Camellia
AC_ARG_ENABLE(camellia,
  AS_HELP_STRING([--disable-camellia], [disable Camellia cipher]),
  enable_camellia=$enableval, enable_camellia=no)
AC_MSG_CHECKING([whether to disable Camellia cipher])
if test "$enable_camellia" != "no"; then
 AC_MSG_RESULT([no])
 AC_DEFINE(ENABLE_CAMELLIA, 1, [enable camellia block cipher])
else
 AC_MSG_RESULT([yes])
fi

AC_MSG_CHECKING([whether to disable extra PKI stuff])
AC_ARG_ENABLE(extra-pki,
	AS_HELP_STRING([--disable-extra-pki],
		[only enable the basic PKI stuff]),
	enable_pki=$enableval, enable_pki=yes)
if test "$enable_pki" != "yes"; then
 ac_full=0
 AC_MSG_RESULT(yes)
else
 AC_MSG_RESULT(no)
 AC_DEFINE(ENABLE_PKI, 1, [whether to include all the PKCS/PKI stuff])
fi
AM_CONDITIONAL(ENABLE_PKI, test "$enable_pki" = "yes")

ac_enable_openpgp=yes
AC_MSG_CHECKING([whether to disable OpenPGP Certificate authentication support])
AC_ARG_ENABLE(openpgp-authentication,
	AS_HELP_STRING([--disable-openpgp-authentication],
		[disable the OpenPGP authentication support]),
	ac_enable_openpgp=no)
if test x$ac_enable_openpgp = xno; then
 AC_MSG_RESULT(yes)
 ac_full=0
else
 AC_DEFINE(ENABLE_OPENPGP, 1, [use openpgp authentication])
 AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(ENABLE_OPENPGP, test "$ac_enable_openpgp" = "yes")

AC_MSG_CHECKING([whether to disable OpenSSL compatibility layer])
AC_ARG_ENABLE(openssl-compatibility,
	AS_HELP_STRING([--disable-openssl-compatibility],
		[disable the OpenSSL compatibility support]),
	ac_enable_openssl=$withval,
	ac_enable_openssl=yes)
if test x$ac_enable_openssl != xno; then
 AC_MSG_RESULT(no)
else
 AC_MSG_RESULT(yes)
fi

AM_CONDITIONAL(ENABLE_OPENSSL, test "$ac_enable_openssl" = "yes")

# Check for libtasn1
AC_ARG_WITH(included-libtasn1,
  AS_HELP_STRING([--with-included-libtasn1], [use the included libtasn1]),
    included_libtasn1=$withval,
    included_libtasn1=no)
if test "$included_libtasn1" = "no"; then
  AC_LIB_HAVE_LINKFLAGS(tasn1,, [#include <libtasn1.h>],
  				[asn1_check_version (NULL)])
  if test "$ac_cv_libtasn1" != yes; then
    included_libtasn1=yes
    AC_MSG_WARN([[
*** 
*** Libtasn1 was not found. Will use the included one.
]])
  fi
fi
AC_MSG_CHECKING([whether to use the included minitasn1])
AC_MSG_RESULT($included_libtasn1)
AM_CONDITIONAL(ENABLE_MINITASN1, test "$included_libtasn1" = "yes")

if test "$ac_full" != 1; then
 AC_MSG_WARN([[
*** 
*** C++ library disabled because some parts of GnuTLS has been disabled.
]])
  use_cxx=no
fi
AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no")
AC_MSG_CHECKING([whether to build C++ library])
AC_MSG_RESULT($use_cxx)

dnl Check for libcfg+

SAVED_LIBS=$LIBS
AC_ARG_WITH(included-libcfg,
	AS_HELP_STRING([--with-included-libcfg],
		[use the included libcfg+ (certtool only)]),
	libcfg_enabled=$withval, 
	libcfg_enabled=no
dnl We search for libcfg+ which is used by certtool
dnl
	AC_CHECK_LIB(cfg+, cfg_get_context,:,
                     libcfg_enabled=yes
                     AC_MSG_WARN([[
*** 
*** Libcfg+ was not found. Will use the included one.]])))

AM_CONDITIONAL(HAVE_LIBCFG, test "$libcfg_enabled" = "no")
LIBS=$SAVED_LIBS

AC_MSG_CHECKING([whether to use the included libcfg])
AC_MSG_RESULT($libcfg_enabled)


dnl CHECK FOR ZLIB SUPPORT
dnl

AC_MSG_CHECKING([whether to include zlib compression support])

AC_ARG_WITH(zlib,
	AS_HELP_STRING([--without-zlib], [disable zlib compression support]),
	ac_zlib=$withval,
	ac_zlib=yes)

if test x$ac_zlib != xno; then
 AC_MSG_RESULT(yes)
 AC_LIB_HAVE_LINKFLAGS(z,, [#include <zlib.h>], [compress (0, 0, 0, 0);])
 if test "$ac_cv_libz" != yes; then
   AC_MSG_WARN(
*** 
*** ZLIB was not found. You will not be able to use ZLIB compression.)
 fi
else
 AC_MSG_RESULT(no)
fi


dnl CHECK FOR LZO SUPPORT
dnl

AC_ARG_WITH(lzo,
	AS_HELP_STRING([--with-lzo], [use experimental LZO compression]),
	use_lzo=$withval,
	use_lzo=no)
AC_MSG_CHECKING([whether to include LZO compression support])
AC_MSG_RESULT($use_lzo)

LZO_LIBS=
if test "$use_lzo" = "yes"; then
  AC_CHECK_LIB(lzo2, lzo1x_1_compress, LZO_LIBS=-llzo2)
  if test "$LZO_LIBS" = ""; then
    AC_CHECK_LIB(lzo, lzo1x_1_compress, LZO_LIBS=-llzo, [
      use_lzo=no
      AC_MSG_WARN(
***
*** Could not find liblzo or liblzo2.  Disabling LZO compression.
)
      ])
  fi
fi
AC_SUBST(LZO_LIBS)

if test "$use_lzo" = "yes"; then
  AC_DEFINE(USE_LZO, 1, [whether to use the LZO compression])
  if test "$LZO_LIBS" = "-llzo"; then
    AC_CHECK_HEADERS(lzo1x.h)
  elif test "$LZO_LIBS" = "-llzo2"; then
    AC_CHECK_HEADERS(lzo/lzo1x.h)
  fi
fi

AM_CONDITIONAL(USE_LZO, test "$use_lzo" = "yes")

# Windows hacks.

AC_DEFINE([WINVER], [0x0501], [Windows 2000 or before not supported.])
save_LIBS="$LIBS"
LIBS="$LIBS -lws2_32"
AC_TRY_LINK([#include <winsock2.h>], [
  WORD wVersionRequested = MAKEWORD(2, 2);
  WSADATA wsaData;
  int err = WSAStartup(wVersionRequested, &wsaData);
  WSACleanup ();], wsastartup=yes, wsastartup=no)
LIBS="$save_LIBS"
if test "$wsastartup" = "yes"; then
  AC_DEFINE(HAVE_WINSOCK, 1, [Call WSAStartup in gnutls_global_init])
fi
AM_CONDITIONAL(NEED_WS2_32, test "$wsastartup" = "yes")
AC_MSG_CHECKING([if we have Windows and WSAStartup/WSACleanup in -lws2_32])
AC_MSG_RESULT($wsastartup)

dnl Gnulib files
dnl

AC_MSG_RESULT([***
*** Setting up gnulib compatibility files...
])
gl_INIT
lgl_INIT
xgl_INIT

AC_MSG_RESULT([***
*** Detecting options for shared libraries...
])
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

LIBGNUTLS_LIBS="-L${libdir} -lgnutls $LIBS"
LIBGNUTLS_CFLAGS="-I${includedir}"
AC_SUBST(LIBGNUTLS_LIBS)
AC_SUBST(LIBGNUTLS_CFLAGS)

LIBGNUTLS_EXTRA_LIBS="-L${libdir} -lgnutls-extra $LZO_LIBS $LIBGNUTLS_LIBS"
LIBGNUTLS_EXTRA_CFLAGS="-I${includedir}"
AC_SUBST(LIBGNUTLS_EXTRA_LIBS)
AC_SUBST(LIBGNUTLS_EXTRA_CFLAGS)

export ac_full

if test $ac_full -eq 0; then
  AC_SUBST(POSSIBLY_WARN_ABOUT_MISSING_FEATURES, [[
#ifdef __GNUC__
#warning This is not the official GnuTLS library. Several features were disabled at compilation.
#endif /* __GNUC__ */]])
fi

AC_SUBST(AM_CFLAGS)

AC_CONFIG_COMMANDS([chmod-config],[[
 chmod +x lib/libgnutls-config
 chmod +x libextra/libgnutls-extra-config
]],[[]])

AC_CONFIG_FILES([Makefile po/Makefile.in \
	doc/Makefile doc/examples/Makefile doc/scripts/Makefile \
	doc/manpages/Makefile doc/reference/Makefile doc/doxygen/Doxyfile \
	doc/credentials/Makefile doc/credentials/x509/Makefile \
	doc/credentials/srp/Makefile doc/credentials/openpgp/Makefile \
	gl/Makefile gl/tests/Makefile lgl/Makefile lgl/tests/Makefile \
	tests/Makefile tests/rsa-md5-collision/Makefile tests/userid/Makefile \
	tests/pkcs1-padding/Makefile tests/pkcs8-decode/Makefile \
	tests/pkcs12-decode/Makefile tests/pathlen/Makefile \
	tests/key-id/Makefile tests/sha2/Makefile \
	tests/hostname-check/Makefile \
	includes/Makefile includes/gnutls/gnutls.h \
	lib/Makefile lib/minitasn1/Makefile lib/x509/Makefile \
	libextra/Makefile libextra/gl/Makefile \
	lib/openpgp/Makefile lib/opencdk/Makefile \
	tests/openpgp/Makefile tests/openpgp-certs/Makefile \
	src/Makefile \
	src/cfg/Makefile src/cfg/platon/Makefile src/cfg/platon/str/Makefile \
	lib/libgnutls-config libextra/libgnutls-extra-config \
	lib/gnutls.pc libextra/gnutls-extra.pc
	guile/Makefile guile/modules/Makefile
	guile/src/Makefile guile/tests/Makefile])

AC_CONFIG_FILES([guile/pre-inst-guile], [chmod +x guile/pre-inst-guile])

AC_OUTPUT