updates.
[silc.git] / configure.in.pre
1 #
2 #  configure.in
3 #
4 #  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
5 #
6 #  Copyright (C) 2000 - 2001 Pekka Riikonen
7 #
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.
12 #
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.
17 #
18
19 AC_INIT(includes/version.h)
20
21 # Compiler settings
22 CFLAGS="-Wall $CFLAGS"
23
24 #
25 # Put here any platform specific stuff
26 #
27 AC_CANONICAL_SYSTEM
28 case "$target" in
29   *-*-linux*|*-*-mklinux*)
30     CFLAGS="-D_GNU_SOURCE $CFLAGS"
31     ;;
32   *)
33     ;;
34 esac
35
36 # ./prepare script will automatically put the correct version. Do not edit!
37 AM_INIT_AUTOMAKE(SILC_PACKAGE, SILC_VERSION)
38 AC_PREREQ(2.3)
39 AM_CONFIG_HEADER(includes/silcdefs.h)
40
41 AC_PROG_CC
42 AC_C_INLINE
43 AC_C_CONST
44 AC_ARG_PROGRAM
45
46 AC_PROG_LN_S
47 AC_SUBST(LN_S)
48
49 # Distribution definition. ./prepare will automatically add here a correct
50 # value. Do not edit!
51 AC_DEFINE(SILC_DIST_DEFINE)
52
53 # XXX
54 # Compiler flags
55 if test "$GCC"; then
56   CFLAGS="-finline-functions $CFLAGS"
57 else
58   # Currently GCC is only supported compiler
59   AC_MSG_ERROR(GCC is only supported compiler currently)
60 fi
61
62 # Program checking
63 AC_PROG_INSTALL
64 AC_PROG_RANLIB
65 AC_PROG_MAKE_SET
66
67 # Header checking
68 AC_HEADER_STDC
69 AC_HEADER_TIME
70 AC_HEADER_STAT
71
72 # More header checking
73 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
74 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
75 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h netdb.h)
76 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
77 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
78 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h)
79
80 # Data type checking
81 AC_TYPE_SIGNAL
82 AC_TYPE_SIZE_T
83 AC_TYPE_MODE_T
84 AC_TYPE_UID_T
85 AC_TYPE_PID_T
86
87 AC_CHECK_SIZEOF(long long, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
89 AC_CHECK_SIZEOF(long, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
91 AC_CHECK_SIZEOF(int, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
93 AC_CHECK_SIZEOF(short, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
95 AC_CHECK_SIZEOF(char, 0)
96 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
97 AC_CHECK_SIZEOF(void *, 0)
98 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
99
100 dnl Curses detection: Munged from Midnight Commander's configure.in
101 AC_DEFUN(AC_CHECK_CURSES,[
102         search_ncurses=true
103         screen_manager=""
104         has_curses=false
105
106         CFLAGS=${CFLAGS--O}
107
108         AC_SUBST(CURSES_LIBS)
109         AC_SUBST(CURSES_INCLUDEDIR)
110
111         AC_ARG_WITH(sco,
112           [  --with-sco              Use this to turn on SCO-specific code],[
113           if test x$withval = xyes; then
114                 AC_DEFINE(SCO_FLAVOR)
115                 CFLAGS="$CFLAGS -D_SVID3"
116           fi
117         ])
118
119         AC_ARG_WITH(sunos-curses,
120           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
121           if test x$withval = xyes; then
122                 AC_USE_SUNOS_CURSES
123           fi
124         ])
125
126         AC_ARG_WITH(osf1-curses,
127           [  --with-osf1-curses      Used to force OSF/1 curses],[
128           if test x$withval = xyes; then
129                 AC_USE_OSF1_CURSES
130           fi
131         ])
132
133         AC_ARG_WITH(vcurses,
134           [  --with-vcurses[=incdir] Used to force SysV curses],
135           if test x$withval != xyes; then
136                 CURSES_INCLUDEDIR="-I$withval"
137           fi
138           AC_USE_SYSV_CURSES
139         )
140
141         AC_ARG_WITH(ncurses,
142           [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
143           if test x$withval = xno ; then
144                 search_ncurses=false
145           elif test x$withval != xyes ; then
146                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
147           fi
148         )
149
150         if $search_ncurses
151         then
152                 AC_SEARCH_NCURSES()
153         fi
154 ])
155
156
157 AC_DEFUN(AC_USE_SUNOS_CURSES, [
158         search_ncurses=false
159         screen_manager="SunOS 4.x /usr/5include curses"
160         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
161         AC_DEFINE(USE_SUNOS_CURSES)
162         AC_DEFINE(HAS_CURSES)
163         has_curses=true
164         AC_DEFINE(NO_COLOR_CURSES)
165         AC_DEFINE(USE_SYSV_CURSES)
166         CURSES_INCLUDEDIR="-I/usr/5include"
167         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
168         AC_MSG_RESULT(Please note that some screen refreshs may fail)
169 ])
170
171 AC_DEFUN(AC_USE_OSF1_CURSES, [
172        AC_MSG_RESULT(Using OSF1 curses)
173        search_ncurses=false
174        screen_manager="OSF1 curses"
175        AC_DEFINE(HAS_CURSES)
176        has_curses=true
177        AC_DEFINE(NO_COLOR_CURSES)
178        AC_DEFINE(USE_SYSV_CURSES)
179        CURSES_LIBS="-lcurses"
180 ])
181
182 AC_DEFUN(AC_USE_SYSV_CURSES, [
183         AC_MSG_RESULT(Using SysV curses)
184         AC_DEFINE(HAS_CURSES)
185         has_curses=true
186         AC_DEFINE(USE_SYSV_CURSES)
187         search_ncurses=false
188         screen_manager="SysV/curses"
189         CURSES_LIBS="-lcurses"
190 ])
191
192 dnl
193 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
194 dnl
195 AC_DEFUN(AC_NCURSES, [
196     if $search_ncurses
197     then
198         if test -f $1/$2
199         then
200             AC_MSG_RESULT(Found ncurses on $1/$2)
201
202             CURSES_LIBS="$3"
203             AC_CHECK_LIB(ncurses, initscr, [
204             ], [
205                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
206                 AC_CHECK_LIB(curses, initscr, [
207                         CURSES_LIBS="$CHECKLIBS"
208                 ],, $CHECKLIBS)
209             ], $CURSES_LIBS)
210             CURSES_INCLUDEDIR="$4"
211             search_ncurses=false
212             screen_manager=$5
213             AC_DEFINE(HAS_CURSES)
214             has_curses=true
215             has_ncurses=true
216             AC_DEFINE(USE_NCURSES)
217         fi
218     fi
219 ])
220
221 AC_DEFUN(AC_SEARCH_NCURSES, [
222     AC_CHECKING("location of ncurses.h file")
223
224     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
225     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
226     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
227     AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
228     AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
229     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")
230
231     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")
232
233     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
234
235     dnl
236     dnl We couldn't find ncurses, try SysV curses
237     dnl
238     if $search_ncurses 
239     then
240         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
241             AC_USE_SYSV_CURSES)
242         AC_EGREP_CPP(USE_NCURSES,[
243 #include <curses.h>
244 #ifdef __NCURSES_H
245 #undef USE_NCURSES
246 USE_NCURSES
247 #endif
248 ],[
249         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
250         AC_DEFINE(HAS_CURSES)
251         has_curses=true
252         has_ncurses=true
253         AC_DEFINE(USE_NCURSES)
254         search_ncurses=false
255         screen_manager="ncurses installed as curses"
256 ])
257     fi
258
259     dnl
260     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
261     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
262     dnl should be replaced by a more fine grained selection routine
263     dnl
264     if $search_ncurses
265     then
266         if test -f /usr/5include/curses.h
267         then
268             AC_USE_SUNOS_CURSES
269         fi
270     fi
271
272     dnl use whatever curses there happens to be
273     if $search_ncurses
274     then
275         if test -f /usr/include/curses.h
276         then
277           CURSES_LIBS="-lcurses"
278           AC_DEFINE(HAS_CURSES)
279           has_curses=true
280           search_ncurses=false
281           screen_manager="curses"
282         fi
283     fi
284 ])
285
286 AC_CHECK_CURSES
287 LIBS="$LIBS $CURSES_LIBS"
288
289 # Function and library checking
290 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
291 ac_gethostbyname_found=0)
292 if test x$ac_gethostbyname_found = x0; then
293     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
294     AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
295     if test x$ac_res_ghbn_found = x0; then
296         AC_CHECK_LIB(resolv, res_gethostbyname,  LIBS="$LIBS -lresolv")
297     fi
298 fi
299 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
300 if test x$ac_socket_found = x0; then
301     AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
302 fi
303 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
304 AC_CHECK_FUNCS(select listen bind shutdown close connect)
305 AC_CHECK_FUNCS(fcntl setsockopt)
306 AC_CHECK_FUNCS(getopt_long time)
307 AC_CHECK_FUNCS(mlock munlock)
308 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
309 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
310 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
311
312 # SIM support checking
313 # XXX These needs to be changed as more supported platforms appear.
314 # XXX This probably needs to be made platform dependant check.
315 sim_support=false
316 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
317 AC_CHECKING(for SIM support)
318 AC_CHECK_HEADERS(dlfcn.h, 
319   AC_CHECK_LIB(dl, dlopen, 
320     AC_DEFINE(SILC_SIM) 
321     sim_support=true
322     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
323     AC_MSG_RESULT(enabled SIM support)
324     LIBS="$LIBS -ldl",
325     AC_MSG_RESULT(no SIM support found)),
326   AC_MSG_RESULT(no SIM support found))
327
328 #
329 # Installation
330 #
331
332 # Default installation destination
333 AC_PREFIX_DEFAULT(/usr/local/silc)
334
335 # etc directory
336 ETCDIR="/etc/silc"
337 AC_ARG_WITH(etcdir,
338 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
339 [ case "$withval" in
340   no)
341     ;;
342   yes)
343     ETCDIR="$withval"
344     ;;
345   *)
346     ETCDIR="$withval"
347     ;;
348   esac ],
349 )
350 AC_SUBST(ETCDIR)
351 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
352
353 # help directory
354 HELPDIR="help"
355 AC_ARG_WITH(helpdir,
356 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
357 [ case "$withval" in
358   no)
359     ;;
360   yes)
361     HELPDIR="$withval"
362     ;;
363   *)
364     HELPDIR="$withval"
365     ;;
366   esac ],
367 )
368 AC_SUBST(HELPDIR)
369 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
370
371 # doc directory
372 DOCDIR="doc"
373 AC_ARG_WITH(docdir,
374 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
375 [ case "$withval" in
376   no)
377     ;;
378   yes)
379     DOCDIR="$withval"
380     ;;
381   *)
382     DOCDIR="$withval"
383     ;;
384   esac ],
385 )
386 AC_SUBST(DOCDIR)
387 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
388
389 # SIM modules directory
390 MODULESDIR="modules"
391 AC_ARG_WITH(simdir,
392 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
393 [ case "$withval" in
394   no)
395     ;;
396   yes)
397     MODULESDIR="$withval"
398     ;;
399   *)
400     MODULESDIR="$withval"
401     ;;
402   esac ],
403 )
404 AC_SUBST(MODULESDIR)
405 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
406
407 # Logs directory
408 LOGSDIR="logs"
409 AC_ARG_WITH(logsdir,
410 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
411 [ case "$withval" in
412   no)
413     ;;
414   yes)
415     LOGSDIR="$withval"
416     ;;
417   *)
418     LOGSDIR="$withval"
419     ;;
420   esac ],
421 )
422 AC_SUBST(LOGSDIR)
423 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
424
425 # Debug checking
426 AC_MSG_CHECKING(for enabled debugging)
427 AC_ARG_ENABLE(debug,
428 [  --enable-debug          Enable debugging (warning: it is heavy!)],
429 [ case "${enableval}" in
430   yes) 
431     AC_MSG_RESULT(yes)
432     AC_DEFINE(SILC_DEBUG)
433     CFLAGS="-O -g $CFLAGS"
434     ;;
435   *)
436     AC_MSG_RESULT(no)
437     CFLAGS="-O2 -g $CFLAGS"
438     ;;
439 esac ], CFLAGS="-O2 -g $CFLAGS"
440         AC_MSG_RESULT(no))
441
442 # SOCKS4 support checking
443 AC_MSG_CHECKING(whether to support SOCKS4)
444 AC_ARG_WITH(socks4,
445 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
446 [ case "$withval" in
447   no)
448     AC_MSG_RESULT(no)
449     ;;
450   *)
451     AC_MSG_RESULT(yes)
452     socks=4
453
454     if test -d "$withval/include"; then
455       CFLAGS="$CFLAGS -I$withval/include"
456     else
457       CFLAGS="$CFLAGS -I$withval"
458     fi
459     if test -d "$withval/lib"; then
460       withval="-L$withval/lib -lsocks"
461     else
462       withval="-L$withval -lsocks"
463     fi
464
465     LIBS="$withval $LIBS"
466
467     AC_TRY_LINK([],
468                 [ Rconnect(); ],
469                 [],
470                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
471       ;;
472   esac ],
473   AC_MSG_RESULT(no)
474 )   
475
476 # SOCKS5 support checking
477 AC_MSG_CHECKING(whether to support SOCKS5)
478 AC_ARG_WITH(socks5,
479 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
480 [ case "$withval" in
481   no)
482     AC_MSG_RESULT(no)
483     ;;
484   *)
485     AC_MSG_RESULT(yes)
486     socks=5
487
488     if test -d "$withval/include"; then
489       CFLAGS="$CFLAGS -I$withval/include"
490     else
491       CFLAGS="$CFLAGS -I$withval"
492     fi
493     if test -d "$withval/lib"; then
494       withval="-L$withval/lib -lsocks5"
495     else
496       withval="-L$withval -lsocks5"
497     fi 
498
499     LIBS="$withval $LIBS"
500
501     AC_TRY_LINK([],
502                 [ SOCKSconnect(); ],
503                 [],
504                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
505       ;;
506   esac ],
507   AC_MSG_RESULT(no)
508 )   
509
510 if test "x$socks" = "x4"; then
511   AC_DEFINE(SOCKS)
512   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
513 fi
514
515 if test "x$socks" = "x5"; then
516   AC_DEFINE(SOCKS)
517   AC_DEFINE(SOCKS5)
518   AC_DEFINE(Rconnect, SOCKSconnect)
519   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
520   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
521   AC_DEFINE(Rbind, SOCKSbind)
522   AC_DEFINE(Raccept, SOCKSaccept)
523   AC_DEFINE(Rlisten, SOCKSlisten)
524   AC_DEFINE(Rselect, SOCKSselect)
525   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
526   AC_DEFINE(Rsendto, SOCKSsendto)
527   AC_DEFINE(Rrecv, SOCKSrecv)
528   AC_DEFINE(Rsend, SOCKSsend)
529   AC_DEFINE(Rread, SOCKSread)
530   AC_DEFINE(Rwrite, SOCKSwrite)
531   AC_DEFINE(Rrresvport, SOCKSrresvport)
532   AC_DEFINE(Rshutdown, SOCKSshutdown)
533   AC_DEFINE(Rlisten, SOCKSlisten)
534   AC_DEFINE(Rclose, SOCKSclose)
535   AC_DEFINE(Rdup, SOCKSdup)
536   AC_DEFINE(Rdup2, SOCKSdup2)
537   AC_DEFINE(Rfclose, SOCKSfclose)
538   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
539 fi
540
541 #
542 # MP library checking. First check whether system has GMP. If it has that
543 # then use it. If not then compile the MPI library in the source tree.
544 #
545 mp_gmp=false
546 AC_CHECK_HEADER(gmp.h,
547   AC_CHECK_LIB(gmp, __gmpz_init,
548     mp_gmp=true
549     AC_DEFINE(SILC_MP_GMP)
550     LIBS="$LIBS -L/usr/lib -L/usr/local/lib -lgmp"
551     AC_MSG_RESULT(Using GMP as MP library)
552   )
553 )
554 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
555 if test x$mp_gmp = xfalse; then
556   AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
557   AC_DEFINE(SILC_MP_NSS_MPI)
558   AC_MSG_RESULT(Using NSS MPI as MP library)
559 fi
560
561 AC_ARG_WITH(silcd-config-file,
562 [  --with-silcd-config-file[=PATH]
563                           Use PATH as default configuration file in SILC
564                           server [/etc/silc/silcd.conf]],
565 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
566
567 #
568 # Other configure scripts
569 #
570 AC_CONFIG_SUBDIRS(irssi)
571 AC_CONFIG_SUBDIRS(lib/dotconf)
572 AC_CONFIG_SUBDIRS(lib/trq)
573 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
574 #AC_CONFIG_SUBDIRS(lib/zlib)
575
576 SILC_TOP_SRCDIR=`pwd`
577 AC_SUBST(SILC_TOP_SRCDIR)
578 #SILC_INSTALL_PREFIX=$ac_default_prefix
579 #AC_SUBST(SILC_INSTALL_PREFIX)
580 AC_SUBST(LIBS)
581 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
582 AC_SUBST(INCLUDE_DEFINES_INT)
583
584 #
585 # Makefile outputs
586 #
587 AC_OUTPUT( \
588 Makefile
589 Makefile.defines
590 Makefile.defines_int
591 irssi/Makefile.defines
592 irssi/Makefile.defines_int
593 doc/Makefile
594 includes/Makefile
595 lib/Makefile
596 lib/contrib/Makefile
597 lib/silcclient/Makefile
598 lib/silccore/Makefile
599 lib/silccrypt/Makefile
600 lib/silcmath/Makefile
601 lib/silcsim/Makefile
602 lib/silcsim/modules/Makefile
603 lib/silcske/Makefile
604 lib/silcutil/Makefile
605 silc/Makefile
606 silcd/Makefile)