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)
163 # Default installation destination
165 AC_PREFIX_DEFAULT(/usr/local/silc)
166 if test "x$prefix" != xNONE; then
167 silc_prefix="$prefix"
169 silc_prefix="$ac_default_prefix"
174 if test "x$sysconfdir" != 'x${prefix}/etc'; then
177 ETCDIR="$silc_prefix/etc"
181 [ --with-etcdir[=PATH] Directory for system files [/etc/silc]],
195 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
199 HELPDIR="$silc_prefix/help"
201 [ --with-helpdir[=PATH] Directory for SILC help files [PREFIX/help]],
215 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
219 DOCDIR="$silc_prefix/doc"
221 [ --with-docdir[=PATH] Directory for SILC documentation [PREFIX/doc]],
235 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
237 # SIM modules directory
239 MODULESDIR="$silc_prefix/modules"
241 [ --with-simdir[=PATH] Directory for SIM modules [PREFIX/modules]],
247 MODULESDIR="$withval"
250 MODULESDIR="$withval"
255 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
259 LOGSDIR="$silc_prefix/logs"
261 [ --with-logsdir[=PATH] Directory for Server logs [PREFIX/logs]],
275 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
277 # SOCKS4 support checking
279 AC_MSG_CHECKING(whether to support SOCKS4)
281 [ --with-socks4[=PATH] Compile with SOCKS4 support],
291 if test -d "$withval/include"; then
292 CFLAGS="$CFLAGS -I$withval/include"
294 CFLAGS="$CFLAGS -I$withval"
296 if test -d "$withval/lib"; then
297 withval="-L$withval/lib -lsocks"
299 withval="-L$withval -lsocks"
302 LIBS="$withval $LIBS"
308 AC_MSG_ERROR(Could not find SOCKS4 library.)
316 # SOCKS5 support checking
318 AC_MSG_CHECKING(whether to support SOCKS5)
320 [ --with-socks5[=PATH] Compile with SOCKS5 support],
330 if test -d "$withval/include"; then
331 CFLAGS="$CFLAGS -I$withval/include"
333 CFLAGS="$CFLAGS -I$withval"
335 if test -d "$withval/lib"; then
336 withval="-L$withval/lib -lsocks5"
338 withval="-L$withval -lsocks5"
341 LIBS="$withval $LIBS"
347 AC_MSG_ERROR(Could not find SOCKS5 library.)
355 if test "x$socks" = "x4"; then
357 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
360 if test "x$socks" = "x5"; then
363 AC_DEFINE(Rconnect, SOCKSconnect)
364 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
365 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
366 AC_DEFINE(Rbind, SOCKSbind)
367 AC_DEFINE(Raccept, SOCKSaccept)
368 AC_DEFINE(Rlisten, SOCKSlisten)
369 AC_DEFINE(Rselect, SOCKSselect)
370 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
371 AC_DEFINE(Rsendto, SOCKSsendto)
372 AC_DEFINE(Rrecv, SOCKSrecv)
373 AC_DEFINE(Rsend, SOCKSsend)
374 AC_DEFINE(Rread, SOCKSread)
375 AC_DEFINE(Rwrite, SOCKSwrite)
376 AC_DEFINE(Rrresvport, SOCKSrresvport)
377 AC_DEFINE(Rshutdown, SOCKSshutdown)
378 AC_DEFINE(Rlisten, SOCKSlisten)
379 AC_DEFINE(Rclose, SOCKSclose)
380 AC_DEFINE(Rdup, SOCKSdup)
381 AC_DEFINE(Rdup2, SOCKSdup2)
382 AC_DEFINE(Rfclose, SOCKSfclose)
383 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
386 # MP library checking. First check whether user wants to use GMP and use
387 # it if found. If not or not defined then compile the MPI library in the
391 AC_MSG_CHECKING(whether to support GMP)
393 [ --with-gmp[=PATH] Compile with GMP support instead of MPI],
402 if test -d "$withval/include"; then
403 CFLAGS="$CFLAGS -I$withval/include"
405 CFLAGS="$CFLAGS -I$withval"
407 if test -d "$withval/lib"; then
408 withval="-L$withval/lib -lgmp"
410 withval="-L$withval -lgmp"
413 LIBS="$withval $LIBS"
414 AC_CHECK_LIB(gmp, __gmpz_init,
417 AC_DEFINE(SILC_MP_GMP)
418 AC_MSG_RESULT(Using GMP as MP library.)
426 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
427 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
428 if test x$mp_gmp = xfalse; then
429 AC_DEFINE(SILC_MP_NSS_MPI)
430 AC_MSG_RESULT(Using NSS MPI as MP library.)
436 [ --with-iconv[=PATH] Search for libiconv in DIR/include and DIR/lib],
438 for dir in `echo "$withval" | tr : ' '`; do
439 if test -d $dir/include; then
440 CPPFLAGS="$CPPFLAGS -I$dir/include"
441 CFLAGS="$CFLAGS -I$dir/include"
443 if test -d $dir/lib; then
444 LDFLAGS="$LDFLAGS -L$dir/lib"
449 AC_CHECK_HEADER(iconv.h,
451 AC_DEFINE(HAVE_ICONV_H, 1, [Define if you have the iconv.h header.])
452 AC_CHECK_FUNC(iconv, ac_iconv_found=1,
455 AC_MSG_CHECKING(for iconv in -liconv)
462 iconv_t cd = iconv_open("", "");
463 iconv(cd, NULL, NULL, NULL, NULL);
468 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
473 if test x$ac_iconv_found = x1; then
475 # (1) Some implementations of iconv won't convert from UTF-8 to UTF-8.
476 # (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and
477 # obl when args 2 and 3 are 0 (fixed in glibc-2.1.3).
479 AC_CACHE_CHECK([whether this iconv is good enough], ac_iconv_good,
490 ob = buf, obl = sizeof(buf);
491 return ((cd = iconv_open("UTF-8", "UTF-8")) != (iconv_t)(-1) &&
492 (iconv(cd, 0, 0, &ob, &obl) ||
493 !(ob == buf && obl == sizeof(buf)) ||
508 if test x$ac_iconv_good = xno; then
509 AC_MSG_ERROR(Try using libiconv instead.)
513 # silcd config file checking
515 AC_ARG_WITH(silcd-config-file,
516 [ --with-silcd-config-file[=PATH]
517 Use PATH as default configuration file in SILC
518 server [/etc/silc/silcd.conf]],
519 AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval")
522 # silcd pid file checking
524 if test "x$localstatedir" != 'x${prefix}/var'; then
525 PIDFILE="$localstatedir/silcd.pid"
527 PIDFILE="$silc_prefix/var/silcd.pid"
530 AC_ARG_WITH(silcd-pid-file,
531 [ --with-silcd-pid-file[=PATH]
532 Use PATH as default pid file in SILC
533 server [/var/run/silcd.pid]],
548 # Native WIN32 compilation under cygwin
551 [ --with-win32 Compile native WIN32 code (-mno-cygwin)],
553 AC_DEFINE(SILC_WIN32)
555 CFLAGS="-mno-cygwin $CFLAGS"
556 LIBS="$LIBS -lwsock32"
558 AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue)
560 # Native EPOC support (disabled by default)
562 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
564 # Native BeOS support (disabled by default)
566 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
568 # Native OS2 support (disabled by default)
570 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
576 [ --without-irssi Compile without Irssi SILC Client],
579 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/irssi//'`
586 [ --without-silcd Compile without SILC Server],
589 SILC_DIST_SUBDIRS=`echo $SILC_DIST_SUBDIRS | $sedpath -e 's/silcd//'`
592 # Disable all assembler optimizations
595 [ --disable-asm Do not use assembler optimizations ])
600 AC_ARG_ENABLE(threads,
601 [ --disable-threads Do not compile with multi-thread support ],
603 case "${enableval}" in
614 if test x$check_threads = xtrue; then
615 AC_CHECK_HEADERS(pthread.h,
617 AC_DEFINE(SILC_HAVE_PTHREAD)
621 if test -f /usr/pkg/include/pthread.h ; then
622 AC_DEFINE(SILC_HAVE_PTHREAD)
624 AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
625 CFLAGS="$CFLAGS -I/usr/pkg/include"
626 elif test -f /usr/contrib/include/pthread.h ; then
627 AC_DEFINE(SILC_HAVE_PTHREAD)
629 AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
630 CFLAGS="$CFLAGS -I/usr/contrib/include"
635 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
636 if test x$want_threads = xtrue; then
645 pthread_attr_init(&attr);
648 AC_DEFINE(SILC_THREADS)
651 LIBS="-L/usr/pkg/lib -lpthread"
658 pthread_attr_init(&attr);
661 AC_DEFINE(SILC_THREADS)
664 LIBS="-L/usr/contrib/lib -lpthread"
671 pthread_attr_init(&attr);
674 AC_DEFINE(SILC_THREADS)
681 CFLAGS="$CFLAGS -D_REENTRANT"
684 CFLAGS="$CFLAGS -D_THREAD_SAFE"
685 if test x"$GCC" = xyes; then
686 CFLAGS="$CFLAGS -mthreads"
690 CFLAGS="$CFLAGS -D_THREAD_SAFE"
692 *-sysv5uw7*) # UnixWare 7
693 if test "$GCC" != "yes"; then
694 CFLAGS="$CFLAGS -Kthread"
696 CFLAGS="$CFLAGS -pthread"
700 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
703 LIBS="$TMP_LIBS $LIBS"
708 AC_MSG_CHECKING(for IPv6 support)
710 [ --enable-ipv6 Enable IPv6 support],
712 case "${enableval}" in
729 if test x$check_ipv6 = xtrue; then
732 #ifdef HAVE_NETINET_TCP_H
733 #include <netinet/tcp.h>
738 #include <sys/socket.h>
739 #ifdef HAVE_NETDB_IN_H
740 #include <netinet/in.h>
744 struct sockaddr_in6 sin6;
745 int family = AF_INET6;
757 AC_MSG_CHECKING(for enabled debugging)
759 [ --enable-debug Enable debugging],
761 case "${enableval}" in
764 AC_DEFINE(SILC_DEBUG)
765 CFLAGS="-O -g $CFLAGS"
769 CFLAGS="-O2 -g $CFLAGS"
774 CFLAGS="-O2 -g $CFLAGS"
778 # Stack trace checking
780 AC_MSG_CHECKING(for enabled stack tracing)
781 AC_ARG_ENABLE(stack-trace,
782 [ --enable-stack-trace Enable memory stack trace],
784 case "${enableval}" in
787 AC_DEFINE(SILC_STACKTRACE)
797 # Other configure scripts
799 if test x$without_irssi = xfalse; then
800 if test "x$silc_dist" = "xsilc-client" ||
801 test "x$silc_dist" = "xsilc-toolkit"; then
802 AC_CONFIG_SUBDIRS(irssi)
806 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
807 #AC_CONFIG_SUBDIRS(lib/zlib)
809 SILC_TOP_SRCDIR=`pwd`
810 AC_SUBST(SILC_TOP_SRCDIR)
811 #SILC_INSTALL_PREFIX=$ac_default_prefix
812 #AC_SUBST(SILC_INSTALL_PREFIX)
814 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
815 AC_SUBST(INCLUDE_DEFINES_INT)
816 AC_SUBST(SILC_DIST_SUBDIRS)
828 lib/silccore/Makefile
829 lib/silccrypt/Makefile
830 lib/silcmath/Makefile
831 lib/silcmath/mpi/Makefile.defines
832 lib/silcmath/mpi/Makefile.defines_int
835 lib/silcutil/Makefile
836 lib/silcutil/unix/Makefile
837 lib/silcutil/win32/Makefile
838 lib/silcutil/beos/Makefile
839 lib/silcutil/os2/Makefile
840 lib/silcutil/epoc/Makefile
841 lib/silcsftp/Makefile
842 lib/silcsftp/tests/Makefile
843 doc/example_silcd.conf
846 if test "x$silc_dist" = "xsilc-client" ||
847 test "x$silc_dist" = "xsilc-toolkit"; then
848 AC_CONFIG_FILES(lib/silcclient/Makefile)
851 if test x$without_irssi = xfalse ; then
852 if test "x$silc_dist" = "xsilc-client" ||
853 test "x$silc_dist" = "xsilc-toolkit"; then
855 irssi/Makefile.defines
856 irssi/Makefile.defines_int
861 if test x$without_silcd = xfalse ; then
862 if test "x$silc_dist" = "xsilc-server" ||
863 test "x$silc_dist" = "xsilc-toolkit"; then
870 if test "x$silc_dist" = "xsilc-toolkit"; then
874 win32/libsilc/Makefile
875 win32/libsilcclient/Makefile