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