4 # Author: Pekka Riikonen <priikone@silcnet.org>
6 # Copyright (C) 2000 - 2002 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; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
19 AC_INIT(includes/silcversion.h)
22 # Put here any platform specific stuff
34 # ./prepare script will automatically put the correct version. Do not edit!
35 AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
37 AM_CONFIG_HEADER(includes/silcdefs.h)
46 # Distribution definition. ./prepare will automatically add here a correct
48 silc_dist=SILC_PACKAGE
49 SILC_DIST_SUBDIRS="SILC_DISTRIBUTION_SUBDIRS"
50 AC_DEFINE(SILC_DIST_DEFINE)
55 CFLAGS="-Wall -finline-functions $CFLAGS"
63 AC_PATH_PROG(sedpath, sed)
70 # More header checking
71 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
72 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
73 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
74 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
75 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
76 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
85 AC_CHECK_SIZEOF(long long, 0)
86 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
87 AC_CHECK_SIZEOF(long, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
89 AC_CHECK_SIZEOF(int, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
91 AC_CHECK_SIZEOF(short, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
93 AC_CHECK_SIZEOF(char, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
95 AC_CHECK_SIZEOF(void *, 0)
96 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
98 # Function and library checking
99 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,ac_gethostbyname_found=0)
100 if test x$ac_gethostbyname_found = x0; then
101 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
102 AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
103 if test x$ac_res_ghbn_found = x0; then
104 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
107 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
108 if test x$ac_socket_found = x0; then
109 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
111 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
112 AC_CHECK_FUNCS(select listen bind shutdown close connect)
113 AC_CHECK_FUNCS(fcntl setsockopt time)
114 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
115 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
116 AC_CHECK_FUNCS(setgroups initgroups)
117 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove utime)
118 AC_CHECK_FUNCS(pthread_create nl_langinfo)
120 # SIM support checking
121 # XXX These needs to be changed as more supported platforms appear.
122 # XXX This probably needs to be made platform dependant check.
124 AC_CHECKING(for SIM support)
125 AC_CHECK_HEADERS(dlfcn.h,
126 AC_CHECK_LIB(dl, dlopen,
130 [AC_CHECK_LIB(c, dlopen,
136 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
137 if test x$sim_support = xtrue; then
138 AC_MSG_RESULT(enabled SIM support)
140 AC_MSG_RESULT(no SIM support found)
145 # lib/contrib conditionals
147 AC_CHECK_HEADER(regex.h, have_regex=1, have_regex=0)
148 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
149 AC_CHECK_FUNC(getopt_long, have_getopt_long=1, have_getopt_long=0)
150 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x$have_getopt_long = x1)
156 # Default installation destination
157 AC_PREFIX_DEFAULT(/usr/local/silc)
159 if test "x$prefix" != xNONE; then
160 silc_prefix="$prefix"
162 silc_prefix="$ac_default_prefix"
166 if test "x$sysconfdir" != 'x${prefix}/etc'; then
169 ETCDIR="$silc_prefix/etc"
172 [ --with-etcdir[=PATH] Directory for system files [/etc/silc]],
185 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
188 HELPDIR="$silc_prefix/help"
190 [ --with-helpdir[=PATH] Directory for SILC help files [PREFIX/help]],
203 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
206 DOCDIR="$silc_prefix/doc"
208 [ --with-docdir[=PATH] Directory for SILC documentation [PREFIX/doc]],
221 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
223 # SIM modules directory
224 MODULESDIR="$silc_prefix/modules"
226 [ --with-simdir[=PATH] Directory for SIM modules [PREFIX/modules]],
231 MODULESDIR="$withval"
234 MODULESDIR="$withval"
239 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
242 LOGSDIR="$silc_prefix/logs"
244 [ --with-logsdir[=PATH] Directory for Server logs [PREFIX/logs]],
257 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
259 # SOCKS4 support checking
260 AC_MSG_CHECKING(whether to support SOCKS4)
262 [ --with-socks4[=PATH] Compile with SOCKS4 support],
271 if test -d "$withval/include"; then
272 CFLAGS="$CFLAGS -I$withval/include"
274 CFLAGS="$CFLAGS -I$withval"
276 if test -d "$withval/lib"; then
277 withval="-L$withval/lib -lsocks"
279 withval="-L$withval -lsocks"
282 LIBS="$withval $LIBS"
287 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
293 # SOCKS5 support checking
294 AC_MSG_CHECKING(whether to support SOCKS5)
296 [ --with-socks5[=PATH] Compile with SOCKS5 support],
305 if test -d "$withval/include"; then
306 CFLAGS="$CFLAGS -I$withval/include"
308 CFLAGS="$CFLAGS -I$withval"
310 if test -d "$withval/lib"; then
311 withval="-L$withval/lib -lsocks5"
313 withval="-L$withval -lsocks5"
316 LIBS="$withval $LIBS"
321 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
327 if test "x$socks" = "x4"; then
329 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
332 if test "x$socks" = "x5"; then
335 AC_DEFINE(Rconnect, SOCKSconnect)
336 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
337 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
338 AC_DEFINE(Rbind, SOCKSbind)
339 AC_DEFINE(Raccept, SOCKSaccept)
340 AC_DEFINE(Rlisten, SOCKSlisten)
341 AC_DEFINE(Rselect, SOCKSselect)
342 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
343 AC_DEFINE(Rsendto, SOCKSsendto)
344 AC_DEFINE(Rrecv, SOCKSrecv)
345 AC_DEFINE(Rsend, SOCKSsend)
346 AC_DEFINE(Rread, SOCKSread)
347 AC_DEFINE(Rwrite, SOCKSwrite)
348 AC_DEFINE(Rrresvport, SOCKSrresvport)
349 AC_DEFINE(Rshutdown, SOCKSshutdown)
350 AC_DEFINE(Rlisten, SOCKSlisten)
351 AC_DEFINE(Rclose, SOCKSclose)
352 AC_DEFINE(Rdup, SOCKSdup)
353 AC_DEFINE(Rdup2, SOCKSdup2)
354 AC_DEFINE(Rfclose, SOCKSfclose)
355 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
359 # MP library checking. First check whether user wants to use GMP and use
360 # it if found. If not or not defined then compile the MPI library in the
363 AC_MSG_CHECKING(whether to support GMP)
365 [ --with-gmp[=PATH] Compile with GMP support instead of MPI],
374 if test -d "$withval/include"; then
375 CFLAGS="$CFLAGS -I$withval/include"
377 CFLAGS="$CFLAGS -I$withval"
379 if test -d "$withval/lib"; then
380 withval="-L$withval/lib -lgmp"
382 withval="-L$withval -lgmp"
385 LIBS="$withval $LIBS"
387 AC_CHECK_LIB(gmp, __gmpz_init,
389 AC_DEFINE(SILC_MP_GMP)
390 AC_MSG_RESULT(Using GMP as MP library)
398 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
399 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
400 if test x$mp_gmp = xfalse; then
401 AC_DEFINE(SILC_MP_NSS_MPI)
402 AC_MSG_RESULT(Using NSS MPI as MP library)
405 AC_ARG_WITH(silcd-config-file,
406 [ --with-silcd-config-file[=PATH]
407 Use PATH as default configuration file in SILC
408 server [/etc/silc/silcd.conf]],
409 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
411 if test "x$localstatedir" != 'x${prefix}/var'; then
412 PIDFILE="$localstatedir/silcd.pid"
414 PIDFILE="$silc_prefix/var/silcd.pid"
416 AC_ARG_WITH(silcd-pid-file,
417 [ --with-silcd-pid-file[=PATH]
418 Use PATH as default pid file in SILC
419 server [/var/run/silcd.pid]],
434 # Native WIN32 compilation under cygwin
437 [ --with-win32 Compile native WIN32 code (-mno-cygwin)],
438 [ AC_DEFINE(SILC_WIN32)
440 CFLAGS="-mno-cygwin $CFLAGS"
441 LIBS="$LIBS -lwsock32" ])
443 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
446 # Native EPOC support (disabled by default)
448 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
451 # Native BeOS support (disabled by default)
453 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
456 # Native OS2 support (disabled by default)
458 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
465 [ --without-irssi Compile without Irssi SILC Client],
467 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
475 [ --without-silcd Compile without SILC Server],
477 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
483 AC_MSG_CHECKING(for IPv6 support)
485 [ --enable-ipv6 Enable IPv6 support],
486 [ case "${enableval}" in
498 esac ], check_ipv6=true)
500 if test x$check_ipv6 = xtrue; then
501 AC_TRY_COMPILE([#ifdef HAVE_NETINET_TCP_H
502 #include <netinet/tcp.h>
507 #include <sys/socket.h>
508 #ifdef HAVE_NETDB_IN_H
509 #include <netinet/in.h>
511 [struct sockaddr_in6 sin6;
512 int family = AF_INET6;
513 ], [AC_DEFINE(HAVE_IPV6)
514 AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
520 AC_MSG_CHECKING(for enabled debugging)
522 [ --enable-debug Enable debugging],
523 [ case "${enableval}" in
526 AC_DEFINE(SILC_DEBUG)
527 CFLAGS="-O -g $CFLAGS"
531 CFLAGS="-O2 -g $CFLAGS"
533 esac ], CFLAGS="-O2 -g $CFLAGS"
536 AC_MSG_CHECKING(for enabled stack tracing)
537 AC_ARG_ENABLE(stack-trace,
538 [ --enable-stack-trace Enable memory stack trace],
539 [ case "${enableval}" in
542 AC_DEFINE(SILC_STACKTRACE)
547 esac ], AC_MSG_RESULT(no))
550 # Disable all assembler optimizations
553 [ --disable-asm Do not use assembler optimizations ],
559 AC_ARG_ENABLE(threads,
560 [ --disable-threads Do not compile with multi-thread support],
561 [ case "${enableval}" in
572 if test x$check_threads = xtrue; then
574 AC_CHECK_HEADERS(pthread.h,
575 [ AC_DEFINE(SILC_HAVE_PTHREAD)
577 [ if test -f /usr/pkg/include/pthread.h ; then
578 AC_DEFINE(SILC_HAVE_PTHREAD)
579 AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
580 CFLAGS="$CFLAGS -I/usr/pkg/include"
582 elif test -f /usr/contrib/include/pthread.h ; then
583 AC_DEFINE(SILC_HAVE_PTHREAD)
584 AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
585 CFLAGS="$CFLAGS -I/usr/contrib/include"
591 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
592 if test x$want_threads = xtrue; then
595 AC_TRY_LINK([#include <pthread.h>],
596 [pthread_attr_t attr; pthread_attr_init(&attr);],
597 AC_DEFINE(SILC_THREADS),
598 LIBS="-L/usr/pkg/lib -lpthread"
599 AC_TRY_LINK([#include <pthread.h>],
600 [pthread_attr_t attr; pthread_attr_init(&attr);],
601 AC_DEFINE(SILC_THREADS),
602 LIBS="-L/usr/contrib/lib -lpthread"
603 AC_TRY_LINK([#include <pthread.h>],
604 [pthread_attr_t attr; pthread_attr_init(&attr);],
605 AC_DEFINE(SILC_THREADS),
609 CFLAGS="$CFLAGS -D_REENTRANT"
612 CFLAGS="$CFLAGS -D_THREAD_SAFE"
613 if test x"$GCC" = xyes; then
614 CFLAGS="$CFLAGS -mthreads"
618 CFLAGS="$CFLAGS -D_THREAD_SAFE"
620 *-sysv5uw7*) # UnixWare 7
621 if test "$GCC" != "yes"; then
622 CFLAGS="$CFLAGS -Kthread"
624 CFLAGS="$CFLAGS -pthread"
628 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
632 LIBS="$TMP_LIBS $LIBS"
640 [ --with-iconv[=PATH] Search for libiconv in DIR/include and DIR/lib],
641 [ for dir in `echo "$withval" | tr : ' '`; do
642 if test -d $dir/include; then
643 CPPFLAGS="$CPPFLAGS -I$dir/include"
644 CFLAGS="$CFLAGS -I$dir/include"
646 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
650 AC_CHECK_HEADER(iconv.h,
651 AC_DEFINE(HAVE_ICONV_H, 1, [Define if you have the iconv.h header.])
652 [AC_CHECK_FUNC(iconv, ac_iconv_found=1,
653 [ LIBS="$LIBS -liconv"
654 AC_MSG_CHECKING(for iconv in -liconv)
655 AC_TRY_LINK([#include <stdlib.h>
657 [iconv_t cd = iconv_open("","");
658 iconv(cd,NULL,NULL,NULL,NULL);
661 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]),
663 )], [ac_iconv_h_found=0]
666 #if test x$ac_iconv_found = x0 -o x$ac_iconv_h_found = x0; then
667 # AC_MSG_ERROR([Unable to find an iconv support. See INSTALL for help.])
670 if test x$ac_iconv_found = x1; then
672 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
673 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
674 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
675 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
686 ob = buf, obl = sizeof(buf);
687 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
688 (iconv(cd, 0, 0, &ob, &obl) ||
689 !(ob == buf && obl == sizeof(buf)) ||
697 if test x$ac_iconv_good = xno; then
698 AC_MSG_ERROR(Try using libiconv instead.)
705 # Other configure scripts
707 if test x$without_irssi = xfalse; then
708 if test "x$silc_dist" = "xsilc-client" ||
709 test "x$silc_dist" = "xsilc-toolkit"; then
710 AC_CONFIG_SUBDIRS(irssi)
714 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
715 #AC_CONFIG_SUBDIRS(lib/zlib)
717 SILC_TOP_SRCDIR=`pwd`
718 AC_SUBST(SILC_TOP_SRCDIR)
719 #SILC_INSTALL_PREFIX=$ac_default_prefix
720 #AC_SUBST(SILC_INSTALL_PREFIX)
722 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
723 AC_SUBST(INCLUDE_DEFINES_INT)
724 AC_SUBST(SILC_DIST_SUBDIRS)
737 lib/silccore/Makefile
738 lib/silccrypt/Makefile
739 lib/silcmath/Makefile
740 lib/silcmath/mpi/Makefile.defines
741 lib/silcmath/mpi/Makefile.defines_int
744 lib/silcutil/Makefile
745 lib/silcutil/unix/Makefile
746 lib/silcutil/win32/Makefile
747 lib/silcutil/beos/Makefile
748 lib/silcutil/os2/Makefile
749 lib/silcutil/epoc/Makefile
750 lib/silcsftp/Makefile
751 lib/silcsftp/tests/Makefile
752 doc/example_silcd.conf
755 if test "x$silc_dist" = "xsilc-client" ||
756 test "x$silc_dist" = "xsilc-toolkit"; then
757 AC_CONFIG_FILES(lib/silcclient/Makefile)
760 if test x$without_irssi = xfalse ; then
761 if test "x$silc_dist" = "xsilc-client" ||
762 test "x$silc_dist" = "xsilc-toolkit"; then
764 irssi/Makefile.defines
765 irssi/Makefile.defines_int
770 if test x$without_silcd = xfalse ; then
771 if test "x$silc_dist" = "xsilc-server" ||
772 test "x$silc_dist" = "xsilc-toolkit"; then
779 if test "x$silc_dist" = "xsilc-toolkit"; then
783 win32/libsilc/Makefile
784 win32/libsilcclient/Makefile