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