4 # Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6 # Copyright (C) 2000 - 2001 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/version.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"
67 # More header checking
68 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
69 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
70 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h xti.h netdb.h)
71 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
72 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
73 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h)
82 AC_CHECK_SIZEOF(long long, 0)
83 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
84 AC_CHECK_SIZEOF(long, 0)
85 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
86 AC_CHECK_SIZEOF(int, 0)
87 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
88 AC_CHECK_SIZEOF(short, 0)
89 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
90 AC_CHECK_SIZEOF(char, 0)
91 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
92 AC_CHECK_SIZEOF(void *, 0)
93 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
95 dnl Curses detection: Munged from Midnight Commander's configure.in
96 AC_DEFUN(AC_CHECK_CURSES,[
103 AC_SUBST(CURSES_LIBS)
104 AC_SUBST(CURSES_INCLUDEDIR)
106 AC_ARG_WITH(sunos-curses,
107 [ --with-sunos-curses Used to force SunOS 4.x curses],[
108 if test x$withval = xyes; then
113 AC_ARG_WITH(osf1-curses,
114 [ --with-osf1-curses Used to force OSF/1 curses],[
115 if test x$withval = xyes; then
121 [ --with-vcurses[=incdir] Used to force SysV curses],
122 if test x$withval != xyes; then
123 CURSES_INCLUDEDIR="-I$withval"
129 [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
130 if test x$withval = xno ; then
132 elif test x$withval != xyes ; then
133 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
144 AC_DEFUN(AC_USE_SUNOS_CURSES, [
146 screen_manager="SunOS 4.x /usr/5include curses"
147 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
148 AC_DEFINE(USE_SUNOS_CURSES)
149 AC_DEFINE(HAS_CURSES)
151 AC_DEFINE(NO_COLOR_CURSES)
152 AC_DEFINE(USE_SYSV_CURSES)
153 CURSES_INCLUDEDIR="-I/usr/5include"
154 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
155 AC_MSG_RESULT(Please note that some screen refreshs may fail)
158 AC_DEFUN(AC_USE_OSF1_CURSES, [
159 AC_MSG_RESULT(Using OSF1 curses)
161 screen_manager="OSF1 curses"
162 AC_DEFINE(HAS_CURSES)
164 AC_DEFINE(NO_COLOR_CURSES)
165 AC_DEFINE(USE_SYSV_CURSES)
166 CURSES_LIBS="-lcurses"
169 AC_DEFUN(AC_USE_SYSV_CURSES, [
170 AC_MSG_RESULT(Using SysV curses)
171 AC_DEFINE(HAS_CURSES)
173 AC_DEFINE(USE_SYSV_CURSES)
175 screen_manager="SysV/curses"
176 CURSES_LIBS="-lcurses"
180 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
182 AC_DEFUN(AC_NCURSES, [
187 AC_MSG_RESULT(Found ncurses on $1/$2)
190 AC_CHECK_LIB(ncurses, initscr, , [
191 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
192 AC_CHECK_LIB(curses, initscr, [
193 CURSES_LIBS="$CHECKLIBS"
196 CURSES_INCLUDEDIR="$4"
199 AC_DEFINE(HAS_CURSES)
202 AC_DEFINE(USE_NCURSES)
207 AC_DEFUN(AC_SEARCH_NCURSES, [
208 AC_CHECKING("location of ncurses.h file")
210 AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
211 AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
212 AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
213 AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
214 AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
215 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")
217 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")
219 AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
222 dnl We couldn't find ncurses, try SysV curses
226 AC_EGREP_HEADER(init_color, /usr/include/curses.h,
228 AC_EGREP_CPP(USE_NCURSES,[
235 CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
236 AC_DEFINE(HAS_CURSES)
239 AC_DEFINE(USE_NCURSES)
241 screen_manager="ncurses installed as curses"
246 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
247 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
248 dnl should be replaced by a more fine grained selection routine
252 if test -f /usr/5include/curses.h
258 dnl use whatever curses there happens to be
261 if test -f /usr/include/curses.h
263 CURSES_LIBS="-lcurses"
264 AC_DEFINE(HAS_CURSES)
267 screen_manager="curses"
273 LIBS="$LIBS $CURSES_LIBS"
275 # Function and library checking
276 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
277 ac_gethostbyname_found=0)
278 if test x$ac_gethostbyname_found = x0; then
279 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
280 AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
281 if test x$ac_res_ghbn_found = x0; then
282 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
285 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
286 if test x$ac_socket_found = x0; then
287 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
289 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
290 AC_CHECK_FUNCS(select listen bind shutdown close connect)
291 AC_CHECK_FUNCS(fcntl setsockopt)
292 AC_CHECK_FUNCS(getopt_long time)
293 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
294 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
295 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
296 AC_CHECK_FUNCS(pthread_create)
298 # SIM support checking
299 # XXX These needs to be changed as more supported platforms appear.
300 # XXX This probably needs to be made platform dependant check.
302 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
303 AC_CHECKING(for SIM support)
304 AC_CHECK_HEADERS(dlfcn.h,
305 AC_CHECK_LIB(dl, dlopen,
308 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
309 AC_MSG_RESULT(enabled SIM support)
311 AC_MSG_RESULT(no SIM support found)),
312 AC_MSG_RESULT(no SIM support found))
318 # Default installation destination
319 AC_PREFIX_DEFAULT(/usr/local/silc)
324 [ --with-etcdir[=PATH] Directory for system files [/etc/silc]],
337 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
342 [ --with-helpdir[=PATH] Directory for SILC help files [PREFIX/help]],
355 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
360 [ --with-docdir[=PATH] Directory for SILC documentation [PREFIX/doc]],
373 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
375 # SIM modules directory
378 [ --with-simdir[=PATH] Directory for SIM modules [PREFIX/modules]],
383 MODULESDIR="$withval"
386 MODULESDIR="$withval"
391 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
396 [ --with-logsdir[=PATH] Directory for Server logs [PREFIX/logs]],
409 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
411 # SOCKS4 support checking
412 AC_MSG_CHECKING(whether to support SOCKS4)
414 [ --with-socks4[=PATH] Compile with SOCKS4 support],
423 if test -d "$withval/include"; then
424 CFLAGS="$CFLAGS -I$withval/include"
426 CFLAGS="$CFLAGS -I$withval"
428 if test -d "$withval/lib"; then
429 withval="-L$withval/lib -lsocks"
431 withval="-L$withval -lsocks"
434 LIBS="$withval $LIBS"
439 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
445 # SOCKS5 support checking
446 AC_MSG_CHECKING(whether to support SOCKS5)
448 [ --with-socks5[=PATH] Compile with SOCKS5 support],
457 if test -d "$withval/include"; then
458 CFLAGS="$CFLAGS -I$withval/include"
460 CFLAGS="$CFLAGS -I$withval"
462 if test -d "$withval/lib"; then
463 withval="-L$withval/lib -lsocks5"
465 withval="-L$withval -lsocks5"
468 LIBS="$withval $LIBS"
473 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
479 if test "x$socks" = "x4"; then
481 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
484 if test "x$socks" = "x5"; then
487 AC_DEFINE(Rconnect, SOCKSconnect)
488 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
489 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
490 AC_DEFINE(Rbind, SOCKSbind)
491 AC_DEFINE(Raccept, SOCKSaccept)
492 AC_DEFINE(Rlisten, SOCKSlisten)
493 AC_DEFINE(Rselect, SOCKSselect)
494 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
495 AC_DEFINE(Rsendto, SOCKSsendto)
496 AC_DEFINE(Rrecv, SOCKSrecv)
497 AC_DEFINE(Rsend, SOCKSsend)
498 AC_DEFINE(Rread, SOCKSread)
499 AC_DEFINE(Rwrite, SOCKSwrite)
500 AC_DEFINE(Rrresvport, SOCKSrresvport)
501 AC_DEFINE(Rshutdown, SOCKSshutdown)
502 AC_DEFINE(Rlisten, SOCKSlisten)
503 AC_DEFINE(Rclose, SOCKSclose)
504 AC_DEFINE(Rdup, SOCKSdup)
505 AC_DEFINE(Rdup2, SOCKSdup2)
506 AC_DEFINE(Rfclose, SOCKSfclose)
507 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
511 # MP library checking. First check whether user wants to use GMP and use
512 # it if found. If not or not defined then compile the MPI library in the
515 AC_MSG_CHECKING(whether to support GMP)
517 [ --with-gmp[=PATH] Compile with GMP support instead of MPI],
526 if test -d "$withval/include"; then
527 CFLAGS="$CFLAGS -I$withval/include"
529 CFLAGS="$CFLAGS -I$withval"
531 if test -d "$withval/lib"; then
532 withval="-L$withval/lib -lgmp"
534 withval="-L$withval -lgmp"
537 LIBS="$withval $LIBS"
539 AC_CHECK_LIB(gmp, __gmpz_init,
541 AC_DEFINE(SILC_MP_GMP)
542 AC_MSG_RESULT(Using GMP as MP library)
550 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
551 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
552 if test x$mp_gmp = xfalse; then
553 AC_DEFINE(SILC_MP_NSS_MPI)
554 AC_MSG_RESULT(Using NSS MPI as MP library)
557 AC_ARG_WITH(silcd-config-file,
558 [ --with-silcd-config-file[=PATH]
559 Use PATH as default configuration file in SILC
560 server [/etc/silc/silcd.conf]],
561 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
564 # Native WIN32 compilation under cygwin
567 [ --with-win32 Compile native WIN32 code (-mno-cygwin)],
568 [ AC_DEFINE(SILC_WIN32)
570 CFLAGS="-mno-cygwin $CFLAGS"
571 LIBS="$LIBS -lwsock32" ])
573 AM_CONDITIONAL(SILC_WIN32, test x$win32-support = xtrue)
578 AC_MSG_CHECKING(for enabled debugging)
580 [ --enable-debug Enable debugging (warning: it is heavy!)],
581 [ case "${enableval}" in
584 AC_DEFINE(SILC_DEBUG)
585 CFLAGS="-O -g $CFLAGS"
589 CFLAGS="-O2 -g $CFLAGS"
591 esac ], CFLAGS="-O2 -g $CFLAGS"
595 # Disable all assembler optimizations
598 [ --disable-asm Do not use assembler optimizations ],
604 AC_ARG_ENABLE(threads,
605 [ --disable-threads Do not compile with multi-thread support],
606 [ case "${enableval}" in
617 if test x$check_threads = xtrue; then
619 AC_CHECK_HEADERS(pthread.h,
620 [ AC_DEFINE(SILC_HAVE_PTHREAD)
622 [ if test -f /usr/pkg/include/pthread.h ; then
623 AC_DEFINE(SILC_HAVE_PTHREAD)
624 AC_MSG_RESULT(Found pthread.h in /usr/pkg/include/)
625 CFLAGS="$CFLAGS -I/usr/pkg/include"
627 elif test -f /usr/contrib/include/pthread.h ; then
628 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
639 AC_TRY_LINK([#include <pthread.h>],
640 [pthread_attr_t attr; pthread_attr_init(&attr);],
641 AC_DEFINE(SILC_THREADS),
642 LIBS="-L/usr/pkg/lib -lpthread"
643 AC_TRY_LINK([#include <pthread.h>],
644 [pthread_attr_t attr; pthread_attr_init(&attr);],
645 AC_DEFINE(SILC_THREADS),
646 LIBS="-L/usr/contrib/lib -lpthread"
647 AC_TRY_LINK([#include <pthread.h>],
648 [pthread_attr_t attr; pthread_attr_init(&attr);],
649 AC_DEFINE(SILC_THREADS),
653 CFLAGS="$CFLAGS -D_REENTRANT"
656 CFLAGS="$CFLAGS -D_THREAD_SAFE"
657 if test x"$GCC" = xyes; then
658 CFLAGS="$CFLAGS -mthreads"
662 CFLAGS="$CFLAGS -D_THREAD_SAFE"
664 *-sysv5uw7*) # UnixWare 7
665 if test "$GCC" != "yes"; then
666 CFLAGS="$CFLAGS -Kthread"
668 CFLAGS="$CFLAGS -pthread"
672 CFLAGS="$CFLAGS -D_POSIX4A_DRAFT10_SOURCE"
676 LIBS="$TMP_LIBS $LIBS"
681 # Other configure scripts
683 AC_CONFIG_SUBDIRS(lib/dotconf)
684 AC_CONFIG_SUBDIRS(lib/trq)
685 AC_CONFIG_SUBDIRS(irssi)
686 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
687 #AC_CONFIG_SUBDIRS(lib/zlib)
689 SILC_TOP_SRCDIR=`pwd`
690 AC_SUBST(SILC_TOP_SRCDIR)
691 #SILC_INSTALL_PREFIX=$ac_default_prefix
692 #AC_SUBST(SILC_INSTALL_PREFIX)
694 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
695 AC_SUBST(INCLUDE_DEFINES_INT)
708 lib/silccore/Makefile
709 lib/silccrypt/Makefile
710 lib/silcmath/Makefile
711 lib/silcmath/mpi/Makefile.defines
712 lib/silcmath/mpi/Makefile.defines_int
714 lib/silcsim/modules/Makefile
716 lib/silcutil/Makefile
717 lib/silcutil/unix/Makefile
718 lib/silcutil/win32/Makefile
719 lib/silcsftp/Makefile
720 lib/silcsftp/tests/Makefile
723 if test "x$silc_dist" = "xsilc-client" ||
724 test "x$silc_dist" = "xsilc-toolkit"; then
726 lib/silcclient/Makefile
727 irssi/Makefile.defines
728 irssi/Makefile.defines_int
732 if test "x$silc_dist" = "xsilc-server" ||
733 test "x$silc_dist" = "xsilc-toolkit"; then
739 if test "x$silc_dist" = "xsilc-toolkit"; then
743 win32/libsilc/Makefile
744 win32/libsilcclient/Makefile