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 # XXX
50 # Compiler flags
51 if test "$GCC"; then
52   CFLAGS="-finline-functions $CFLAGS"
53 else
54   # Currently GCC is only supported compiler
55   AC_MSG_ERROR(GCC is only supported compiler currently)
56 fi
57
58 # Program checking
59 AC_PROG_INSTALL
60 AC_PROG_RANLIB
61 AC_PROG_MAKE_SET
62
63 # Header checking
64 AC_HEADER_STDC
65 AC_HEADER_TIME
66 AC_HEADER_STAT
67
68 # More header checking
69 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
70 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
71 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h netdb.h)
72 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
73 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h regex.h)
74 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h)
75
76 # Data type checking
77 AC_TYPE_SIGNAL
78 AC_TYPE_SIZE_T
79 AC_TYPE_MODE_T
80 AC_TYPE_UID_T
81 AC_TYPE_PID_T
82
83 AC_CHECK_SIZEOF(long long, 0)
84 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long)
85 AC_CHECK_SIZEOF(long, 0)
86 AC_DEFINE_UNQUOTED(SILC_SIZEOF_LONG, $ac_cv_sizeof_long)
87 AC_CHECK_SIZEOF(int, 0)
88 AC_DEFINE_UNQUOTED(SILC_SIZEOF_INT, $ac_cv_sizeof_int)
89 AC_CHECK_SIZEOF(short, 0)
90 AC_DEFINE_UNQUOTED(SILC_SIZEOF_SHORT, $ac_cv_sizeof_short)
91 AC_CHECK_SIZEOF(char, 0)
92 AC_DEFINE_UNQUOTED(SILC_SIZEOF_CHAR, $ac_cv_sizeof_char)
93 AC_CHECK_SIZEOF(void *, 0)
94 AC_DEFINE_UNQUOTED(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
95
96 # Function and library checking
97 AC_CHECK_FUNC(initscr, ac_initscr_found=1, ac_initscr_found=0)
98 if test x$ac_initscr_found = x0; then
99     AC_CHECK_LIB(ncurses, initscr, LIBS="$LIBS -lncurses")
100 fi
101 AC_CHECK_FUNC(gethostbyname, ac_gethostbyname_found=1,
102 ac_gethostbyname_found=0)
103 if test x$ac_gethostbyname_found = x0; then
104     AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")
105     AC_CHECK_FUNC(res_gethostbyname, ac_res_ghbn_found=1, ac_res_ghbn_found=0)
106     if test x$ac_res_ghbn_found = x0; then
107         AC_CHECK_LIB(resolv, res_gethostbyname,  LIBS="$LIBS -lresolv")
108     fi
109 fi
110 AC_CHECK_FUNC(socket, ac_socket_found=1, ac_socket_found=0)
111 if test x$ac_socket_found = x0; then
112     AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket")
113 fi
114 AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
115 AC_CHECK_FUNCS(select listen bind shutdown close connect)
116 AC_CHECK_FUNCS(fcntl setsockopt)
117 AC_CHECK_FUNCS(getopt_long time)
118 AC_CHECK_FUNCS(mlock munlock)
119 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
120 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
121 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
122
123 # SIM support checking
124 # XXX These needs to be changed as more supported platforms appear.
125 # XXX This probably needs to be made platform dependant check.
126 sim_support=false
127 AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
128 AC_CHECKING(for SIM support)
129 AC_CHECK_HEADERS(dlfcn.h, 
130   AC_CHECK_LIB(dl, dlopen, 
131     AC_DEFINE(SILC_SIM) 
132     sim_support=true
133     AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue)
134     AC_MSG_RESULT(enabled SIM support)
135     LIBS="$LIBS -ldl",
136     AC_MSG_RESULT(no SIM support found)),
137   AC_MSG_RESULT(no SIM support found))
138
139 #
140 # Installation
141 #
142
143 # Default installation destination
144 AC_PREFIX_DEFAULT(/usr/local/silc)
145
146 # etc directory
147 ETCDIR="/etc/silc"
148 AC_ARG_WITH(etcdir,
149 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
150 [ case "$withval" in
151   no)
152     ;;
153   yes)
154     ;;
155   *)
156     ETCDIR="$withwal"
157     ;;
158   esac ],
159 )
160 AC_SUBST(ETCDIR)
161
162 # help directory
163 HELPDIR="help"
164 AC_ARG_WITH(helpdir,
165 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
166 [ case "$withval" in
167   no)
168     ;;
169   yes)
170     ;;
171   *)
172     HELPDIR="$withwal"
173     ;;
174   esac ],
175 )
176 AC_SUBST(HELPDIR)
177
178 # doc directory
179 DOCDIR="doc"
180 AC_ARG_WITH(docdir,
181 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
182 [ case "$withval" in
183   no)
184     ;;
185   yes)
186     ;;
187   *)
188     DOCDIR="$withwal"
189     ;;
190   esac ],
191 )
192 AC_SUBST(DOCDIR)
193
194 # SIM modules directory
195 MODULESDIR="modules"
196 AC_ARG_WITH(simdir,
197 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
198 [ case "$withval" in
199   no)
200     ;;
201   yes)
202     ;;
203   *)
204     MODULESDIR="$withwal"
205     ;;
206   esac ],
207 )
208 AC_SUBST(MODULESDIR)
209
210 # Logs directory
211 LOGSDIR="logs"
212 AC_ARG_WITH(logsdir,
213 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
214 [ case "$withval" in
215   no)
216     ;;
217   yes)
218     ;;
219   *)
220     LOGSDIR="$withwal"
221     ;;
222   esac ],
223 )
224 AC_SUBST(LOGSDIR)
225
226 # Debug checking
227 AC_MSG_CHECKING(for enabled debugging)
228 AC_ARG_ENABLE(debug,
229 [  --enable-debug          Enable debugging (warning: it is heavy!)],
230 [ case "${enableval}" in
231   yes) 
232     AC_MSG_RESULT(yes)
233     AC_DEFINE(SILC_DEBUG)
234     CFLAGS="-O -g $CFLAGS"
235     ;;
236   *)
237     AC_MSG_RESULT(no)
238     CFLAGS="-O2 -g $CFLAGS"
239     ;;
240 esac ], CFLAGS="-O2 -g $CFLAGS"
241         AC_MSG_RESULT(no))
242
243 # SOCKS4 support checking
244 AC_MSG_CHECKING(whether to support SOCKS4)
245 AC_ARG_WITH(socks4,
246 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
247 [ case "$withval" in
248   no)
249     AC_MSG_RESULT(no)
250     ;;
251   *)
252     AC_MSG_RESULT(yes)
253     socks=4
254
255     if test -d "$withval/include"; then
256       CFLAGS="$CFLAGS -I$withval/include"
257     else
258       CFLAGS="$CFLAGS -I$withval"
259     fi
260     if test -d "$withval/lib"; then
261       withval="-L$withval/lib -lsocks"
262     else
263       withval="-L$withval -lsocks"
264     fi
265
266     LIBS="$withval $LIBS"
267
268     AC_TRY_LINK([],
269                 [ Rconnect(); ],
270                 [],
271                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
272       ;;
273   esac ],
274   AC_MSG_RESULT(no)
275 )   
276
277 # SOCKS5 support checking
278 AC_MSG_CHECKING(whether to support SOCKS5)
279 AC_ARG_WITH(socks5,
280 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
281 [ case "$withval" in
282   no)
283     AC_MSG_RESULT(no)
284     ;;
285   *)
286     AC_MSG_RESULT(yes)
287     socks=5
288
289     if test -d "$withval/include"; then
290       CFLAGS="$CFLAGS -I$withval/include"
291     else
292       CFLAGS="$CFLAGS -I$withval"
293     fi
294     if test -d "$withval/lib"; then
295       withval="-L$withval/lib -lsocks5"
296     else
297       withval="-L$withval -lsocks5"
298     fi 
299
300     LIBS="$withval $LIBS"
301
302     AC_TRY_LINK([],
303                 [ SOCKSconnect(); ],
304                 [],
305                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
306       ;;
307   esac ],
308   AC_MSG_RESULT(no)
309 )   
310
311 if test "x$socks" = "x4"; then
312   AC_DEFINE(SOCKS)
313   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
314 fi
315
316 if test "x$socks" = "x5"; then
317   AC_DEFINE(SOCKS)
318   AC_DEFINE(SOCKS5)
319   AC_DEFINE(Rconnect, SOCKSconnect)
320   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
321   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
322   AC_DEFINE(Rbind, SOCKSbind)
323   AC_DEFINE(Raccept, SOCKSaccept)
324   AC_DEFINE(Rlisten, SOCKSlisten)
325   AC_DEFINE(Rselect, SOCKSselect)
326   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
327   AC_DEFINE(Rsendto, SOCKSsendto)
328   AC_DEFINE(Rrecv, SOCKSrecv)
329   AC_DEFINE(Rsend, SOCKSsend)
330   AC_DEFINE(Rread, SOCKSread)
331   AC_DEFINE(Rwrite, SOCKSwrite)
332   AC_DEFINE(Rrresvport, SOCKSrresvport)
333   AC_DEFINE(Rshutdown, SOCKSshutdown)
334   AC_DEFINE(Rlisten, SOCKSlisten)
335   AC_DEFINE(Rclose, SOCKSclose)
336   AC_DEFINE(Rdup, SOCKSdup)
337   AC_DEFINE(Rdup2, SOCKSdup2)
338   AC_DEFINE(Rfclose, SOCKSfclose)
339   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
340 fi
341
342 # GMP Library checking
343 AC_MSG_CHECKING(whether to compile GMP)
344 AC_ARG_WITH(gmp,
345 [  --with-gmp              Build the GMP in the SILC source tree],
346 [ case "${withval}" in
347   yes) 
348     AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = xyes)
349     AC_MSG_RESULT(yes)
350     ;;
351   *)
352     AC_CHECK_HEADER(gmp.h,
353       AC_CHECK_LIB(gmp, __gmpz_init,
354         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = yes)
355         LIBS="$LIBS -L/usr/lib -L/usr/local/lib -lgmp"
356         AC_MSG_RESULT(GMP will not be compiled),
357         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
358         AC_MSG_RESULT(GMP will be compiled)
359       ),
360       AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
361       AC_MSG_RESULT(GMP will be compiled)
362     )
363     ;;
364 esac ], [
365   AC_CHECK_HEADER(gmp.h,
366     AC_CHECK_LIB(gmp, __gmpz_init,
367       build_gmp=false
368       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
369       LIBS="$LIBS -L/usr/lib -L/usr/local/lib -lgmp"
370       AC_MSG_RESULT(GMP will not be compiled),
371       build_gmp=true
372       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
373       AC_MSG_RESULT(GMP will be compiled)
374     ),
375     build_gmp=true
376     AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
377     AC_MSG_RESULT(GMP will be compiled)
378   )
379 ])
380
381 AC_ARG_WITH(silcd-config-file,
382 [  --with-silcd-config-file[=PATH]
383                           Use PATH as default configuration file in SILC
384                           server [/etc/silc/silcd.conf]],
385 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
386
387 #
388 # Other configure scripts
389 #
390 AC_CONFIG_SUBDIRS(irssi)
391 AC_CONFIG_SUBDIRS(lib/dotconf)
392 AC_CONFIG_SUBDIRS(lib/silcmath/gmp)
393 AC_CONFIG_SUBDIRS(lib/trq)
394 #AC_CONFIG_SUBDIRS(lib/zlib)
395
396 SILC_TOP_SRCDIR=`pwd`
397 AC_SUBST(SILC_TOP_SRCDIR)
398 AC_SUBST(LIBS)
399 INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int"
400 AC_SUBST(INCLUDE_DEFINES_INT)
401
402 #
403 # Makefile outputs
404 #
405 AC_OUTPUT( \
406 Makefile
407 Makefile.defines
408 Makefile.defines_int
409 irssi/Makefile.defines
410 irssi/Makefile.defines_int
411 doc/Makefile
412 includes/Makefile
413 lib/Makefile
414 lib/contrib/Makefile
415 lib/silcclient/Makefile
416 lib/silccore/Makefile
417 lib/silccrypt/Makefile
418 lib/silcmath/Makefile
419 lib/silcsim/Makefile
420 lib/silcsim/modules/Makefile
421 lib/silcske/Makefile
422 lib/silcutil/Makefile
423 silc/Makefile
424 silcd/Makefile)