]> arthur.barton.de Git - ngircd-alex.git/blob - configure.in
add test for strcspn.
[ngircd-alex.git] / configure.in
1 #
2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2005 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.124 2006/10/02 21:57:13 fw 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([ZEROCONF], [Define if support for Zeroconf 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 AC_C_INLINE
57
58 # -- Hard coded system and compiler dependencies/features/options ... --
59
60 AC_DEFUN([GCC_STACK_PROTECT_CC],[
61   ssp_cc=yes
62   # we use -fstack-protector-all for the test to enfoce the use of the guard variable 
63   AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
64   ssp_old_cflags="$CFLAGS"
65   CFLAGS="$CFLAGS -fstack-protector-all"
66   AC_TRY_LINK(,,, ssp_cc=no)
67   echo $ssp_cc
68   CFLAGS="$ssp_old_cflags"
69   if test "X$ssp_cc" = "Xyes"; then
70       CFLAGS="$CFLAGS -fstack-protector"
71       AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
72   fi
73 ])
74
75
76 if test "$GCC" = "yes"; then
77         # We are using the GNU C compiler. Good!
78         CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
79
80         GCC_STACK_PROTECT_CC
81 fi
82
83 case "$target_os" in
84         hpux*)
85                 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
86                 # (tested with HP/UX 11.11)
87                 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
88                 ;;
89 esac
90
91 # Add additional CFLAGS, eventually specified on the command line:
92 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
93
94 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
95
96 # -- Headers --
97
98 AC_HEADER_STDC
99 AC_HEADER_TIME
100 AC_HEADER_SYS_WAIT
101
102 AC_CHECK_HEADERS([ \
103         ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
104         strings.h sys/socket.h sys/time.h unistd.h \
105         ],,AC_MSG_ERROR([required C header missing!]))
106
107 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
108
109 # -- Datatypes --
110
111 AC_MSG_CHECKING(whether socklen_t exists)
112 AC_TRY_COMPILE([
113 #include <sys/types.h>
114 #include <sys/socket.h>
115         ],[
116         socklen_t a, b;
117         a = 2; b = 4; a += b;
118         ],[
119         AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
120         ],[
121         AC_MSG_RESULT(no)
122 ])
123
124 AC_TYPE_SIGNAL
125 AC_TYPE_SIZE_T
126
127
128 # -- Libraries --
129
130 AC_CHECK_LIB(UTIL,memmove)
131 AC_CHECK_LIB(socket,bind)
132 AC_CHECK_LIB(nsl,gethostent)
133
134 # -- Functions --
135
136 AC_FUNC_FORK
137 AC_FUNC_STRFTIME
138
139 AC_CHECK_FUNCS([ \
140         bind gethostbyaddr gethostbyname gethostname inet_ntoa malloc memmove \
141         memset realloc setsid setsockopt socket strcasecmp strchr strcspn strerror \
142         strstr waitpid],,AC_MSG_ERROR([required function missing!]))
143
144 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat)
145
146 AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
147         AC_MSG_ERROR([required function select() is missing!])
148 )
149
150 # -- Configuration options --
151
152 x_syslog_on=no
153 AC_ARG_WITH(syslog,
154         [  --without-syslog        disable syslog (autodetected by default)],
155         [       if test "$withval" != "no"; then
156                         if test "$withval" != "yes"; then
157                                 CFLAGS="-I$withval/include $CFLAGS"
158                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
159                                 LDFLAGS="-L$withval/lib $LDFLAGS"
160                         fi
161                         AC_CHECK_LIB(be, syslog)
162                         AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
163                                 AC_MSG_ERROR([Can't enable syslog!])
164                         )
165                 fi
166         ],
167         [
168                 AC_CHECK_LIB(be, syslog)
169                 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
170         ]
171 )
172 if test "$x_syslog_on" = "yes"; then
173         AC_DEFINE(SYSLOG, 1)
174         AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
175 fi
176
177 x_zlib_on=no
178 AC_ARG_WITH(zlib,
179         [  --without-zlib          disable zlib compression (autodetected by default)],
180         [       if test "$withval" != "no"; then
181                         if test "$withval" != "yes"; then
182                                 CFLAGS="-I$withval/include $CFLAGS"
183                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
184                                 LDFLAGS="-L$withval/lib $LDFLAGS"
185                         fi
186                         AC_CHECK_LIB(z, deflate)
187                         AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
188                                 AC_MSG_ERROR([Can't enable zlib!])
189                         )
190                 fi
191         ],
192         [       AC_CHECK_LIB(z, deflate)
193                 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
194         ]
195 )
196 if test "$x_zlib_on" = "yes"; then
197         AC_DEFINE(ZLIB, 1)
198         AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
199 fi
200
201
202 x_io_backend=select\(\)
203 AC_ARG_WITH(poll,
204         [  --without-poll          disable poll support (autodetected by default)],
205         [       if test "$withval" != "no"; then
206                         if test "$withval" != "yes"; then
207                                 CFLAGS="-I$withval/include $CFLAGS"
208                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
209                                 LDFLAGS="-L$withval/lib $LDFLAGS"
210                         fi
211                         AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
212                                 AC_MSG_ERROR([Can't enable poll support!])
213                         )
214                 fi
215         ],
216         [
217                 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
218         ]
219 )
220
221
222 AC_ARG_WITH(devpoll,
223         [  --without-devpoll          disable /dev/poll support (autodetected by default)],
224         [       if test "$withval" != "no"; then
225                         if test "$withval" != "yes"; then
226                                 CFLAGS="-I$withval/include $CFLAGS"
227                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
228                                 LDFLAGS="-L$withval/lib $LDFLAGS"
229                         fi
230
231                                 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
232                 fi
233         ],
234         [
235                 AC_CHECK_HEADERS(sys/devpoll.h,x_io_backend=/dev/poll,)
236         ]
237 )
238
239 AC_ARG_WITH(epoll,
240         [  --without-epoll         disable epoll support (autodetected by default)],
241         [       if test "$withval" != "no"; then
242                         if test "$withval" != "yes"; then
243                                 CFLAGS="-I$withval/include $CFLAGS"
244                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
245                                 LDFLAGS="-L$withval/lib $LDFLAGS"
246                         fi
247                         AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\),
248                                 AC_MSG_ERROR([Can't enable epoll support!])
249                         )
250                 fi
251         ],
252         [
253                 AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll\(\))
254         ]
255 )
256
257
258 AC_ARG_WITH(kqueue,
259         [  --without-kqueue        disable kqueue support (autodetected by default)],
260         [       if test "$withval" != "no"; then
261                         if test "$withval" != "yes"; then
262                                 CFLAGS="-I$withval/include $CFLAGS"
263                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
264                                 LDFLAGS="-L$withval/lib $LDFLAGS"
265                         fi
266                         AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
267                                 AC_MSG_ERROR([Can't enable kqueue support!])
268                         )
269                 fi
270         ],
271         [
272                 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
273         ]
274 )
275
276
277 x_tcpwrap_on=no
278 AC_ARG_WITH(tcp-wrappers,
279         [  --with-tcp-wrappers     enable TCP wrappers support],
280         [       if test "$withval" != "no"; then
281                         if test "$withval" != "yes"; then
282                                 CFLAGS="-I$withval/include $CFLAGS"
283                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
284                                 LDFLAGS="-L$withval/lib $LDFLAGS"
285                         fi
286                         AC_MSG_CHECKING(for hosts_access)
287                         LIBS="-lwrap $LIBS"
288                         AC_TRY_LINK([
289 #include <tcpd.h>
290 int allow_severity = 0;
291 int deny_severity = 0;
292                                 ],[
293                                 tcpd_warn("link test");
294                                 ],[
295                                 AC_MSG_RESULT(yes)
296                                 AC_DEFINE(TCPWRAP, 1)
297                                 x_tcpwrap_on=yes
298                                 ],[
299                                 AC_MSG_RESULT(no)
300                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
301                         ])
302                 fi
303         ]
304 )
305
306 x_zeroconf_on=no
307 AC_ARG_WITH(zeroconf,
308         [  --with-zeroconf         enable support for "Zeroconf"],
309         [       if test "$withval" != "no"; then
310                         if test "$withval" != "yes"; then
311                                 CFLAGS="-I$withval/include $CFLAGS"
312                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
313                                 LDFLAGS="-L$withval/lib $LDFLAGS"
314                         fi
315                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
316                         [
317                                 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
318                                 AC_CHECK_LIB(howl, sw_discovery_init)
319                                 AC_CHECK_FUNCS(sw_discovery_init, \
320                                  x_zeroconf_on=howl, \
321                                  AC_MSG_ERROR([Can't enable Zeroconf!]))
322                         ])
323                 fi
324         ]
325 )
326 if test "$x_zeroconf_on" = "osx"; then
327         AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
328          mach/port.h],,AC_MSG_ERROR([required C header missing!]))
329         AC_DEFINE(ZEROCONF, 1)
330 fi
331 if test "$x_zeroconf_on" = "howl"; then
332         for dir in /usr/local/include /usr/local/include/howl* \
333          /usr/include /usr/include/howl* \
334          /usr/local/include/avahi* /usr/include/avahi*; do
335                 test -d "$dir" || continue
336                 AC_MSG_CHECKING([for Howl headers in $dir])
337                 if test -f "$dir/rendezvous/rendezvous.h"; then
338                         if test "$dir" != "/usr/local/include" -a \
339                          "$dir" != "/usr/include"; then
340                                 CFLAGS="-I$dir $CFLAGS"
341                                 CPPFLAGS="-I$dir $CPPFLAGS"
342                         fi
343                         AC_MSG_RESULT(yes)
344                         break
345                 else
346                         AC_MSG_RESULT(no)
347                 fi
348         done
349         AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
350          AC_MSG_ERROR([required C header missing!]))
351         AC_DEFINE(ZEROCONF, 1)
352 fi
353
354 x_identauth_on=no
355 AC_ARG_WITH(ident,
356         [  --with-ident            enable "IDENT" ("AUTH") protocol support],
357         [       if test "$withval" != "no"; then
358                         if test "$withval" != "yes"; then
359                                 CFLAGS="-I$withval/include $CFLAGS"
360                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
361                                 LDFLAGS="-L$withval/lib $LDFLAGS"
362                         fi
363                         AC_CHECK_LIB(ident, ident_id)
364                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
365                                 AC_MSG_ERROR([Can't enable IDENT support!])
366                         )
367                 fi
368         ]
369 )
370 if test "$x_identauth_on" = "yes"; then
371         AC_DEFINE(IDENTAUTH, 1)
372         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
373 fi
374
375 x_ircplus_on=yes
376 AC_ARG_ENABLE(ircplus,
377         [  --disable-ircplus       disable IRC+ protocol],
378         if test "$enableval" = "no"; then x_ircplus_on=no; fi
379 )
380 if test "$x_ircplus_on" = "yes"; then
381         AC_DEFINE(IRCPLUS, 1)
382 fi
383
384 x_sniffer_on=no; x_debug_on=no
385 AC_ARG_ENABLE(sniffer,
386         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
387         if test "$enableval" = "yes"; then
388                 AC_DEFINE(SNIFFER, 1)
389                 x_sniffer_on=yes; x_debug_on=yes
390         fi
391 )
392
393 AC_ARG_ENABLE(debug,
394         [  --enable-debug          show additional debug output],
395         if test "$enableval" = "yes"; then x_debug_on=yes; fi
396 )
397 if test "$x_debug_on" = "yes"; then
398         AC_DEFINE(DEBUG, 1)
399         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
400 fi
401
402 x_strict_rfc_on=no
403 AC_ARG_ENABLE(strict-rfc,
404         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
405         if test "$enableval" = "yes"; then
406                 AC_DEFINE(STRICT_RFC, 1)
407                 x_strict_rfc_on=yes
408         fi
409 )
410
411 # -- Definitions --
412
413 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
414 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
415 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
416
417 # Add additional CFLAGS, eventually specified on the command line, but after
418 # running this configure script. Useful for "-Werror" for example.
419 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
420
421 # -- Generate files --
422
423 AC_OUTPUT([ \
424         Makefile \
425         doc/Makefile \
426         doc/src/Makefile \
427         src/Makefile \
428         src/portab/Makefile \
429         src/tool/Makefile \
430         src/ngircd/Makefile \
431         src/testsuite/Makefile \
432         man/Makefile \
433         contrib/Makefile \
434         contrib/Debian/Makefile \
435         contrib/MacOSX/Makefile \
436 ])
437
438 type dpkg >/dev/null 2>&1
439 if test $? -eq 0; then
440         # Generate debian/ link if the dpkg command exists
441         # (read: if we are running on a debian compatible system)
442         echo "creating Debian-specific links ..."
443         test -f debian/rules || ln -s contrib/Debian debian
444 fi
445
446 # -- Result --
447
448 echo
449 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
450 echo
451
452 # Someone please show me a better way :)  [borrowed by OpenSSH]
453 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
454 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
455 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
456 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
457 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
458
459 echo "             Target: ${target}"
460 test "$target" != "$host" && echo "               Host: ${host}"
461 echo "           Compiler: ${CC}"
462 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
463 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
464 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
465 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
466 echo
467 echo "    'ngircd' binary: $S"
468 echo " Configuration file: $C"
469 echo "       Manual pages: $M"
470 echo "      Documentation: $D"
471 echo
472
473 echo $ECHO_N "     Syslog support: $ECHO_C"
474 test "$x_syslog_on" = "yes" \
475         && echo $ECHO_N "yes   $ECHO_C" \
476         || echo $ECHO_N "no    $ECHO_C"
477 echo $ECHO_N "  Enable debug code: $ECHO_C"
478 test "$x_debug_on" = "yes" \
479         && echo "yes" \
480         || echo "no"
481
482 echo $ECHO_N "   zlib compression: $ECHO_C"
483 test "$x_zlib_on" = "yes" \
484         && echo $ECHO_N "yes   $ECHO_C" \
485         || echo $ECHO_N "no    $ECHO_C"
486 echo $ECHO_N "        IRC sniffer: $ECHO_C"
487 test "$x_sniffer_on" = "yes" \
488         && echo "yes" \
489         || echo "no"
490
491 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
492 test "$x_tcpwrap_on" = "yes" \
493         && echo $ECHO_N "yes   $ECHO_C" \
494         || echo $ECHO_N "no    $ECHO_C"
495 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
496 test "$x_strict_rfc_on" = "yes" \
497         && echo "yes" \
498         || echo "no"
499
500 echo $ECHO_N "   Zeroconf support: $ECHO_C"
501 case "$x_zeroconf_on" in
502         osx)
503                 echo $ECHO_N "Apple $ECHO_C"
504                 ;;
505         howl)
506                 echo $ECHO_N "Howl  $ECHO_C"
507                 ;;
508         *)
509                 echo $ECHO_N "no    $ECHO_C"
510                 ;;
511 esac
512 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
513 test "$x_ircplus_on" = "yes" \
514         && echo "yes" \
515         || echo "no"
516
517 echo $ECHO_N "      IDENT support: $ECHO_C"
518 test "$x_identauth_on" = "yes" \
519         && echo $ECHO_N "yes   $ECHO_C" \
520         || echo $ECHO_N "no    $ECHO_C"
521 echo $ECHO_N "        I/O backend: $ECHO_C"
522         echo "\"$x_io_backend\""
523
524 echo
525
526 # -eof-