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