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 AC_DEFINE(SILC_DIST_DEFINE)
54 CFLAGS="-Wall -finline-functions $CFLAGS"
68 # More header checking
69 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
70 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h stddef.h)
71 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
72 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
73 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
74 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h)
83 AC_CHECK_SIZEOF(long long, 0)
84 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
85 AC_CHECK_SIZEOF(long, 0)
86 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
87 AC_CHECK_SIZEOF(int, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
89 AC_CHECK_SIZEOF(short, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
91 AC_CHECK_SIZEOF(char, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
93 AC_CHECK_SIZEOF(void *, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
96 dnl Curses detection: Munged from Midnight Commander's configure.in
97 AC_DEFUN(AC_CHECK_CURSES,[
104 AC_SUBST(CURSES_LIBS)
105 AC_SUBST(CURSES_INCLUDEDIR)
107 AC_ARG_WITH(sunos-curses,
108 [ --with-sunos-curses Used to force SunOS 4.x curses],[
109 if test x$withval = xyes; then
114 AC_ARG_WITH(osf1-curses,
115 [ --with-osf1-curses Used to force OSF/1 curses],[
116 if test x$withval = xyes; then
122 [ --with-vcurses[=incdir] Used to force SysV curses],
123 if test x$withval != xyes; then
124 CURSES_INCLUDEDIR="-I$withval"
130 [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
131 if test x$withval = xno ; then
133 elif test x$withval != xyes ; then
134 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
145 AC_DEFUN(AC_USE_SUNOS_CURSES, [
147 screen_manager="SunOS 4.x /usr/5include curses"
148 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
149 AC_DEFINE(USE_SUNOS_CURSES)
150 AC_DEFINE(HAS_CURSES)
152 AC_DEFINE(NO_COLOR_CURSES)
153 AC_DEFINE(USE_SYSV_CURSES)
154 CURSES_INCLUDEDIR="-I/usr/5include"
155 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
156 AC_MSG_RESULT(Please note that some screen refreshs may fail)
159 AC_DEFUN(AC_USE_OSF1_CURSES, [
160 AC_MSG_RESULT(Using OSF1 curses)
162 screen_manager="OSF1 curses"
163 AC_DEFINE(HAS_CURSES)
165 AC_DEFINE(NO_COLOR_CURSES)
166 AC_DEFINE(USE_SYSV_CURSES)
167 CURSES_LIBS="-lcurses"
170 AC_DEFUN(AC_USE_SYSV_CURSES, [
171 AC_MSG_RESULT(Using SysV curses)
172 AC_DEFINE(HAS_CURSES)
174 AC_DEFINE(USE_SYSV_CURSES)
176 screen_manager="SysV/curses"
177 CURSES_LIBS="-lcurses"
181 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
183 AC_DEFUN(AC_NCURSES, [
188 AC_MSG_RESULT(Found ncurses on $1/$2)
191 AC_CHECK_LIB(ncurses, initscr, , [
192 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
193 AC_CHECK_LIB(curses, initscr, [
194 CURSES_LIBS="$CHECKLIBS"
197 CURSES_INCLUDEDIR="$4"
200 AC_DEFINE(HAS_CURSES)
203 AC_DEFINE(USE_NCURSES)
208 AC_DEFUN(AC_SEARCH_NCURSES, [
209 AC_CHECKING("location of ncurses.h file")
211 AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
212 AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
213 AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
214 AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
215 AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
216 AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
218 AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
220 AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
223 dnl We couldn't find ncurses, try SysV curses
227 AC_EGREP_HEADER(init_color, /usr/include/curses.h,
229 AC_EGREP_CPP(USE_NCURSES,[
236 CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
237 AC_DEFINE(HAS_CURSES)
240 AC_DEFINE(USE_NCURSES)
242 screen_manager="ncurses installed as curses"
247 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
248 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
249 dnl should be replaced by a more fine grained selection routine
253 if test -f /usr/5include/curses.h
259 dnl use whatever curses there happens to be
262 if test -f /usr/include/curses.h
264 CURSES_LIBS="-lcurses"
265 AC_DEFINE(HAS_CURSES)
268 screen_manager="curses"
274 LIBS="$LIBS $CURSES_LIBS"
276 # Function and library checking
277 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
278 ac_gethostbyname_found=0)
279 if test x$ac_gethostbyname_found = x0; then
280 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
281 AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
282 if test x$ac_res_ghbn_found = x0; then
283 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
286 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
287 if test x$ac_socket_found = x0; then
288 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
290 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
291 AC_CHECK_FUNCS(select listen bind shutdown close connect)
292 AC_CHECK_FUNCS(fcntl setsockopt)
293 AC_CHECK_FUNCS(getopt_long time)
294 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
295 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid setgroups initgroups)
296 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
297 AC_CHECK_FUNCS(pthread_create)
299 # SIM support checking
300 # XXX These needs to be changed as more supported platforms appear.
301 # XXX This probably needs to be made platform dependant check.
303 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
304 AC_CHECKING(for SIM support)
305 AC_CHECK_HEADERS(dlfcn.h,
306 AC_CHECK_LIB(dl, dlopen,
309 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
310 AC_MSG_RESULT(enabled SIM support)
312 AC_MSG_RESULT(no SIM support found)),
313 AC_MSG_RESULT(no SIM support found))
319 # Default installation destination
320 AC_PREFIX_DEFAULT(/usr/local/silc)
322 if test "x$prefix" != xNONE; then
323 silc_prefix="$prefix"
325 silc_prefix="$ac_default_prefix"
330 if test "x$sysconfdir" != 'x${prefix}/etc'; then
333 ETCDIR="$silc_prefix/etc"
336 [ --with-etcdir[=PATH] Directory for system files [/etc/silc]],
349 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
353 HELPDIR="$silc_prefix/help"
355 [ --with-helpdir[=PATH] Directory for SILC help files [PREFIX/help]],
368 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
372 DOCDIR="$silc_prefix/doc"
374 [ --with-docdir[=PATH] Directory for SILC documentation [PREFIX/doc]],
387 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
389 # SIM modules directory
390 #MODULESDIR="modules"
391 MODULESDIR="$silc_prefix/modules"
393 [ --with-simdir[=PATH] Directory for SIM modules [PREFIX/modules]],
398 MODULESDIR="$withval"
401 MODULESDIR="$withval"
406 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
410 LOGSDIR="$silc_prefix/logs"
412 [ --with-logsdir[=PATH] Directory for Server logs [PREFIX/logs]],
425 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
427 # SOCKS4 support checking
428 AC_MSG_CHECKING(whether to support SOCKS4)
430 [ --with-socks4[=PATH] Compile with SOCKS4 support],
439 if test -d "$withval/include"; then
440 CFLAGS="$CFLAGS -I$withval/include"
442 CFLAGS="$CFLAGS -I$withval"
444 if test -d "$withval/lib"; then
445 withval="-L$withval/lib -lsocks"
447 withval="-L$withval -lsocks"
450 LIBS="$withval $LIBS"
455 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
461 # SOCKS5 support checking
462 AC_MSG_CHECKING(whether to support SOCKS5)
464 [ --with-socks5[=PATH] Compile with SOCKS5 support],
473 if test -d "$withval/include"; then
474 CFLAGS="$CFLAGS -I$withval/include"
476 CFLAGS="$CFLAGS -I$withval"
478 if test -d "$withval/lib"; then
479 withval="-L$withval/lib -lsocks5"
481 withval="-L$withval -lsocks5"
484 LIBS="$withval $LIBS"
489 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
495 if test "x$socks" = "x4"; then
497 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
500 if test "x$socks" = "x5"; then
503 AC_DEFINE(Rconnect, SOCKSconnect)
504 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
505 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
506 AC_DEFINE(Rbind, SOCKSbind)
507 AC_DEFINE(Raccept, SOCKSaccept)
508 AC_DEFINE(Rlisten, SOCKSlisten)
509 AC_DEFINE(Rselect, SOCKSselect)
510 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
511 AC_DEFINE(Rsendto, SOCKSsendto)
512 AC_DEFINE(Rrecv, SOCKSrecv)
513 AC_DEFINE(Rsend, SOCKSsend)
514 AC_DEFINE(Rread, SOCKSread)
515 AC_DEFINE(Rwrite, SOCKSwrite)
516 AC_DEFINE(Rrresvport, SOCKSrresvport)
517 AC_DEFINE(Rshutdown, SOCKSshutdown)
518 AC_DEFINE(Rlisten, SOCKSlisten)
519 AC_DEFINE(Rclose, SOCKSclose)
520 AC_DEFINE(Rdup, SOCKSdup)
521 AC_DEFINE(Rdup2, SOCKSdup2)
522 AC_DEFINE(Rfclose, SOCKSfclose)
523 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
527 # MP library checking. First check whether user wants to use GMP and use
528 # it if found. If not or not defined then compile the MPI library in the
531 AC_MSG_CHECKING(whether to support GMP)
533 [ --with-gmp[=PATH] Compile with GMP support instead of MPI],
542 if test -d "$withval/include"; then
543 CFLAGS="$CFLAGS -I$withval/include"
545 CFLAGS="$CFLAGS -I$withval"
547 if test -d "$withval/lib"; then
548 withval="-L$withval/lib -lgmp"
550 withval="-L$withval -lgmp"
553 LIBS="$withval $LIBS"
555 AC_CHECK_LIB(gmp, __gmpz_init,
557 AC_DEFINE(SILC_MP_GMP)
558 AC_MSG_RESULT(Using GMP as MP library)
566 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
567 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
568 if test x$mp_gmp = xfalse; then
569 AC_DEFINE(SILC_MP_NSS_MPI)
570 AC_MSG_RESULT(Using NSS MPI as MP library)
573 AC_ARG_WITH(silcd-config-file,
574 [ --with-silcd-config-file[=PATH]
575 Use PATH as default configuration file in SILC
576 server [/etc/silc/silcd.conf]],
577 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
579 if test "x$localstatedir" != 'x${prefix}/var'; then
580 PIDFILE="$localstatedir/silcd.pid"
582 PIDFILE="$silc_prefix/var/silcd.pid"
584 AC_ARG_WITH(silcd-pid-file,
585 [ --with-silcd-pid-file[=PATH]
586 Use PATH as default pid file in SILC
587 server [/var/run/silcd.pid]],
602 # Native WIN32 compilation under cygwin
605 [ --with-win32 Compile native WIN32 code (-mno-cygwin)],
606 [ AC_DEFINE(SILC_WIN32)
608 CFLAGS="-mno-cygwin $CFLAGS"
609 LIBS="$LIBS -lwsock32" ])
611 AM_CONDITIONAL(SILC_WIN32, test x$win32-support = xtrue)
614 # Native EPOC support (disabled by default)
616 AM_CONDITIONAL(SILC_EPOC, test xfalse = xtrue)
619 # Native BeOS support (disabled by default)
621 AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue)
624 # Native OS2 support (disabled by default)
626 AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue)
631 AC_MSG_CHECKING(for IPv6 support)
633 [ --enable-ipv6 Enable IPv6 support],
634 [ case "${enableval}" in
646 esac ], check_ipv6=true)
648 if test x$check_ipv6 = xtrue; then
649 AC_TRY_COMPILE([#ifdef HAVE_NETINET_TCP_H
650 #include <netinet/tcp.h>
655 #include <sys/socket.h>
656 #ifdef HAVE_NETDB_IN_H
657 #include <netinet/in.h>
659 [struct sockaddr_in6 sin6;
660 int family = AF_INET6;
661 ], [AC_DEFINE(HAVE_IPV6)
662 AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
668 AC_MSG_CHECKING(for enabled debugging)
670 [ --enable-debug Enable debugging],
671 [ case "${enableval}" in
674 AC_DEFINE(SILC_DEBUG)
675 CFLAGS="-O -g $CFLAGS"
679 CFLAGS="-O2 -g $CFLAGS"
681 esac ], CFLAGS="-O2 -g $CFLAGS"
685 # Disable all assembler optimizations
688 [ --disable-asm Do not use assembler optimizations ],
694 AC_ARG_ENABLE(threads,
695 [ --disable-threads Do not compile with multi-thread support],
696 [ case "${enableval}" in
707 if test x$check_threads = xtrue; then
709 AC_CHECK_HEADERS(pthread.h,
710 [ AC_DEFINE(SILC_HAVE_PTHREAD)
712 [ if test -f /usr/pkg/include/pthread.h ; then
713 AC_DEFINE(SILC_HAVE_PTHREAD)
714 AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
715 CFLAGS="$CFLAGS -I/usr/pkg/include"
717 elif test -f /usr/contrib/include/pthread.h ; then
718 AC_DEFINE(SILC_HAVE_PTHREAD)
719 AC_MSG_RESULT(Found pthread.h in /usr/contrib/include/)
720 CFLAGS="$CFLAGS -I/usr/contrib/include"
725 AM_CONDITIONAL(SILC_THREADS, test x$want_threads = xtrue)
726 if test x$want_threads = xtrue; then
729 AC_TRY_LINK([#include <pthread.h>],
730 [pthread_attr_t attr; pthread_attr_init(&attr);],
731 AC_DEFINE(SILC_THREADS),
732 LIBS="-L/usr/pkg/lib -lpthread"
733 AC_TRY_LINK([#include <pthread.h>],
734 [pthread_attr_t attr; pthread_attr_init(&attr);],
735 AC_DEFINE(SILC_THREADS),
736 LIBS="-L/usr/contrib/lib -lpthread"
737 AC_TRY_LINK([#include <pthread.h>],
738 [pthread_attr_t attr; pthread_attr_init(&attr);],
739 AC_DEFINE(SILC_THREADS),
743 CFLAGS="$CFLAGS -D_REENTRANT"
746 CFLAGS="$CFLAGS -D_THREAD_SAFE"
747 if test x"$GCC" = xyes; then
748 CFLAGS="$CFLAGS -mthreads"
752 CFLAGS="$CFLAGS -D_THREAD_SAFE"
754 *-sysv5uw7*) # UnixWare 7
755 if test "$GCC" != "yes"; then
756 CFLAGS="$CFLAGS -Kthread"
758 CFLAGS="$CFLAGS -pthread"
762 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
766 LIBS="$TMP_LIBS $LIBS"
771 # Other configure scripts
773 if test "x$silc_dist" = "xsilc-client" ||
774 test "x$silc_dist" = "xsilc-toolkit"; then
775 AC_CONFIG_SUBDIRS(irssi)
777 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
778 #AC_CONFIG_SUBDIRS(lib/zlib)
780 SILC_TOP_SRCDIR=`pwd`
781 AC_SUBST(SILC_TOP_SRCDIR)
782 #SILC_INSTALL_PREFIX=$ac_default_prefix
783 #AC_SUBST(SILC_INSTALL_PREFIX)
785 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
786 AC_SUBST(INCLUDE_DEFINES_INT)
799 lib/silccore/Makefile
800 lib/silccrypt/Makefile
801 lib/silcmath/Makefile
802 lib/silcmath/mpi/Makefile.defines
803 lib/silcmath/mpi/Makefile.defines_int
806 lib/silcutil/Makefile
807 lib/silcutil/unix/Makefile
808 lib/silcutil/win32/Makefile
809 lib/silcutil/beos/Makefile
810 lib/silcutil/os2/Makefile
811 lib/silcutil/epoc/Makefile
812 lib/silcsftp/Makefile
813 lib/silcsftp/tests/Makefile
814 doc/example_silcd.conf
817 if test "x$silc_dist" = "xsilc-client" ||
818 test "x$silc_dist" = "xsilc-toolkit"; then
820 lib/silcclient/Makefile
821 irssi/Makefile.defines
822 irssi/Makefile.defines_int
826 if test "x$silc_dist" = "xsilc-server" ||
827 test "x$silc_dist" = "xsilc-toolkit"; then
833 if test "x$silc_dist" = "xsilc-toolkit"; then
837 win32/libsilc/Makefile
838 win32/libsilcclient/Makefile