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