4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2000 - 2008 Pekka Riikonen
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; version 2 of the License.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
22 AC_CONFIG_HEADERS(cryptodefs.h)
33 #ifdef SILC_DIST_INPLACE
35 #endif SILC_DIST_INPLACE
41 ## Library versioning.
44 # Do the releases and library versioning according to following rules:
46 # - If any code has changed in library, increment CRYPTO_REVISION
47 # - If API were added, removed or changed, set CRYPTO_REVISION to 0
48 # - If API were added, removed or changed, increment CRYPTO_CURRENT
49 # - If APi were added, increment CRYPTO_AGE
50 # - If API were removed, set CRYPTO_AGE to 0
53 # Base version for library.
54 CRYPTO_BASE_VERSION=1.2
57 CRYPTO_CURRENT=1 # prev = 0
58 CRYPTO_REVISION=0 # prev = 0
59 CRYPTo_AGE=0 # prev = 0
61 # Substitute the version numbers
62 AC_SUBST(CRYPTO_BASE_VERSION)
63 AC_SUBST(CRYPTO_CURRENT)
64 AC_SUBST(CRYPTO_REVISION)
72 # Default installation destination
73 AC_PREFIX_DEFAULT(/usr/local)
74 if test "x$prefix" != xNONE; then
77 silc_prefix="$ac_default_prefix"
83 ## Required dependencies
87 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
89 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silccrypt"
90 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcasn1"
91 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcacc"
92 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcskr"
93 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcmath"
95 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcssh"
98 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpgp"
100 #ifdef SILC_DIST_PKIX
101 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpkix"
102 #endif SILC_DIST_PKIX
104 # SILC Runtime Toolkit checking
105 AC_ARG_WITH(srt-includes,
106 [ --with-srt-includes=DIR SILC Runtime Toolkit includes [search in DIR]],
107 [ac_srt_includes="$withval"], [ac_srt_includes="no"])
108 AC_ARG_WITH(srt-libs,
109 [ --with-srt-libs=DIR SILC Runtime Toolkit libraries [search in DIR]],
110 [ac_srt_libs="$withval"], [ac_srt_libs="no"])
112 if test -n "$with_srt_includes" || test -n "$with_srt_libs"; then
113 # Manually provided libs
114 if test "$ac_srt_includes" != "no"; then
115 SILC_LIB_INCLUDES="-I$ac_srt_includes"
117 if test "$ac_srt_libs" != "no"; then
118 LDFLAGS="-L$ac_srt_libs $LDFLAGS"
121 # Check libs to link against
122 f=`$EGREP __SILC_HAVE_PTHREAD $ac_srt_includes/silc.h`
123 if test -n "$f"; then
124 LIBS="$LIBS -lpthread"
129 PKG_CHECK_MODULES(SRT, [srt >= 1.2])
130 LIBS="$SRT_LIBS $LIBS"
131 CFLAGS="$CFLAGS $SRT_CFLAGS"
139 # Disable all CPU feature optimizations
140 AC_MSG_CHECKING(whether to enable CPU feature optimizations)
141 AC_ARG_ENABLE(cpu-optimizations,
142 [ --disable-cpu-optimizations do not use any CPU feature optimizations],
145 AC_DEFINE([SILC_NO_CPU_OPTIMIZATIONS], [], [SILC_NO_CPU_OPTIMIZATIONS])
146 want_cpu_optimizations=false
150 want_cpu_optimizations=true
152 AM_CONDITIONAL(SILC_NO_CPU_OPTIMIZATIONS,
153 test x$want_cpu_optimizations = xfalse)
155 SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [],
156 AC_DEFINE([SILC_SMP], [], [SILC_SMP]))
166 # All following Intels are considered 32-bit CPUs.
168 # All CPUs of today are considered i386 and i486 compatible */
172 if test "x$host_cpu" = "xi586"; then
176 if test "x$host_cpu" = "xi686"; then
181 if test "x$host_cpu" = "xi786"; then
187 # Check for specific CPU features
188 SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
189 SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
190 SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
191 SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
192 SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), [])
193 SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), [])
194 SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), [])
195 SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), [])
198 # Intel IA-64, 64-bit CPU (not x86_64 compatible)
200 AC_DEFINE([SILC_IA64], [], [SILC_IA64])
204 # AMD/Intel x86_64, 64-bit CPU
208 # Check for specific CPU features
209 SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
210 SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
211 SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
212 SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
213 SILC_CPU_FLAG(sse4a, true, AC_DEFINE([SILC_CPU_SSE4A], [], [SILC_CPU_SSE4A]), [])
214 SILC_CPU_FLAG(sse4_1, true, AC_DEFINE([SILC_CPU_SSE41], [], [SILC_CPU_SSE41]), [])
215 SILC_CPU_FLAG(sse4_2, true, AC_DEFINE([SILC_CPU_SSE42], [], [SILC_CPU_SSE42]), [])
216 SILC_CPU_FLAG(sse5, true, AC_DEFINE([SILC_CPU_SSE5], [], [SILC_CPU_SSE5]), [])
219 # PowerPC, 32-bit and 64-bit CPUs
224 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
225 AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue)
226 AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue)
227 AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue)
228 AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue)
229 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
230 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
231 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
233 if test x$want_cpu_optimizations = xtrue; then
234 # Set some compiler options based on CPU
235 if test "x$CC" = "xicc"; then
237 if test x$x_have_cpu_sse4_1 = xtrue; then
238 SILC_ADD_CFLAGS(-axS)
240 if test x$x_have_cpu_sse4_2 = xtrue; then
241 SILC_ADD_CFLAGS(-axS)
243 if test x$x_have_cpu_ssse3 = xtrue; then
244 SILC_ADD_CFLAGS(-axT)
245 elif test x$x_have_cpu_pni = xtrue; then
246 SILC_ADD_CFLAGS(-axP)
247 elif test x$x_have_cpu_sse2 = xtrue; then
248 SILC_ADD_CFLAGS(-axW)
252 if test x$x_have_cpu_sse2 = xtrue; then
253 SILC_ADD_CFLAGS(-msse2)
255 if test x$x_have_cpu_pni = xtrue; then
256 SILC_ADD_CFLAGS(-msse3)
258 if test x$x_have_cpu_ssse3 = xtrue; then
259 SILC_ADD_CFLAGS(-mssse3)
261 if test x$x_have_cpu_sse4_1 = xtrue; then
262 SILC_ADD_CFLAGS(-msse4)
264 if test x$x_have_cpu_sse4_2 = xtrue; then
265 SILC_ADD_CFLAGS(-msse4)
272 ## Put here any platform specific stuff
277 CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
295 # More header checking
297 AC_CHECK_HEADERS(unistd.h assert.h time.h fcntl.h)
298 AC_CHECK_HEADERS(sys/types.h sys/times.h sys/time.h sys/resource.h)
300 # Check for big-endian machines
305 ## Compiler and compiler flag checks
308 # Disable all compiler optimizations
309 AC_MSG_CHECKING(whether to enable compiler optimizations)
310 AC_ARG_ENABLE(optimizations,
311 [ --disable-optimizations do not use any compiler optimizations],
314 AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
315 want_cc_optimizations=false
319 want_cc_optimizations=true
321 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
324 # GCC specific options
325 if test "x$summary_debug" = "xyes"; then
330 SILC_ADD_CFLAGS(-Wall -finline-functions)
331 SILC_ADD_CFLAGS(-Wno-pointer-sign)
346 # Intel C++ Compiler flags
347 if test "x$CC" = "xicc"; then
348 SILC_ADD_CFLAGS(-restrict)
349 SILC_ADD_CFLAGS(-finline-functions)
351 # Don't define __GNUC__ except for system includes
352 SILC_ADD_CFLAGS(-gcc-sys)
356 if test x$want_cc_optimizations = xtrue; then
358 # GCC specific options
359 if test "x$summary_debug" = "xyes"; then
368 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
371 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
374 SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
380 # Workaround a bug in GCC 2.x which causes memory exhaustion
381 # when compiling sha1 with optimizations on UltraSPARC.
383 if test "$GCC" -a "$host_cpu" = "sparc64"; then
384 AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1)
387 #if defined(__sparc64__) && (__GNUC__ == 2)
403 ## Function and libary checking
405 AC_CHECK_FUNCS(times clock time)
406 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid getrusage setsid)
408 cryptover=`echo $VERSION | sed 's/\./ /g'`
414 if test $maj -eq 0; then
418 if test $min -eq 0; then
422 if test $bld -eq 0; then
427 __CRYPTO_PACKAGE_VERSION="#define __SILC_CRYPTO_VERSION SILC_VERSION($maj,$min,$bld)"
431 ## Enable/disable checking
434 #ifdef SILC_DIST_INPLACE
436 # Profiling options (never delivered to distributions)
438 AC_MSG_CHECKING(whether to enable gprof)
440 [ --enable-gprof enable gprof profiling],
442 case "${enableval}" in
457 AC_MSG_CHECKING(whether to enable gcov)
459 [ --enable-gcov enable gcov],
461 case "${enableval}" in
464 SILC_ADD_CFLAGS(-fprofile-arcs)
475 #endif SILC_DIST_INPLACE
478 AC_MSG_CHECKING(whether to enable debugging)
481 [ --enable-debug enable debugging],
483 case "${enableval}" in
497 # Disable all assembler optimizations
498 AC_MSG_CHECKING(whether to enable assembler optimizations)
500 [ --disable-asm do not use assembler optimizations],
503 AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
510 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
512 # Check for assembler
515 if test x$want_asm = xtrue; then
517 if test x$x_have_cpu_sse2 = xtrue; then
518 ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE2"
520 if test x$x_have_cpu_pni = xtrue; then
521 ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE3"
523 if test x$x_have_cpu_ssse3 = xtrue; then
524 ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSSE3"
526 if test x$x_have_cpu_sse4_1 = xtrue; then
527 ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE41"
529 if test x$x_have_cpu_sse4_2 = xtrue; then
530 ASM_FLAGS="$ASM_FLAGS -D SILC_CPU_SSE42"
533 AC_PATH_PROG([NASM], [nasm], [no])
534 if test "x$NASM" != "xno"; then
535 if test x$cpu_x86_64 = xtrue; then
536 SILC_ASSEMBLER="$NASM -O2 -felf64 $ASM_FLAGS"
538 SILC_ASSEMBLER="$NASM -O2 -felf $ASM_FLAGS"
543 AC_PATH_PROG([YASM], [yasm], [no])
544 if test "x$YASM" != "xno"; then
545 if test x$cpu_x86_64 = xtrue; then
546 SILC_ASSEMBLER="$YASM -Xgnu -felf64 $ASM_FLAGS"
548 SILC_ASSEMBLER="$YASM -Xgnu -felf $ASM_FLAGS"
553 AC_SUBST(SILC_ASSEMBLER)
556 ## With/without checkings
559 # MP library checking. First check whether user wants to use GMP and use
560 # it if found. If not or not defined then compile the default library in the
565 SAVE_CFLAGS="$CFLAGS"
566 SAVE_LDFLAGS="$LDFLAGS"
567 AC_MSG_CHECKING(whether to search for GMP)
569 [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]],
578 if test -d "$withval/include"; then
579 CFLAGS="$CFLAGS -I$withval/include"
581 if test -d "$withval/lib"; then
582 LDFLAGS="$LDFLAGS -L$withval/lib"
589 AC_CHECK_LIB(gmp, __gmpz_init,
592 AC_DEFINE([SILC_MP_GMP], [], [GMP])
593 AC_MSG_RESULT(Using GMP as a MP library.)
597 CFLAGS="$SAVE_CFLAGS"
598 LDFLAGS="$SAVE_LDFLAGS"
604 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
605 AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse)
606 if test x$mp_gmp = xfalse; then
607 AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH])
608 AC_MSG_RESULT(Using SILC Math as a MP library.)
613 ## Native WIN32 compilation under cygwin
615 AC_MSG_CHECKING(whether to compile native WIN32 code)
617 [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)],
620 AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
622 CFLAGS="-mno-cygwin $CFLAGS"
623 LIBS="$LIBS -lwsock32"
629 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
633 ## Include configure fragments
639 ## Outputs and substitutions
643 AC_SUBST(SILC_TOP_SRCDIR)
646 AC_SUBST(SILC_LIB_INCLUDES)
647 AC_SUBST(__CRYPTO_PACKAGE_VERSION)
649 # Native Symbian OS support (disabled by default)
650 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
652 # Make enable-shared aware
653 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
655 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
657 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
659 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
661 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
663 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
664 AC_SUBST(INCLUDE_DEFINES_INT)
676 doc/crypto.in/index.html
677 doc/crypto.in/manual.html
687 lib/silccrypt/Makefile
688 lib/silccrypt/silccrypto.h
689 lib/silccrypt/tests/Makefile
690 lib/silcasn1/Makefile
691 lib/silcasn1/tests/Makefile
693 lib/silcacc/tests/Makefile
696 lib/silcssh/tests/Makefile
700 lib/silcpgp/tests/Makefile
702 #ifdef SILC_DIST_PKIX
703 lib/silcpkix/Makefile
704 lib/silcpkix/tests/Makefile
705 #endif SILC_DIST_PKIX
707 lib/silcskr/tests/Makefile
708 lib/silcmath/Makefile
709 lib/silcmath/tests/Makefile
719 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
720 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
721 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
722 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
725 echo "SILC Crypto Toolkit configuration summary:"
726 echo "-----------------------------------------"
727 echo " Target host ...................: $target"
728 echo " Compiler ......................: $CC"
729 echo " CFLAGS ........................: $CFLAGS"
730 echo " LDFLAGS .......................: $LDFLAGS"
731 echo " LIBS ..........................: $LIBS"
733 echo " Installation prefix ...........: $prefix"
734 echo " bin directory .................: $s_bindir"
735 echo " sbin directory ................: $s_sbindir"
736 echo " etc directory .................: $ETCDIR"
737 echo " man directory .................: $s_mandir"
738 echo " doc directory .................: $DOCDIR"
739 echo " include directory .............: $s_includedir"
742 if test x$mp_gmp = xtrue; then
743 echo " Arithmetic library ............: GMP"
746 if test x$want_asm = xfalse; then
751 echo " Assembler optimizations .......: $summary_asm"
753 if test x$want_cc_optimizations = xfalse; then
758 echo " Compiler optimizations ........: $summary_cc_opt"
760 if test x$want_cpu_optimizations = xfalse; then
763 summary_cpu_opt="yes"
765 echo " CPU feature optimizations .....: $summary_cpu_opt"
768 if test x$has_threads = xtrue; then
771 echo " Multi-threads support .........: $threads"
772 echo " Debugging enabled .............: $summary_debug"
774 echo "Compile the sources with 'make' or 'gmake' command."