]> arthur.barton.de Git - ngircd-alex.git/blob - configure.ng
Make vsnprintf() portab function more portable
[ngircd-alex.git] / configure.ng
1 #
2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors
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 define(VERSION_ID,esyscmd([
13         V=`git describe 2>/dev/null | sed -e 's/rel-//g' | sed -e 's/-/~/'`;
14         [ -z "$V" -a -r configure ] \
15                 && V=`grep "PACKAGE_STRING=" configure | cut -d"'" -f2 | cut -d' ' -f2`
16         ( [ -n "$V" ] && echo "$V" || echo "??" ) | tr -d '\n';
17 ]))
18
19 m4_ifdef([AM_SILENT_RULES],
20         [m4_define([ng_color_tests], [color-tests])],
21         [m4_define([ng_color_tests], [])])
22
23 # -- Initialisation --
24
25 AC_PREREQ([2.61])
26 AC_INIT([ngIRCd],[VERSION_ID],[ngircd-ml@ngircd.barton.de],[ngircd],[http://ngircd.barton.de/])
27
28 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
29 AC_CONFIG_HEADER([src/config.h])
30 AC_CANONICAL_HOST
31
32 AM_INIT_AUTOMAKE([-Wall 1.10 ]ng_color_tests)
33
34 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
35
36 # -- Templates for config.h --
37
38 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
39 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
40 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
41 AH_TEMPLATE([ICONV], [Define if libiconv can be used, e.g. for CHARCONV])
42 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
43 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
44 AH_TEMPLATE([PAM], [Define if PAM should be used])
45 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
46 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
47 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
48 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
49 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
50 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
51
52 AH_TEMPLATE([HOST_OS], [Target operating system name])
53 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
54 AH_TEMPLATE([HOST_CPU], [Target CPU name])
55
56 # -- C Compiler --
57
58 AC_PROG_CC
59 AC_PROG_CC_STDC
60
61 # -- Helper programs --
62
63 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
64
65 AC_PROG_AWK
66 AC_PROG_INSTALL
67 AC_PROG_LN_S
68 AC_PROG_MAKE_SET
69 AC_PROG_MKDIR_P
70 AC_PROG_RANLIB
71
72 # -- Compiler Features --
73
74 AC_C_CONST
75 AC_C_INLINE
76 __ng_PROTOTYPES__
77
78 # -- Function Definitions --
79
80 AC_DEFUN([GCC_STACK_PROTECT_CC],[
81         ssp_cc=yes
82         # Use -fstack-protector-all for the test to enfoce the use of the
83         # guard variable
84         AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
85         ssp_old_cflags="$CFLAGS"
86         CFLAGS="$CFLAGS -fstack-protector-all"
87         AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],[],[ssp_cc=no])
88         echo $ssp_cc
89         CFLAGS="$ssp_old_cflags"
90         if test "X$ssp_cc" = "Xyes"; then
91                 CFLAGS="$CFLAGS -fstack-protector"
92                 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
93         fi
94 ])
95
96 AC_DEFUN([WORKING_GETADDRINFO],[
97         AC_CHECK_FUNCS([getaddrinfo],[
98                 AC_MSG_CHECKING([whether getaddrinfo() works])
99                 AC_RUN_IFELSE([AC_LANG_SOURCE([[
100 #include <stdio.h>
101 #include <sys/types.h>
102 #include <sys/socket.h>
103 #include <netdb.h>
104 int
105 main(int argc, char **argv)
106 {
107         struct addrinfo hints, *ai;
108         memset(&hints, 0, sizeof(hints));
109         hints.ai_flags = AI_PASSIVE;
110         hints.ai_socktype = SOCK_STREAM;
111         hints.ai_family = PF_UNSPEC;
112         if(getaddrinfo(NULL, "0", &hints, &ai) != 0)
113                 return 1;
114         return 0;
115 }
116                 ]])],[
117                 AC_DEFINE([HAVE_WORKING_GETADDRINFO], 1, [getaddrinfo(0)])
118                 AC_MSG_RESULT(yes)
119                 ],[
120                 AC_MSG_RESULT(no)
121                 ],[
122                 AC_MSG_RESULT(no)
123                 ])
124         ])
125 ])
126
127 # -- Hard coded system and compiler dependencies/features/options ... --
128
129 if test "$GCC" = "yes"; then
130         # We are using the GNU C compiler. Good!
131         CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
132
133         GCC_STACK_PROTECT_CC
134 fi
135
136 case "$host_os" in
137         hpux*)
138                 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
139                 # (tested with HP/UX 11.11)
140                 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
141                 ;;
142 esac
143
144 # Add additional CFLAGS, eventually specified on the command line:
145 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
146
147 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"' -DDOCDIR='\"\$(docdir)\"'"
148
149 # -- Headers --
150
151 AC_HEADER_STDC
152 AC_HEADER_SYS_WAIT
153 AC_HEADER_TIME
154
155 # Required header files
156 AC_CHECK_HEADERS([ \
157                 fcntl.h \
158                 netdb.h \
159                 netinet/in.h \
160                 stdlib.h \
161                 string.h \
162                 strings.h \
163                 sys/socket.h \
164                 sys/time.h \
165                 sys/types.h \
166                 unistd.h \
167         ],,AC_MSG_ERROR([required C header missing!]))
168
169 # Optional header files
170 AC_CHECK_HEADERS_ONCE([ \
171         arpa/inet.h \
172         inttypes.h \
173         malloc.h \
174         netinet/in_systm.h \
175         netinet/ip.h \
176         stdbool.h \
177         stddef.h \
178         stdint.h \
179         varargs.h \
180 ])
181
182 # -- Datatypes --
183
184 AC_MSG_CHECKING(whether socklen_t exists)
185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
186 #include <sys/types.h>
187 #include <sys/socket.h>
188         ]],[[
189         socklen_t a, b;
190         a = 2; b = 4; a += b;
191         ]])],[
192         AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
193         ],[
194         AC_MSG_RESULT(no)
195 ])
196
197 AC_TYPE_PID_T
198 AC_TYPE_SIZE_T
199 AC_TYPE_SSIZE_T
200 AC_TYPE_UID_T
201 AC_TYPE_UINT16_T
202 AC_TYPE_UINT32_T
203 AC_TYPE_UINT8_T
204
205 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
206  [#include <arpa/inet.h>])
207
208 # -- Libraries --
209
210 # memmove: A/UX libUTIL; but we can use our own implementation.
211 AC_SEARCH_LIBS([memmove], [UTIL])
212 # gethostbyname: Solaris libnsl
213 AC_SEARCH_LIBS([gethostbyname], [bind nsl network], [], [
214         AC_MSG_ERROR([unable to find the gethostbyname() function])
215 ])
216 # bind: SVR4 libsocket
217 AC_SEARCH_LIBS([bind], [socket network], [], [
218         AC_MSG_ERROR([unable to find the bind() function])
219 ])
220
221 # -- Functions --
222
223 AC_FUNC_FORK
224 AC_FUNC_STRFTIME
225
226 # Required functions
227 AC_CHECK_FUNCS([ \
228                 alarm \
229                 dup2 \
230                 endpwent \
231                 gethostbyaddr \
232                 gethostbyname \
233                 gethostname \
234                 gettimeofday \
235                 inet_ntoa \
236                 memset \
237                 setsid \
238                 socket \
239                 strcasecmp \
240                 strchr \
241                 strcspn \
242                 strncasecmp \
243                 strrchr \
244                 strspn \
245                 strstr \
246         ],,
247         AC_MSG_ERROR([required function missing!]))
248
249 # Optional functions
250 AC_CHECK_FUNCS_ONCE([
251         arc4random \
252         arc4random_stir \
253         gai_strerror \
254         getnameinfo \
255         inet_aton \
256         memmove \
257         setgroups \
258         sigaction \
259         sigprocmask \
260         snprintf \
261         strdup \
262         strerror \
263         strlcat \
264         strlcpy \
265         strndup \
266         strtok_r \
267         unsetenv \
268         vsnprintf \
269         waitpid \
270 ])
271
272 WORKING_GETADDRINFO
273
274 # -- Configuration options --
275
276 # use syslog?
277
278 x_syslog_on=no
279 AC_ARG_WITH(syslog,
280         AS_HELP_STRING([--without-syslog],
281                        [disable syslog (autodetected by default)]),
282         [       if test "$withval" != "no"; then
283                         if test "$withval" != "yes"; then
284                                 CFLAGS="-I$withval/include $CFLAGS"
285                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
286                                 LDFLAGS="-L$withval/lib $LDFLAGS"
287                         fi
288                         AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
289                                 AC_MSG_ERROR([Can't enable syslog!])
290                         ])
291                 fi
292         ],
293         [       AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
294         ]
295 )
296 if test "$x_syslog_on" = "yes"; then
297         AC_DEFINE(SYSLOG, 1)
298         AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
299 fi
300
301 # use zlib compression?
302
303 x_zlib_on=no
304 AC_ARG_WITH(zlib,
305         AS_HELP_STRING([--without-zlib],
306                        [disable zlib compression (autodetected by default)]),
307         [       if test "$withval" != "no"; then
308                         if test "$withval" != "yes"; then
309                                 CFLAGS="-I$withval/include $CFLAGS"
310                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
311                                 LDFLAGS="-L$withval/lib $LDFLAGS"
312                         fi
313                         AC_CHECK_LIB(z, deflate)
314                         AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
315                                 AC_MSG_ERROR([Can't enable zlib!])
316                         )
317                 fi
318         ],
319         [       AC_CHECK_LIB(z, deflate)
320                 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
321         ]
322 )
323 if test "$x_zlib_on" = "yes"; then
324         AC_DEFINE(ZLIB, 1)
325         AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
326 fi
327
328 # detect which IO API to use:
329
330 x_io_backend=none
331
332 AC_ARG_WITH(select,
333         AS_HELP_STRING([--without-select],
334                        [disable select IO support (autodetected by default)]),
335         [       if test "$withval" != "no"; then
336                         if test "$withval" != "yes"; then
337                                 CFLAGS="-I$withval/include $CFLAGS"
338                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
339                                 LDFLAGS="-L$withval/lib $LDFLAGS"
340                         fi
341                         AC_CHECK_FUNCS(select, x_io_select=yes,
342                                 AC_MSG_ERROR([Can't enable select IO support!])
343                         )
344                 fi
345         ],
346         [
347                 AC_CHECK_FUNCS(select, x_io_select=yes)
348         ]
349 )
350
351 AC_ARG_WITH(poll,
352         AS_HELP_STRING([--without-poll],
353                        [disable poll support (autodetected by default)]),
354         [       if test "$withval" != "no"; then
355                         if test "$withval" != "yes"; then
356                                 CFLAGS="-I$withval/include $CFLAGS"
357                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
358                                 LDFLAGS="-L$withval/lib $LDFLAGS"
359                         fi
360                         AC_CHECK_FUNCS(poll, [
361                                 AC_CHECK_HEADERS(poll.h,
362                                         x_io_backend=poll\(\),
363                                         AC_MSG_ERROR(
364                                              [Can't enable poll IO support!])
365                                 )
366                         ], [
367                                 AC_MSG_ERROR([Can't enable poll IO support!])
368                         ])
369                 fi
370         ],
371         [
372                 AC_CHECK_FUNCS(poll, [
373                         AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
374                 ])
375         ]
376 )
377
378 AC_ARG_WITH(devpoll,
379         AS_HELP_STRING([--without-devpoll],
380                        [disable /dev/poll IO support (autodetected by default)]),
381         [       if test "$withval" != "no"; then
382                         if test "$withval" != "yes"; then
383                                 CFLAGS="-I$withval/include $CFLAGS"
384                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
385                                 LDFLAGS="-L$withval/lib $LDFLAGS"
386                         fi
387
388                                 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
389                 fi
390         ],
391         [
392                 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
393         ]
394 )
395
396 AC_ARG_WITH(epoll,
397         AS_HELP_STRING([--without-epoll],
398                        [disable epoll IO support (autodetected by default)]),
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_FUNCS(epoll_create, x_io_epoll=yes,
406                                 AC_MSG_ERROR([Can't enable epoll IO support!])
407                         )
408                 fi
409         ],
410         [
411                 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
412         ]
413 )
414
415 AC_ARG_WITH(kqueue,
416         AS_HELP_STRING([--without-kqueue],
417                        [disable kqueue IO support (autodetected by default)]),
418         [       if test "$withval" != "no"; then
419                         if test "$withval" != "yes"; then
420                                 CFLAGS="-I$withval/include $CFLAGS"
421                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
422                                 LDFLAGS="-L$withval/lib $LDFLAGS"
423                         fi
424                         AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
425                                 AC_MSG_ERROR([Can't enable kqueue IO support!])
426                         )
427                 fi
428         ],
429         [
430                 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
431         ]
432 )
433
434 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
435         # when epoll() and select() are available, we'll use both!
436         x_io_backend="epoll(), select()"
437 else
438         if test "$x_io_epoll" = "yes"; then
439                 # we prefere epoll() if it is available
440                 x_io_backend="epoll()"
441         else
442                 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
443                         # we'll use select, when available and no "better"
444                         # interface has been detected ...
445                         x_io_backend="select()"
446                 fi
447         fi
448 fi
449
450 if test "$x_io_backend" = "none"; then
451         AC_MSG_ERROR([No useable IO API activated/found!?])
452 fi
453
454 # use SSL?
455
456 AC_ARG_WITH(openssl,
457         AS_HELP_STRING([--with-openssl],
458                        [enable SSL support using OpenSSL]),
459         [       if test "$withval" != "no"; then
460                         if test "$withval" != "yes"; then
461                                 CFLAGS="-I$withval/include $CFLAGS"
462                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
463                                 LDFLAGS="-L$withval/lib $LDFLAGS"
464                         fi
465                         AC_CHECK_LIB(crypto, BIO_s_mem)
466                         AC_CHECK_LIB(ssl, SSL_new)
467                         AC_CHECK_FUNCS(SSL_new, x_ssl_openssl=yes,
468                                 AC_MSG_ERROR([Can't enable openssl])
469                         )
470                 fi
471         ]
472 )
473
474 AC_ARG_WITH(gnutls,
475         AS_HELP_STRING([--with-gnutls],
476                        [enable SSL support using gnutls]),
477         [       if test "$withval" != "no"; then
478                         if test "$withval" != "yes"; then
479                                 CFLAGS="-I$withval/include $CFLAGS"
480                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
481                                 LDFLAGS="-L$withval/lib $LDFLAGS"
482                         fi
483                         AC_CHECK_LIB(gnutls, gnutls_global_init)
484                         AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
485                                 AC_MSG_ERROR([Can't enable gnutls])
486                         )
487                 fi
488         ]
489 )
490
491 x_ssl_lib="no"
492 if test "$x_ssl_gnutls" = "yes"; then
493         if test "$x_ssl_openssl" = "yes";then
494                 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
495         fi
496         x_ssl_lib=gnutls
497 fi
498 if test "$x_ssl_openssl" = "yes"; then
499         x_ssl_lib=openssl
500 fi
501
502 # use TCP wrappers?
503
504 x_tcpwrap_on=no
505 AC_ARG_WITH(tcp-wrappers,
506         AS_HELP_STRING([--with-tcp-wrappers],
507                        [enable TCP wrappers support]),
508         [       if test "$withval" != "no"; then
509                         if test "$withval" != "yes"; then
510                                 CFLAGS="-I$withval/include $CFLAGS"
511                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
512                                 LDFLAGS="-L$withval/lib $LDFLAGS"
513                         fi
514                         AC_MSG_CHECKING(for hosts_access)
515                         saved_LIBS="$LIBS"
516                         LIBS="-lwrap $LIBS"
517                         LIBS_END="-lwrap $LIBS_END"
518                         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
519 #include <sys/types.h>
520 #include <sys/socket.h>
521 #include <tcpd.h>
522 int allow_severity = 0;
523 int deny_severity = 0;
524                                 ]],[[
525                                 tcpd_warn("link test");
526                                 ]])],[
527                                 AC_MSG_RESULT(yes)
528                                 AC_DEFINE(TCPWRAP, 1)
529                                 x_tcpwrap_on=yes
530                                 ],[
531                                 AC_MSG_RESULT(no)
532                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
533                         ])
534                         LIBS="$saved_LIBS"
535                 fi
536         ]
537 )
538
539 # do IDENT requests using libident?
540
541 x_identauth_on=no
542 AC_ARG_WITH(ident,
543         AS_HELP_STRING([--with-ident],
544                        [enable "IDENT" ("AUTH") protocol support]),
545         [       if test "$withval" != "no"; then
546                         if test "$withval" != "yes"; then
547                                 CFLAGS="-I$withval/include $CFLAGS"
548                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
549                                 LDFLAGS="-L$withval/lib $LDFLAGS"
550                         fi
551                         AC_CHECK_LIB(ident, ident_id)
552                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
553                                 AC_MSG_ERROR([Can't enable IDENT support!])
554                         )
555                 fi
556         ]
557 )
558 if test "$x_identauth_on" = "yes"; then
559         AC_DEFINE(IDENTAUTH, 1)
560         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
561 fi
562
563 # compile in PAM support?
564
565 x_pam_on=no
566 AC_ARG_WITH(pam,
567         AS_HELP_STRING([--with-pam],
568                        [enable user authentication using PAM]),
569         [       if test "$withval" != "no"; then
570                         if test "$withval" != "yes"; then
571                                 CFLAGS="-I$withval/include $CFLAGS"
572                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
573                                 LDFLAGS="-L$withval/lib $LDFLAGS"
574                         fi
575                         AC_CHECK_LIB(pam, pam_authenticate)
576                         AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
577                                 AC_MSG_ERROR([Can't enable PAM support!])
578                         )
579                 fi
580         ]
581 )
582 if test "$x_pam_on" = "yes"; then
583         AC_DEFINE(PAM, 1)
584         AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
585         if test "$pam_ok" != "yes"; then
586                 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
587                         AC_MSG_ERROR([required C header missing!]))
588         fi
589 fi
590
591 # compile in IRC+ protocol support?
592
593 x_ircplus_on=yes
594 AC_ARG_ENABLE(ircplus,
595         AS_HELP_STRING([--disable-ircplus],
596                        [disable IRC+ protocol]),
597         if test "$enableval" = "no"; then x_ircplus_on=no; fi
598 )
599 if test "$x_ircplus_on" = "yes"; then
600         AC_DEFINE(IRCPLUS, 1)
601
602         # Compile in iconv support?
603         # We only check for it when IRC+ is enabled, because the IRC+ command
604         # CHARCONV is the only function depending on it.
605         x_iconv_on=no
606         AC_ARG_WITH(iconv,
607                 AS_HELP_STRING([--with-iconv],
608                                [enable character conversion using libiconv]),
609                 [ if test "$withval" != "no"; then
610                         if test "$withval" != "yes"; then
611                                 CFLAGS="-I$withval/include $CFLAGS"
612                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
613                                 LDFLAGS="-L$withval/lib $LDFLAGS"
614                         fi
615                         AC_CHECK_LIB(iconv, iconv_open)
616                         AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes)
617                         if test "$x_iconv_on" != "yes"; then
618                                 AC_CHECK_LIB(iconv, libiconv_open)
619                                 AC_CHECK_FUNCS(libiconv_open, x_iconv_on=yes)
620                         fi
621                         if test "$x_iconv_on" != "yes"; then
622                                 AC_MSG_ERROR([Can't enable libiconv support!])
623                         fi
624                 fi ]
625         )
626         if test "$x_iconv_on" = "yes"; then
627                 AC_DEFINE(ICONV, 1)
628         fi
629 fi
630
631 # enable support for IPv6?
632 x_ipv6_on=no
633 AC_ARG_ENABLE(ipv6,
634         AS_HELP_STRING([--enable-ipv6],
635                        [enable IPv6 protocol support]),
636         if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
637 )
638 if test "$x_ipv6_on" = "yes"; then
639         # getaddrinfo() and getnameinfo() are optional when not compiling
640         # with IPv6 support, but are required for IPv6 to work!
641         AC_CHECK_FUNCS([ \
642                 getaddrinfo getnameinfo \
643                 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
644         AC_DEFINE(WANT_IPV6, 1)
645 fi
646
647 # compile in IRC "sniffer"?
648
649 x_sniffer_on=no; x_debug_on=no
650 AC_ARG_ENABLE(sniffer,
651         AS_HELP_STRING([--enable-sniffer],
652                        [enable IRC traffic sniffer (enables debug mode)]),
653         if test "$enableval" = "yes"; then
654                 AC_DEFINE(SNIFFER, 1)
655                 x_sniffer_on=yes; x_debug_on=yes
656         fi
657 )
658
659 # enable additional debugging code?
660
661 AC_ARG_ENABLE(debug,
662         AS_HELP_STRING([--enable-debug],
663                        [show additional debug output]),
664         if test "$enableval" = "yes"; then x_debug_on=yes; fi
665 )
666 if test "$x_debug_on" = "yes"; then
667         AC_DEFINE(DEBUG, 1)
668         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
669         AC_CHECK_FUNCS(mtrace)
670 fi
671
672 # enable "strict RFC rules"?
673
674 x_strict_rfc_on=no
675 AC_ARG_ENABLE(strict-rfc,
676         AS_HELP_STRING([--enable-strict-rfc],
677                        [strict RFC conformance -- may break clients!]),
678         if test "$enableval" = "yes"; then
679                 AC_DEFINE(STRICT_RFC, 1)
680                 x_strict_rfc_on=yes
681         fi
682 )
683
684 # -- Definitions --
685
686 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
687 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
688 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
689
690 # Add additional CFLAGS, LDFLAGS and LIBS which were specified on the command
691 # line or by some tests from above, but after running this script. Useful for
692 # adding "-Werror", for example:
693 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
694 test -n "$LDFLAGS_END" && LDFLAGS="$LDFLAGS $LDFLAGS_END"
695 test -n "$LIBS_END" && LIBS="$LIBS $LIBS_END"
696
697 # -- Generate files --
698
699 AC_CONFIG_FILES([ \
700         Makefile \
701         contrib/Debian/Makefile \
702         contrib/MacOSX/Makefile \
703         contrib/MacOSX/ngIRCd.pmdoc/Makefile \
704         contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
705         contrib/Makefile \
706         doc/Makefile \
707         doc/src/Makefile \
708         man/Makefile \
709         src/ipaddr/Makefile \
710         src/Makefile \
711         src/ngircd/Makefile \
712         src/portab/Makefile \
713         src/testsuite/Makefile \
714         src/tool/Makefile \
715 ])
716
717 AC_OUTPUT
718
719 type dpkg >/dev/null 2>&1
720 if test $? -eq 0; then
721         # Generate debian/ link if the dpkg command exists
722         # (read: if we are running on a debian compatible system)
723         echo "creating Debian-specific links ..."
724         if test ! -f debian/rules -a -f contrib/Debian/rules; then
725                 ln -s contrib/Debian debian
726         fi
727 fi
728
729 # -- Result --
730
731 echo
732 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
733 echo
734
735 # Someone please show me a better way :)  [borrowed by OpenSSH]
736 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
737 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
738 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
739 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
740 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
741
742 echo "               Host: ${host}"
743 echo "           Compiler: ${CC}"
744 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
745 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
746 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
747 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
748 echo
749 echo "    'ngircd' binary: $S"
750 echo " Configuration file: $C"
751 echo "       Manual pages: $M"
752 echo "      Documentation: $D"
753 echo
754
755 echo $ECHO_N "     Syslog support: $ECHO_C"
756 test "$x_syslog_on" = "yes" \
757         && echo $ECHO_N "yes   $ECHO_C" \
758         || echo $ECHO_N "no    $ECHO_C"
759 echo $ECHO_N "  Enable debug code: $ECHO_C"
760 test "$x_debug_on" = "yes" \
761         && echo "yes" \
762         || echo "no"
763
764 echo $ECHO_N "   zlib compression: $ECHO_C"
765 test "$x_zlib_on" = "yes" \
766         && echo $ECHO_N "yes   $ECHO_C" \
767         || echo $ECHO_N "no    $ECHO_C"
768 echo $ECHO_N "        IRC sniffer: $ECHO_C"
769 test "$x_sniffer_on" = "yes" \
770         && echo "yes" \
771         || echo "no"
772
773 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
774 test "$x_tcpwrap_on" = "yes" \
775         && echo $ECHO_N "yes   $ECHO_C" \
776         || echo $ECHO_N "no    $ECHO_C"
777 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
778 test "$x_strict_rfc_on" = "yes" \
779         && echo "yes" \
780         || echo "no"
781
782 echo $ECHO_N "      IDENT support: $ECHO_C"
783 test "$x_identauth_on" = "yes" \
784         && echo $ECHO_N "yes   $ECHO_C" \
785         || echo $ECHO_N "no    $ECHO_C"
786 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
787 test "$x_ircplus_on" = "yes" \
788         && echo "yes" \
789         || echo "no"
790
791 echo $ECHO_N "      IPv6 protocol: $ECHO_C"
792 test "$x_ipv6_on" = "yes" \
793         && echo $ECHO_N "yes   $ECHO_C" \
794         || echo $ECHO_N "no    $ECHO_C"
795 echo $ECHO_N "        I/O backend: $ECHO_C"
796         echo "$x_io_backend"
797
798 echo $ECHO_N "        PAM support: $ECHO_C"
799 test "$x_pam_on" = "yes" \
800         && echo $ECHO_N "yes   $ECHO_C" \
801         || echo $ECHO_N "no    $ECHO_C"
802 echo $ECHO_N "        SSL support: $ECHO_C"
803 echo "$x_ssl_lib"
804
805 echo $ECHO_N "   libiconv support: $ECHO_C"
806         echo "$x_iconv_on"
807
808 echo
809
810 define(_automake_regex_,[[^AUTOMAKE_OPTIONS = [a-z .\-]*/portab/ansi2knr]])
811 if ! grep "_automake_regex_" src/ngircd/Makefile.am >/dev/null 2>&1; then
812         echo "WARNING:"
813         echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
814         echo "therefore don't use it to generate \"official\" distribution archives!"
815         echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"
816         echo
817 fi
818
819 # -eof-