]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/CyaSSL/configure.ac
88a368dec67e6a05934fc7f6acf6c9bdd37e2a30
[freertos] / FreeRTOS-Plus / CyaSSL / configure.ac
1 # configure.ac
2 #
3 # Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
4 #
5 # This file is part of CyaSSL.
6 #
7 #
8
9 AC_INIT([cyassl],[2.3.0],[http://www.yassl.com])
10
11 AC_CONFIG_AUX_DIR(config)
12
13 AC_CANONICAL_TARGET
14
15 AM_INIT_AUTOMAKE(-Wall -Werror -Wno-portability foreign tar-ustar subdir-objects)
16
17 AC_CANONICAL_HOST
18 AC_CANONICAL_BUILD
19
20 AC_PREREQ([2.61])
21
22 AC_CONFIG_MACRO_DIR(m4)
23
24 AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
25
26
27 #shared library versioning
28 CYASSL_LIBRARY_VERSION=3:1:0
29 #                      | | |
30 #               +------+ | +---+
31 #               |        |     |
32 #              current:revision:age
33 #               |        |     |
34 #               |        |     +- increment if interfaces have been added
35 #               |        |        set to zero if interfaces have been removed
36 #                        |        or changed
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)
41
42 # Make sure configure doesn't add to CFLAGS
43 CFLAGS="$CFLAGS $C_EXTRA_FLAGS"
44
45 LT_INIT([win32-dll])
46 LT_LANG([C++])
47 LT_LANG([C])
48 gl_VISIBILITY
49
50 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
51
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)
70 AC_C_BIGENDIAN
71 AC_DISABLE_STATIC
72 AC_DISABLE_STATIC
73 AC_FUNC_MALLOC
74 AC_FUNC_MKTIME
75 AC_FUNC_REALLOC
76
77 AC_PROG_CC
78 AC_PROG_CC_C_O
79 AC_PROG_CXX
80 AC_PROG_INSTALL
81 LT_INIT
82 AC_TYPE_SIZE_T
83 AC_TYPE_UINT8_T
84 AM_PROG_AS
85 AM_PROG_CC_C_O
86 LT_LIB_M
87
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"
92
93
94 # DEBUG
95 AC_ARG_ENABLE(debug,
96     [  --enable-debug          Enable CyaSSL debugging support (default: disabled)],
97     [ ENABLED_DEBUG=$enableval ],
98     [ ENABLED_DEBUG=no ]
99     )
100 if test "$ENABLED_DEBUG" = "yes"
101 then
102   # Full debug. Very slow in some cases
103   AM_CFLAGS="$DEBUG_CFLAGS $AM_CFLAGS"
104 else
105   # Optimized version. No debug
106   AM_CFLAGS="$AM_CFLAGS -DNDEBUG"
107 fi
108
109
110 # SMALL BUILD
111 AC_ARG_ENABLE(small,
112     [  --enable-small          Enable smallest build (default: disabled)],
113     [ ENABLED_SMALL=$enableval ],
114     [ ENABLED_SMALL=no ]
115     )
116 if test "$ENABLED_SMALL" = "yes"
117 then
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" 
123 fi
124
125
126 # SINGLE THREADED
127 AC_ARG_ENABLE(singleThreaded,
128     [  --enable-singleThreaded Enable CyaSSL single threaded (default: disabled)],
129     [ ENABLED_SINGLETHREADED=$enableval ],
130     [ ENABLED_SINGLETHREADED=no ]
131     )
132 if test "$ENABLED_SINGLETHREADED" = "yes"
133 then
134   AM_CFLAGS="-DSINGLE_THREADED $AM_CFLAGS"
135 fi
136
137
138 # DTLS
139 AC_ARG_ENABLE(dtls,
140     [  --enable-dtls           Enable CyaSSL DTLS (default: disabled)],
141     [ ENABLED_DTLS=$enableval ],
142     [ ENABLED_DTLS=no ]
143     )
144 if test "$ENABLED_DTLS" = "yes"
145 then
146   AM_CFLAGS="-DCYASSL_DTLS $AM_CFLAGS"
147 fi
148
149
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 ]
155     )
156 if test "$ENABLED_OPENSSLEXTRA" = "yes"
157 then
158   AM_CFLAGS="-DOPENSSL_EXTRA $AM_CFLAGS"
159 fi
160
161 if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_SMALL" = "yes"
162 then
163     AC_MSG_ERROR([cannot enable small and opensslExtra, only one or the other.])
164 fi
165
166
167 # IPv6 Test Apps
168 AC_ARG_ENABLE(ipv6,
169     [  --enable-ipv6           Enable testing of IPV6 (default: disabled)],
170     [ ENABLED_IPV6=$enableval ],
171     [ ENABLED_IPV6=no ]
172     )
173
174 if test "$ENABLED_IPV6" = "yes"
175 then
176     AM_CFLAGS="$AM_CFLAGS -DTEST_IPV6"
177 fi
178
179
180 # Fortress build 
181 AC_ARG_ENABLE(fortress,
182     [  --enable-fortress       Enable SSL fortress build (default: disabled)],
183     [ ENABLED_FORTRESS=$enableval ],
184     [ ENABLED_FORTRESS=no ]
185     )
186
187 if test "$ENABLED_FORTRESS" = "yes"
188 then
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"
190 fi
191
192
193 # ssl bump build 
194 AC_ARG_ENABLE(bump,
195     [  --enable-bump           Enable SSL Bump build (default: disabled)],
196     [ ENABLED_BUMP=$enableval ],
197     [ ENABLED_BUMP=no ]
198     )
199
200 if test "$ENABLED_BUMP" = "yes"
201 then
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"
203 fi
204
205 # fastmath
206 AC_ARG_ENABLE(fastmath,
207     [  --enable-fastmath       Enable fast math for BigInts (default: disabled)],
208     [ ENABLED_FASTMATH=$enableval ],
209     [ ENABLED_FASTMATH=no ]
210     )
211
212 if test "x$ENABLED_FASTMATH" = "xyes"
213 then
214     AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH"
215 fi
216
217
218 # fast HUGE math
219 AC_ARG_ENABLE(fasthugemath,
220     [  --enable-fasthugemath   Enable fast math + huge code (default: disabled)],
221     [ ENABLED_FASTHUGEMATH=$enableval ],
222     [ ENABLED_FASTHUGEMATH=no ]
223     )
224
225 if test "$ENABLED_BUMP" = "yes"
226 then
227     ENABLED_FASTHUGEMATH="yes"
228 fi
229
230 if test "$ENABLED_FASTHUGEMATH" = "yes"
231 then
232     ENABLED_FASTMATH="yes"
233     AM_CFLAGS="$AM_CFLAGS -DUSE_FAST_MATH"
234 fi
235
236 AM_CONDITIONAL([BUILD_FASTMATH], [test "x$ENABLED_FASTMATH" = "xyes"])
237
238
239 # big cache
240 AC_ARG_ENABLE(bigcache,
241     [  --enable-bigcache       Enable big session cache (default: disabled)],
242     [ ENABLED_BIGCACHE=$enableval ],
243     [ ENABLED_BIGCACHE=no ]
244     )
245
246 if test "$ENABLED_BIGCACHE" = "yes"
247 then
248     AM_CFLAGS="$AM_CFLAGS -DBIG_SESSION_CACHE"
249 fi
250
251
252 # HUGE cache
253 AC_ARG_ENABLE(hugecache,
254     [  --enable-hugecache      Enable huge session cache (default: disabled)],
255     [ ENABLED_HUGECACHE=$enableval ],
256     [ ENABLED_HUGECACHE=no ]
257     )
258
259 if test "$ENABLED_HUGECACHE" = "yes"
260 then
261     AM_CFLAGS="$AM_CFLAGS -DHUGE_SESSION_CACHE"
262 fi
263
264
265 # SMALL cache
266 AC_ARG_ENABLE(smallcache,
267     [  --enable-smallcache     Enable small session cache (default: disabled)],
268     [ ENABLED_SMALLCACHE=$enableval ],
269     [ ENABLED_SMALLCACHE=no ]
270     )
271
272 if test "$ENABLED_SMALLCACHE" = "yes"
273 then
274     AM_CFLAGS="$AM_CFLAGS -DSMALL_SESSION_CACHE"
275 fi
276
277
278 # SNIFFER
279 AC_ARG_ENABLE(sniffer,
280     [  --enable-sniffer        Enable CyaSSL sniffer support (default: disabled)],
281     [ ENABLED_SNIFFER=$enableval ],
282     [ ENABLED_SNIFFER=no ]
283     )
284
285 if test "$ENABLED_SNIFFER" = "yes"
286 then
287     AM_CFLAGS="$AM_CFLAGS -DCYASSL_SNIFFER -DOPENSSL_EXTRA"
288 fi
289
290 AM_CONDITIONAL([BUILD_SNIFFER], [test "x$ENABLED_SNIFFER" = "xyes"])
291
292 # AES-GCM
293 AC_ARG_ENABLE(aesgcm,
294     [  --enable-aesgcm         Enable CyaSSL AES-GCM support (default: disabled)],
295     [ ENABLED_AESGCM=$enableval ],
296     [ ENABLED_AESGCM=no ]
297     )
298
299 if test "$ENABLED_AESGCM" = "word32"
300 then
301     AM_CFLAGS="$AM_CFLAGS -DGCM_WORD32"
302     ENABLED_AESGCM=yes
303 fi
304
305 if test "$ENABLED_AESGCM" = "small"
306 then
307     AM_CFLAGS="$AM_CFLAGS -DGCM_SMALL"
308     ENABLED_AESGCM=yes
309 fi
310
311 if test "$ENABLED_AESGCM" = "table"
312 then
313     AM_CFLAGS="$AM_CFLAGS -DGCM_TABLE"
314     ENABLED_AESGCM=yes
315 fi
316
317 if test "$ENABLED_AESGCM" = "yes"
318 then
319     AM_CFLAGS="$AM_CFLAGS -DHAVE_AESGCM -DCYASSL_SHA384 -DCYASSL_SHA512"
320 fi
321
322 AM_CONDITIONAL([BUILD_AESGCM], [test "x$ENABLED_AESGCM" = "xyes"])
323
324 # AES-NI
325 AC_ARG_ENABLE(aesni,
326     [  --enable-aesni          Enable CyaSSL AES-NI support (default: disabled)],
327     [ ENABLED_AESNI=$enableval ],
328     [ ENABLED_AESNI=no ]
329     )
330
331 if test "$ENABLED_AESNI" = "yes"
332 then
333     AM_CFLAGS="$AM_CFLAGS -DCYASSL_AESNI"
334     if test "$GCC" = "yes"
335     then
336         # GCC needs these flags, icc doesn't
337         AM_CFLAGS="$AM_CFLAGS -maes -msse4"
338     fi
339 fi
340
341 AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"])
342
343
344 # MD2
345 AC_ARG_ENABLE(md2,
346     [  --enable-md2            Enable CyaSSL MD2 support (default: disabled)],
347     [ ENABLED_MD2=$enableval ],
348     [ ENABLED_MD2=no ]
349     )
350
351 if test "$ENABLED_BUMP" = "yes"
352 then
353     ENABLED_MD2="yes"
354 fi
355
356 if test "$ENABLED_MD2" = "yes"
357 then
358     AM_CFLAGS="$AM_CFLAGS -DCYASSL_MD2"
359 fi
360
361 AM_CONDITIONAL([BUILD_MD2], [test "x$ENABLED_MD2" = "xyes"])
362
363
364 # RIPEMD
365 AC_ARG_ENABLE(ripemd,
366     [  --enable-ripemd         Enable CyaSSL RIPEMD-160 support (default: disabled)],
367     [ ENABLED_RIPEMD=$enableval ],
368     [ ENABLED_RIPEMD=no ]
369     )
370
371 if test "$ENABLED_RIPEMD" = "yes"
372 then
373     AM_CFLAGS="$AM_CFLAGS -DCYASSL_RIPEMD"
374 fi
375
376 AM_CONDITIONAL([BUILD_RIPEMD], [test "x$ENABLED_RIPEMD" = "xyes"])
377
378
379 # SHA512
380 AC_ARG_ENABLE(sha512,
381     [  --enable-sha512         Enable CyaSSL SHA-512 support (default: disabled)],
382     [ ENABLED_SHA512=$enableval ],
383     [ ENABLED_SHA512=no ]
384     )
385
386 if test "$ENABLED_SHA512" = "yes"
387 then
388     AM_CFLAGS="$AM_CFLAGS -DCYASSL_SHA512"
389 fi
390
391 if test "$ENABLED_FORTRESS" = "yes"
392 then
393     ENABLED_SHA512="yes"
394 fi
395
396 if test "$ENABLED_AESGCM" = "yes"
397 then
398     ENABLED_SHA512="yes"
399 fi
400
401
402 AM_CONDITIONAL([BUILD_SHA512], [test "x$ENABLED_SHA512" = "xyes"])
403
404
405 # SESSION CERTS
406 AC_ARG_ENABLE(sessioncerts,
407     [  --enable-sessioncerts   Enable session cert storing (default: disabled)],
408     [ ENABLED_SESSIONCERTS=$enableval ],
409     [ ENABLED_SESSIONCERTS=no ]
410     )
411
412 if test "$ENABLED_SESSIONCERTS" = "yes"
413 then
414     AM_CFLAGS="$AM_CFLAGS -DSESSION_CERTS"
415 fi
416
417
418 # KEY GENERATION
419 AC_ARG_ENABLE(keygen,
420     [  --enable-keygen         Enable key generation (default: disabled)],
421     [ ENABLED_KEYGEN=$enableval ],
422     [ ENABLED_KEYGEN=no ]
423     )
424
425 if test "$ENABLED_KEYGEN" = "yes"
426 then
427     AM_CFLAGS="$AM_CFLAGS -DCYASSL_KEY_GEN"
428 fi
429
430
431 # CERT GENERATION
432 AC_ARG_ENABLE(certgen,
433     [  --enable-certgen        Enable cert generation (default: disabled)],
434     [ ENABLED_CERTGEN=$enableval ],
435     [ ENABLED_CERTGEN=no ]
436     )
437
438 if test "$ENABLED_CERTGEN" = "yes"
439 then
440     AM_CFLAGS="$AM_CFLAGS -DCYASSL_CERT_GEN"
441 fi
442
443
444 # HC128 
445 AC_ARG_ENABLE(hc128,
446     [  --enable-hc128          Enable HC-128 (default: disabled)],
447     [ ENABLED_HC128=$enableval ],
448     [ ENABLED_HC128=no ]
449     )
450
451 if test "$ENABLED_HC128" = "no"
452 then
453     AM_CFLAGS="$AM_CFLAGS -DNO_HC128"
454 else
455     AM_CFLAGS="$AM_CFLAGS -DHAVE_HC128"
456 fi
457
458 AM_CONDITIONAL([BUILD_HC128], [test "x$ENABLED_HC128" = "xyes"])
459
460
461 # PSK 
462 AC_ARG_ENABLE(psk,
463     [  --enable-psk            Enable PSK (default: disabled)],
464     [ ENABLED_PSK=$enableval ],
465     [ ENABLED_PSK=no ]
466     )
467
468 if test "$ENABLED_PSK" = "no"
469 then
470     AM_CFLAGS="$AM_CFLAGS -DNO_PSK"
471 fi
472
473
474 # Web Server Build 
475 AC_ARG_ENABLE(webServer,
476     [  --enable-webServer      Enable Web Server (default: disabled)],
477     [ ENABLED_WEBSERVER=$enableval ],
478     [ ENABLED_WEBSERVER=no ]
479     )
480
481 if test "$ENABLED_WEBSERVER" = "yes"
482 then
483     AM_CFLAGS="$AM_CFLAGS -DHAVE_WEBSERVER"
484 fi
485
486
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 ]
492     )
493
494 if test "$ENABLED_NOFILESYSTEM" = "yes"
495 then
496     AM_CFLAGS="$AM_CFLAGS -DNO_FILESYSTEM"
497 fi
498
499
500 # No inline Build 
501 AC_ARG_ENABLE(noInline,
502     [  --enable-noInline       Enable No inline (default: disabled)],
503     [ ENABLED_NOINLINE=$enableval ],
504     [ ENABLED_NOINLINE=no ]
505     )
506
507 if test "$ENABLED_NOINLINE" = "yes"
508 then
509     AM_CFLAGS="$AM_CFLAGS -DNO_INLINE"
510 fi
511
512 AM_CONDITIONAL([BUILD_NOINLINE], [test "x$ENABLED_NOINLINE" = "xyes"])
513
514
515 # ECC 
516 AC_ARG_ENABLE(ecc,
517     [  --enable-ecc            Enable ECC (default: disabled)],
518     [ ENABLED_ECC=$enableval ],
519     [ ENABLED_ECC=no ]
520     )
521
522 if test "$ENABLED_ECC" = "yes"
523 then
524     AM_CFLAGS="$AM_CFLAGS -DHAVE_ECC"
525 fi
526
527 AM_CONDITIONAL([BUILD_ECC], [test "x$ENABLED_ECC" = "xyes"])
528
529
530 if test "$ENABLED_ECC" = "yes" && test "$ENABLED_SMALL" = "yes"
531 then
532     AC_MSG_ERROR([cannot enable ecc and small, ecc requires TLS which small turns off.]) 
533 fi
534
535
536 # OCSP
537 AC_ARG_ENABLE(ocsp,
538     [  --enable-ocsp           Enable OCSP (default: disabled)],
539     [ ENABLED_OCSP=$enableval ],
540     [ ENABLED_OCSP=no ],
541     )
542
543 if test "$ENABLED_OCSP" = "yes"
544 then
545     AM_CFLAGS="$AM_CFLAGS -DHAVE_OCSP"
546 fi
547
548 AM_CONDITIONAL([BUILD_OCSP], [test "x$ENABLED_OCSP" = "xyes"])
549
550
551 # CRL 
552 AC_ARG_ENABLE(crl,
553     [  --enable-crl            Enable CRL (default: disabled)],
554     [ ENABLED_CRL=$enableval ],
555     [ ENABLED_CRL=no ],
556     )
557
558 if test "$ENABLED_CRL" = "yes"
559 then
560     AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL"
561 fi
562
563 AM_CONDITIONAL([BUILD_CRL], [test "x$ENABLED_CRL" = "xyes"])
564
565
566 # CRL Monitor
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 ],
571     )
572
573 if test "$ENABLED_CRL_MONITOR" = "yes"
574 then
575     AM_CFLAGS="$AM_CFLAGS -DHAVE_CRL_MONITOR"
576 fi
577
578 AM_CONDITIONAL([BUILD_CRL_MONITOR], [test "x$ENABLED_CRL_MONITOR" = "xyes"])
579
580
581 # NTRU
582 ntruHome=`pwd`/NTRU_algorithm
583 ntruInclude=$ntruHome/cryptolib
584 ntruLib=$ntruHome
585 AC_ARG_ENABLE(ntru,
586     [  --enable-ntru           Enable NTRU (default: disabled)],
587     [ ENABLED_NTRU=$enableval ],
588     [ ENABLED_NTRU=no ]
589     )
590
591 if test "$ENABLED_NTRU" = "yes"
592 then
593     AM_CFLAGS="$AM_CFLAGS -DHAVE_NTRU -I$ntruInclude"
594     AM_LDFLAGS="$AM_LDFLAGS -L$ntruLib"
595     LIBS="$LIBS -lntru_encrypt"
596 fi
597
598 AM_CONDITIONAL([BUILD_NTRU], [test "x$ENABLED_NTRU" = "xyes"])
599
600 if test "$ENABLED_NTRU" = "yes" && test "$ENABLED_SMALL" = "yes"
601 then
602     AC_MSG_ERROR([cannot enable ntru and small, ntru requires TLS which small turns off.]) 
603 fi
604
605
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 ]
611     )
612
613 if test "$ENABLED_TESTCERT" = "yes"
614 then
615     AM_CFLAGS="$AM_CFLAGS -DCYASSL_TEST_CERT"
616 fi
617
618
619 # LIBZ
620 trylibzdir=""
621 AC_ARG_WITH(libz,
622     [  --with-libz=PATH        PATH to libz install (default /usr/) ],
623     [
624         AC_MSG_CHECKING([for libz])
625         CPPFLAGS="$CPPFLAGS -DHAVE_LIBZ"
626         LIBS="$LIBS -lz"
627
628         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
629
630         if test "x$libz_linked" == "xno" ; then
631             if test "x$withval" != "xno" ; then
632                 trylibzdir=$withval
633             fi
634             if test "x$withval" == "xyes" ; then
635                 trylibzdir="/usr"
636             fi
637
638             AM_LDFLAGS="$AM_LDFLAGS -L$trylibzdir/lib"
639             CPPFLAGS="$CPPFLAGS -I$trylibzdir/include"
640
641             AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <zlib.h>]], [[ deflateInit(0, 8); ]])],[ libz_linked=yes ],[ libz_linked=no ])
642
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/])
646             fi
647             AC_MSG_RESULT([yes])
648         else
649             AC_MSG_RESULT([yes])
650         fi
651
652     ]
653 )
654
655
656 # OPTIMIZE FLAGS
657 if test "$GCC" = "yes"
658 then
659     AM_CFLAGS="$AM_CFLAGS -Wall -Wno-unused"
660     if test "$ENABLED_DEBUG" = "no"
661     then
662         if test "$ENABLED_FASTMATH" = "yes"
663         then
664             AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_FAST_CFLAGS"
665             if test "$ENABLED_FASTHUGEMATH" = "yes"
666             then
667                 AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_HUGE_CFLAGS"
668             fi
669         else
670             AM_CFLAGS="$AM_CFLAGS $OPTIMIZE_CFLAGS"
671         fi
672     fi
673 fi
674
675 AX_PTHREAD([
676             AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
677             ],
678             [
679              AC_DEFINE([HAVE_PTHREAD], [0], [Define if you have POSIX threads libraries and header files.])
680              ])
681
682 LIB_SOCKET_NSL
683
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"
694
695 case "$host_os" in
696   *linux*)
697 GCCWARNINGS="$GCCWARNINGS -Warray-bounds"
698   ;;
699 esac
700
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"
705 fi])
706
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"
714 fi])
715
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"
722 fi])
723
724 CREATE_HEX_VERSION
725 AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
726 AC_SUBST(AM_CFLAGS)
727 AC_SUBST(AM_LDFLAGS)
728
729 # FINAL
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])
734
735 AC_OUTPUT
736