]> arthur.barton.de Git - ngircd-alex.git/blob - configure.in
Don't send trailing space in MODE messages
[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.125 2006/12/26 16:00:45 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([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 # -- Configuration options --
147
148 # use syslog?
149
150 x_syslog_on=no
151 AC_ARG_WITH(syslog,
152         [  --without-syslog        disable syslog (autodetected by default)],
153         [       if test "$withval" != "no"; then
154                         if test "$withval" != "yes"; then
155                                 CFLAGS="-I$withval/include $CFLAGS"
156                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
157                                 LDFLAGS="-L$withval/lib $LDFLAGS"
158                         fi
159                         AC_CHECK_LIB(be, syslog)
160                         AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
161                                 AC_MSG_ERROR([Can't enable syslog!])
162                         )
163                 fi
164         ],
165         [
166                 AC_CHECK_LIB(be, syslog)
167                 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
168         ]
169 )
170 if test "$x_syslog_on" = "yes"; then
171         AC_DEFINE(SYSLOG, 1)
172         AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
173 fi
174
175 # use zlib compression?
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 # detect which IO API to use:
202
203 x_io_backend=none
204
205 AC_ARG_WITH(select,
206         [  --without-select        disable select IO support (autodetected by default)],
207         [       if test "$withval" != "no"; then
208                         if test "$withval" != "yes"; then
209                                 CFLAGS="-I$withval/include $CFLAGS"
210                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
211                                 LDFLAGS="-L$withval/lib $LDFLAGS"
212                         fi
213                         AC_CHECK_FUNCS(select, x_io_select=yes,
214                                 AC_MSG_ERROR([Can't enable select IO support!])
215                         )
216                 fi
217         ],
218         [
219                 AC_CHECK_FUNCS(select, x_io_select=yes)
220         ]
221 )
222
223 AC_ARG_WITH(poll,
224         [  --without-poll          disable poll support (autodetected by default)],
225         [       if test "$withval" != "no"; then
226                         if test "$withval" != "yes"; then
227                                 CFLAGS="-I$withval/include $CFLAGS"
228                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
229                                 LDFLAGS="-L$withval/lib $LDFLAGS"
230                         fi
231                         AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
232                                 AC_MSG_ERROR([Can't enable poll IO support!])
233                         )
234                 fi
235         ],
236         [
237                 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
238         ]
239 )
240
241 AC_ARG_WITH(devpoll,
242         [  --without-devpoll       disable /dev/poll IO support (autodetected by default)],
243         [       if test "$withval" != "no"; then
244                         if test "$withval" != "yes"; then
245                                 CFLAGS="-I$withval/include $CFLAGS"
246                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
247                                 LDFLAGS="-L$withval/lib $LDFLAGS"
248                         fi
249
250                                 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
251                 fi
252         ],
253         [
254                 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
255         ]
256 )
257
258 AC_ARG_WITH(epoll,
259         [  --without-epoll         disable epoll IO 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(epoll_create, x_io_epoll=yes,
267                                 AC_MSG_ERROR([Can't enable epoll IO support!])
268                         )
269                 fi
270         ],
271         [
272                 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
273         ]
274 )
275
276 AC_ARG_WITH(kqueue,
277         [  --without-kqueue        disable kqueue IO support (autodetected by default)],
278         [       if test "$withval" != "no"; then
279                         if test "$withval" != "yes"; then
280                                 CFLAGS="-I$withval/include $CFLAGS"
281                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
282                                 LDFLAGS="-L$withval/lib $LDFLAGS"
283                         fi
284                         AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
285                                 AC_MSG_ERROR([Can't enable kqueue IO support!])
286                         )
287                 fi
288         ],
289         [
290                 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
291         ]
292 )
293
294 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
295         # when epoll() and select() are available, we'll use both!
296         x_io_backend="epoll(), select()"
297 else
298         if test "$x_io_epoll" = "yes"; then
299                 # we prefere epoll() if it is available
300                 x_io_backend="epoll()"
301         else
302                 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
303                         # we'll use select, when available and no "better"
304                         # interface has been detected ...
305                         x_io_backend="select()"
306                 fi
307         fi
308 fi
309
310 if test "$x_io_backend" = "none"; then
311         AC_MSG_ERROR([No useabe IO API activated/found!?])
312 fi
313
314 # use TCP wrappers?
315
316 x_tcpwrap_on=no
317 AC_ARG_WITH(tcp-wrappers,
318         [  --with-tcp-wrappers     enable TCP wrappers support],
319         [       if test "$withval" != "no"; then
320                         if test "$withval" != "yes"; then
321                                 CFLAGS="-I$withval/include $CFLAGS"
322                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
323                                 LDFLAGS="-L$withval/lib $LDFLAGS"
324                         fi
325                         AC_MSG_CHECKING(for hosts_access)
326                         LIBS="-lwrap $LIBS"
327                         AC_TRY_LINK([
328 #include <tcpd.h>
329 int allow_severity = 0;
330 int deny_severity = 0;
331                                 ],[
332                                 tcpd_warn("link test");
333                                 ],[
334                                 AC_MSG_RESULT(yes)
335                                 AC_DEFINE(TCPWRAP, 1)
336                                 x_tcpwrap_on=yes
337                                 ],[
338                                 AC_MSG_RESULT(no)
339                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
340                         ])
341                 fi
342         ]
343 )
344
345 # include support for "zeroconf"?
346
347 x_zeroconf_on=no
348 AC_ARG_WITH(zeroconf,
349         [  --with-zeroconf         enable support for "Zeroconf"],
350         [       if test "$withval" != "no"; then
351                         if test "$withval" != "yes"; then
352                                 CFLAGS="-I$withval/include $CFLAGS"
353                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
354                                 LDFLAGS="-L$withval/lib $LDFLAGS"
355                         fi
356                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
357                         [
358                                 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
359                                 AC_CHECK_LIB(howl, sw_discovery_init)
360                                 AC_CHECK_FUNCS(sw_discovery_init, \
361                                  x_zeroconf_on=howl, \
362                                  AC_MSG_ERROR([Can't enable Zeroconf!]))
363                         ])
364                 fi
365         ]
366 )
367 if test "$x_zeroconf_on" = "osx"; then
368         AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
369          mach/port.h],,AC_MSG_ERROR([required C header missing!]))
370         AC_DEFINE(ZEROCONF, 1)
371 fi
372 if test "$x_zeroconf_on" = "howl"; then
373         for dir in /usr/local/include /usr/local/include/howl* \
374          /usr/include /usr/include/howl* \
375          /usr/local/include/avahi* /usr/include/avahi*; do
376                 test -d "$dir" || continue
377                 AC_MSG_CHECKING([for Howl headers in $dir])
378                 if test -f "$dir/rendezvous/rendezvous.h"; then
379                         if test "$dir" != "/usr/local/include" -a \
380                          "$dir" != "/usr/include"; then
381                                 CFLAGS="-I$dir $CFLAGS"
382                                 CPPFLAGS="-I$dir $CPPFLAGS"
383                         fi
384                         AC_MSG_RESULT(yes)
385                         break
386                 else
387                         AC_MSG_RESULT(no)
388                 fi
389         done
390         AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
391          AC_MSG_ERROR([required C header missing!]))
392         AC_DEFINE(ZEROCONF, 1)
393 fi
394
395 # do IDENT requests using libident?
396
397 x_identauth_on=no
398 AC_ARG_WITH(ident,
399         [  --with-ident            enable "IDENT" ("AUTH") protocol support],
400         [       if test "$withval" != "no"; then
401                         if test "$withval" != "yes"; then
402                                 CFLAGS="-I$withval/include $CFLAGS"
403                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
404                                 LDFLAGS="-L$withval/lib $LDFLAGS"
405                         fi
406                         AC_CHECK_LIB(ident, ident_id)
407                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
408                                 AC_MSG_ERROR([Can't enable IDENT support!])
409                         )
410                 fi
411         ]
412 )
413 if test "$x_identauth_on" = "yes"; then
414         AC_DEFINE(IDENTAUTH, 1)
415         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
416 fi
417
418 # compile in IRC+ protocol support?
419
420 x_ircplus_on=yes
421 AC_ARG_ENABLE(ircplus,
422         [  --disable-ircplus       disable IRC+ protocol],
423         if test "$enableval" = "no"; then x_ircplus_on=no; fi
424 )
425 if test "$x_ircplus_on" = "yes"; then
426         AC_DEFINE(IRCPLUS, 1)
427 fi
428
429 # compile in IRC "sniffer"?
430
431 x_sniffer_on=no; x_debug_on=no
432 AC_ARG_ENABLE(sniffer,
433         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
434         if test "$enableval" = "yes"; then
435                 AC_DEFINE(SNIFFER, 1)
436                 x_sniffer_on=yes; x_debug_on=yes
437         fi
438 )
439
440 # enable additional debugging code?
441
442 AC_ARG_ENABLE(debug,
443         [  --enable-debug          show additional debug output],
444         if test "$enableval" = "yes"; then x_debug_on=yes; fi
445 )
446 if test "$x_debug_on" = "yes"; then
447         AC_DEFINE(DEBUG, 1)
448         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
449 fi
450
451 # enable "strict RFC rules"?
452
453 x_strict_rfc_on=no
454 AC_ARG_ENABLE(strict-rfc,
455         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
456         if test "$enableval" = "yes"; then
457                 AC_DEFINE(STRICT_RFC, 1)
458                 x_strict_rfc_on=yes
459         fi
460 )
461
462 # -- Definitions --
463
464 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
465 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
466 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
467
468 # Add additional CFLAGS, eventually specified on the command line, but after
469 # running this configure script. Useful for "-Werror" for example.
470 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
471
472 # -- Generate files --
473
474 AC_OUTPUT([ \
475         Makefile \
476         doc/Makefile \
477         doc/src/Makefile \
478         src/Makefile \
479         src/portab/Makefile \
480         src/tool/Makefile \
481         src/ngircd/Makefile \
482         src/testsuite/Makefile \
483         man/Makefile \
484         contrib/Makefile \
485         contrib/Debian/Makefile \
486         contrib/MacOSX/Makefile \
487 ])
488
489 type dpkg >/dev/null 2>&1
490 if test $? -eq 0; then
491         # Generate debian/ link if the dpkg command exists
492         # (read: if we are running on a debian compatible system)
493         echo "creating Debian-specific links ..."
494         test -f debian/rules || ln -s contrib/Debian debian
495 fi
496
497 # -- Result --
498
499 echo
500 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
501 echo
502
503 # Someone please show me a better way :)  [borrowed by OpenSSH]
504 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
505 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
506 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
507 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
508 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
509
510 echo "             Target: ${target}"
511 test "$target" != "$host" && echo "               Host: ${host}"
512 echo "           Compiler: ${CC}"
513 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
514 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
515 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
516 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
517 echo
518 echo "    'ngircd' binary: $S"
519 echo " Configuration file: $C"
520 echo "       Manual pages: $M"
521 echo "      Documentation: $D"
522 echo
523
524 echo $ECHO_N "     Syslog support: $ECHO_C"
525 test "$x_syslog_on" = "yes" \
526         && echo $ECHO_N "yes   $ECHO_C" \
527         || echo $ECHO_N "no    $ECHO_C"
528 echo $ECHO_N "  Enable debug code: $ECHO_C"
529 test "$x_debug_on" = "yes" \
530         && echo "yes" \
531         || echo "no"
532
533 echo $ECHO_N "   zlib compression: $ECHO_C"
534 test "$x_zlib_on" = "yes" \
535         && echo $ECHO_N "yes   $ECHO_C" \
536         || echo $ECHO_N "no    $ECHO_C"
537 echo $ECHO_N "        IRC sniffer: $ECHO_C"
538 test "$x_sniffer_on" = "yes" \
539         && echo "yes" \
540         || echo "no"
541
542 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
543 test "$x_tcpwrap_on" = "yes" \
544         && echo $ECHO_N "yes   $ECHO_C" \
545         || echo $ECHO_N "no    $ECHO_C"
546 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
547 test "$x_strict_rfc_on" = "yes" \
548         && echo "yes" \
549         || echo "no"
550
551 echo $ECHO_N "   Zeroconf support: $ECHO_C"
552 case "$x_zeroconf_on" in
553         osx)
554                 echo $ECHO_N "Apple $ECHO_C"
555                 ;;
556         howl)
557                 echo $ECHO_N "Howl  $ECHO_C"
558                 ;;
559         *)
560                 echo $ECHO_N "no    $ECHO_C"
561                 ;;
562 esac
563 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
564 test "$x_ircplus_on" = "yes" \
565         && echo "yes" \
566         || echo "no"
567
568 echo $ECHO_N "      IDENT support: $ECHO_C"
569 test "$x_identauth_on" = "yes" \
570         && echo $ECHO_N "yes   $ECHO_C" \
571         || echo $ECHO_N "no    $ECHO_C"
572 echo $ECHO_N "        I/O backend: $ECHO_C"
573         echo "\"$x_io_backend\""
574
575 echo
576
577 # -eof-