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