3 # Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
5 # This file is part of CyaSSL.
9 AC_INIT([cyassl],[2.3.0],[http://www.yassl.com])
11 AC_CONFIG_AUX_DIR(config)
15 AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability foreign tar-ustar subdir-objects)
22 AC_CONFIG_MACRO_DIR(m4)
24 AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
27 #shared library versioning
28 CYASSL_LIBRARY_VERSION=3:1:0
32 # current:revision:age
34 # | | +- increment if interfaces have been added
35 # | | set to zero if interfaces have been removed
37 # | +- increment if source code has changed
38 # | set to zero if current is incremented
39 # +- increment if interfaces have been added, removed or changed
40 AC_SUBST(CYASSL_LIBRARY_VERSION)
42 # Make sure configure doesn't add to CFLAGS
43 CFLAGS="$CFLAGS $C_EXTRA_FLAGS"
50 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
52 AC_CHECK_FUNCS([gethostbyname])
53 AC_CHECK_FUNCS([gettimeofday])
54 AC_CHECK_FUNCS([inet_ntoa])
55 AC_CHECK_FUNCS([memset])
56 AC_CHECK_FUNCS([socket])
57 AC_CHECK_HEADERS([arpa/inet.h])
58 AC_CHECK_HEADERS([fcntl.h])
59 AC_CHECK_HEADERS([limits.h])
60 AC_CHECK_HEADERS([netdb.h])
61 AC_CHECK_HEADERS([netinet/in.h])
62 AC_CHECK_HEADERS([stddef.h])
63 AC_CHECK_HEADERS([sys/ioctl.h])
64 AC_CHECK_HEADERS([sys/socket.h])
65 AC_CHECK_HEADERS([sys/time.h])
66 AC_CHECK_HEADERS(errno.h)
67 AC_CHECK_LIB(network,socket)
68 AC_CHECK_SIZEOF(long long, 8)
69 AC_CHECK_SIZEOF(long, 4)
88 OPTIMIZE_CFLAGS="-Os -fomit-frame-pointer"
89 OPTIMIZE_FAST_CFLAGS="-O3 -fomit-frame-pointer"
90 OPTIMIZE_HUGE_CFLAGS="-funroll-loops -DTFM_SMALL_SET"
91 DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_CYASSL"
96 [ --enable-debug Enable CyaSSL debugging support (default: disabled)],
97 [ ENABLED_DEBUG=$enableval ],
100 if test "$ENABLED_DEBUG" = "yes"
102 # Full debug. Very slow in some cases
103 AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS"
105 # Optimized version. No debug
106 AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
112 [ --enable-small Enable smallest build (default: disabled)],
113 [ ENABLED_SMALL=$enableval ],
116 if test "$ENABLED_SMALL" = "yes"
118 # make small no tls build with smallest cipher
119 # if you only want server or client you can define NO_CYASSL_SERVER or
120 # NO_CYASSL_CLIENT but then some of the examples and testsuite won't build
121 # note that TLS needs HMAC
122 AM_CFLAGS="-DNO_TLS -DNO_HMAC -DNO_AES -DNO_DES3 -DNO_SHA256 -DNO_ERROR_STRINGS -DNO_RABBIT -DNO_PSK -DNO_DSA -DNO_DH -DNO_PWDBASED $AM_CFLAGS"
127 AC_ARG_ENABLE(singleThreaded,
128 [ --enable-singleThreaded Enable CyaSSL single threaded (default: disabled)],
129 [ ENABLED_SINGLETHREADED=$enableval ],
130 [ ENABLED_SINGLETHREADED=no ]
132 if test "$ENABLED_SINGLETHREADED" = "yes"
134 AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS"
140 [ --enable-dtls Enable CyaSSL DTLS (default: disabled)],
141 [ ENABLED_DTLS=$enableval ],
144 if test "$ENABLED_DTLS" = "yes"
146 AM_CFLAGS="-DCYASSL_DTLS $AM_CFLAGS"
150 # OPENSSL Extra Compatibility
151 AC_ARG_ENABLE(opensslExtra,
152 [ --enable-opensslExtra Enable extra OpenSSL API, size+ (default: disabled)],
153 [ ENABLED_OPENSSLEXTRA=$enableval ],
154 [ ENABLED_OPENSSLEXTRA=no ]
156 if test "$ENABLED_OPENSSLEXTRA" = "yes"
158 AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS"
161 if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_SMALL" = "yes"
163 AC_MSG_ERROR([cannot enable small and opensslExtra, only one or the other.])
169 [ --enable-ipv6 Enable testing of IPV6 (default: disabled)],
170 [ ENABLED_IPV6=$enableval ],
174 if test "$ENABLED_IPV6" = "yes"
176 AM_CFLAGS="$AM_CFLAGS -DTEST_IPV6"
181 AC_ARG_ENABLE(fortress,
182 [ --enable-fortress Enable SSL fortress build (default: disabled)],
183 [ ENABLED_FORTRESS=$enableval ],
184 [ ENABLED_FORTRESS=no ]
187 if test "$ENABLED_FORTRESS" = "yes"
189 AM_CFLAGS="$AM_CFLAGS -DFORTRESS -DOPENSSL_EXTRA -DCYASSL_DES_ECB -DCYASSL_AES_COUNTER -DCYASSL_AES_DIRECT -DCYASSL_DER_LOAD -DCYASSL_SHA512 -DCYASSL_SHA384 -DCYASSL_KEY_GEN"
195 [ --enable-bump Enable SSL Bump build (default: disabled)],
196 [ ENABLED_BUMP=$enableval ],
200 if test "$ENABLED_BUMP" = "yes"
202 AM_CFLAGS="$AM_CFLAGS -DLARGE_STATIC_BUFFERS -DCYASSL_CERT_GEN -DCYASSL_KEY_GEN -DHUGE_SESSION_CACHE -DOPENSSL_EXTRA -DFP_MAX_BITS=8192 -DCYASSL_DER_LOAD -DCYASSL_ALT_NAMES -DCYASSL_TEST_CERT"
206 AC_ARG_ENABLE(fastmath,
207 [ --enable-fastmath Enable fast math for BigInts (default: disabled)],
208 [ ENABLED_FASTMATH=$enableval ],
209 [ ENABLED_FASTMATH=no ]
212 if test "x$ENABLED_FASTMATH" = "xyes"
214 AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH"
219 AC_ARG_ENABLE(fasthugemath,
220 [ --enable-fasthugemath Enable fast math + huge code (default: disabled)],
221 [ ENABLED_FASTHUGEMATH=$enableval ],
222 [ ENABLED_FASTHUGEMATH=no ]
225 if test "$ENABLED_BUMP" = "yes"
227 ENABLED_FASTHUGEMATH="yes"
230 if test "$ENABLED_FASTHUGEMATH" = "yes"
232 ENABLED_FASTMATH="yes"
233 AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH"
236 AM_CONDITIONAL([BUILD_FASTMATH], [test "x$ENABLED_FASTMATH" = "xyes"])
240 AC_ARG_ENABLE(bigcache,
241 [ --enable-bigcache Enable big session cache (default: disabled)],
242 [ ENABLED_BIGCACHE=$enableval ],
243 [ ENABLED_BIGCACHE=no ]
246 if test "$ENABLED_BIGCACHE" = "yes"
248 AM_CFLAGS="$AM_CFLAGS -DBIG_SESSION_CACHE"
253 AC_ARG_ENABLE(hugecache,
254 [ --enable-hugecache Enable huge session cache (default: disabled)],
255 [ ENABLED_HUGECACHE=$enableval ],
256 [ ENABLED_HUGECACHE=no ]
259 if test "$ENABLED_HUGECACHE" = "yes"
261 AM_CFLAGS="$AM_CFLAGS -DHUGE_SESSION_CACHE"
266 AC_ARG_ENABLE(smallcache,
267 [ --enable-smallcache Enable small session cache (default: disabled)],
268 [ ENABLED_SMALLCACHE=$enableval ],
269 [ ENABLED_SMALLCACHE=no ]
272 if test "$ENABLED_SMALLCACHE" = "yes"
274 AM_CFLAGS="$AM_CFLAGS -DSMALL_SESSION_CACHE"
279 AC_ARG_ENABLE(sniffer,
280 [ --enable-sniffer Enable CyaSSL sniffer support (default: disabled)],
281 [ ENABLED_SNIFFER=$enableval ],
282 [ ENABLED_SNIFFER=no ]
285 if test "$ENABLED_SNIFFER" = "yes"
287 AM_CFLAGS="$AM_CFLAGS -DCYASSL_SNIFFER -DOPENSSL_EXTRA"
290 AM_CONDITIONAL([BUILD_SNIFFER], [test "x$ENABLED_SNIFFER" = "xyes"])
293 AC_ARG_ENABLE(aesgcm,
294 [ --enable-aesgcm Enable CyaSSL AES-GCM support (default: disabled)],
295 [ ENABLED_AESGCM=$enableval ],
296 [ ENABLED_AESGCM=no ]
299 if test "$ENABLED_AESGCM" = "word32"
301 AM_CFLAGS="$AM_CFLAGS -DGCM_WORD32"
305 if test "$ENABLED_AESGCM" = "small"
307 AM_CFLAGS="$AM_CFLAGS -DGCM_SMALL"
311 if test "$ENABLED_AESGCM" = "table"
313 AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE"
317 if test "$ENABLED_AESGCM" = "yes"
319 AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM -DCYASSL_SHA384 -DCYASSL_SHA512"
322 AM_CONDITIONAL([BUILD_AESGCM], [test "x$ENABLED_AESGCM" = "xyes"])
326 [ --enable-aesni Enable CyaSSL AES-NI support (default: disabled)],
327 [ ENABLED_AESNI=$enableval ],
331 if test "$ENABLED_AESNI" = "yes"
333 AM_CFLAGS="$AM_CFLAGS -DCYASSL_AESNI"
334 if test "$GCC" = "yes"
336 # GCC needs these flags, icc doesn't
337 AM_CFLAGS="$AM_CFLAGS -maes -msse4"
341 AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"])
346 [ --enable-md2 Enable CyaSSL MD2 support (default: disabled)],
347 [ ENABLED_MD2=$enableval ],
351 if test "$ENABLED_BUMP" = "yes"
356 if test "$ENABLED_MD2" = "yes"
358 AM_CFLAGS="$AM_CFLAGS -DCYASSL_MD2"
361 AM_CONDITIONAL([BUILD_MD2], [test "x$ENABLED_MD2" = "xyes"])
365 AC_ARG_ENABLE(ripemd,
366 [ --enable-ripemd Enable CyaSSL RIPEMD-160 support (default: disabled)],
367 [ ENABLED_RIPEMD=$enableval ],
368 [ ENABLED_RIPEMD=no ]
371 if test "$ENABLED_RIPEMD" = "yes"
373 AM_CFLAGS="$AM_CFLAGS -DCYASSL_RIPEMD"
376 AM_CONDITIONAL([BUILD_RIPEMD], [test "x$ENABLED_RIPEMD" = "xyes"])
380 AC_ARG_ENABLE(sha512,
381 [ --enable-sha512 Enable CyaSSL SHA-512 support (default: disabled)],
382 [ ENABLED_SHA512=$enableval ],
383 [ ENABLED_SHA512=no ]
386 if test "$ENABLED_SHA512" = "yes"
388 AM_CFLAGS="$AM_CFLAGS -DCYASSL_SHA512"
391 if test "$ENABLED_FORTRESS" = "yes"
396 if test "$ENABLED_AESGCM" = "yes"
402 AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"])
406 AC_ARG_ENABLE(sessioncerts,
407 [ --enable-sessioncerts Enable session cert storing (default: disabled)],
408 [ ENABLED_SESSIONCERTS=$enableval ],
409 [ ENABLED_SESSIONCERTS=no ]
412 if test "$ENABLED_SESSIONCERTS" = "yes"
414 AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS"
419 AC_ARG_ENABLE(keygen,
420 [ --enable-keygen Enable key generation (default: disabled)],
421 [ ENABLED_KEYGEN=$enableval ],
422 [ ENABLED_KEYGEN=no ]
425 if test "$ENABLED_KEYGEN" = "yes"
427 AM_CFLAGS="$AM_CFLAGS -DCYASSL_KEY_GEN"
432 AC_ARG_ENABLE(certgen,
433 [ --enable-certgen Enable cert generation (default: disabled)],
434 [ ENABLED_CERTGEN=$enableval ],
435 [ ENABLED_CERTGEN=no ]
438 if test "$ENABLED_CERTGEN" = "yes"
440 AM_CFLAGS="$AM_CFLAGS -DCYASSL_CERT_GEN"
446 [ --enable-hc128 Enable HC-128 (default: disabled)],
447 [ ENABLED_HC128=$enableval ],
451 if test "$ENABLED_HC128" = "no"
453 AM_CFLAGS="$AM_CFLAGS -DNO_HC128"
455 AM_CFLAGS="$AM_CFLAGS -DHAVE_HC128"
458 AM_CONDITIONAL([BUILD_HC128], [test "x$ENABLED_HC128" = "xyes"])
463 [ --enable-psk Enable PSK (default: disabled)],
464 [ ENABLED_PSK=$enableval ],
468 if test "$ENABLED_PSK" = "no"
470 AM_CFLAGS="$AM_CFLAGS -DNO_PSK"
475 AC_ARG_ENABLE(webServer,
476 [ --enable-webServer Enable Web Server (default: disabled)],
477 [ ENABLED_WEBSERVER=$enableval ],
478 [ ENABLED_WEBSERVER=no ]
481 if test "$ENABLED_WEBSERVER" = "yes"
483 AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER"
487 # No Filesystem Build
488 AC_ARG_ENABLE(noFilesystem,
489 [ --enable-noFilesystem Enable No Filesystem (default: disabled)],
490 [ ENABLED_NOFILESYSTEM=$enableval ],
491 [ ENABLED_NOFILESYSTEM=no ]
494 if test "$ENABLED_NOFILESYSTEM" = "yes"
496 AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM"
501 AC_ARG_ENABLE(noInline,
502 [ --enable-noInline Enable No inline (default: disabled)],
503 [ ENABLED_NOINLINE=$enableval ],
504 [ ENABLED_NOINLINE=no ]
507 if test "$ENABLED_NOINLINE" = "yes"
509 AM_CFLAGS="$AM_CFLAGS -DNO_INLINE"
512 AM_CONDITIONAL([BUILD_NOINLINE], [test "x$ENABLED_NOINLINE" = "xyes"])
517 [ --enable-ecc Enable ECC (default: disabled)],
518 [ ENABLED_ECC=$enableval ],
522 if test "$ENABLED_ECC" = "yes"
524 AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC"
527 AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"])
530 if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SMALL" = "yes"
532 AC_MSG_ERROR([cannot enable ecc and small, ecc requires TLS which small turns off.])
538 [ --enable-ocsp Enable OCSP (default: disabled)],
539 [ ENABLED_OCSP=$enableval ],
543 if test "$ENABLED_OCSP" = "yes"
545 AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP"
548 AM_CONDITIONAL([BUILD_OCSP], [test "x$ENABLED_OCSP" = "xyes"])
553 [ --enable-crl Enable CRL (default: disabled)],
554 [ ENABLED_CRL=$enableval ],
558 if test "$ENABLED_CRL" = "yes"
560 AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL"
563 AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"])
567 AC_ARG_ENABLE(crl-monitor,
568 [ --enable-crl-monitor Enable CRL Monitor (default: disabled)],
569 [ ENABLED_CRL_MONITOR=$enableval ],
570 [ ENABLED_CRL_MONITOR=no ],
573 if test "$ENABLED_CRL_MONITOR" = "yes"
575 AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR"
578 AM_CONDITIONAL([BUILD_CRL_MONITOR], [test "x$ENABLED_CRL_MONITOR" = "xyes"])
582 ntruHome=`pwd`/NTRU_algorithm
583 ntruInclude=$ntruHome/cryptolib
586 [ --enable-ntru Enable NTRU (default: disabled)],
587 [ ENABLED_NTRU=$enableval ],
591 if test "$ENABLED_NTRU" = "yes"
593 AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU -I$ntruInclude"
594 AM_LDFLAGS="$AM_LDFLAGS -L$ntruLib"
595 LIBS="$LIBS -lntru_encrypt"
598 AM_CONDITIONAL([BUILD_NTRU], [test "x$ENABLED_NTRU" = "xyes"])
600 if test "$ENABLED_NTRU" = "yes" && test "$ENABLED_SMALL" = "yes"
602 AC_MSG_ERROR([cannot enable ntru and small, ntru requires TLS which small turns off.])
606 # Test certs, use internal cert functions for extra testing
607 AC_ARG_ENABLE(testcert,
608 [ --enable-testcert Enable Test Cert (default: disabled)],
609 [ ENABLED_TESTCERT=$enableval ],
610 [ ENABLED_TESTCERT=no ]
613 if test "$ENABLED_TESTCERT" = "yes"
615 AM_CFLAGS="$AM_CFLAGS -DCYASSL_TEST_CERT"
622 [ --with-libz=PATH PATH to libz install (default /usr/) ],
624 AC_MSG_CHECKING([for libz])
625 CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ"
628 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
630 if test "x$libz_linked" == "xno" ; then
631 if test "x$withval" != "xno" ; then
634 if test "x$withval" == "xyes" ; then
638 AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib"
639 CPPFLAGS="$CPPFLAGS -I$trylibzdir/include"
641 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
643 if test "x$libz_linked" == "xno" ; then
644 AC_MSG_ERROR([libz isn't found.
645 If it's already installed, specify its path using --with-libz=/dir/])
657 if test "$GCC" = "yes"
659 AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused"
660 if test "$ENABLED_DEBUG" = "no"
662 if test "$ENABLED_FASTMATH" = "yes"
664 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS"
665 if test "$ENABLED_FASTHUGEMATH" = "yes"
667 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS"
670 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS"
676 AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
679 AC_DEFINE([HAVE_PTHREAD], [0], [Define if you have POSIX threads libraries and header files.])
684 dnl Various GCC warnings that should never fire for release quality code
685 GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \
686 -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
687 -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \
688 -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls \
689 -Wnested-externs -Wbad-function-cast -Wswitch-enum -Winit-self \
690 -Wmissing-field-initializers -Wdeclaration-after-statement \
691 -Wold-style-definition -Waddress -Wmissing-noreturn -Wnormalized=id \
692 -Woverride-init -Wstrict-overflow=1 -Wextra -Wstack-protector -Wformat \
693 -Wformat-security -Wpointer-sign -Wshadow -Wswitch-default"
697 GCCWARNINGS="$GCCWARNINGS -Warray-bounds"
701 AC_ARG_ENABLE(gcc-lots-o-warnings,
702 AS_HELP_STRING(--enable-gcc-lots-o-warnings, Enable lots of gcc warnings (default: disabled)),
703 [if test x$enableval = xyes; then
704 AM_CFLAGS="$AM_CFLAGS $GCCWARNINGS"
707 AC_ARG_ENABLE(gcc-hardening,
708 AS_HELP_STRING(--enable-gcc-hardening, Enable compiler security checks (default: disabled)),
709 [if test x$enableval = xyes; then
710 AM_CFLAGS="$AM_CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
711 AM_CFLAGS="$AM_CFLAGS -fwrapv -fPIE -Wstack-protector"
712 AM_CFLAGS="$AM_CFLAGS --param ssp-buffer-size=1"
713 LDFLAGS="$LDFLAGS -pie"
716 dnl Linker hardening options
717 dnl Currently these options are ELF specific - you can't use this with MacOSX
718 AC_ARG_ENABLE(linker-hardening,
719 AS_HELP_STRING(--enable-linker-hardening, Enable linker security fixups (default: disabled)),
720 [if test x$enableval = xyes; then
721 LDFLAGS="$LDFLAGS -z relro -z now"
725 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
730 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
731 AC_CONFIG_FILES([Makefile])
732 AC_CONFIG_FILES([cyassl/version.h])
733 AC_CONFIG_FILES([support/libcyassl.pc])