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)
21 # Put here any platform specific stuff
36 # ./prepare script will automatically put the correct version. Do not edit!
38 AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
40 AC_CONFIG_HEADERS(includes/silcdefs.h)
49 # Distribution definition. ./prepare will automatically add here a correct
52 silc_dist=SILC_PACKAGE
53 SILC_DIST_SUBDIRS="SILC_DISTRIBUTION_SUBDIRS"
54 AC_DEFINE(SILC_DIST_DEFINE)
60 CFLAGS="-Wall -finline-functions $CFLAGS"
69 AC_PATH_PROG(sedpath, sed)
77 # More header checking
79 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
80 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
81 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
82 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
83 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
84 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
94 AC_CHECK_SIZEOF(long long, 0)
95 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
96 AC_CHECK_SIZEOF(long, 0)
97 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
98 AC_CHECK_SIZEOF(int, 0)
99 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
100 AC_CHECK_SIZEOF(short, 0)
101 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
102 AC_CHECK_SIZEOF(char, 0)
103 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
104 AC_CHECK_SIZEOF(void *, 0)
105 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
107 # Function and library checking
109 AC_CHECK_FUNC(gethostbyname, [],
111 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
112 AC_CHECK_FUNC(res_gethostbyname, [],
113 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
116 AC_CHECK_FUNC(socket, [],
117 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
119 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
120 AC_CHECK_FUNCS(select listen bind shutdown close connect setsockopt)
121 AC_CHECK_FUNCS(time ctime utime gettimeofday)
122 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
123 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
124 AC_CHECK_FUNCS(setgroups initgroups nl_langinfo)
125 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
127 # SIM support checking
128 # XXX These needs to be changed as more supported platforms appear.
129 # XXX This probably needs to be made platform dependant check.
132 AC_MSG_CHECKING(for SIM support)
134 AC_CHECK_HEADERS(dlfcn.h,
135 AC_CHECK_LIB(dl, dlopen,
142 AC_CHECK_LIB(c, dlopen,
150 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
151 if test x$sim_support = xtrue; then
152 AC_MSG_RESULT(Enabled SIM support.)
154 AC_MSG_RESULT(No SIM support found.)
157 # lib/contrib conditionals
159 AC_CHECK_HEADER(regex.h, have_regex=1, have_regex=0)
160 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
161 AC_CHECK_FUNC(getopt_long, have_getopt_long=1, have_getopt_long=0)
162 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x$have_getopt_long = x1)
166 ## Enable/disable checking
171 AC_MSG_CHECKING(whether to enable IPv6 support)
173 [ --enable-ipv6 enable IPv6 support],
175 case "${enableval}" in
192 if test x$check_ipv6 = xtrue; then
195 #ifdef HAVE_NETINET_TCP_H
196 #include <netinet/tcp.h>
201 #include <sys/socket.h>
202 #ifdef HAVE_NETDB_IN_H
203 #include <netinet/in.h>
207 struct sockaddr_in6 sin6;
208 int family = AF_INET6;
220 AC_MSG_CHECKING(whether to enable debugging)
222 [ --enable-debug enable debugging],
224 case "${enableval}" in
227 AC_DEFINE(SILC_DEBUG)
228 CFLAGS="-O -g $CFLAGS"
232 CFLAGS="-O2 -g $CFLAGS"
237 CFLAGS="-O2 -g $CFLAGS"
241 # Stack trace checking
243 AC_MSG_CHECKING(whether to enable stack tracing)
244 AC_ARG_ENABLE(stack-trace,
245 [ --enable-stack-trace enable memory stack trace],
247 case "${enableval}" in
250 AC_DEFINE(SILC_STACKTRACE)
260 # Disable all assembler optimizations
262 AC_MSG_CHECKING(whether to enable assembler optimizations)
264 [ --disable-asm do not use assembler optimizations],
277 # Default installation destination
279 AC_PREFIX_DEFAULT(/usr/local/silc)
280 if test "x$prefix" != xNONE; then
281 silc_prefix="$prefix"
283 silc_prefix="$ac_default_prefix"
288 if test "x$sysconfdir" != 'x${prefix}/etc'; then
291 ETCDIR="$silc_prefix/etc"
295 [[ --with-etcdir=DIR directory for system files [/etc/silc]]],
306 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
310 HELPDIR="$silc_prefix/help"
312 [[ --with-helpdir=DIR directory for SILC help files [PREFIX/help]]],
323 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
327 DOCDIR="$silc_prefix/doc"
329 [[ --with-docdir=DIR directory for SILC documentation [PREFIX/doc]]],
340 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
342 # SIM modules directory
344 MODULESDIR="$silc_prefix/modules"
346 [[ --with-simdir=DIR directory for SIM modules [PREFIX/modules]]],
352 MODULESDIR="$withval"
357 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
361 LOGSDIR="$silc_prefix/logs"
363 [[ --with-logsdir=DIR directory for SILC Server logs [PREFIX/logs]]],
374 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
376 # silcd config file checking
378 AC_ARG_WITH(silcd-config-file,
379 [[ --with-silcd-config-file=FILE use FILE as default configuration file
380 for SILC Server [/etc/silc/silcd.conf]]],
381 AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
384 # silcd pid file checking
386 if test "x$localstatedir" != 'x${prefix}/var'; then
387 PIDFILE="$localstatedir/silcd.pid"
389 PIDFILE="$silc_prefix/var/silcd.pid"
392 AC_ARG_WITH(silcd-pid-file,
393 [[ --with-silcd-pid-file=FILE use FILE as default pid file for SILC
394 Server [/var/run/silcd.pid]]],
408 ## With/without checkings
411 # SOCKS4 support checking
413 AC_MSG_CHECKING(whether to support SOCKS4)
415 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
425 if test -d "$withval/include"; then
426 CFLAGS="$CFLAGS -I$withval/include"
428 CFLAGS="$CFLAGS -I$withval"
430 if test -d "$withval/lib"; then
431 withval="-L$withval/lib -lsocks"
433 withval="-L$withval -lsocks"
436 LIBS="$withval $LIBS"
442 AC_MSG_ERROR(Could not find SOCKS4 library.)
450 # SOCKS5 support checking
452 AC_MSG_CHECKING(whether to support SOCKS5)
454 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
464 if test -d "$withval/include"; then
465 CFLAGS="$CFLAGS -I$withval/include"
467 CFLAGS="$CFLAGS -I$withval"
469 if test -d "$withval/lib"; then
470 withval="-L$withval/lib -lsocks5"
472 withval="-L$withval -lsocks5"
475 LIBS="$withval $LIBS"
481 AC_MSG_ERROR(Could not find SOCKS5 library.)
489 if test "x$socks" = "x4"; then
491 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
494 if test "x$socks" = "x5"; then
497 AC_DEFINE(Rconnect, SOCKSconnect)
498 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
499 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
500 AC_DEFINE(Rbind, SOCKSbind)
501 AC_DEFINE(Raccept, SOCKSaccept)
502 AC_DEFINE(Rlisten, SOCKSlisten)
503 AC_DEFINE(Rselect, SOCKSselect)
504 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
505 AC_DEFINE(Rsendto, SOCKSsendto)
506 AC_DEFINE(Rrecv, SOCKSrecv)
507 AC_DEFINE(Rsend, SOCKSsend)
508 AC_DEFINE(Rread, SOCKSread)
509 AC_DEFINE(Rwrite, SOCKSwrite)
510 AC_DEFINE(Rrresvport, SOCKSrresvport)
511 AC_DEFINE(Rshutdown, SOCKSshutdown)
512 AC_DEFINE(Rlisten, SOCKSlisten)
513 AC_DEFINE(Rclose, SOCKSclose)
514 AC_DEFINE(Rdup, SOCKSdup)
515 AC_DEFINE(Rdup2, SOCKSdup2)
516 AC_DEFINE(Rfclose, SOCKSfclose)
517 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
520 # MP library checking. First check whether user wants to use GMP and use
521 # it if found. If not or not defined then compile the MPI library in the
525 AC_MSG_CHECKING(whether to search for GMP)
527 [[ --with-gmp[=DIR] use GMP instead of MPI [search in DIR/lib and DIR/include]]],
536 if test -d "$withval/include"; then
537 CFLAGS="$CFLAGS -I$withval/include"
539 CFLAGS="$CFLAGS -I$withval"
541 if test -d "$withval/lib"; then
542 withval="-L$withval/lib -lgmp"
544 withval="-L$withval -lgmp"
547 LIBS="$withval $LIBS"
548 AC_CHECK_LIB(gmp, __gmpz_init,
551 AC_DEFINE(SILC_MP_GMP)
552 AC_MSG_RESULT(Using GMP as a MP library.)
560 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
561 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
562 if test x$mp_gmp = xfalse; then
563 AC_DEFINE(SILC_MP_NSS_MPI)
564 AC_MSG_RESULT(Using NSS MPI as a MP library.)
571 AC_MSG_CHECKING(whether to implicit search for libiconv)
573 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
579 AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNC(iconv, has_iconv=true))
585 if test -d $withval/include; then
586 CPPFLAGS="$CPPFLAGS -I$withval/include"
587 CFLAGS="$CFLAGS -I$withval/include"
589 if test -d $withval/lib; then
590 LDFLAGS="$LDFLAGS -L$withval/lib"
597 AC_CHECK_HEADERS(iconv.h, AC_CHECK_FUNCS(iconv,
604 if test x$check_iconv = xtrue; then
605 AC_MSG_RESULT(starting search...)
608 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
610 AC_CHECK_HEADERS(iconv.h,
613 AC_MSG_CHECKING(for iconv in -liconv)
620 iconv_t cd = iconv_open("", "");
621 iconv(cd, NULL, NULL, NULL, NULL);
626 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
633 if test x$check_iconv = xtrue; then
634 # search for iconv library..
635 SAVE_CPPFLAGS="$CPPFLAGS"
636 SAVE_CFLAGS="$CFLAGS"
637 SAVE_LDFLAGS="$LDFLAGS"
639 for dir in `echo "/usr/local /usr/pkg /usr/contrib"`; do
640 if test x$has_iconv = xfalse; then
641 AC_MSG_RESULT(searching in $dir...)
643 CPPFLAGS="$SAVE_CPPFLAGS"
644 CFLAGS="$SAVE_CFLAGS"
645 LDFLAGS="$SAVE_LDFLAGS"
647 if test -d $dir/include; then
648 CPPFLAGS="$CPPFLAGS -I$dir/include"
649 CFLAGS="$CFLAGS -I$dir/include"
651 if test -d $dir/lib; then
652 LDFLAGS="$LDFLAGS -L$dir/lib"
656 unset ac_cv_header__iconv_h_ ac_cv_header_iconv_h || true
658 AC_CHECK_HEADERS(iconv.h,
661 AC_MSG_CHECKING(for iconv in -liconv)
668 iconv_t cd = iconv_open("", "");
669 iconv(cd, NULL, NULL, NULL, NULL);
675 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
685 if test x$has_iconv = xtrue; then
686 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
687 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
688 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
690 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
701 ob = buf, obl = sizeof(buf);
702 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
703 (iconv(cd, 0, 0, &ob, &obl) ||
704 !(ob == buf && obl == sizeof(buf)) ||
719 if test x$ac_iconv_good = xno; then
720 AC_MSG_ERROR(Try using libiconv instead.)
724 # POSIX threads support
727 AC_MSG_CHECKING(whether to search for POSIX threads)
728 AC_ARG_WITH(pthreads,
729 [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]],
736 if test -d $withval/include; then
737 CPPFLAGS="$CPPFLAGS -I$withval/include"
738 CFLAGS="$CFLAGS -I$withval/include"
740 if test -d $withval/lib; then
741 LDFLAGS="$LDFLAGS -L$withval/lib"
749 if test x$check_threads = xtrue; then
751 AC_CHECK_HEADERS(pthread.h,
754 LIBS="$LIBS -lpthread"
755 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
760 LIBS="$SAVE_LIBS -pthread"
761 AC_CHECK_LIB(c_r, pthread_attr_init, has_threads=true)
767 # search for pthread library..
768 SAVE_CPPFLAGS="$CPPFLAGS"
769 SAVE_CFLAGS="$CFLAGS"
770 SAVE_LDFLAGS="$LDFLAGS"
772 for dir in `echo "/usr/local /usr/pkg /usr/contrib /usr/pkg/pthreads /usr/local/pthreads"`; do
773 if test x$has_threads = xfalse; then
774 AC_MSG_RESULT(searching in $dir...)
776 CPPFLAGS="$SAVE_CPPFLAGS"
777 CFLAGS="$SAVE_CFLAGS"
778 LDFLAGS="$SAVE_LDFLAGS"
780 if test -d $dir/include; then
781 CPPFLAGS="$CPPFLAGS -I$dir/include"
782 CFLAGS="$CFLAGS -I$dir/include"
784 if test -d $dir/lib; then
785 LDFLAGS="$LDFLAGS -L$dir/lib"
789 unset ac_cv_header__pthread_h_ ac_cv_header_pthread_h || true
791 AC_CHECK_HEADERS(pthread.h,
793 LIBS="$LIBS -lpthread"
794 AC_CHECK_LIB(pthread, pthread_attr_init, has_threads=true,
805 AM_CONDITIONAL(SILC_THREADS, test x$has_threads = xtrue)
806 if test x$has_threads = xtrue; then
807 CFLAGS="$CFLAGS -D_REENTRANT"
809 # XXX possibly incomplete
812 CFLAGS="$CFLAGS -D_THREAD_SAFE"
813 if test x"$GCC" = xyes; then
814 CFLAGS="$CFLAGS -mthreads"
818 CFLAGS="$CFLAGS -D_THREAD_SAFE"
820 *-*-sysv5uw7*) # UnixWare 7
821 if test "$GCC" != "yes"; then
822 CFLAGS="$CFLAGS -Kthread"
824 CFLAGS="$CFLAGS -pthread"
828 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
832 AC_CHECK_FUNC(pthread_create)
833 AC_DEFINE(SILC_HAVE_PTHREAD)
834 AC_DEFINE(SILC_THREADS)
837 # Native WIN32 compilation under cygwin
839 AC_MSG_CHECKING(whether to compile native WIN32 code)
841 [ --with-win32 compile native WIN32 code (-mno-cygwin)],
844 AC_DEFINE(SILC_WIN32)
846 CFLAGS="-mno-cygwin $CFLAGS"
847 LIBS="$LIBS -lwsock32"
852 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
854 # Native EPOC support (disabled by default)
856 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
858 # Native BeOS support (disabled by default)
860 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
862 # Native OS2 support (disabled by default)
864 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
869 AC_MSG_CHECKING(whether to compile Irssi SILC Client)
871 [ --without-irssi compile without Irssi SILC Client],
875 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
884 AC_MSG_CHECKING(whether to compile SILC Server)
886 [ --without-silcd compile without SILC Server],
890 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
901 # Other configure scripts
903 if test x$without_irssi = xfalse; then
904 if test "x$silc_dist" = "xsilc-client" ||
905 test "x$silc_dist" = "xsilc-toolkit"; then
906 AC_CONFIG_SUBDIRS(irssi)
910 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
911 #AC_CONFIG_SUBDIRS(lib/zlib)
913 SILC_TOP_SRCDIR=`pwd`
914 AC_SUBST(SILC_TOP_SRCDIR)
915 #SILC_INSTALL_PREFIX=$ac_default_prefix
916 #AC_SUBST(SILC_INSTALL_PREFIX)
918 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
919 AC_SUBST(INCLUDE_DEFINES_INT)
920 AC_SUBST(SILC_DIST_SUBDIRS)
932 lib/silccore/Makefile
933 lib/silccrypt/Makefile
934 lib/silcmath/Makefile
935 lib/silcmath/mpi/Makefile.defines
936 lib/silcmath/mpi/Makefile.defines_int
939 lib/silcutil/Makefile
940 lib/silcutil/unix/Makefile
941 lib/silcutil/win32/Makefile
942 lib/silcutil/beos/Makefile
943 lib/silcutil/os2/Makefile
944 lib/silcutil/epoc/Makefile
945 lib/silcsftp/Makefile
946 lib/silcsftp/tests/Makefile
947 doc/example_silcd.conf
950 if test "x$silc_dist" = "xsilc-client" ||
951 test "x$silc_dist" = "xsilc-toolkit"; then
952 AC_CONFIG_FILES(lib/silcclient/Makefile)
955 if test x$without_irssi = xfalse ; then
956 if test "x$silc_dist" = "xsilc-client" ||
957 test "x$silc_dist" = "xsilc-toolkit"; then
959 irssi/Makefile.defines
960 irssi/Makefile.defines_int
965 if test x$without_silcd = xfalse ; then
966 if test "x$silc_dist" = "xsilc-server" ||
967 test "x$silc_dist" = "xsilc-toolkit"; then
974 if test "x$silc_dist" = "xsilc-toolkit"; then
978 win32/libsilc/Makefile
979 win32/libsilcclient/Makefile