A LOT updates. Cannot separate. :)
[silc.git] / configure.in
1 #
2 #  configure.in
3 #
4 #  Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
5 #
6 #  Copyright (C) 2000 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 AM_INIT_AUTOMAKE(silc, 20001101)
37 AC_PREREQ(2.3)
38 AM_CONFIG_HEADER(includes/silcdefs.h)
39
40 AC_PROG_CC
41 AC_C_INLINE
42 AC_C_CONST
43 AC_ARG_PROGRAM
44
45 AC_PROG_LN_S
46 AC_SUBST(LN_S)
47
48 # XXX
49 # Compiler flags
50 if test "$GCC"; then
51   CFLAGS="-finline-functions $CFLAGS"
52 else
53   # Currently GCC is only supported compiler
54   AC_MSG_ERROR(GCC is only supported compiler currently)
55 fi
56
57 # Program checking
58 AC_PROG_INSTALL
59 AC_PROG_RANLIB
60 AC_PROG_MAKE_SET
61
62 # Header checking
63 AC_HEADER_STDC
64 AC_HEADER_TIME
65 AC_HEADER_STAT
66
67 # More header checking
68 AC_CHECK_HEADERS(unistd.h string.h getopt.h errno.h fcntl.h assert.h)
69 AC_CHECK_HEADERS(sys/types.h sys/stat.h sys/time.h)
70 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h netdb.h)
71 AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h)
72 AC_CHECK_HEADERS(ncurses.h signal.h ctype.h)
73 AC_CHECK_HEADERS(arpa/inet.h sys/mman.h)
74
75 # Data type checking
76 AC_TYPE_SIGNAL
77 AC_TYPE_SIZE_T
78 AC_TYPE_MODE_T
79 AC_TYPE_UID_T
80 AC_TYPE_PID_T
81
82 # Function checking
83 AC_CHECK_FUNCS(chmod stat fstat getenv putenv strerror ctime gettimeofday)
84 AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
85 AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
86 AC_CHECK_FUNCS(gethostname gethostbyname gethostbyaddr)
87 AC_CHECK_FUNCS(select socket listen bind shutdown close connect)
88 AC_CHECK_FUNCS(fcntl setsockopt)
89 AC_CHECK_FUNCS(getservbyname getservbyport)
90 AC_CHECK_FUNCS(getopt_long time)
91 AC_CHECK_FUNCS(mlock munlock)
92
93 # SIM support checking
94 # XXX These needs to be changed as more supported platforms appear.
95 # XXX This probably needs to be made platform dependant check.
96 AC_CHECKING(for SIM support)
97 AC_CHECK_HEADERS(dlfcn.h, 
98   AC_CHECK_LIB(dl, dlopen, 
99     AC_DEFINE(SILC_SIM) 
100     AC_MSG_RESULT(enabled SIM support)
101     LIBS="$LIBS -ldl",
102     AC_MSG_RESULT(no SIM support found)),
103   AC_MSG_RESULT(no SIM support found))
104
105 # Debug checking
106 AC_MSG_CHECKING(for enabled debugging)
107 AC_ARG_ENABLE(debug,
108 [  --enable-debug          Enable debugging (warning: it is heavy!)],
109 [ case "${enableval}" in
110   yes) 
111     AC_MSG_RESULT(yes)
112     AC_DEFINE(SILC_DEBUG)
113     CFLAGS="-O -g $CFLAGS"
114     ;;
115   *)
116     AC_MSG_RESULT(no)
117     CFLAGS="-O2 -g $CFLAGS"
118     ;;
119 esac ], CFLAGS="-O2 -g $CFLAGS"
120         AC_MSG_RESULT(no))
121
122 # SOCKS4 support checking
123 AC_MSG_CHECKING(whether to support SOCKS4)
124 AC_ARG_WITH(socks4,
125 [  --with-socks4[=PATH]    Compile with SOCKS4 support.],
126 [ case "$withval" in
127   no)
128     AC_MSG_RESULT(no)
129     ;;
130   *)
131     AC_MSG_RESULT(yes)
132     socks=4
133
134     if test -d "$withval/include"; then
135       CFLAGS="$CFLAGS -I$withval/include"
136     else
137       CFLAGS="$CFLAGS -I$withval"
138     fi
139     if test -d "$withval/lib"; then
140       withval="-L$withval/lib -lsocks"
141     else
142       withval="-L$withval -lsocks"
143     fi
144
145     LIBS="$withval $LIBS"
146
147     AC_TRY_LINK([],
148                 [ Rconnect(); ],
149                 [],
150                 [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
151       ;;
152   esac ],
153   AC_MSG_RESULT(no)
154 )   
155
156 # SOCKS5 support checking
157 AC_MSG_CHECKING(whether to support SOCKS5)
158 AC_ARG_WITH(socks5,
159 [  --with-socks5[=PATH]    Compile with SOCKS5 support.],
160 [ case "$withval" in
161   no)
162     AC_MSG_RESULT(no)
163     ;;
164   *)
165     AC_MSG_RESULT(yes)
166     socks=5
167
168     if test -d "$withval/include"; then
169       CFLAGS="$CFLAGS -I$withval/include"
170     else
171       CFLAGS="$CFLAGS -I$withval"
172     fi
173     if test -d "$withval/lib"; then
174       withval="-L$withval/lib -lsocks5"
175     else
176       withval="-L$withval -lsocks5"
177     fi 
178
179     LIBS="$withval $LIBS"
180
181     AC_TRY_LINK([],
182                 [ SOCKSconnect(); ],
183                 [],
184                 [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
185       ;;
186   esac ],
187   AC_MSG_RESULT(no)
188 )   
189
190 if test "x$socks" = "x4"; then
191   AC_DEFINE(SOCKS)
192   CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
193 fi
194
195 if test "x$socks" = "x5"; then
196   AC_DEFINE(SOCKS)
197   AC_DEFINE(SOCKS5)
198   AC_DEFINE(Rconnect, SOCKSconnect)
199   AC_DEFINE(Rgetsockname, SOCKSgetsockname)
200   AC_DEFINE(Rgetpeername, SOCKSgetpeername)
201   AC_DEFINE(Rbind, SOCKSbind)
202   AC_DEFINE(Raccept, SOCKSaccept)
203   AC_DEFINE(Rlisten, SOCKSlisten)
204   AC_DEFINE(Rselect, SOCKSselect)
205   AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
206   AC_DEFINE(Rsendto, SOCKSsendto)
207   AC_DEFINE(Rrecv, SOCKSrecv)
208   AC_DEFINE(Rsend, SOCKSsend)
209   AC_DEFINE(Rread, SOCKSread)
210   AC_DEFINE(Rwrite, SOCKSwrite)
211   AC_DEFINE(Rrresvport, SOCKSrresvport)
212   AC_DEFINE(Rshutdown, SOCKSshutdown)
213   AC_DEFINE(Rlisten, SOCKSlisten)
214   AC_DEFINE(Rclose, SOCKSclose)
215   AC_DEFINE(Rdup, SOCKSdup)
216   AC_DEFINE(Rdup2, SOCKSdup2)
217   AC_DEFINE(Rfclose, SOCKSfclose)
218   AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
219 fi
220
221
222 AC_ARG_WITH(silcd-config-file,
223 [  --with-silcd-config-file[=PATH]
224                           Use PATH as default configuration file in SILC
225                           server.],
226 [ AC_DEFINE_UNQUOTED(SILC_SERVER_CONFIG_FILE, "$withval") ])
227
228 # XXX
229 #LIBS="$LIBS -lefence"
230
231 # Other configure scripts
232 #AC_CONFIG_SUBDIRS(lib/zlib)
233 AC_CONFIG_SUBDIRS(lib/silcmath/gmp)
234 AC_CONFIG_SUBDIRS(lib/trq)
235
236 AC_OUTPUT( \
237 Makefile
238 doc/Makefile
239 includes/Makefile
240 lib/Makefile
241 lib/contrib/Makefile
242 lib/silcclient/Makefile
243 lib/silccore/Makefile
244 lib/silccrypt/Makefile
245 lib/silcmath/Makefile
246 lib/silcsim/Makefile
247 lib/silcsim/modules/Makefile
248 lib/silcske/Makefile
249 lib/silcutil/Makefile
250 silc/Makefile
251 silcd/Makefile)