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(sunos-curses,
109           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
110           if test x$withval = xyes; then
111                 AC_USE_SUNOS_CURSES
112           fi
113         ])
114
115         AC_ARG_WITH(osf1-curses,
116           [  --with-osf1-curses      Used to force OSF/1 curses],[
117           if test x$withval = xyes; then
118                 AC_USE_OSF1_CURSES
119           fi
120         ])
121
122         AC_ARG_WITH(vcurses,
123           [  --with-vcurses[=incdir] Used to force SysV curses],
124           if test x$withval != xyes; then
125                 CURSES_INCLUDEDIR="-I$withval"
126           fi
127           AC_USE_SYSV_CURSES
128         )
129
130         AC_ARG_WITH(ncurses,
131           [  --with-ncurses[=dir]    Compile with ncurses/locate base dir],
132           if test x$withval = xno ; then
133                 search_ncurses=false
134           elif test x$withval != xyes ; then
135                 AC_NCURSES($withval/include, ncurses.h, -L$withval/lib -lncurses, -I$withval/include, "ncurses on $withval/include")
136           fi
137         )
138
139         if $search_ncurses
140         then
141                 AC_SEARCH_NCURSES()
142         fi
143 ])
144
145
146 AC_DEFUN(AC_USE_SUNOS_CURSES, [
147         search_ncurses=false
148         screen_manager="SunOS 4.x /usr/5include curses"
149         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
150         AC_DEFINE(USE_SUNOS_CURSES)
151         AC_DEFINE(HAS_CURSES)
152         has_curses=true
153         AC_DEFINE(NO_COLOR_CURSES)
154         AC_DEFINE(USE_SYSV_CURSES)
155         CURSES_INCLUDEDIR="-I/usr/5include"
156         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
157         AC_MSG_RESULT(Please note that some screen refreshs may fail)
158 ])
159
160 AC_DEFUN(AC_USE_OSF1_CURSES, [
161        AC_MSG_RESULT(Using OSF1 curses)
162        search_ncurses=false
163        screen_manager="OSF1 curses"
164        AC_DEFINE(HAS_CURSES)
165        has_curses=true
166        AC_DEFINE(NO_COLOR_CURSES)
167        AC_DEFINE(USE_SYSV_CURSES)
168        CURSES_LIBS="-lcurses"
169 ])
170
171 AC_DEFUN(AC_USE_SYSV_CURSES, [
172         AC_MSG_RESULT(Using SysV curses)
173         AC_DEFINE(HAS_CURSES)
174         has_curses=true
175         AC_DEFINE(USE_SYSV_CURSES)
176         search_ncurses=false
177         screen_manager="SysV/curses"
178         CURSES_LIBS="-lcurses"
179 ])
180
181 dnl
182 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
183 dnl
184 AC_DEFUN(AC_NCURSES, [
185     if $search_ncurses
186     then
187         if test -f $1/$2
188         then
189             AC_MSG_RESULT(Found ncurses on $1/$2)
190
191             CURSES_LIBS="$3"
192             AC_CHECK_LIB(ncurses, initscr, [
193             ], [
194                 CHECKLIBS=`echo "$3"|sed 's/-lncurses/-lcurses/g'`
195                 AC_CHECK_LIB(curses, initscr, [
196                         CURSES_LIBS="$CHECKLIBS"
197                 ],, $CHECKLIBS)
198             ], $CURSES_LIBS)
199             CURSES_INCLUDEDIR="$4"
200             search_ncurses=false
201             screen_manager=$5
202             AC_DEFINE(HAS_CURSES)
203             has_curses=true
204             has_ncurses=true
205             AC_DEFINE(USE_NCURSES)
206         fi
207     fi
208 ])
209
210 AC_DEFUN(AC_SEARCH_NCURSES, [
211     AC_CHECKING("location of ncurses.h file")
212
213     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
214     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
215     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
216     AC_NCURSES(/usr/pkg/include, ncurses.h, -L/usr/pkg/lib -lncurses, -I/usr/pkg/include, "ncurses on /usr/pkg")
217     AC_NCURSES(/usr/contrib/include, ncurses.h, -L/usr/contrib/lib -lncurses, -I/usr/contrib/include, "ncurses on /usr/contrib")
218     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")
219
220     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")
221
222     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
223
224     dnl
225     dnl We couldn't find ncurses, try SysV curses
226     dnl
227     if $search_ncurses 
228     then
229         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
230             AC_USE_SYSV_CURSES)
231         AC_EGREP_CPP(USE_NCURSES,[
232 #include <curses.h>
233 #ifdef __NCURSES_H
234 #undef USE_NCURSES
235 USE_NCURSES
236 #endif
237 ],[
238         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
239         AC_DEFINE(HAS_CURSES)
240         has_curses=true
241         has_ncurses=true
242         AC_DEFINE(USE_NCURSES)
243         search_ncurses=false
244         screen_manager="ncurses installed as curses"
245 ])
246     fi
247
248     dnl
249     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
250     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
251     dnl should be replaced by a more fine grained selection routine
252     dnl
253     if $search_ncurses
254     then
255         if test -f /usr/5include/curses.h
256         then
257             AC_USE_SUNOS_CURSES
258         fi
259     fi
260
261     dnl use whatever curses there happens to be
262     if $search_ncurses
263     then
264         if test -f /usr/include/curses.h
265         then
266           CURSES_LIBS="-lcurses"
267           AC_DEFINE(HAS_CURSES)
268           has_curses=true
269           search_ncurses=false
270           screen_manager="curses"
271         fi
272     fi
273 ])
274
275 AC_CHECK_CURSES
276 LIBS="$LIBS $CURSES_LIBS"
277
278 # Function and library checking
279 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
280 ac_gethostbyname_found=0)
281 if test x$ac_gethostbyname_found = x0; then
282     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
283     AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
284     if test x$ac_res_ghbn_found = x0; then
285         AC_CHECK_LIB(resolv, res_gethostbyname,  LIBS="$LIBS -lresolv")
286     fi
287 fi
288 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
289 if test x$ac_socket_found = x0; then
290     AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
291 fi
292 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
293 AC_CHECK_FUNCS(select listen bind shutdown close connect)
294 AC_CHECK_FUNCS(fcntl setsockopt)
295 AC_CHECK_FUNCS(getopt_long time)
296 AC_CHECK_FUNCS(mlock munlock)
297 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
298 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
299 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
300
301 # SIM support checking
302 # XXX These needs to be changed as more supported platforms appear.
303 # XXX This probably needs to be made platform dependant check.
304 sim_support=false
305 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
306 AC_CHECKING(for SIM support)
307 AC_CHECK_HEADERS(dlfcn.h, 
308   AC_CHECK_LIB(dl, dlopen, 
309     AC_DEFINE(SILC_SIM) 
310     sim_support=true
311     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
312     AC_MSG_RESULT(enabled SIM support)
313     LIBS="$LIBS -ldl",
314     AC_MSG_RESULT(no SIM support found)),
315   AC_MSG_RESULT(no SIM support found))
316
317 #
318 # Installation
319 #
320
321 # Default installation destination
322 AC_PREFIX_DEFAULT(/usr/local/silc)
323
324 # etc directory
325 ETCDIR="/etc/silc"
326 AC_ARG_WITH(etcdir,
327 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
328 [ case "$withval" in
329   no)
330     ;;
331   yes)
332     ETCDIR="$withval"
333     ;;
334   *)
335     ETCDIR="$withval"
336     ;;
337   esac ],
338 )
339 AC_SUBST(ETCDIR)
340 AC_DEFINE_UNQUOTED(SILC_ETCDIR, "$ETCDIR")
341
342 # help directory
343 HELPDIR="help"
344 AC_ARG_WITH(helpdir,
345 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
346 [ case "$withval" in
347   no)
348     ;;
349   yes)
350     HELPDIR="$withval"
351     ;;
352   *)
353     HELPDIR="$withval"
354     ;;
355   esac ],
356 )
357 AC_SUBST(HELPDIR)
358 AC_DEFINE_UNQUOTED(SILC_HELPDIR, "$HELPDIR")
359
360 # doc directory
361 DOCDIR="doc"
362 AC_ARG_WITH(docdir,
363 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
364 [ case "$withval" in
365   no)
366     ;;
367   yes)
368     DOCDIR="$withval"
369     ;;
370   *)
371     DOCDIR="$withval"
372     ;;
373   esac ],
374 )
375 AC_SUBST(DOCDIR)
376 AC_DEFINE_UNQUOTED(SILC_DOCDIR, "$DOCDIR")
377
378 # SIM modules directory
379 MODULESDIR="modules"
380 AC_ARG_WITH(simdir,
381 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
382 [ case "$withval" in
383   no)
384     ;;
385   yes)
386     MODULESDIR="$withval"
387     ;;
388   *)
389     MODULESDIR="$withval"
390     ;;
391   esac ],
392 )
393 AC_SUBST(MODULESDIR)
394 AC_DEFINE_UNQUOTED(SILC_MODULESDIR, "$MODULESDIR")
395
396 # Logs directory
397 LOGSDIR="logs"
398 AC_ARG_WITH(logsdir,
399 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
400 [ case "$withval" in
401   no)
402     ;;
403   yes)
404     LOGSDIR="$withval"
405     ;;
406   *)
407     LOGSDIR="$withval"
408     ;;
409   esac ],
410 )
411 AC_SUBST(LOGSDIR)
412 AC_DEFINE_UNQUOTED(SILC_LOGSDIR, "$LOGSDIR")
413
414 # SOCKS4 support checking
415 AC_MSG_CHECKING(whether to support SOCKS4)
416 AC_ARG_WITH(socks4,
417 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
418 [ case "$withval" in
419   no)
420     AC_MSG_RESULT(no)
421     ;;
422   *)
423     AC_MSG_RESULT(yes)
424     socks=4
425
426     if test -d "$withval/include"; then
427       CFLAGS="$CFLAGS -I$withval/include"
428     else
429       CFLAGS="$CFLAGS -I$withval"
430     fi
431     if test -d "$withval/lib"; then
432       withval="-L$withval/lib -lsocks"
433     else
434       withval="-L$withval -lsocks"
435     fi
436
437     LIBS="$withval $LIBS"
438
439     AC_TRY_LINK([],
440                 [ Rconnect(); ],
441                 [],
442                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
443       ;;
444   esac ],
445   AC_MSG_RESULT(no)
446 )   
447
448 # SOCKS5 support checking
449 AC_MSG_CHECKING(whether to support SOCKS5)
450 AC_ARG_WITH(socks5,
451 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
452 [ case "$withval" in
453   no)
454     AC_MSG_RESULT(no)
455     ;;
456   *)
457     AC_MSG_RESULT(yes)
458     socks=5
459
460     if test -d "$withval/include"; then
461       CFLAGS="$CFLAGS -I$withval/include"
462     else
463       CFLAGS="$CFLAGS -I$withval"
464     fi
465     if test -d "$withval/lib"; then
466       withval="-L$withval/lib -lsocks5"
467     else
468       withval="-L$withval -lsocks5"
469     fi 
470
471     LIBS="$withval $LIBS"
472
473     AC_TRY_LINK([],
474                 [ SOCKSconnect(); ],
475                 [],
476                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
477       ;;
478   esac ],
479   AC_MSG_RESULT(no)
480 )   
481
482 if test "x$socks" = "x4"; then
483   AC_DEFINE(SOCKS)
484   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
485 fi
486
487 if test "x$socks" = "x5"; then
488   AC_DEFINE(SOCKS)
489   AC_DEFINE(SOCKS5)
490   AC_DEFINE(Rconnect, SOCKSconnect)
491   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
492   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
493   AC_DEFINE(Rbind, SOCKSbind)
494   AC_DEFINE(Raccept, SOCKSaccept)
495   AC_DEFINE(Rlisten, SOCKSlisten)
496   AC_DEFINE(Rselect, SOCKSselect)
497   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
498   AC_DEFINE(Rsendto, SOCKSsendto)
499   AC_DEFINE(Rrecv, SOCKSrecv)
500   AC_DEFINE(Rsend, SOCKSsend)
501   AC_DEFINE(Rread, SOCKSread)
502   AC_DEFINE(Rwrite, SOCKSwrite)
503   AC_DEFINE(Rrresvport, SOCKSrresvport)
504   AC_DEFINE(Rshutdown, SOCKSshutdown)
505   AC_DEFINE(Rlisten, SOCKSlisten)
506   AC_DEFINE(Rclose, SOCKSclose)
507   AC_DEFINE(Rdup, SOCKSdup)
508   AC_DEFINE(Rdup2, SOCKSdup2)
509   AC_DEFINE(Rfclose, SOCKSfclose)
510   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
511 fi
512
513 #
514 # MP library checking. First check whether system has GMP. If it has that
515 # then use it. If not then compile the MPI library in the source tree.
516 #
517 mp_gmp=false
518 AC_CHECK_HEADER(gmp.h,
519   AC_CHECK_LIB(gmp, __gmpz_init,
520     mp_gmp=true
521     AC_DEFINE(SILC_MP_GMP)
522     LIBS="$LIBS -L/usr/lib -L/usr/local/lib -lgmp"
523     AC_MSG_RESULT(Using GMP as MP library)
524   )
525 )
526 AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue)
527 if test x$mp_gmp = xfalse; then
528   AM_CONDITIONAL(SILC_MP_NSS_MPI, test x$mp_gmp = xfalse)
529   AC_DEFINE(SILC_MP_NSS_MPI)
530   AC_MSG_RESULT(Using NSS MPI as MP library)
531 fi
532
533 AC_ARG_WITH(silcd-config-file,
534 [  --with-silcd-config-file[=PATH]
535                           Use PATH as default configuration file in SILC
536                           server [/etc/silc/silcd.conf]],
537 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
538
539 # Native WIN32 compilation under cygwin
540 AC_ARG_WITH(win32,
541 [  --with-win32            Compile native WIN32 code (-mno-cygwin)],
542 [ AC_DEFINE(SILC_WIN32)
543   AM_CONDITIONAL(SILC_WIN32, test xtrue = xtrue)
544   CFLAGS="-mno-cygwin $CFLAGS" 
545   LIBS="-lwsock32 $LIBS" ])
546
547 # Debug checking
548 AC_MSG_CHECKING(for enabled debugging)
549 AC_ARG_ENABLE(debug,
550 [  --enable-debug          Enable debugging (warning: it is heavy!)],
551 [ case "${enableval}" in
552   yes) 
553     AC_MSG_RESULT(yes)
554     AC_DEFINE(SILC_DEBUG)
555     CFLAGS="-O -g $CFLAGS"
556     ;;
557   *)
558     AC_MSG_RESULT(no)
559     CFLAGS="-O2 -g $CFLAGS"
560     ;;
561 esac ], CFLAGS="-O2 -g $CFLAGS"
562         AC_MSG_RESULT(no))
563
564 #
565 # Other configure scripts
566 #
567 AC_CONFIG_SUBDIRS(lib/dotconf)
568 AC_CONFIG_SUBDIRS(lib/trq)
569 AC_CONFIG_SUBDIRS(lib/silcmath/mpi)
570 AC_CONFIG_SUBDIRS(irssi)
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 lib/silcutil/unix/Makefile
603 lib/silcutil/win32/Makefile
604 silc/Makefile
605 silcd/Makefile)