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