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 date. Do not edit!
37 AM_INIT_AUTOMAKE(silc, YYYYMMDD)
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 checking
97 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
98 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
99 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
100 AC_CHECK_FUNCS(gethostname gethostbyname gethostbyaddr)
101 AC_CHECK_FUNCS(select socket listen bind shutdown close connect)
102 AC_CHECK_FUNCS(fcntl setsockopt)
103 AC_CHECK_FUNCS(getservbyname getservbyport)
104 AC_CHECK_FUNCS(getopt_long time)
105 AC_CHECK_FUNCS(mlock munlock)
106
107 # SIM support checking
108 # XXX These needs to be changed as more supported platforms appear.
109 # XXX This probably needs to be made platform dependant check.
110 AC_CHECKING(for SIM support)
111 AC_CHECK_HEADERS(dlfcn.h, 
112   AC_CHECK_LIB(dl, dlopen, 
113     AC_DEFINE(SILC_SIM) 
114     AC_MSG_RESULT(enabled SIM support)
115     LIBS="$LIBS -ldl",
116     AC_MSG_RESULT(no SIM support found)),
117   AC_MSG_RESULT(no SIM support found))
118
119 #
120 # Installation
121 #
122
123 # Default installation destination
124 AC_PREFIX_DEFAULT(/usr/local/silc/)
125
126 # etc directory
127 ETCDIR="/etc/silc"
128 AC_ARG_WITH(etcdir,
129 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
130 [ case "$withval" in
131   no)
132     ;;
133   yes)
134     ;;
135   *)
136     ETCDIR="$withwal"
137     ;;
138   esac ],
139 )
140 AC_SUBST(ETCDIR)
141
142 # help directory
143 HELPDIR="help"
144 AC_ARG_WITH(helpdir,
145 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
146 [ case "$withval" in
147   no)
148     ;;
149   yes)
150     ;;
151   *)
152     HELPDIR="$withwal"
153     ;;
154   esac ],
155 )
156 AC_SUBST(HELPDIR)
157
158 # doc directory
159 DOCDIR="doc"
160 AC_ARG_WITH(docdir,
161 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
162 [ case "$withval" in
163   no)
164     ;;
165   yes)
166     ;;
167   *)
168     DOCDIR="$withwal"
169     ;;
170   esac ],
171 )
172 AC_SUBST(DOCDIR)
173
174 # SIM modules directory
175 MODULESDIR="modules"
176 AC_ARG_WITH(simdir,
177 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
178 [ case "$withval" in
179   no)
180     ;;
181   yes)
182     ;;
183   *)
184     MODULESDIR="$withwal"
185     ;;
186   esac ],
187 )
188 AC_SUBST(MODULESDIR)
189
190 # Debug checking
191 AC_MSG_CHECKING(for enabled debugging)
192 AC_ARG_ENABLE(debug,
193 [  --enable-debug          Enable debugging (warning: it is heavy!)],
194 [ case "${enableval}" in
195   yes) 
196     AC_MSG_RESULT(yes)
197     AC_DEFINE(SILC_DEBUG)
198     CFLAGS="-O -g $CFLAGS"
199     ;;
200   *)
201     AC_MSG_RESULT(no)
202     CFLAGS="-O2 -g $CFLAGS"
203     ;;
204 esac ], CFLAGS="-O2 -g $CFLAGS"
205         AC_MSG_RESULT(no))
206
207 # SOCKS4 support checking
208 AC_MSG_CHECKING(whether to support SOCKS4)
209 AC_ARG_WITH(socks4,
210 [  --with-socks4[=PATH]    Compile with SOCKS4 support.],
211 [ case "$withval" in
212   no)
213     AC_MSG_RESULT(no)
214     ;;
215   *)
216     AC_MSG_RESULT(yes)
217     socks=4
218
219     if test -d "$withval/include"; then
220       CFLAGS="$CFLAGS -I$withval/include"
221     else
222       CFLAGS="$CFLAGS -I$withval"
223     fi
224     if test -d "$withval/lib"; then
225       withval="-L$withval/lib -lsocks"
226     else
227       withval="-L$withval -lsocks"
228     fi
229
230     LIBS="$withval $LIBS"
231
232     AC_TRY_LINK([],
233                 [ Rconnect(); ],
234                 [],
235                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
236       ;;
237   esac ],
238   AC_MSG_RESULT(no)
239 )   
240
241 # SOCKS5 support checking
242 AC_MSG_CHECKING(whether to support SOCKS5)
243 AC_ARG_WITH(socks5,
244 [  --with-socks5[=PATH]    Compile with SOCKS5 support.],
245 [ case "$withval" in
246   no)
247     AC_MSG_RESULT(no)
248     ;;
249   *)
250     AC_MSG_RESULT(yes)
251     socks=5
252
253     if test -d "$withval/include"; then
254       CFLAGS="$CFLAGS -I$withval/include"
255     else
256       CFLAGS="$CFLAGS -I$withval"
257     fi
258     if test -d "$withval/lib"; then
259       withval="-L$withval/lib -lsocks5"
260     else
261       withval="-L$withval -lsocks5"
262     fi 
263
264     LIBS="$withval $LIBS"
265
266     AC_TRY_LINK([],
267                 [ SOCKSconnect(); ],
268                 [],
269                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
270       ;;
271   esac ],
272   AC_MSG_RESULT(no)
273 )   
274
275 if test "x$socks" = "x4"; then
276   AC_DEFINE(SOCKS)
277   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
278 fi
279
280 if test "x$socks" = "x5"; then
281   AC_DEFINE(SOCKS)
282   AC_DEFINE(SOCKS5)
283   AC_DEFINE(Rconnect, SOCKSconnect)
284   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
285   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
286   AC_DEFINE(Rbind, SOCKSbind)
287   AC_DEFINE(Raccept, SOCKSaccept)
288   AC_DEFINE(Rlisten, SOCKSlisten)
289   AC_DEFINE(Rselect, SOCKSselect)
290   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
291   AC_DEFINE(Rsendto, SOCKSsendto)
292   AC_DEFINE(Rrecv, SOCKSrecv)
293   AC_DEFINE(Rsend, SOCKSsend)
294   AC_DEFINE(Rread, SOCKSread)
295   AC_DEFINE(Rwrite, SOCKSwrite)
296   AC_DEFINE(Rrresvport, SOCKSrresvport)
297   AC_DEFINE(Rshutdown, SOCKSshutdown)
298   AC_DEFINE(Rlisten, SOCKSlisten)
299   AC_DEFINE(Rclose, SOCKSclose)
300   AC_DEFINE(Rdup, SOCKSdup)
301   AC_DEFINE(Rdup2, SOCKSdup2)
302   AC_DEFINE(Rfclose, SOCKSfclose)
303   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
304 fi
305
306 # GMP Library checking
307 AC_MSG_CHECKING(whether to compile GMP)
308 AC_ARG_WITH(gmp,
309 [  --with-gmp              Build the GMP in the SILC source tree],
310 [ case "${withval}" in
311   yes) 
312     AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = xyes)
313     AC_MSG_RESULT(yes)
314     ;;
315   *)
316     AC_CHECK_HEADER(gmp.h,
317       AC_CHECK_LIB(gmp, __gmpz_init,
318         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = yes)
319         AC_MSG_RESULT(GMP will not be compiled),
320         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
321         AC_MSG_RESULT(GMP will be compiled)
322       ),
323       AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
324       AC_MSG_RESULT(GMP will be compiled)
325     )
326     ;;
327 esac ], [
328   AC_CHECK_HEADER(gmp.h,
329     AC_CHECK_LIB(gmp, __gmpz_init,
330       build_gmp=false
331       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
332       AC_MSG_RESULT(GMP will not be compiled),
333       build_gmp=true
334       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
335       AC_MSG_RESULT(GMP will be compiled)
336     ),
337     build_gmp=true
338     AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
339     AC_MSG_RESULT(GMP will be compiled)
340   )
341 ])
342
343 AC_ARG_WITH(silcd-config-file,
344 [  --with-silcd-config-file[=PATH]
345                           Use PATH as default configuration file in SILC
346                           server.],
347 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
348
349 # XXX
350 #LIBS="$LIBS -lefence"
351
352 # Other configure scripts
353 #AC_CONFIG_SUBDIRS(lib/zlib)
354 AC_CONFIG_SUBDIRS(lib/dotconf)
355 AC_CONFIG_SUBDIRS(lib/silcmath/gmp)
356 AC_CONFIG_SUBDIRS(lib/trq)
357
358 AC_OUTPUT( \
359 Makefile
360 doc/Makefile
361 includes/Makefile
362 lib/Makefile
363 lib/contrib/Makefile
364 lib/silcclient/Makefile
365 lib/silccore/Makefile
366 lib/silccrypt/Makefile
367 lib/silcmath/Makefile
368 lib/silcsim/Makefile
369 lib/silcsim/modules/Makefile
370 lib/silcske/Makefile
371 lib/silcutil/Makefile
372 silc/Makefile
373 silcd/Makefile)