3 # Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
5 # This file is part of CyaSSL.
9 AC_INIT([cyassl],[2.2.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"])
294 [ --enable-aesni Enable CyaSSL AES-NI support (default: disabled)],
295 [ ENABLED_AESNI=$enableval ],
299 if test "$ENABLED_AESNI" = "yes"
301 AM_CFLAGS="$AM_CFLAGS -DCYASSL_AESNI"
302 if test "$GCC" = "yes"
304 # GCC needs these flags, icc doesn't
305 AM_CFLAGS="$AM_CFLAGS -maes -msse4"
309 AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"])
313 AC_ARG_ENABLE(ripemd,
314 [ --enable-ripemd Enable CyaSSL RIPEMD-160 support (default: disabled)],
315 [ ENABLED_RIPEMD=$enableval ],
316 [ ENABLED_RIPEMD=no ]
319 if test "$ENABLED_RIPEMD" = "yes"
321 AM_CFLAGS="$AM_CFLAGS -DCYASSL_RIPEMD"
324 AM_CONDITIONAL([BUILD_RIPEMD], [test "x$ENABLED_RIPEMD" = "xyes"])
328 AC_ARG_ENABLE(sha512,
329 [ --enable-sha512 Enable CyaSSL SHA-160 support (default: disabled)],
330 [ ENABLED_SHA512=$enableval ],
331 [ ENABLED_SHA512=no ]
334 if test "$ENABLED_SHA512" = "yes"
336 AM_CFLAGS="$AM_CFLAGS -DCYASSL_SHA512"
339 if test "$ENABLED_FORTRESS" = "yes"
345 AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"])
349 AC_ARG_ENABLE(sessioncerts,
350 [ --enable-sessioncerts Enable session cert storing (default: disabled)],
351 [ ENABLED_SESSIONCERTS=$enableval ],
352 [ ENABLED_SESSIONCERTS=no ]
355 if test "$ENABLED_SESSIONCERTS" = "yes"
357 AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS"
362 AC_ARG_ENABLE(keygen,
363 [ --enable-keygen Enable key generation (default: disabled)],
364 [ ENABLED_KEYGEN=$enableval ],
365 [ ENABLED_KEYGEN=no ]
368 if test "$ENABLED_KEYGEN" = "yes"
370 AM_CFLAGS="$AM_CFLAGS -DCYASSL_KEY_GEN"
375 AC_ARG_ENABLE(certgen,
376 [ --enable-certgen Enable cert generation (default: disabled)],
377 [ ENABLED_CERTGEN=$enableval ],
378 [ ENABLED_CERTGEN=no ]
381 if test "$ENABLED_CERTGEN" = "yes"
383 AM_CFLAGS="$AM_CFLAGS -DCYASSL_CERT_GEN"
389 [ --enable-hc128 Enable HC-128 (default: disabled)],
390 [ ENABLED_HC128=$enableval ],
394 if test "$ENABLED_HC128" = "no"
396 AM_CFLAGS="$AM_CFLAGS -DNO_HC128"
398 AM_CFLAGS="$AM_CFLAGS -DHAVE_HC128"
401 AM_CONDITIONAL([BUILD_HC128], [test "x$ENABLED_HC128" = "xyes"])
406 [ --enable-psk Enable PSK (default: disabled)],
407 [ ENABLED_PSK=$enableval ],
411 if test "$ENABLED_PSK" = "no"
413 AM_CFLAGS="$AM_CFLAGS -DNO_PSK"
418 AC_ARG_ENABLE(webServer,
419 [ --enable-webServer Enable Web Server (default: disabled)],
420 [ ENABLED_WEBSERVER=$enableval ],
421 [ ENABLED_WEBSERVER=no ]
424 if test "$ENABLED_WEBSERVER" = "yes"
426 AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER"
430 # No Filesystem Build
431 AC_ARG_ENABLE(noFilesystem,
432 [ --enable-noFilesystem Enable No Filesystem (default: disabled)],
433 [ ENABLED_NOFILESYSTEM=$enableval ],
434 [ ENABLED_NOFILESYSTEM=no ]
437 if test "$ENABLED_NOFILESYSTEM" = "yes"
439 AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM"
444 AC_ARG_ENABLE(noInline,
445 [ --enable-noInline Enable No inline (default: disabled)],
446 [ ENABLED_NOINLINE=$enableval ],
447 [ ENABLED_NOINLINE=no ]
450 if test "$ENABLED_NOINLINE" = "yes"
452 AM_CFLAGS="$AM_CFLAGS -DNO_INLINE"
455 AM_CONDITIONAL([BUILD_NOINLINE], [test "x$ENABLED_NOINLINE" = "xyes"])
460 [ --enable-ecc Enable ECC (default: disabled)],
461 [ ENABLED_ECC=$enableval ],
465 if test "$ENABLED_ECC" = "yes"
467 AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC"
470 AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"])
473 if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SMALL" = "yes"
475 AC_MSG_ERROR([cannot enable ecc and small, ecc requires TLS which small turns off.])
481 [ --enable-ocsp Enable OCSP (default: disabled)],
482 [ ENABLED_OCSP=$enableval ],
486 if test "$ENABLED_OCSP" = "yes"
488 AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP"
491 AM_CONDITIONAL([BUILD_OCSP], [test "x$ENABLED_OCSP" = "xyes"])
496 [ --enable-crl Enable CRL (default: disabled)],
497 [ ENABLED_CRL=$enableval ],
501 if test "$ENABLED_CRL" = "yes"
503 AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL"
506 AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"])
510 ntruHome=`pwd`/NTRU_algorithm
511 ntruInclude=$ntruHome/cryptolib
514 [ --enable-ntru Enable NTRU (default: disabled)],
515 [ ENABLED_NTRU=$enableval ],
519 if test "$ENABLED_NTRU" = "yes"
521 AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU -I$ntruInclude"
522 AM_LDFLAGS="$AM_LDFLAGS -L$ntruLib"
523 LIBS="$LIBS -lntru_encrypt"
526 AM_CONDITIONAL([BUILD_NTRU], [test "x$ENABLED_NTRU" = "xyes"])
528 if test "$ENABLED_NTRU" = "yes" && test "$ENABLED_SMALL" = "yes"
530 AC_MSG_ERROR([cannot enable ntru and small, ntru requires TLS which small turns off.])
534 # Test certs, use internal cert functions for extra testing
535 AC_ARG_ENABLE(testcert,
536 [ --enable-testcert Enable Test Cert (default: disabled)],
537 [ ENABLED_TESTCERT=$enableval ],
538 [ ENABLED_TESTCERT=no ]
541 if test "$ENABLED_TESTCERT" = "yes"
543 AM_CFLAGS="$AM_CFLAGS -DCYASSL_TEST_CERT"
550 [ --with-libz=PATH PATH to libz install (default /usr/) ],
552 AC_MSG_CHECKING([for libz])
553 CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ"
556 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
558 if test "x$libz_linked" == "xno" ; then
559 if test "x$withval" != "xno" ; then
562 if test "x$withval" == "xyes" ; then
566 AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib"
567 CPPFLAGS="$CPPFLAGS -I$trylibzdir/include"
569 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
571 if test "x$libz_linked" == "xno" ; then
572 AC_MSG_ERROR([libz isn't found.
573 If it's already installed, specify its path using --with-libz=/dir/])
585 if test "$GCC" = "yes"
587 AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused"
588 if test "$ENABLED_DEBUG" = "no"
590 if test "$ENABLED_FASTMATH" = "yes"
592 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS"
593 if test "$ENABLED_FASTHUGEMATH" = "yes"
595 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS"
598 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS"
604 AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
607 AC_DEFINE([HAVE_PTHREAD], [0], [Define if you have POSIX threads libraries and header files.])
612 dnl Various GCC warnings that should never fire for release quality code
613 GCCWARNINGS="-Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef \
614 -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
615 -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment \
616 -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls \
617 -Wnested-externs -Wbad-function-cast -Wswitch-enum -Winit-self \
618 -Wmissing-field-initializers -Wdeclaration-after-statement \
619 -Wold-style-definition -Waddress -Wmissing-noreturn -Wnormalized=id \
620 -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds \
621 -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wshadow \
624 AC_ARG_ENABLE(gcc-lots-o-warnings,
625 AS_HELP_STRING(--enable-gcc-lots-o-warnings, Enable lots of gcc warnings (default: disabled)),
626 [if test x$enableval = xyes; then
627 AM_CFLAGS="$AM_CFLAGS $GCCWARNINGS"
630 AC_ARG_ENABLE(gcc-hardening,
631 AS_HELP_STRING(--enable-gcc-hardening, Enable compiler security checks (default: disabled)),
632 [if test x$enableval = xyes; then
633 AM_CFLAGS="$AM_CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
634 AM_CFLAGS="$AM_CFLAGS -fwrapv -fPIE -Wstack-protector"
635 AM_CFLAGS="$AM_CFLAGS --param ssp-buffer-size=1"
636 LDFLAGS="$LDFLAGS -pie"
639 dnl Linker hardening options
640 dnl Currently these options are ELF specific - you can't use this with MacOSX
641 AC_ARG_ENABLE(linker-hardening,
642 AS_HELP_STRING(--enable-linker-hardening, Enable linker security fixups (default: disabled)),
643 [if test x$enableval = xyes; then
644 LDFLAGS="$LDFLAGS -z relro -z now"
648 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
653 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
654 AC_CONFIG_FILES([Makefile])
655 AC_CONFIG_FILES([cyassl/version.h])
656 AC_CONFIG_FILES([support/libcyassl.pc])