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