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