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