]> arthur.barton.de Git - ngircd-alex.git/blob - configure.in
fix gcc 4.1 -fstack-protector detection.
[ngircd-alex.git] / configure.in
1 #
2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2005 Alexander Barton <alex@barton.de>
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 # $Id: configure.in,v 1.120 2006/08/13 18:11:18 fw Exp $
12 #
13
14 # -- Initialisation --
15
16 AC_PREREQ(2.50)
17 AC_INIT(ngircd, CVSHEAD)
18 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
19 AC_CANONICAL_TARGET
20 AM_INIT_AUTOMAKE(1.6)
21 AM_CONFIG_HEADER(src/config.h)
22
23 # -- Templates for config.h --
24
25 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
26 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
27 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
28 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
29 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
30 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
31 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
32 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
33 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
34 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
35
36 AH_TEMPLATE([TARGET_OS], [Target operating system name])
37 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
38 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
39
40 # -- C Compiler --
41
42 AC_PROG_CC
43
44 # -- Helper programs --
45
46 AC_PROG_AWK
47 AC_PROG_INSTALL
48 AC_PROG_LN_S
49 AC_PROG_MAKE_SET
50 AC_PROG_RANLIB
51
52 # -- Compiler Features --
53
54 AM_C_PROTOTYPES
55 AC_C_CONST
56 AC_C_INLINE
57
58 # -- Hard coded system and compiler dependencies/features/options ... --
59
60 if test "$GCC" = "yes"; then
61         # We are using the GNU C compiler. Good!
62         CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
63 fi
64
65
66 AC_DEFUN([GCC_STACK_PROTECT_CC],[
67   ssp_cc=yes
68   if test "X$CC" != "X"; then
69     AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
70     ssp_old_cflags="$CFLAGS"
71     CFLAGS="$CFLAGS -fstack-protector"
72     AC_TRY_LINK(,,, ssp_cc=no)
73     echo $ssp_cc
74     if test "X$ssp_cc" = "Xno"; then
75       CFLAGS="$ssp_old_cflags"
76     else
77       AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
78     fi
79   fi
80 ])
81
82 GCC_STACK_PROTECT_CC
83
84 case "$target_os" in
85         hpux*)
86                 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
87                 # (tested with HP/UX 11.11)
88                 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
89                 ;;
90 esac
91
92 # Add additional CFLAGS, eventually specified on the command line:
93 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
94
95 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
96
97 # -- Headers --
98
99 AC_HEADER_STDC
100 AC_HEADER_TIME
101 AC_HEADER_SYS_WAIT
102
103 AC_CHECK_HEADERS([ \
104         ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
105         strings.h sys/socket.h sys/time.h unistd.h \
106         ],,AC_MSG_ERROR([required C header missing!]))
107
108 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
109
110 # -- Datatypes --
111
112 AC_MSG_CHECKING(whether socklen_t exists)
113 AC_TRY_COMPILE([
114 #include <sys/types.h>
115 #include <sys/socket.h>
116         ],[
117         socklen_t a, b;
118         a = 2; b = 4; a += b;
119         ],[
120         AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
121         ],[
122         AC_MSG_RESULT(no)
123 ])
124
125 AC_TYPE_SIGNAL
126 AC_TYPE_SIZE_T
127
128
129 # -- Libraries --
130
131 AC_CHECK_LIB(UTIL,memmove)
132 AC_CHECK_LIB(socket,bind)
133 AC_CHECK_LIB(nsl,gethostent)
134
135 # -- Functions --
136
137 AC_FUNC_FORK
138 AC_FUNC_STRFTIME
139
140 AC_CHECK_FUNCS([ \
141         bind gethostbyaddr gethostbyname gethostname inet_ntoa malloc memmove \
142         memset realloc setsid setsockopt socket strcasecmp strchr strerror \
143         strstr waitpid],,AC_MSG_ERROR([required function missing!]))
144
145 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat)
146
147 AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
148         AC_MSG_ERROR([required function select() is missing!])
149 )
150
151 # -- Configuration options --
152
153 x_syslog_on=no
154 AC_ARG_WITH(syslog,
155         [  --without-syslog        disable syslog (autodetected by default)],
156         [       if test "$withval" != "no"; then
157                         if test "$withval" != "yes"; then
158                                 CFLAGS="-I$withval/include $CFLAGS"
159                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
160                                 LDFLAGS="-L$withval/lib $LDFLAGS"
161                         fi
162                         AC_CHECK_LIB(be, syslog)
163                         AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
164                                 AC_MSG_ERROR([Can't enable syslog!])
165                         )
166                 fi
167         ],
168         [
169                 AC_CHECK_LIB(be, syslog)
170                 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
171         ]
172 )
173 if test "$x_syslog_on" = "yes"; then
174         AC_DEFINE(SYSLOG, 1)
175         AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
176 fi
177
178 x_zlib_on=no
179 AC_ARG_WITH(zlib,
180         [  --without-zlib          disable zlib compression (autodetected by default)],
181         [       if test "$withval" != "no"; then
182                         if test "$withval" != "yes"; then
183                                 CFLAGS="-I$withval/include $CFLAGS"
184                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
185                                 LDFLAGS="-L$withval/lib $LDFLAGS"
186                         fi
187                         AC_CHECK_LIB(z, deflate)
188                         AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
189                                 AC_MSG_ERROR([Can't enable zlib!])
190                         )
191                 fi
192         ],
193         [       AC_CHECK_LIB(z, deflate)
194                 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
195         ]
196 )
197 if test "$x_zlib_on" = "yes"; then
198         AC_DEFINE(ZLIB, 1)
199         AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
200 fi
201
202
203 x_io_backend=select
204 AC_ARG_WITH(epoll,
205         [  --without-epoll         disable epoll support (autodetected by default)],
206         [       if test "$withval" != "no"; then
207                         if test "$withval" != "yes"; then
208                                 CFLAGS="-I$withval/include $CFLAGS"
209                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
210                                 LDFLAGS="-L$withval/lib $LDFLAGS"
211                         fi
212                         AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll,
213                                 AC_MSG_ERROR([Can't enable epoll support!])
214                         )
215                 fi
216         ],
217         [
218                 AC_CHECK_FUNCS(epoll_create, x_io_backend=epoll)
219         ]
220 )
221
222 AC_ARG_WITH(kqueue,
223         [  --without-kqueue        disable kqueue support (autodetected by default)],
224         [       if test "$withval" != "no"; then
225                         if test "$withval" != "yes"; then
226                                 CFLAGS="-I$withval/include $CFLAGS"
227                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
228                                 LDFLAGS="-L$withval/lib $LDFLAGS"
229                         fi
230                         AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue,
231                                 AC_MSG_ERROR([Can't enable kqueue support!])
232                         )
233                 fi
234         ],
235         [
236                 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue)
237         ]
238 )
239
240
241 x_tcpwrap_on=no
242 AC_ARG_WITH(tcp-wrappers,
243         [  --with-tcp-wrappers     enable TCP wrappers support],
244         [       if test "$withval" != "no"; then
245                         if test "$withval" != "yes"; then
246                                 CFLAGS="-I$withval/include $CFLAGS"
247                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
248                                 LDFLAGS="-L$withval/lib $LDFLAGS"
249                         fi
250                         AC_MSG_CHECKING(for hosts_access)
251                         LIBS="-lwrap $LIBS"
252                         AC_TRY_LINK([
253 #include <tcpd.h>
254 int allow_severity = 0;
255 int deny_severity = 0;
256                                 ],[
257                                 tcpd_warn("link test");
258                                 ],[
259                                 AC_MSG_RESULT(yes)
260                                 AC_DEFINE(TCPWRAP, 1)
261                                 x_tcpwrap_on=yes
262                                 ],[
263                                 AC_MSG_RESULT(no)
264                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
265                         ])
266                 fi
267         ]
268 )
269
270 x_zeroconf_on=no
271 AC_ARG_WITH(zeroconf,
272         [  --with-zeroconf         enable support for "Zeroconf"],
273         [       if test "$withval" != "no"; then
274                         if test "$withval" != "yes"; then
275                                 CFLAGS="-I$withval/include $CFLAGS"
276                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
277                                 LDFLAGS="-L$withval/lib $LDFLAGS"
278                         fi
279                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
280                         [
281                                 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
282                                 AC_CHECK_LIB(howl, sw_discovery_init)
283                                 AC_CHECK_FUNCS(sw_discovery_init, \
284                                  x_zeroconf_on=howl, \
285                                  AC_MSG_ERROR([Can't enable Zeroconf!]))
286                         ])
287                 fi
288         ]
289 )
290 if test "$x_zeroconf_on" = "osx"; then
291         AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
292          mach/port.h],,AC_MSG_ERROR([required C header missing!]))
293         AC_DEFINE(ZEROCONF, 1)
294 fi
295 if test "$x_zeroconf_on" = "howl"; then
296         for dir in /usr/local/include /usr/local/include/howl* \
297          /usr/include /usr/include/howl* \
298          /usr/local/include/avahi* /usr/include/avahi*; do
299                 test -d "$dir" || continue
300                 AC_MSG_CHECKING([for Howl headers in $dir])
301                 if test -f "$dir/rendezvous/rendezvous.h"; then
302                         if test "$dir" != "/usr/local/include" -a \
303                          "$dir" != "/usr/include"; then
304                                 CFLAGS="-I$dir $CFLAGS"
305                                 CPPFLAGS="-I$dir $CPPFLAGS"
306                         fi
307                         AC_MSG_RESULT(yes)
308                         break
309                 else
310                         AC_MSG_RESULT(no)
311                 fi
312         done
313         AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
314          AC_MSG_ERROR([required C header missing!]))
315         AC_DEFINE(ZEROCONF, 1)
316 fi
317
318 x_identauth_on=no
319 AC_ARG_WITH(ident,
320         [  --with-ident            enable "IDENT" ("AUTH") protocol support],
321         [       if test "$withval" != "no"; then
322                         if test "$withval" != "yes"; then
323                                 CFLAGS="-I$withval/include $CFLAGS"
324                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
325                                 LDFLAGS="-L$withval/lib $LDFLAGS"
326                         fi
327                         AC_CHECK_LIB(ident, ident_id)
328                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
329                                 AC_MSG_ERROR([Can't enable IDENT support!])
330                         )
331                 fi
332         ]
333 )
334 if test "$x_identauth_on" = "yes"; then
335         AC_DEFINE(IDENTAUTH, 1)
336         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
337 fi
338
339 x_ircplus_on=yes
340 AC_ARG_ENABLE(ircplus,
341         [  --disable-ircplus       disable IRC+ protocol],
342         if test "$enableval" = "no"; then x_ircplus_on=no; fi
343 )
344 if test "$x_ircplus_on" = "yes"; then
345         AC_DEFINE(IRCPLUS, 1)
346 fi
347
348 x_sniffer_on=no; x_debug_on=no
349 AC_ARG_ENABLE(sniffer,
350         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
351         if test "$enableval" = "yes"; then
352                 AC_DEFINE(SNIFFER, 1)
353                 x_sniffer_on=yes; x_debug_on=yes
354         fi
355 )
356
357 AC_ARG_ENABLE(debug,
358         [  --enable-debug          show additional debug output],
359         if test "$enableval" = "yes"; then x_debug_on=yes; fi
360 )
361 if test "$x_debug_on" = "yes"; then
362         AC_DEFINE(DEBUG, 1)
363         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
364 fi
365
366 x_strict_rfc_on=no
367 AC_ARG_ENABLE(strict-rfc,
368         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
369         if test "$enableval" = "yes"; then
370                 AC_DEFINE(STRICT_RFC, 1)
371                 x_strict_rfc_on=yes
372         fi
373 )
374
375 # -- Definitions --
376
377 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
378 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
379 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
380
381 # Add additional CFLAGS, eventually specified on the command line, but after
382 # running this configure script. Useful for "-Werror" for example.
383 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
384
385 # -- Generate files --
386
387 AC_OUTPUT([ \
388         Makefile \
389         doc/Makefile \
390         doc/src/Makefile \
391         src/Makefile \
392         src/portab/Makefile \
393         src/tool/Makefile \
394         src/ngircd/Makefile \
395         src/testsuite/Makefile \
396         man/Makefile \
397         contrib/Makefile \
398         contrib/Debian/Makefile \
399         contrib/MacOSX/Makefile \
400 ])
401
402 type dpkg >/dev/null 2>&1
403 if test $? -eq 0; then
404         # Generate debian/ link if the dpkg command exists
405         # (read: if we are running on a debian compatible system)
406         echo "creating Debian-specific links ..."
407         test -f debian/rules || ln -s contrib/Debian debian
408 fi
409
410 # -- Result --
411
412 echo
413 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
414 echo
415
416 # Someone please show me a better way :)  [borrowed by OpenSSH]
417 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
418 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
419 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
420 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
421 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
422
423 echo "             Target: ${target}"
424 test "$target" != "$host" && echo "               Host: ${host}"
425 echo "           Compiler: ${CC}"
426 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
427 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
428 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
429 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
430 echo
431 echo "    'ngircd' binary: $S"
432 echo " Configuration file: $C"
433 echo "       Manual pages: $M"
434 echo "      Documentation: $D"
435 echo
436
437 echo $ECHO_N "     Syslog support: $ECHO_C"
438 test "$x_syslog_on" = "yes" \
439         && echo $ECHO_N "yes   $ECHO_C" \
440         || echo $ECHO_N "no    $ECHO_C"
441 echo $ECHO_N "  Enable debug code: $ECHO_C"
442 test "$x_debug_on" = "yes" \
443         && echo "yes" \
444         || echo "no"
445
446 echo $ECHO_N "   zlib compression: $ECHO_C"
447 test "$x_zlib_on" = "yes" \
448         && echo $ECHO_N "yes   $ECHO_C" \
449         || echo $ECHO_N "no    $ECHO_C"
450 echo $ECHO_N "        IRC sniffer: $ECHO_C"
451 test "$x_sniffer_on" = "yes" \
452         && echo "yes" \
453         || echo "no"
454
455 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
456 test "$x_tcpwrap_on" = "yes" \
457         && echo $ECHO_N "yes   $ECHO_C" \
458         || echo $ECHO_N "no    $ECHO_C"
459 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
460 test "$x_strict_rfc_on" = "yes" \
461         && echo "yes" \
462         || echo "no"
463
464 echo $ECHO_N "   Zeroconf support: $ECHO_C"
465 case "$x_zeroconf_on" in
466         osx)
467                 echo $ECHO_N "Apple $ECHO_C"
468                 ;;
469         howl)
470                 echo $ECHO_N "Howl  $ECHO_C"
471                 ;;
472         *)
473                 echo $ECHO_N "no    $ECHO_C"
474                 ;;
475 esac
476 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
477 test "$x_ircplus_on" = "yes" \
478         && echo "yes" \
479         || echo "no"
480
481 echo $ECHO_N "      IDENT support: $ECHO_C"
482 test "$x_identauth_on" = "yes" \
483         && echo $ECHO_N "yes   $ECHO_C" \
484         || echo $ECHO_N "no    $ECHO_C"
485 echo $ECHO_N "        I/O backend: $ECHO_C"
486         echo "\"$x_io_backend()\""
487
488 echo
489
490 # -eof-