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
30 # ./prepare script will automatically put the correct version. Do not edit!
31 AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
33 AM_CONFIG_HEADER(includes/silcdefs.h)
43 # Distribution definition. ./prepare will automatically add here a correct
45 AC_DEFINE(SILC_DIST_DEFINE)
50 CFLAGS="-Wall -finline-functions $CFLAGS"
63 # More header checking
64 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
65 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
66 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h netdb.h)
67 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
68 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
69 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h)
70 AC_CHECK_HEADERS(pthread.h)
79 AC_CHECK_SIZEOF(long long, 0)
80 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
81 AC_CHECK_SIZEOF(long, 0)
82 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
83 AC_CHECK_SIZEOF(int, 0)
84 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
85 AC_CHECK_SIZEOF(short, 0)
86 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
87 AC_CHECK_SIZEOF(char, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
89 AC_CHECK_SIZEOF(void *, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
92 dnl Curses detection: Munged from Midnight Commander's configure.in
93 AC_DEFUN(AC_CHECK_CURSES,[
100 AC_SUBST(CURSES_LIBS)
101 AC_SUBST(CURSES_INCLUDEDIR)
103 AC_ARG_WITH(sunos-curses,
104 [ --with-sunos-curses Used to force SunOS 4.x curses],[
105 if test x$withval = xyes; then
110 AC_ARG_WITH(osf1-curses,
111 [ --with-osf1-curses Used to force OSF/1 curses],[
112 if test x$withval = xyes; then
118 [ --with-vcurses[=incdir] Used to force SysV curses],
119 if test x$withval != xyes; then
120 CURSES_INCLUDEDIR="-I$withval"
126 [ --with-ncurses[=dir] Compile with ncurses/locate base dir],
127 if test x$withval = xno ; then
129 elif test x$withval != xyes ; then
130 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
141 AC_DEFUN(AC_USE_SUNOS_CURSES, [
143 screen_manager="SunOS 4.x /usr/5include curses"
144 AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
145 AC_DEFINE(USE_SUNOS_CURSES)
146 AC_DEFINE(HAS_CURSES)
148 AC_DEFINE(NO_COLOR_CURSES)
149 AC_DEFINE(USE_SYSV_CURSES)
150 CURSES_INCLUDEDIR="-I/usr/5include"
151 CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
152 AC_MSG_RESULT(Please note that some screen refreshs may fail)
155 AC_DEFUN(AC_USE_OSF1_CURSES, [
156 AC_MSG_RESULT(Using OSF1 curses)
158 screen_manager="OSF1 curses"
159 AC_DEFINE(HAS_CURSES)
161 AC_DEFINE(NO_COLOR_CURSES)
162 AC_DEFINE(USE_SYSV_CURSES)
163 CURSES_LIBS="-lcurses"
166 AC_DEFUN(AC_USE_SYSV_CURSES, [
167 AC_MSG_RESULT(Using SysV curses)
168 AC_DEFINE(HAS_CURSES)
170 AC_DEFINE(USE_SYSV_CURSES)
172 screen_manager="SysV/curses"
173 CURSES_LIBS="-lcurses"
177 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
179 AC_DEFUN(AC_NCURSES, [
184 AC_MSG_RESULT(Found ncurses on $1/$2)
187 AC_CHECK_LIB(ncurses, initscr, [
189 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
190 AC_CHECK_LIB(curses, initscr, [
191 CURSES_LIBS="$CHECKLIBS"
194 CURSES_INCLUDEDIR="$4"
197 AC_DEFINE(HAS_CURSES)
200 AC_DEFINE(USE_NCURSES)
205 AC_DEFUN(AC_SEARCH_NCURSES, [
206 AC_CHECKING("location of ncurses.h file")
208 AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
209 AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
210 AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
211 AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
212 AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
213 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")
215 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")
217 AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
220 dnl We couldn't find ncurses, try SysV curses
224 AC_EGREP_HEADER(init_color, /usr/include/curses.h,
226 AC_EGREP_CPP(USE_NCURSES,[
233 CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
234 AC_DEFINE(HAS_CURSES)
237 AC_DEFINE(USE_NCURSES)
239 screen_manager="ncurses installed as curses"
244 dnl Try SunOS 4.x /usr/5{lib,include} ncurses
245 dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
246 dnl should be replaced by a more fine grained selection routine
250 if test -f /usr/5include/curses.h
256 dnl use whatever curses there happens to be
259 if test -f /usr/include/curses.h
261 CURSES_LIBS="-lcurses"
262 AC_DEFINE(HAS_CURSES)
265 screen_manager="curses"
271 LIBS="$LIBS $CURSES_LIBS"
273 # Function and library checking
274 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
275 ac_gethostbyname_found=0)
276 if test x$ac_gethostbyname_found = x0; then
277 AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
278 AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
279 if test x$ac_res_ghbn_found = x0; then
280 AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv")
283 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
284 if test x$ac_socket_found = x0; then
285 AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
287 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
288 AC_CHECK_FUNCS(select listen bind shutdown close connect)
289 AC_CHECK_FUNCS(fcntl setsockopt)
290 AC_CHECK_FUNCS(getopt_long time)
291 AC_CHECK_FUNCS(mlock munlock)
292 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
293 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
294 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
295 AC_CHECK_FUNCS(pthread_create)
297 # SIM support checking
298 # XXX These needs to be changed as more supported platforms appear.
299 # XXX This probably needs to be made platform dependant check.
301 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
302 AC_CHECKING(for SIM support)
303 AC_CHECK_HEADERS(dlfcn.h,
304 AC_CHECK_LIB(dl, dlopen,
307 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
308 AC_MSG_RESULT(enabled SIM support)
310 AC_MSG_RESULT(no SIM support found)),
311 AC_MSG_RESULT(no SIM support found))
317 # Default installation destination
318 AC_PREFIX_DEFAULT(/usr/local/silc)
323 [ --with-etcdir[=PATH] Directory for system files [/etc/silc]],
336 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
341 [ --with-helpdir[=PATH] Directory for SILC help files [PREFIX/help]],
354 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
359 [ --with-docdir[=PATH] Directory for SILC documentation [PREFIX/doc]],
372 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
374 # SIM modules directory
377 [ --with-simdir[=PATH] Directory for SIM modules [PREFIX/modules]],
382 MODULESDIR="$withval"
385 MODULESDIR="$withval"
390 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
395 [ --with-logsdir[=PATH] Directory for Server logs [PREFIX/logs]],
408 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
410 # SOCKS4 support checking
411 AC_MSG_CHECKING(whether to support SOCKS4)
413 [ --with-socks4[=PATH] Compile with SOCKS4 support],
422 if test -d "$withval/include"; then
423 CFLAGS="$CFLAGS -I$withval/include"
425 CFLAGS="$CFLAGS -I$withval"
427 if test -d "$withval/lib"; then
428 withval="-L$withval/lib -lsocks"
430 withval="-L$withval -lsocks"
433 LIBS="$withval $LIBS"
438 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
444 # SOCKS5 support checking
445 AC_MSG_CHECKING(whether to support SOCKS5)
447 [ --with-socks5[=PATH] Compile with SOCKS5 support],
456 if test -d "$withval/include"; then
457 CFLAGS="$CFLAGS -I$withval/include"
459 CFLAGS="$CFLAGS -I$withval"
461 if test -d "$withval/lib"; then
462 withval="-L$withval/lib -lsocks5"
464 withval="-L$withval -lsocks5"
467 LIBS="$withval $LIBS"
472 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
478 if test "x$socks" = "x4"; then
480 CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
483 if test "x$socks" = "x5"; then
486 AC_DEFINE(Rconnect, SOCKSconnect)
487 AC_DEFINE(Rgetsockname, SOCKSgetsockname)
488 AC_DEFINE(Rgetpeername, SOCKSgetpeername)
489 AC_DEFINE(Rbind, SOCKSbind)
490 AC_DEFINE(Raccept, SOCKSaccept)
491 AC_DEFINE(Rlisten, SOCKSlisten)
492 AC_DEFINE(Rselect, SOCKSselect)
493 AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
494 AC_DEFINE(Rsendto, SOCKSsendto)
495 AC_DEFINE(Rrecv, SOCKSrecv)
496 AC_DEFINE(Rsend, SOCKSsend)
497 AC_DEFINE(Rread, SOCKSread)
498 AC_DEFINE(Rwrite, SOCKSwrite)
499 AC_DEFINE(Rrresvport, SOCKSrresvport)
500 AC_DEFINE(Rshutdown, SOCKSshutdown)
501 AC_DEFINE(Rlisten, SOCKSlisten)
502 AC_DEFINE(Rclose, SOCKSclose)
503 AC_DEFINE(Rdup, SOCKSdup)
504 AC_DEFINE(Rdup2, SOCKSdup2)
505 AC_DEFINE(Rfclose, SOCKSfclose)
506 AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
510 # MP library checking. First check whether system has GMP. If it has that
511 # then use it. If not then compile the MPI library in the source tree.
514 AC_CHECK_HEADER(gmp.h,
515 AC_CHECK_LIB(gmp, __gmpz_init,
517 AC_DEFINE(SILC_MP_GMP)
518 LIBS="$LIBS -L/usr/lib -L/usr/local/lib -lgmp"
519 AC_MSG_RESULT(Using GMP as MP library)
522 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
523 if test x$mp_gmp = xfalse; then
524 AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
525 AC_DEFINE(SILC_MP_NSS_MPI)
526 AC_MSG_RESULT(Using NSS MPI as MP library)
529 AC_ARG_WITH(silcd-config-file,
530 [ --with-silcd-config-file[=PATH]
531 Use PATH as default configuration file in SILC
532 server [/etc/silc/silcd.conf]],
533 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
535 # Native WIN32 compilation under cygwin
537 [ --with-win32 Compile native WIN32 code (-mno-cygwin)],
538 [ AC_DEFINE(SILC_WIN32)
539 AM_CONDITIONAL(SILC_WIN32, test xtrue = xtrue)
540 CFLAGS="-mno-cygwin $CFLAGS"
541 LIBS="$LIBS -lwsock32" ])
544 AC_MSG_CHECKING(for enabled debugging)
546 [ --enable-debug Enable debugging (warning: it is heavy!)],
547 [ case "${enableval}" in
550 AC_DEFINE(SILC_DEBUG)
551 CFLAGS="-O -g $CFLAGS"
555 CFLAGS="-O2 -g $CFLAGS"
557 esac ], CFLAGS="-O2 -g $CFLAGS"
561 AC_ARG_ENABLE(threads,
562 [ --disable-threads Do not compile with multi-thread support],
563 [ case "${enableval}" in
565 AC_DEFINE(SILC_THREADS)
566 AM_CONDITIONAL(SILC_THREADS)
572 esac ], AC_DEFINE(SILC_THREADS)
573 AM_CONDITIONAL(SILC_THREADS)
576 if test x$want_threads = xtrue; then
577 AC_TRY_COMPILE([#include <pthread.h>],
578 [pthread_attr_t attr; pthread_attr_init(&attr);],
579 LIBS="$LIBS -lpthread")
583 # Other configure scripts
585 AC_CONFIG_SUBDIRS(lib/dotconf)
586 AC_CONFIG_SUBDIRS(lib/trq)
587 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
588 AC_CONFIG_SUBDIRS(irssi)
589 #AC_CONFIG_SUBDIRS(lib/zlib)
591 SILC_TOP_SRCDIR=`pwd`
592 AC_SUBST(SILC_TOP_SRCDIR)
593 #SILC_INSTALL_PREFIX=$ac_default_prefix
594 #AC_SUBST(SILC_INSTALL_PREFIX)
596 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
597 AC_SUBST(INCLUDE_DEFINES_INT)
606 irssi/Makefile.defines
607 irssi/Makefile.defines_int
612 lib/silcclient/Makefile
613 lib/silccore/Makefile
614 lib/silccrypt/Makefile
615 lib/silcmath/Makefile
616 lib/silcmath/mpi/Makefile.defines
617 lib/silcmath/mpi/Makefile.defines_int
619 lib/silcsim/modules/Makefile
621 lib/silcutil/Makefile
622 lib/silcutil/unix/Makefile
623 lib/silcutil/win32/Makefile