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