Updated to latest strl{cat|cpy} code of rsync:
[ngircd-alex.git] / configure.in
1 #
2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2004 Alexander Barton <alex@barton.de>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 # Please read the file COPYING, README and AUTHORS for more information.
10 #
11 # $Id: configure.in,v 1.104 2004/12/26 00:14:33 alex Exp $
12 #
13
14 # -- Initialisation --
15
16 AC_PREREQ(2.50)
17 AC_INIT(ngircd, CVSHEAD)
18 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
19 AC_CANONICAL_TARGET
20 AM_INIT_AUTOMAKE(1.6)
21 AM_CONFIG_HEADER(src/config.h)
22
23 # -- Templates for config.h --
24
25 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
26 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
27 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
28 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
29 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
30 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
31 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
32 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
33 AH_TEMPLATE([RENDEZVOUS], [Define if Rendezvous support should be included])
34 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
35
36 AH_TEMPLATE([TARGET_OS], [Target operating system name])
37 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
38 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
39
40 # -- C Compiler --
41
42 AC_PROG_CC
43
44 # -- Helper programs --
45
46 AC_PROG_AWK
47 AC_PROG_INSTALL
48 AC_PROG_LN_S
49 AC_PROG_MAKE_SET
50 AC_PROG_RANLIB
51
52 # -- Compiler Features --
53
54 AM_C_PROTOTYPES
55 AC_C_CONST
56
57 # -- Hard coded system and compiler dependencies/features/options ... --
58
59 if test "$GCC" = "yes"; then
60         # We are using the GNU C compiler. Good!
61         CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
62 fi
63
64 case "$target_os" in
65         hpux*)
66                 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
67                 # (tested with HP/UX 11.11)
68                 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
69                 ;;
70 esac
71
72 # Add additional CFLAGS, eventually specified on the command line:
73 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
74
75 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
76
77 # -- Headers --
78
79 AC_HEADER_STDC
80 AC_HEADER_TIME
81 AC_HEADER_SYS_WAIT
82
83 AC_CHECK_HEADERS([ \
84         ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
85         strings.h sys/socket.h sys/time.h unistd.h \
86         ],,AC_MSG_ERROR([required C header missing!]))
87
88 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdint.h varargs.h])
89
90 # -- Datatypes --
91
92 AC_MSG_CHECKING(whether socklen_t exists)
93 AC_TRY_COMPILE([
94         #include <sys/socket.h>
95         #include <sys/types.h>
96         ],[
97         socklen_t a, b;
98         a = 2; b = 4; a += b;
99         ],[
100         AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
101         ],[
102         AC_MSG_RESULT(no)
103 ])
104
105 AC_TYPE_SIGNAL
106 AC_TYPE_SIZE_T
107
108 # -- Libraries --
109
110 AC_CHECK_LIB(UTIL,memmove)
111 AC_CHECK_LIB(socket,bind)
112 AC_CHECK_LIB(nsl,gethostent)
113
114 # -- Functions --
115
116 AC_FUNC_FORK
117 AC_FUNC_STRFTIME
118
119 AC_CHECK_FUNCS([ \
120         bind gethostbyaddr gethostbyname gethostname inet_ntoa malloc memmove \
121         memset realloc setsid setsockopt socket strcasecmp strchr strerror \
122         strstr waitpid],,AC_MSG_ERROR([required function missing!]))
123
124 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strlcpy strlcat)
125
126 AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
127         AC_MSG_ERROR([required function select() is missing!])
128 )
129
130 # -- Configuration options --
131
132 x_syslog_on=no
133 AC_ARG_WITH(syslog,
134         [  --without-syslog        disable syslog (autodetected by default)],
135         [       if test "$withval" = "yes"; then
136                         AC_CHECK_LIB(be, syslog)
137                         AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
138                                 AC_MSG_ERROR([Can't enable syslog!])
139                         )
140                 fi
141         ],
142         [
143                 AC_CHECK_LIB(be, syslog)
144                 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
145         ]
146 )
147 if test "$x_syslog_on" = "yes"; then
148         AC_DEFINE(SYSLOG, 1)
149         AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
150 fi
151
152 x_zlib_on=no
153 AC_ARG_WITH(zlib,
154         [  --without-zlib          disable zlib compression (autodetected by default)],
155         [       if test "$withval" = "yes"; then
156                         AC_CHECK_LIB(z, deflate)
157                         AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
158                                 AC_MSG_ERROR([Can't enable zlib!])
159                         )
160                 fi
161         ],
162         [       AC_CHECK_LIB(z, deflate)
163                 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
164         ]
165 )
166 if test "$x_zlib_on" = "yes"; then
167         AC_DEFINE(ZLIB, 1)
168         AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
169 fi
170
171 x_tcpwrap_on=no
172 AC_ARG_WITH(tcp-wrappers,
173         [  --with-tcp-wrappers     enable TCP wrappers support],
174         [       if test "$withval" = "yes"; then
175                         AC_CHECK_LIB(wrap, tcpd_warn)
176                         AC_MSG_CHECKING(for hosts_access)
177                         AC_TRY_LINK([
178                                 #include <tcpd.h>
179                                 ],[
180                                 void *ptr;
181                                 ptr = hosts_access;
182                                 ],[
183                                 AC_MSG_RESULT(yes)
184                                 AC_DEFINE(TCPWRAP, 1)
185                                 x_tcpwrap_on=yes
186                                 ],[
187                                 AC_MSG_RESULT(no)
188                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
189                         ])
190                 fi
191         ]
192 )
193
194 x_rendezvous_on=no
195 AC_ARG_WITH(rendezvous,
196         [  --with-rendezvous       enable support for "Rendezvous"],
197         [       if test "$withval" = "yes"; then
198                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_rendezvous_on=osx,
199                         [
200                                 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
201                                 AC_CHECK_LIB(howl, sw_discovery_init)
202                                 AC_CHECK_FUNCS(sw_discovery_init, \
203                                  x_rendezvous_on=howl, \
204                                  AC_MSG_ERROR([Can't enable Rendezvous!]))
205                         ])
206                 fi
207         ]
208 )
209 if test "$x_rendezvous_on" = "osx"; then
210         AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
211          mach/port.h],,AC_MSG_ERROR([required C header missing!]))
212         AC_DEFINE(RENDEZVOUS, 1)
213 fi
214 if test "$x_rendezvous_on" = "howl"; then
215         for dir in /usr/local/include /usr/local/include/howl* \
216          /usr/include /usr/include/howl*; do
217                 test -d "$dir" || continue
218                 AC_MSG_CHECKING([for Howl headers in $dir])
219                 if test -f "$dir/rendezvous/rendezvous.h"; then
220                         if test "$dir" != "/usr/local/include" -a \
221                          "$dir" != "/usr/include"; then
222                                 CFLAGS="$CFLAGS -I$dir"
223                                 CPPFLAGS="-I$dir $CPPFLAGS"
224                         fi
225                         AC_MSG_RESULT(yes)
226                         break
227                 else
228                         AC_MSG_RESULT(no)
229                 fi
230         done
231         AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
232          AC_MSG_ERROR([required C header missing!]))
233         AC_DEFINE(RENDEZVOUS, 1)
234 fi
235
236 x_identauth_on=no
237 AC_ARG_WITH(ident,
238         [  --with-ident            enable "IDENT" ("AUTH") protocol support],
239         [       if test "$withval" = "yes"; then
240                         AC_CHECK_LIB(ident, ident_id)
241                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
242                                 AC_MSG_ERROR([Can't enable IDENT support!])
243                         )
244                 fi
245         ]
246 )
247 if test "$x_identauth_on" = "yes"; then
248         AC_DEFINE(IDENTAUTH, 1)
249         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
250 fi
251
252 x_ircplus_on=yes
253 AC_ARG_ENABLE(ircplus,
254         [  --disable-ircplus       disable IRC+ protocol],
255         if test "$enableval" = "no"; then x_ircplus_on=no; fi
256 )
257 if test "$x_ircplus_on" = "yes"; then
258         AC_DEFINE(IRCPLUS, 1)
259 fi
260
261 x_sniffer_on=no; x_debug_on=no
262 AC_ARG_ENABLE(sniffer,
263         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
264         if test "$enableval" = "yes"; then
265                 AC_DEFINE(SNIFFER, 1)
266                 x_sniffer_on=yes; x_debug_on=yes
267         fi
268 )
269
270 AC_ARG_ENABLE(debug,
271         [  --enable-debug          show additional debug output],
272         if test "$enableval" = "yes"; then x_debug_on=yes; fi
273 )
274 if test "$x_debug_on" = "yes"; then
275         AC_DEFINE(DEBUG, 1)
276         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
277 fi
278
279 x_strict_rfc_on=no
280 AC_ARG_ENABLE(strict-rfc,
281         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
282         if test "$enableval" = "yes"; then
283                 AC_DEFINE(STRICT_RFC, 1)
284                 x_strict_rfc_on=yes
285         fi
286 )
287
288 # -- Definitions --
289
290 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
291 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
292 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
293
294 # Add additional CFLAGS, eventually specified on the command line, but after
295 # running this configure script. Useful for "-Werror" for example.
296 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
297
298 # -- Generate files --
299
300 AC_OUTPUT([ \
301         Makefile \
302         doc/Makefile \
303         src/Makefile \
304         src/portab/Makefile \
305         src/tool/Makefile \
306         src/ngircd/Makefile \
307         src/testsuite/Makefile \
308         man/Makefile \
309         contrib/Makefile \
310         contrib/Debian/Makefile \
311         contrib/MacOSX/Makefile \
312 ])
313
314 type dpkg >/dev/null 2>&1
315 if test $? -eq 0; then
316         # Generate debian/ link if the dpkg command exists
317         # (read: if we are running on a debian compatible system)
318         echo "creating Debian-specific links ..."
319         test -f debian/rules || ln -s contrib/Debian debian
320 fi
321
322 # -- Result --
323
324 echo
325 echo "ngIRCd has been configured with the following options:"
326 echo
327
328 # Someone please show me a better way :)  [borrowed by OpenSSH]
329 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
330 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
331 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
332 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
333 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
334
335 echo "             Target: ${target}"
336 test "$target" != "$host" && echo "               Host: ${host}"
337 echo "           Compiler: ${CC}"
338 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
339 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
340 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
341 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
342 echo
343 echo "    'ngircd' binary: $S"
344 echo " Configuration file: $C"
345 echo "       Manual pages: $M"
346 echo "      Documentation: $D"
347 echo
348
349 echo $ECHO_N "     Syslog support: $ECHO_C"
350 test "$x_syslog_on" = "yes" \
351         && echo $ECHO_N "yes $ECHO_C" \
352         || echo $ECHO_N "no  $ECHO_C"
353 echo $ECHO_N "  Enable debug code: $ECHO_C"
354 test "$x_debug_on" = "yes" \
355         && echo "yes" \
356         || echo "no"
357
358 echo $ECHO_N "   zlib compression: $ECHO_C"
359 test "$x_zlib_on" = "yes" \
360         && echo $ECHO_N "yes $ECHO_C" \
361         || echo $ECHO_N "no  $ECHO_C"
362 echo $ECHO_N "        IRC sniffer: $ECHO_C"
363 test "$x_sniffer_on" = "yes" \
364         && echo "yes" \
365         || echo "no"
366
367 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
368 test "$x_tcpwrap_on" = "yes" \
369         && echo $ECHO_N "yes $ECHO_C" \
370         || echo $ECHO_N "no  $ECHO_C"
371 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
372 test "$x_strict_rfc_on" = "yes" \
373         && echo "yes" \
374         || echo "no"
375
376 echo $ECHO_N " Rendezvous support: $ECHO_C"
377 test "$x_rendezvous_on" = "osx" -o "$x_rendezvous_on" = "howl" \
378         && echo $ECHO_N "yes $ECHO_C" \
379         || echo $ECHO_N "no  $ECHO_C"
380 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
381 test "$x_ircplus_on" = "yes" \
382         && echo "yes" \
383         || echo "no"
384
385 echo $ECHO_N "      IDENT support: $ECHO_C"
386 test "$x_identauth_on" = "yes" \
387         && echo $ECHO_N "yes $ECHO_C" \
388         || echo $ECHO_N "no  $ECHO_C"
389
390 echo; echo
391
392 # -eof-