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