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