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
33 # ./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
49 silc_dist=SILC_PACKAGE
50 SILC_DIST_SUBDIRS="SILC_DISTRIBUTION_SUBDIRS"
51 AC_DEFINE(SILC_DIST_DEFINE)
57 CFLAGS="-Wall -finline-functions $CFLAGS"
66 AC_PATH_PROG(sedpath, sed)
74 # More header checking
76 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
77 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
78 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
79 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
80 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h)
81 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h)
91 AC_CHECK_SIZEOF(long long, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
93 AC_CHECK_SIZEOF(long, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
95 AC_CHECK_SIZEOF(int, 0)
96 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
97 AC_CHECK_SIZEOF(short, 0)
98 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
99 AC_CHECK_SIZEOF(char, 0)
100 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
101 AC_CHECK_SIZEOF(void *, 0)
102 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
104 # Function and library checking
106 AC_CHECK_FUNC(gethostbyname, [],
108 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
109 AC_CHECK_FUNC(res_gethostbyname, [],
110 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
113 AC_CHECK_FUNC(socket, [],
114 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
116 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
117 AC_CHECK_FUNCS(select listen bind shutdown close connect setsockopt)
118 AC_CHECK_FUNCS(time ctime utime gettimeofday)
119 AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
120 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
121 AC_CHECK_FUNCS(setgroups initgroups pthread_create nl_langinfo)
122 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
124 # SIM support checking
125 # XXX These needs to be changed as more supported platforms appear.
126 # XXX This probably needs to be made platform dependant check.
129 AC_CHECKING(for SIM support)
130 AC_CHECK_HEADERS(dlfcn.h,
131 AC_CHECK_LIB(dl, dlopen,
138 AC_CHECK_LIB(c, dlopen,
146 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
147 if test x$sim_support = xtrue; then
148 AC_MSG_RESULT(Enabled SIM support.)
150 AC_MSG_RESULT(No SIM support found.)
153 # lib/contrib conditionals
155 AC_CHECK_HEADER(regex.h, have_regex=1, have_regex=0)
156 AM_CONDITIONAL(HAVE_REGEX, test x$have_regex = x1)
157 AC_CHECK_FUNC(getopt_long, have_getopt_long=1, have_getopt_long=0)
158 AM_CONDITIONAL(HAVE_GETOPT_LONG, test x$have_getopt_long = x1)
162 ## Enable/disable checking
167 AC_MSG_CHECKING(for IPv6 support)
169 [ --enable-ipv6 enable IPv6 support],
171 case "${enableval}" in
188 if test x$check_ipv6 = xtrue; then
191 #ifdef HAVE_NETINET_TCP_H
192 #include <netinet/tcp.h>
197 #include <sys/socket.h>
198 #ifdef HAVE_NETDB_IN_H
199 #include <netinet/in.h>
203 struct sockaddr_in6 sin6;
204 int family = AF_INET6;
216 AC_MSG_CHECKING(for enabled debugging)
218 [ --enable-debug enable debugging],
220 case "${enableval}" in
223 AC_DEFINE(SILC_DEBUG)
224 CFLAGS="-O -g $CFLAGS"
228 CFLAGS="-O2 -g $CFLAGS"
233 CFLAGS="-O2 -g $CFLAGS"
237 # Stack trace checking
239 AC_MSG_CHECKING(for enabled stack tracing)
240 AC_ARG_ENABLE(stack-trace,
241 [ --enable-stack-trace enable memory stack trace],
243 case "${enableval}" in
246 AC_DEFINE(SILC_STACKTRACE)
256 # Disable all assembler optimizations
259 [ --disable-asm do not use assembler optimizations])
264 AC_ARG_ENABLE(threads,
265 [ --disable-threads do not compile with multi-thread support],
267 case "${enableval}" in
278 if test x$check_threads = xtrue; then
279 AC_CHECK_HEADERS(pthread.h,
281 AC_DEFINE(SILC_HAVE_PTHREAD)
285 if test -f /usr/pkg/include/pthread.h ; then
286 AC_DEFINE(SILC_HAVE_PTHREAD)
288 AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
289 CFLAGS="$CFLAGS -I/usr/pkg/include"
290 elif test -f /usr/contrib/include/pthread.h ; then
291 AC_DEFINE(SILC_HAVE_PTHREAD)
293 AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
294 CFLAGS="$CFLAGS -I/usr/contrib/include"
299 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
300 if test x$want_threads = xtrue; then
309 pthread_attr_init(&attr);
312 AC_DEFINE(SILC_THREADS)
315 LIBS="-L/usr/pkg/lib -lpthread"
322 pthread_attr_init(&attr);
325 AC_DEFINE(SILC_THREADS)
328 LIBS="-L/usr/contrib/lib -lpthread"
335 pthread_attr_init(&attr);
338 AC_DEFINE(SILC_THREADS)
345 CFLAGS="$CFLAGS -D_REENTRANT"
348 CFLAGS="$CFLAGS -D_THREAD_SAFE"
349 if test x"$GCC" = xyes; then
350 CFLAGS="$CFLAGS -mthreads"
354 CFLAGS="$CFLAGS -D_THREAD_SAFE"
356 *-sysv5uw7*) # UnixWare 7
357 if test "$GCC" != "yes"; then
358 CFLAGS="$CFLAGS -Kthread"
360 CFLAGS="$CFLAGS -pthread"
364 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
367 LIBS="$TMP_LIBS $LIBS"
375 # Default installation destination
377 AC_PREFIX_DEFAULT(/usr/local/silc)
378 if test "x$prefix" != xNONE; then
379 silc_prefix="$prefix"
381 silc_prefix="$ac_default_prefix"
386 if test "x$sysconfdir" != 'x${prefix}/etc'; then
389 ETCDIR="$silc_prefix/etc"
393 [[ --with-etcdir=DIR directory for system files [/etc/silc]]],
404 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
408 HELPDIR="$silc_prefix/help"
410 [[ --with-helpdir=DIR directory for SILC help files [PREFIX/help]]],
421 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
425 DOCDIR="$silc_prefix/doc"
427 [[ --with-docdir=DIR directory for SILC documentation [PREFIX/doc]]],
438 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
440 # SIM modules directory
442 MODULESDIR="$silc_prefix/modules"
444 [[ --with-simdir=DIR directory for SIM modules [PREFIX/modules]]],
450 MODULESDIR="$withval"
455 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
459 LOGSDIR="$silc_prefix/logs"
461 [[ --with-logsdir=DIR directory for SILC Server logs [PREFIX/logs]]],
472 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
474 # silcd config file checking
476 AC_ARG_WITH(silcd-conf,
477 [[ --with-silcd-conf=FILE use FILE as default configuration file for SILC
478 Server [/etc/silc/silcd.conf]]],
479 AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
482 # silcd pid file checking
484 if test "x$localstatedir" != 'x${prefix}/var'; then
485 PIDFILE="$localstatedir/silcd.pid"
487 PIDFILE="$silc_prefix/var/silcd.pid"
490 AC_ARG_WITH(silcd-pid,
491 [[ --with-silcd-pid=FILE use FILE as default pid file for SILC
492 Server [/var/run/silcd.pid]]],
506 ## With/without checkings
509 # SOCKS4 support checking
511 AC_MSG_CHECKING(whether to support SOCKS4)
513 [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]],
523 if test -d "$withval/include"; then
524 CFLAGS="$CFLAGS -I$withval/include"
526 CFLAGS="$CFLAGS -I$withval"
528 if test -d "$withval/lib"; then
529 withval="-L$withval/lib -lsocks"
531 withval="-L$withval -lsocks"
534 LIBS="$withval $LIBS"
540 AC_MSG_ERROR(Could not find SOCKS4 library.)
548 # SOCKS5 support checking
550 AC_MSG_CHECKING(whether to support SOCKS5)
552 [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]],
562 if test -d "$withval/include"; then
563 CFLAGS="$CFLAGS -I$withval/include"
565 CFLAGS="$CFLAGS -I$withval"
567 if test -d "$withval/lib"; then
568 withval="-L$withval/lib -lsocks5"
570 withval="-L$withval -lsocks5"
573 LIBS="$withval $LIBS"
579 AC_MSG_ERROR(Could not find SOCKS5 library.)
587 if test "x$socks" = "x4"; then
589 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
592 if test "x$socks" = "x5"; then
595 AC_DEFINE(Rconnect, SOCKSconnect)
596 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
597 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
598 AC_DEFINE(Rbind, SOCKSbind)
599 AC_DEFINE(Raccept, SOCKSaccept)
600 AC_DEFINE(Rlisten, SOCKSlisten)
601 AC_DEFINE(Rselect, SOCKSselect)
602 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
603 AC_DEFINE(Rsendto, SOCKSsendto)
604 AC_DEFINE(Rrecv, SOCKSrecv)
605 AC_DEFINE(Rsend, SOCKSsend)
606 AC_DEFINE(Rread, SOCKSread)
607 AC_DEFINE(Rwrite, SOCKSwrite)
608 AC_DEFINE(Rrresvport, SOCKSrresvport)
609 AC_DEFINE(Rshutdown, SOCKSshutdown)
610 AC_DEFINE(Rlisten, SOCKSlisten)
611 AC_DEFINE(Rclose, SOCKSclose)
612 AC_DEFINE(Rdup, SOCKSdup)
613 AC_DEFINE(Rdup2, SOCKSdup2)
614 AC_DEFINE(Rfclose, SOCKSfclose)
615 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
618 # MP library checking. First check whether user wants to use GMP and use
619 # it if found. If not or not defined then compile the MPI library in the
623 AC_MSG_CHECKING(whether to support GMP)
625 [[ --with-gmp[=DIR] use GMP instead of MPI [search in DIR/lib and DIR/include]]],
634 if test -d "$withval/include"; then
635 CFLAGS="$CFLAGS -I$withval/include"
637 CFLAGS="$CFLAGS -I$withval"
639 if test -d "$withval/lib"; then
640 withval="-L$withval/lib -lgmp"
642 withval="-L$withval -lgmp"
645 LIBS="$withval $LIBS"
646 AC_CHECK_LIB(gmp, __gmpz_init,
649 AC_DEFINE(SILC_MP_GMP)
650 AC_MSG_RESULT(Using GMP as a MP library.)
658 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
659 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
660 if test x$mp_gmp = xfalse; then
661 AC_DEFINE(SILC_MP_NSS_MPI)
662 AC_MSG_RESULT(Using NSS MPI as a MP library.)
668 [[ --with-iconv[=DIR] use libiconv [search in DIR/include and DIR/lib]]],
670 if test -d $dir/include; then
671 CPPFLAGS="$CPPFLAGS -I$dir/include"
672 CFLAGS="$CFLAGS -I$dir/include"
674 if test -d $dir/lib; then
675 LDFLAGS="$LDFLAGS -L$dir/lib"
679 AC_CHECK_HEADER(iconv.h,
681 AC_DEFINE(HAVE_ICONV_H, 1, [Define if you have the iconv.h header.])
682 AC_CHECK_FUNC(iconv, ac_iconv_found=1,
685 AC_MSG_CHECKING(for iconv in -liconv)
692 iconv_t cd = iconv_open("", "");
693 iconv(cd, NULL, NULL, NULL, NULL);
698 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
703 if test x$ac_iconv_found = x1; then
705 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
706 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
707 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
709 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
720 ob = buf, obl = sizeof(buf);
721 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
722 (iconv(cd, 0, 0, &ob, &obl) ||
723 !(ob == buf && obl == sizeof(buf)) ||
738 if test x$ac_iconv_good = xno; then
739 AC_MSG_ERROR(Try using libiconv instead.)
743 # Native WIN32 compilation under cygwin
746 [ --with-win32 compile native WIN32 code (-mno-cygwin)],
748 AC_DEFINE(SILC_WIN32)
750 CFLAGS="-mno-cygwin $CFLAGS"
751 LIBS="$LIBS -lwsock32"
753 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
755 # Native EPOC support (disabled by default)
757 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
759 # Native BeOS support (disabled by default)
761 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
763 # Native OS2 support (disabled by default)
765 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
771 [ --without-irssi compile without Irssi SILC Client],
774 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
781 [ --without-silcd compile without SILC Server],
784 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
792 # Other configure scripts
794 if test x$without_irssi = xfalse; then
795 if test "x$silc_dist" = "xsilc-client" ||
796 test "x$silc_dist" = "xsilc-toolkit"; then
797 AC_CONFIG_SUBDIRS(irssi)
801 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
802 #AC_CONFIG_SUBDIRS(lib/zlib)
804 SILC_TOP_SRCDIR=`pwd`
805 AC_SUBST(SILC_TOP_SRCDIR)
806 #SILC_INSTALL_PREFIX=$ac_default_prefix
807 #AC_SUBST(SILC_INSTALL_PREFIX)
809 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
810 AC_SUBST(INCLUDE_DEFINES_INT)
811 AC_SUBST(SILC_DIST_SUBDIRS)
823 lib/silccore/Makefile
824 lib/silccrypt/Makefile
825 lib/silcmath/Makefile
826 lib/silcmath/mpi/Makefile.defines
827 lib/silcmath/mpi/Makefile.defines_int
830 lib/silcutil/Makefile
831 lib/silcutil/unix/Makefile
832 lib/silcutil/win32/Makefile
833 lib/silcutil/beos/Makefile
834 lib/silcutil/os2/Makefile
835 lib/silcutil/epoc/Makefile
836 lib/silcsftp/Makefile
837 lib/silcsftp/tests/Makefile
838 doc/example_silcd.conf
841 if test "x$silc_dist" = "xsilc-client" ||
842 test "x$silc_dist" = "xsilc-toolkit"; then
843 AC_CONFIG_FILES(lib/silcclient/Makefile)
846 if test x$without_irssi = xfalse ; then
847 if test "x$silc_dist" = "xsilc-client" ||
848 test "x$silc_dist" = "xsilc-toolkit"; then
850 irssi/Makefile.defines
851 irssi/Makefile.defines_int
856 if test x$without_silcd = xfalse ; then
857 if test "x$silc_dist" = "xsilc-server" ||
858 test "x$silc_dist" = "xsilc-toolkit"; then
865 if test "x$silc_dist" = "xsilc-toolkit"; then
869 win32/libsilc/Makefile
870 win32/libsilcclient/Makefile