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