Merge commit 'origin/silc.1.1.branch'
[silc.git] / configure.ad
1 #
2 #  configure.ad
3 #
4 #  Author: Pekka Riikonen <priikone@silcnet.org>
5 #
6 #  Copyright (C) 2000 - 2008 Pekka Riikonen
7 #
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.
11 #
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.
16 #
17
18 AD_INIT
19 AC_CANONICAL_SYSTEM
20 AM_INIT_AUTOMAKE
21 AC_PREREQ(2.52)
22 AC_CONFIG_HEADERS(silcdefs.h)
23
24 AC_PROG_INSTALL
25 AC_PROG_MAKE_SET
26
27 AC_PROG_LN_S
28 AC_PROG_EGREP
29 AC_SUBST(LN_S)
30 AC_PATH_PROG(sedpath, sed)
31
32 AC_PROG_CC
33 AM_PROG_AS
34 AC_C_INLINE
35 AC_C_CONST
36
37 AC_PROG_RANLIB
38 #ifndef SILC_DIST_TOOLKIT
39 AC_DISABLE_SHARED
40 #endif SILC_DIST_TOOLKIT
41 #ifdef SILC_DIST_INPLACE
42 AC_DISABLE_SHARED
43 #endif SILC_DIST_INPLACE
44 AC_PROG_LIBTOOL
45
46 SILC_TOP_SRCDIR=`pwd`
47
48
49 ##
50 ## Library versioning.
51 ##
52
53 # Do the releases and library versioning according to following rules:
54 #
55 #  - If any code has changed in library, increment [LIB]_REVISION
56 #  - If functions were added, removed or changed, set [LIB]_REVISION to 0
57 #  - If functions were added, removed or changed, increment [LIB]_CURRENT
58 #  - If functions were added, increment [LIB]_AGE
59 #  - If functions were removed, set [LIB]_AGE to 0
60 #
61 # where [LIB] is LIBSILC, LIBSILCCLIENT or LIBSILCSERVER, and where
62 # "functions" means functions public interfaces (API).
63 #
64 # The LIB_BASE_VERSION defines the SILC software major.minor version and
65 # it is increment only when these version numbers actually change.
66 #
67
68 # Base version for libraries.  Do not change this unless SILC version
69 # changes too.
70 LIB_BASE_VERSION=1.2
71
72 # libsilc versions
73 LIBSILC_CURRENT=1               # prev = 0
74 LIBSILC_REVISION=0              # prev = 0
75 LIBSILC_AGE=0                   # prev = 0
76
77 # libsilcclient versions
78 LIBSILCCLIENT_CURRENT=1         # prev = 0
79 LIBSILCCLIENT_REVISION=0        # prev = 0
80 LIBSILCCLIENT_AGE=0             # prev = 0
81
82 # libsilcserver versions
83 LIBSILCSERVER_CURRENT=1         # prev = 0
84 LIBSILCSERVER_REVISION=0        # prev = 0
85 LIBSILCSERVER_AGE=0             # prev = 0
86
87 # Substitute the version numbers
88 AC_SUBST(LIB_BASE_VERSION)
89 AC_SUBST(LIBSILC_CURRENT)
90 AC_SUBST(LIBSILC_REVISION)
91 AC_SUBST(LIBSILC_AGE)
92 AC_SUBST(LIBSILCCLIENT_CURRENT)
93 AC_SUBST(LIBSILCCLIENT_REVISION)
94 AC_SUBST(LIBSILCCLIENT_AGE)
95 AC_SUBST(LIBSILCSERVER_CURRENT)
96 AC_SUBST(LIBSILCSERVER_REVISION)
97 AC_SUBST(LIBSILCSERVER_AGE)
98
99
100 ##
101 ##  Installation
102 ##
103
104 # Default installation destination
105 AC_PREFIX_DEFAULT(/usr/local)
106 if test "x$prefix" != xNONE; then
107   silc_prefix="$prefix"
108 else
109   silc_prefix="$ac_default_prefix"
110   prefix="$silc_prefix"
111 fi
112
113 #ifdef SILC_DIST_TOOLKIT
114 toolkitver=`echo $VERSION | sed 's/\./ /g'`
115 maj=0
116 min=0
117 bld=0
118 for v in $toolkitver
119 do
120   if test $maj -eq 0; then
121     maj=$v
122     continue
123   fi
124   if test $min -eq 0; then
125     min=$v
126     continue
127   fi
128   if test $bld -eq 0; then
129     bld=$v
130     continue
131   fi
132 done
133 __SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)"
134 #endif SILC_DIST_TOOLKIT
135
136
137 ##
138 ## Required dependencies
139 ##
140
141 compile_libs=true
142 LIBSUBDIR=lib
143 LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS"
144
145 # SILC Runtime Toolkit checking
146 AC_ARG_WITH(srt-includes,
147   [  --with-srt-includes=DIR  SILC Runtime Toolkit includes [search in DIR]],
148   [ac_srt_includes="$withval"], [ac_srt_includes="no"])
149 AC_ARG_WITH(srt-libs,
150   [  --with-srt-libs=DIR      SILC Runtime Toolkit libraries [search in DIR]],
151   [ac_srt_libs="$withval"], [ac_srt_libs="no"])
152
153 if test -n "$with_srt_includes" || test -n "$with_srt_libs"; then
154   # Manually provided libs
155   if test "$ac_srt_includes" != "no"; then
156     SILC_LIB_INCLUDES="-I$ac_srt_includes"
157   fi
158   if test "$ac_srt_libs" != "no"; then
159     LDFLAGS="-L$ac_srt_libs $LDFLAGS"
160   fi
161
162   # Check libs to link against
163   f=`$EGREP __SILC_HAVE_PTHREAD $ac_srt_includes/silc.h`
164   if test -n "$f"; then
165     LIBS="$LIBS -lpthread"
166     has_threads=true
167   fi
168 else
169   # pkg-config check
170   PKG_CHECK_MODULES(SRT, [srt >= 1.2])
171   LIBS="$SRT_LIBS $LIBS"
172   CFLAGS="$CFLAGS $SRT_CFLAGS"
173 fi
174
175 # SILC Crypto Toolkit checking
176 AC_ARG_WITH(sct-includes,
177   [  --with-sct-includes=DIR  SILC Crypto Toolkit includes [search in DIR]],
178   [ac_sct_includes="$withval"], [ac_sct_includes="no"])
179 AC_ARG_WITH(sct-libs,
180   [  --with-sct-libs=DIR      SILC Crypto Toolkit libraries [search in DIR]],
181   [ac_sct_libs="$withval"], [ac_sct_libs="no"])
182
183 if test -n "$with_sct_includes" || test -n "$with_sct_libs"; then
184   # Manually provided libs
185   if test "$ac_sct_includes" != "no"; then
186     SILC_LIB_INCLUDES="-I$ac_sct_includes"
187   fi
188   if test "$ac_sct_libs" != "no"; then
189     LDFLAGS="-L$ac_sct_libs $LDFLAGS"
190   fi
191
192   # Check libs to link against
193   f=`$EGREP __SILC_HAVE_PTHREAD $ac_sct_includes/silc.h`
194   if test -n "$f"; then
195     LIBS="$LIBS -lpthread"
196     has_threads=true
197   fi
198 else
199   # pkg-config check
200   PKG_CHECK_MODULES(SCT, [sct >= 1.2])
201   LIBS="$SCT_LIBS $LIBS"
202   CFLAGS="$CFLAGS $SCT_CFLAGS"
203 fi
204
205
206 ##
207 ## Detect CPU
208 ##
209
210 # Disable all CPU feature optimizations
211 AC_MSG_CHECKING(whether to enable CPU feature optimizations)
212 AC_ARG_ENABLE(cpu-optimizations,
213   [  --disable-cpu-optimizations  do not use any CPU feature optimizations],
214   [
215     AC_MSG_RESULT(no)
216     AC_DEFINE([SILC_NO_CPU_OPTIMIZATIONS], [], [SILC_NO_CPU_OPTIMIZATIONS])
217     want_cpu_optimizations=false
218   ],
219   [
220     AC_MSG_RESULT(yes)
221     want_cpu_optimizations=true
222   ])
223 AM_CONDITIONAL(SILC_NO_CPU_OPTIMIZATIONS,
224                test x$want_cpu_optimizations = xfalse)
225
226 SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [],
227                    AC_DEFINE([SILC_SMP], [], [SILC_SMP]))
228 cpu_i386=false
229 cpu_i486=false
230 cpu_i586=false
231 cpu_i686=false
232 cpu_i786=false
233 cpu_x86_64=false
234 cpu_ppc=false
235 cpu_ia64=false
236 case "$host_cpu" in
237   # All following Intels are considered 32-bit CPUs.
238   i?86)
239     # All CPUs of today are considered i386 and i486 compatible */
240     cpu_i386=true
241     cpu_i486=true
242
243     if test "x$host_cpu" = "xi586"; then
244       cpu_i586=true
245     fi
246
247     if test "x$host_cpu" = "xi686"; then
248       cpu_i586=true
249       cpu_i686=true
250     fi
251
252     if test "x$host_cpu" = "xi786"; then
253       cpu_i586=true
254       cpu_i686=true
255       cpu_i786=true
256     fi
257
258     # Check for specific CPU features
259     SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
260     SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
261     SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
262     SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
263     SILC_CPU_FLAG(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
264     ;;
265
266   # Intel IA-64, 64-bit CPU (not x86_64 compatible)
267   ia64)
268     AC_DEFINE([SILC_IA64], [], [SILC_IA64])
269     cpu_ia64=true
270     ;;
271
272   # AMD/Intel x86_64, 64-bit CPU
273   x86_64)
274     cpu_x86_64=true
275
276     # Check for specific CPU features
277     SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), [])
278     SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), [])
279     SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), [])
280     SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), [])
281     SILC_CPU_FLAG(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), [])
282     ;;
283
284   # PowerPC, 32-bit and 64-bit CPUs
285   powerpc*)
286     cpu_ppc=true
287     ;;
288 esac
289 AM_CONDITIONAL(SILC_I386, test x$cpu_i386 = xtrue)
290 AM_CONDITIONAL(SILC_I486, test x$cpu_i486 = xtrue)
291 AM_CONDITIONAL(SILC_I586, test x$cpu_i586 = xtrue)
292 AM_CONDITIONAL(SILC_I686, test x$cpu_i686 = xtrue)
293 AM_CONDITIONAL(SILC_7686, test x$cpu_i786 = xtrue)
294 AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue)
295 AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue)
296 AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue)
297
298 if test x$want_cpu_optimizations = xtrue; then
299   # Set some compiler options based on CPU
300   if test "x$CC" = "xicc"; then
301     # ICC flags
302     if test x$x_have_cpu_sse4 = xtrue; then
303       SILC_ADD_CFLAGS(-axS)
304     fi
305     if test x$x_have_cpu_ssse3 = xtrue; then
306       SILC_ADD_CFLAGS(-axT)
307     elif test x$x_have_cpu_pni = xtrue; then
308       SILC_ADD_CFLAGS(-axP)
309     elif test x$x_have_cpu_sse2 = xtrue; then
310       SILC_ADD_CFLAGS(-axW)
311     fi
312   else
313     # Other compilers
314     if test x$x_have_cpu_sse2 = xtrue; then
315       SILC_ADD_CFLAGS(-msse2)
316     fi
317     if test x$x_have_cpu_pni = xtrue; then
318       SILC_ADD_CFLAGS(-msse3)
319     fi
320     if test x$x_have_cpu_ssse3 = xtrue; then
321       SILC_ADD_CFLAGS(-mssse3)
322     fi
323     if test x$x_have_cpu_sse4 = xtrue; then
324       SILC_ADD_CFLAGS(-msse4)
325     fi
326   fi
327 fi
328
329
330 ##
331 ## Put here any platform specific stuff
332 ##
333
334 case "$target" in
335   *-*-linux*)
336     CFLAGS=`echo $CFLAGS -D_GNU_SOURCE`
337     ;;
338   *-*-freebsd*)
339     ;;
340   *-*-netbsd*)
341     ;;
342   *-*-*bsd*)
343     ;;
344   *)
345     ;;
346 esac
347
348
349 ##
350 ## Header checking
351 ##
352 AC_HEADER_STDC
353
354 # More header checking
355 #
356 AC_CHECK_HEADERS(unistd.h assert.h time.h fcntl.h stdarg.h)
357 AC_CHECK_HEADERS(sys/types.h sys/times.h sys/time.h)
358
359 # Check for big-endian machines
360 AC_C_BIGENDIAN
361
362
363 ##
364 ## Compiler and compiler flag checks
365 ##
366
367 # Disable all compiler optimizations
368 AC_MSG_CHECKING(whether to enable compiler optimizations)
369 AC_ARG_ENABLE(optimizations,
370   [  --disable-optimizations do not use any compiler optimizations],
371   [
372     AC_MSG_RESULT(no)
373     AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS])
374     want_cc_optimizations=false
375   ],
376   [
377     AC_MSG_RESULT(yes)
378     want_cc_optimizations=true
379   ])
380 AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse)
381
382 if test "$GCC"; then
383   # GCC specific options
384   if test "x$summary_debug" = "xyes"; then
385     SILC_ADD_CFLAGS(-g)
386   else
387     SILC_ADD_CFLAGS(-g)
388   fi
389   SILC_ADD_CFLAGS(-Wall -finline-functions)
390   SILC_ADD_CFLAGS(-Wno-pointer-sign)
391 else
392   # Other compilers
393   case "$target" in
394     alpha*-dec-osf*)
395       SILC_ADD_CFLAGS(-g3)
396       ;;
397     mips*-sgi-irix*)
398       SILC_ADD_CFLAGS(-g3)
399       ;;
400     *)
401       SILC_ADD_CFLAGS(-g)
402       ;;
403   esac
404
405   # Intel C++ Compiler flags
406   if test "x$CC" = "xicc"; then
407     SILC_ADD_CFLAGS(-restrict)
408     SILC_ADD_CFLAGS(-finline-functions)
409
410     # Don't define __GNUC__ except for system includes
411     SILC_ADD_CFLAGS(-gcc-sys)
412   fi
413 fi
414
415 if test x$want_cc_optimizations = xtrue; then
416   if test "$GCC"; then
417     # GCC specific options
418     if test "x$summary_debug" = "xyes"; then
419       SILC_ADD_CFLAGS(-O)
420     else
421       SILC_ADD_CFLAGS(-O2)
422     fi
423   else
424     # Other compilers
425     case "$target" in
426       alpha*-dec-osf*)
427         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
428         ;;
429       mips*-sgi-irix*)
430         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
431         ;;
432       *)
433         SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O))
434         ;;
435     esac
436   fi
437 fi
438
439
440 ##
441 ## Function and libary checking
442 ##
443
444
445 ##
446 ##  Enable/disable checking
447 ##
448
449 #ifdef SILC_DIST_INPLACE
450 #
451 # Profiling options (never delivered to distributions)
452 #
453 AC_MSG_CHECKING(whether to enable gprof)
454 AC_ARG_ENABLE(gprof,
455   [  --enable-gprof          enable gprof profiling],
456   [
457     case "${enableval}" in
458       yes)
459         AC_MSG_RESULT(yes)
460         SILC_ADD_CFLAGS(-pg)
461         LIBS="$LIBS -pg"
462         ;;
463       *)
464         AC_MSG_RESULT(no)
465         ;;
466     esac
467   ],
468   [
469     AC_MSG_RESULT(no)
470   ])
471
472 AC_MSG_CHECKING(whether to enable gcov)
473 AC_ARG_ENABLE(gcov,
474   [  --enable-gcov           enable gcov],
475   [
476     case "${enableval}" in
477       yes)
478         AC_MSG_RESULT(yes)
479         SILC_ADD_CFLAGS(-fprofile-arcs)
480         LIBS="$LIBS -lgcov"
481         ;;
482       *)
483         AC_MSG_RESULT(no)
484         ;;
485     esac
486   ],
487   [
488     AC_MSG_RESULT(no)
489   ])
490 #endif SILC_DIST_INPLACE
491
492 # Debug checking
493 AC_MSG_CHECKING(whether to enable debugging)
494 summary_debug="no"
495 AC_ARG_ENABLE(debug,
496   [  --enable-debug          enable debugging],
497   [
498     case "${enableval}" in
499       yes)
500         AC_MSG_RESULT(yes)
501         summary_debug="yes"
502         ;;
503       *)
504         AC_MSG_RESULT(no)
505         ;;
506     esac
507   ],
508   [
509     AC_MSG_RESULT(no)
510   ])
511
512 # Disable all assembler optimizations
513 AC_MSG_CHECKING(whether to enable assembler optimizations)
514 want_asm=true
515 AC_ARG_ENABLE(asm,
516   [  --disable-asm           do not use assembler optimizations],
517   [
518     AC_MSG_RESULT(no)
519     AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM])
520     want_asm=false
521   ],
522   [
523     AC_MSG_RESULT(yes)
524     want_asm=true
525   ])
526 AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse)
527
528
529 ##
530 ##  With/without checkings
531 ##
532
533 #ifndef SILC_DIST_TOOLKIT
534 # SILC Protocol Toolkit checking
535 AC_ARG_WITH(silc-includes,
536   [  --with-silc-includes=DIR SILC Toolkit includes [search in DIR]],
537   [ac_silc_includes="$withval"], [ac_silc_includes="no"])
538 AC_ARG_WITH(silc-libs,
539   [  --with-silc-libs=DIR     SILC Toolkit libraries [search in DIR]],
540   [ac_silc_libs="$withval"], [ac_silc_libs="no"])
541
542 if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then
543
544   # Manually provided libs
545   if test "$ac_silc_includes" != "no"; then
546     compile_libs=false
547     SILC_LIB_INCLUDES="-I$ac_silc_includes"
548     LIBSUBDIR=
549   fi
550   if test "$ac_silc_libs" != "no"; then
551     compile_libs=false
552     LIBSUBDIR=
553     LDFLAGS="-L$ac_silc_libs $LDFLAGS"
554   fi
555
556   # Check libs to link against
557   f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h`
558   if test -n "$f"; then
559     LIBS="$LIBS -lpthread"
560     check_threads=false
561     has_threads=true
562   fi
563   f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h`
564   if test -n "$f"; then
565     LIBS="$LIBS -ldl"
566   fi
567
568 else
569   # pkg-config check
570   PKG_CHECK_MODULES(SILC, [silc >= 1.2], compile_libs=false, compile_libs=true)
571 #ifdef SILC_DIST_CLIENTLIB
572   PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.2], compile_libs=false, compile_libs=true)
573 #endif SILC_DIST_CLIENTLIB
574 #ifdef SILC_DIST_SERVERLIB
575   PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true)
576 #endif SILC_DIST_SERVERLIB
577
578   if test x$compile_libs = xfalse; then
579     LIBSUBDIR=
580     LIBS="$SILC_LIBS $LIBS"
581     CFLAGS="$CFLAGS $SILC_CFLAGS"
582 #ifdef SILC_DIST_CLIENTLIB
583     LIBS="$SILCCLIENT_LIBS $LIBS"
584     CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS"
585 #endif SILC_DIST_CLIENTLIB
586 #ifdef SILC_DIST_SERVERLIB
587     LIBS="$LIBS $SILCSERVER_LIBS"
588     CFLAGS="$CFLAGS $SILCSERVER_CFLAGS"
589 #endif SILC_DIST_SERVERLIB
590   fi
591 fi
592 #endif SILC_DIST_TOOLKIT
593
594 if test x$compile_libs = xtrue; then
595 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silccore"
596 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcapputil"
597 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcske"
598 #ifdef SILC_DIST_SFTP
599 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcsftp"
600 #endif SILC_DIST_SFTP
601 #ifdef SILC_DIST_CLIENTLIB
602 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient"
603 #endif SILC_DIST_CLIENTLIB
604 #ifdef SILC_DIST_SERVERLIB
605 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcserver"
606 #endif SILC_DIST_SERVERLIB
607 #ifdef SILC_DIST_VCARD
608 SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcvcard"
609 #endif SILC_DIST_VCARD
610 fi
611
612 # SOCKS4 support checking
613 SAVE_LIBS="$LIBS"
614 SAVE_CFLAGS="$CFLAGS"
615 SAVE_LDFLAGS="$LDFLAGS"
616 AC_MSG_CHECKING(whether to support SOCKS4)
617 AC_ARG_WITH(socks4,
618   [[  --with-socks4[=DIR]     with SOCKS4 support [search in DIR/lib and DIR/include]]],
619   [
620     case "$withval" in
621       no)
622         AC_MSG_RESULT(no)
623         ;;
624       *)
625         AC_MSG_RESULT(yes)
626         socks=4
627
628         if test -d "$withval/include"; then
629           CFLAGS="$CFLAGS -I$withval/include"
630         fi
631         if test -d "$withval/lib"; then
632           LDFLAGS="$LDFLAGS -L$withval/lib"
633         fi
634
635         LIBS="-lsocks $LIBS"
636         ;;
637     esac
638
639     AC_TRY_LINK([],
640       [
641         Rconnect();
642       ], [],
643       [
644         AC_MSG_ERROR(Could not find SOCKS4 library.)
645         LIBS="$SAVE_LIBS"
646         CFLAGS="$SAVE_CFLAGS"
647         LDFLAGS="$SAVE_LDFLAGS"
648       ])
649   ],
650     AC_MSG_RESULT(no)
651   )
652
653 # SOCKS5 support checking
654 SAVE_LIBS="$LIBS"
655 SAVE_CFLAGS="$CFLAGS"
656 SAVE_LDFLAGS="$LDFLAGS"
657 AC_MSG_CHECKING(whether to support SOCKS5)
658 AC_ARG_WITH(socks5,
659   [[  --with-socks5[=DIR]     with SOCKS5 support [search in DIR/lib and DIR/include]]],
660   [
661     case "$withval" in
662       no)
663         AC_MSG_RESULT(no)
664         ;;
665       *)
666         AC_MSG_RESULT(yes)
667         socks=5
668
669         if test -d "$withval/include"; then
670           CFLAGS="$CFLAGS -I$withval/include"
671         fi
672         if test -d "$withval/lib"; then
673           LDFLAGS="$LDFLAGS -L$withval/lib"
674         fi
675
676         LIBS="-lsocks5 $LIBS"
677         ;;
678     esac
679
680     AC_TRY_LINK([],
681       [
682         SOCKSconnect();
683       ], [],
684       [
685         AC_MSG_ERROR(Could not find SOCKS5 library.)
686         LIBS="$SAVE_LIBS"
687         CFLAGS="$SAVE_CFLAGS"
688         LDFLAGS="$SAVE_LDFLAGS"
689       ])
690   ],
691     AC_MSG_RESULT(no)
692   )
693
694 if test "x$socks" = "x4"; then
695   AC_DEFINE([SOCKS], [], [Socks])
696   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
697 fi
698
699 if test "x$socks" = "x5"; then
700   AC_DEFINE([SOCKS], [], [Socks])
701   AC_DEFINE([SOCKS5], [], [Socks5])
702   AC_DEFINE([Rconnect], [SOCKSconnect], [Socks])
703   AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks])
704   AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks])
705   AC_DEFINE([Rbind], [SOCKSbind], [Socks])
706   AC_DEFINE([Raccept], [SOCKSaccept], [Socks])
707   AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
708   AC_DEFINE([Rselect], [SOCKSselect], [Socks])
709   AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks])
710   AC_DEFINE([Rsendto], [SOCKSsendto], [Socks])
711   AC_DEFINE([Rrecv], [SOCKSrecv], [Socks])
712   AC_DEFINE([Rsend], [SOCKSsend], [Socks])
713   AC_DEFINE([Rread], [SOCKSread], [Socks])
714   AC_DEFINE([Rwrite], [SOCKSwrite], [Socks])
715   AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks])
716   AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks])
717   AC_DEFINE([Rlisten], [SOCKSlisten], [Socks])
718   AC_DEFINE([Rclose], [SOCKSclose], [Socks])
719   AC_DEFINE([Rdup], [SOCKSdup], [Socks])
720   AC_DEFINE([Rdup2], [SOCKSdup2], [Socks])
721   AC_DEFINE([Rfclose], [SOCKSfclose], [Socks])
722   AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks])
723 fi
724
725
726 ##
727 ## Native WIN32 compilation under cygwin
728 ##
729 AC_MSG_CHECKING(whether to compile native WIN32 code)
730 AC_ARG_WITH(win32,
731   [  --with-win32            compile native WIN32 (MinGW) code (-mno-cygwin)],
732   [
733     AC_MSG_RESULT(yes)
734     AC_DEFINE([SILC_WIN32], [], [SILC_WIN32])
735     win32_support=true
736     CFLAGS="-mno-cygwin $CFLAGS"
737     LIBS="$LIBS -lwsock32"
738   ],
739   [
740     AC_MSG_RESULT(no)
741   ])
742 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
743
744
745 #ifdef SILC_DIST_SERVER
746 without_silcd=false
747 #endif SILC_DIST_SERVER
748 #ifdef SILC_DIST_CLIENT
749 AM_CONDITIONAL(with_irssi, true)
750 #endif SILC_DIST_CLIENT
751 #ifdef SILC_DIST_INPLACE
752 without_irssi=false
753 without_silcd=false
754 #endif SILC_DIST_INPLACE
755
756
757 ##
758 ## Include configure fragments
759 ##
760 AD_INCLUDE_CONFIGURE
761
762
763 ##
764 ## Outputs and substitutions
765 ##
766
767 AC_SUBST(LIBSUBDIR)
768 AC_SUBST(SILC_TOP_SRCDIR)
769 AC_SUBST(LDFLAGS)
770 AC_SUBST(LIBS)
771 AC_SUBST(SILC_LIB_INCLUDES)
772 AC_SUBST(__SILC_PACKAGE_VERSION)
773
774 AC_SUBST(ETCDIR)
775 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
776
777 #ifndef SILC_DIST_AUTODIST
778 ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR`
779 AC_SUBST(ETCDIR)
780 AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR])
781
782 DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR`
783 AC_SUBST(DOCDIR)
784 AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR])
785 #endif SILC_DIST_AUTODIST
786
787 # Native Symbian OS support (disabled by default)
788 AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue)
789
790 # Make enable-shared aware
791 AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes)
792
793 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
794 AC_SUBST(INCLUDE_DEFINES_INT)
795
796 DATE=`date`
797 AC_SUBST(DATE)
798
799
800 #
801 # Makefile outputs
802 #
803 AC_CONFIG_FILES(
804 Makefile
805 #ifdef SILC_DIST_DOC
806 doc/Makefile
807 #endif SILC_DIST_DOC
808 Makefile.defines
809 Makefile.defines_int
810 includes/Makefile
811 includes/silcversion.h
812 includes/silc.h
813 #ifdef SILC_DIST_APPS
814 apps/Makefile
815 #endif SILC_DIST_APPS
816 )
817
818 #ifdef SILC_DIST_TOOLKIT
819 AC_CONFIG_FILES(
820 win32/Makefile
821 win32/libsilc/Makefile
822 win32/libsilcclient/Makefile
823 tutorial/Makefile
824 tutorial/Makefile.defines
825 tutorial/Makefile.defines_int
826 )
827 #endif SILC_DIST_TOOLKIT
828
829 if test x$compile_libs = xtrue; then
830
831 AC_CONFIG_FILES(
832 lib/Makefile
833 lib/silccore/Makefile
834 lib/silcske/Makefile
835 lib/silcapputil/Makefile
836 #ifdef SILC_DIST_SFTP
837 lib/silcsftp/Makefile
838 lib/silcsftp/tests/Makefile
839 #endif SILC_DIST_SFTP
840 )
841
842 #ifdef SILC_DIST_TOOLKIT
843 AC_CONFIG_FILES(
844 lib/silc.pc
845 lib/silcclient.pc
846 lib/silcserver.pc
847 )
848 #endif SILC_DIST_TOOLKIT
849
850 #ifdef SILC_DIST_CLIENTLIB
851 AC_CONFIG_FILES(
852 lib/silcclient/Makefile
853 lib/silcclient/tests/Makefile
854 )
855 #endif SILC_DIST_CLIENTLIB
856
857 #ifdef SILC_DIST_SERVERLIB
858 AC_CONFIG_FILES(
859 lib/silcserver/Makefile
860 lib/silcserver/tests/Makefile
861 )
862 #endif SILC_DIST_SERVERLIB
863
864 #ifdef SILC_DIST_VCARD
865 AC_CONFIG_FILES(
866 lib/silcvcard/Makefile
867 )
868 #endif SILC_DIST_VCARD
869
870 fi      # compile_libs
871
872 AC_OUTPUT
873
874 s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir`
875 s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir`
876 s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir`
877 s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir`
878
879 echo ""
880 echo "$PACKAGE Configuration Summary:"
881 echo "---------------------------"
882 echo " Target host ...................: $target"
883 echo " Compiler ......................: $CC"
884 echo " CFLAGS ........................: $CFLAGS"
885 echo " LDFLAGS .......................: $LDFLAGS"
886 echo " LIBS ..........................: $LIBS"
887 echo ""
888 echo " Installation prefix ...........: $prefix"
889 echo " bin directory .................: $s_bindir"
890 echo " sbin directory ................: $s_sbindir"
891 echo " etc directory .................: $ETCDIR"
892 echo " man directory .................: $s_mandir"
893 echo " doc directory .................: $DOCDIR"
894 #ifdef SILC_DIST_INCLUDES
895 echo " include directory .............: $s_includedir"
896 #endif SILC_DIST_INCLUDES
897 echo ""
898
899 #ifdef SILC_DIST_CLIENT
900 if test x$without_irssi = xtrue; then
901   irssi="no"
902 fi
903 echo " Compile SILC Client ...........: $irssi"
904 #endif SILC_DIST_CLIENT
905
906 #ifdef SILC_DIST_SERVER
907 if test x$without_silcd = xtrue; then
908   silcd="no"
909 fi
910 echo " Compile SILC Server ...........: $silcd"
911 #endif SILC_DIST_SERVER
912
913 echo " Debugging enabled .............: $summary_debug"
914 echo ""
915 echo "Compile the sources with 'make' or 'gmake' command."