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, 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 AC_CHECKING(for SIM support)
127 AC_CHECK_HEADERS(dlfcn.h, 
128   AC_CHECK_LIB(dl, dlopen, 
129     AC_DEFINE(SILC_SIM) 
130     AC_MSG_RESULT(enabled SIM support)
131     LIBS="$LIBS -ldl",
132     AC_MSG_RESULT(no SIM support found)),
133   AC_MSG_RESULT(no SIM support found))
134
135 #
136 # Installation
137 #
138
139 # Default installation destination
140 AC_PREFIX_DEFAULT(/usr/local/silc)
141
142 # etc directory
143 ETCDIR="/etc/silc"
144 AC_ARG_WITH(etcdir,
145 [  --with-etcdir[=PATH]    Directory for system files [/etc/silc]],
146 [ case "$withval" in
147   no)
148     ;;
149   yes)
150     ;;
151   *)
152     ETCDIR="$withwal"
153     ;;
154   esac ],
155 )
156 AC_SUBST(ETCDIR)
157
158 # help directory
159 HELPDIR="help"
160 AC_ARG_WITH(helpdir,
161 [  --with-helpdir[=PATH]   Directory for SILC help files [PREFIX/help]],
162 [ case "$withval" in
163   no)
164     ;;
165   yes)
166     ;;
167   *)
168     HELPDIR="$withwal"
169     ;;
170   esac ],
171 )
172 AC_SUBST(HELPDIR)
173
174 # doc directory
175 DOCDIR="doc"
176 AC_ARG_WITH(docdir,
177 [  --with-docdir[=PATH]    Directory for SILC documentation [PREFIX/doc]],
178 [ case "$withval" in
179   no)
180     ;;
181   yes)
182     ;;
183   *)
184     DOCDIR="$withwal"
185     ;;
186   esac ],
187 )
188 AC_SUBST(DOCDIR)
189
190 # SIM modules directory
191 MODULESDIR="modules"
192 AC_ARG_WITH(simdir,
193 [  --with-simdir[=PATH]    Directory for SIM modules [PREFIX/modules]],
194 [ case "$withval" in
195   no)
196     ;;
197   yes)
198     ;;
199   *)
200     MODULESDIR="$withwal"
201     ;;
202   esac ],
203 )
204 AC_SUBST(MODULESDIR)
205
206 # Logs directory
207 LOGSDIR="logs"
208 AC_ARG_WITH(logsdir,
209 [  --with-logsdir[=PATH]   Directory for Server logs [PREFIX/logs]],
210 [ case "$withval" in
211   no)
212     ;;
213   yes)
214     ;;
215   *)
216     LOGSDIR="$withwal"
217     ;;
218   esac ],
219 )
220 AC_SUBST(LOGSDIR)
221
222 # Debug checking
223 AC_MSG_CHECKING(for enabled debugging)
224 AC_ARG_ENABLE(debug,
225 [  --enable-debug          Enable debugging (warning: it is heavy!)],
226 [ case "${enableval}" in
227   yes) 
228     AC_MSG_RESULT(yes)
229     AC_DEFINE(SILC_DEBUG)
230     CFLAGS="-O -g $CFLAGS"
231     ;;
232   *)
233     AC_MSG_RESULT(no)
234     CFLAGS="-O2 -g $CFLAGS"
235     ;;
236 esac ], CFLAGS="-O2 -g $CFLAGS"
237         AC_MSG_RESULT(no))
238
239 # SOCKS4 support checking
240 AC_MSG_CHECKING(whether to support SOCKS4)
241 AC_ARG_WITH(socks4,
242 [  --with-socks4[=PATH]    Compile with SOCKS4 support],
243 [ case "$withval" in
244   no)
245     AC_MSG_RESULT(no)
246     ;;
247   *)
248     AC_MSG_RESULT(yes)
249     socks=4
250
251     if test -d "$withval/include"; then
252       CFLAGS="$CFLAGS -I$withval/include"
253     else
254       CFLAGS="$CFLAGS -I$withval"
255     fi
256     if test -d "$withval/lib"; then
257       withval="-L$withval/lib -lsocks"
258     else
259       withval="-L$withval -lsocks"
260     fi
261
262     LIBS="$withval $LIBS"
263
264     AC_TRY_LINK([],
265                 [ Rconnect(); ],
266                 [],
267                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
268       ;;
269   esac ],
270   AC_MSG_RESULT(no)
271 )   
272
273 # SOCKS5 support checking
274 AC_MSG_CHECKING(whether to support SOCKS5)
275 AC_ARG_WITH(socks5,
276 [  --with-socks5[=PATH]    Compile with SOCKS5 support],
277 [ case "$withval" in
278   no)
279     AC_MSG_RESULT(no)
280     ;;
281   *)
282     AC_MSG_RESULT(yes)
283     socks=5
284
285     if test -d "$withval/include"; then
286       CFLAGS="$CFLAGS -I$withval/include"
287     else
288       CFLAGS="$CFLAGS -I$withval"
289     fi
290     if test -d "$withval/lib"; then
291       withval="-L$withval/lib -lsocks5"
292     else
293       withval="-L$withval -lsocks5"
294     fi 
295
296     LIBS="$withval $LIBS"
297
298     AC_TRY_LINK([],
299                 [ SOCKSconnect(); ],
300                 [],
301                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
302       ;;
303   esac ],
304   AC_MSG_RESULT(no)
305 )   
306
307 if test "x$socks" = "x4"; then
308   AC_DEFINE(SOCKS)
309   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
310 fi
311
312 if test "x$socks" = "x5"; then
313   AC_DEFINE(SOCKS)
314   AC_DEFINE(SOCKS5)
315   AC_DEFINE(Rconnect, SOCKSconnect)
316   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
317   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
318   AC_DEFINE(Rbind, SOCKSbind)
319   AC_DEFINE(Raccept, SOCKSaccept)
320   AC_DEFINE(Rlisten, SOCKSlisten)
321   AC_DEFINE(Rselect, SOCKSselect)
322   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
323   AC_DEFINE(Rsendto, SOCKSsendto)
324   AC_DEFINE(Rrecv, SOCKSrecv)
325   AC_DEFINE(Rsend, SOCKSsend)
326   AC_DEFINE(Rread, SOCKSread)
327   AC_DEFINE(Rwrite, SOCKSwrite)
328   AC_DEFINE(Rrresvport, SOCKSrresvport)
329   AC_DEFINE(Rshutdown, SOCKSshutdown)
330   AC_DEFINE(Rlisten, SOCKSlisten)
331   AC_DEFINE(Rclose, SOCKSclose)
332   AC_DEFINE(Rdup, SOCKSdup)
333   AC_DEFINE(Rdup2, SOCKSdup2)
334   AC_DEFINE(Rfclose, SOCKSfclose)
335   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
336 fi
337
338 # GMP Library checking
339 AC_MSG_CHECKING(whether to compile GMP)
340 AC_ARG_WITH(gmp,
341 [  --with-gmp              Build the GMP in the SILC source tree],
342 [ case "${withval}" in
343   yes) 
344     AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = xyes)
345     AC_MSG_RESULT(yes)
346     ;;
347   *)
348     AC_CHECK_HEADER(gmp.h,
349       AC_CHECK_LIB(gmp, __gmpz_init,
350         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval = yes)
351         AC_MSG_RESULT(GMP will not be compiled),
352         AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
353         AC_MSG_RESULT(GMP will be compiled)
354       ),
355       AM_CONDITIONAL(SILC_BUILD_GMP, test x$withval != yes)
356       AC_MSG_RESULT(GMP will be compiled)
357     )
358     ;;
359 esac ], [
360   AC_CHECK_HEADER(gmp.h,
361     AC_CHECK_LIB(gmp, __gmpz_init,
362       build_gmp=false
363       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
364       AC_MSG_RESULT(GMP will not be compiled),
365       build_gmp=true
366       AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
367       AC_MSG_RESULT(GMP will be compiled)
368     ),
369     build_gmp=true
370     AM_CONDITIONAL(SILC_BUILD_GMP, test x$build_gmp = xtrue)
371     AC_MSG_RESULT(GMP will be compiled)
372   )
373 ])
374
375 AC_ARG_WITH(silcd-config-file,
376 [  --with-silcd-config-file[=PATH]
377                           Use PATH as default configuration file in SILC
378                           server [/etc/silc/silcd.conf]],
379 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
380
381 # XXX
382 #LIBS="$LIBS -lefence"
383
384 # Other configure scripts
385 #AC_CONFIG_SUBDIRS(lib/zlib)
386 AC_CONFIG_SUBDIRS(lib/dotconf)
387 AC_CONFIG_SUBDIRS(lib/silcmath/gmp)
388 AC_CONFIG_SUBDIRS(lib/trq)
389
390 AC_OUTPUT( \
391 Makefile
392 doc/Makefile
393 includes/Makefile
394 lib/Makefile
395 lib/contrib/Makefile
396 lib/silcclient/Makefile
397 lib/silccore/Makefile
398 lib/silccrypt/Makefile
399 lib/silcmath/Makefile
400 lib/silcsim/Makefile
401 lib/silcsim/modules/Makefile
402 lib/silcske/Makefile
403 lib/silcutil/Makefile
404 silc/Makefile
405 silcd/Makefile)