]> arthur.barton.de Git - ngircd-alex.git/blob - configure.in
Enhanced configure script: now you can pass an (optional) search path
[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.107 2005/03/20 17:23:36 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([RENDEZVOUS], [Define if Rendezvous support 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/socket.h>
95 #include <sys/types.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 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 x_tcpwrap_on=no
182 AC_ARG_WITH(tcp-wrappers,
183         [  --with-tcp-wrappers     enable TCP wrappers support],
184         [       if test "$withval" != "no"; then
185                         if test "$withval" != "yes"; then
186                                 CFLAGS="-I$withval/include $CFLAGS"
187                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
188                                 LDFLAGS="-L$withval/lib $LDFLAGS"
189                         fi
190                         AC_CHECK_LIB(wrap, hosts_access)
191                         AC_MSG_CHECKING(for hosts_access)
192                         AC_TRY_LINK([
193                                 #include <tcpd.h>
194                                 ],[
195                                 void *ptr;
196                                 ptr = hosts_access;
197                                 ],[
198                                 AC_MSG_RESULT(yes)
199                                 AC_DEFINE(TCPWRAP, 1)
200                                 x_tcpwrap_on=yes
201                                 ],[
202                                 AC_MSG_RESULT(no)
203                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
204                         ])
205                 fi
206         ]
207 )
208
209 x_rendezvous_on=no
210 AC_ARG_WITH(rendezvous,
211         [  --with-rendezvous       enable support for "Rendezvous"],
212         [       if test "$withval" != "no"; then
213                         if test "$withval" != "yes"; then
214                                 CFLAGS="-I$withval/include $CFLAGS"
215                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
216                                 LDFLAGS="-L$withval/lib $LDFLAGS"
217                         fi
218                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_rendezvous_on=osx,
219                         [
220                                 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
221                                 AC_CHECK_LIB(howl, sw_discovery_init)
222                                 AC_CHECK_FUNCS(sw_discovery_init, \
223                                  x_rendezvous_on=howl, \
224                                  AC_MSG_ERROR([Can't enable Rendezvous!]))
225                         ])
226                 fi
227         ]
228 )
229 if test "$x_rendezvous_on" = "osx"; then
230         AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
231          mach/port.h],,AC_MSG_ERROR([required C header missing!]))
232         AC_DEFINE(RENDEZVOUS, 1)
233 fi
234 if test "$x_rendezvous_on" = "howl"; then
235         for dir in /usr/local/include /usr/local/include/howl* \
236          /usr/include /usr/include/howl*; do
237                 test -d "$dir" || continue
238                 AC_MSG_CHECKING([for Howl headers in $dir])
239                 if test -f "$dir/rendezvous/rendezvous.h"; then
240                         if test "$dir" != "/usr/local/include" -a \
241                          "$dir" != "/usr/include"; then
242                                 CFLAGS="-I$dir $CFLAGS"
243                                 CPPFLAGS="-I$dir $CPPFLAGS"
244                         fi
245                         AC_MSG_RESULT(yes)
246                         break
247                 else
248                         AC_MSG_RESULT(no)
249                 fi
250         done
251         AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
252          AC_MSG_ERROR([required C header missing!]))
253         AC_DEFINE(RENDEZVOUS, 1)
254 fi
255
256 x_identauth_on=no
257 AC_ARG_WITH(ident,
258         [  --with-ident            enable "IDENT" ("AUTH") protocol support],
259         [       if test "$withval" != "no"; then
260                         if test "$withval" != "yes"; then
261                                 CFLAGS="-I$withval/include $CFLAGS"
262                                 CPPFLAGS="-I$withval/include $CPPFLAGS"
263                                 LDFLAGS="-L$withval/lib $LDFLAGS"
264                         fi
265                         AC_CHECK_LIB(ident, ident_id)
266                         AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
267                                 AC_MSG_ERROR([Can't enable IDENT support!])
268                         )
269                 fi
270         ]
271 )
272 if test "$x_identauth_on" = "yes"; then
273         AC_DEFINE(IDENTAUTH, 1)
274         AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
275 fi
276
277 x_ircplus_on=yes
278 AC_ARG_ENABLE(ircplus,
279         [  --disable-ircplus       disable IRC+ protocol],
280         if test "$enableval" = "no"; then x_ircplus_on=no; fi
281 )
282 if test "$x_ircplus_on" = "yes"; then
283         AC_DEFINE(IRCPLUS, 1)
284 fi
285
286 x_sniffer_on=no; x_debug_on=no
287 AC_ARG_ENABLE(sniffer,
288         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
289         if test "$enableval" = "yes"; then
290                 AC_DEFINE(SNIFFER, 1)
291                 x_sniffer_on=yes; x_debug_on=yes
292         fi
293 )
294
295 AC_ARG_ENABLE(debug,
296         [  --enable-debug          show additional debug output],
297         if test "$enableval" = "yes"; then x_debug_on=yes; fi
298 )
299 if test "$x_debug_on" = "yes"; then
300         AC_DEFINE(DEBUG, 1)
301         test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
302 fi
303
304 x_strict_rfc_on=no
305 AC_ARG_ENABLE(strict-rfc,
306         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
307         if test "$enableval" = "yes"; then
308                 AC_DEFINE(STRICT_RFC, 1)
309                 x_strict_rfc_on=yes
310         fi
311 )
312
313 # -- Definitions --
314
315 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
316 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
317 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
318
319 # Add additional CFLAGS, eventually specified on the command line, but after
320 # running this configure script. Useful for "-Werror" for example.
321 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
322
323 # -- Generate files --
324
325 AC_OUTPUT([ \
326         Makefile \
327         doc/Makefile \
328         src/Makefile \
329         src/portab/Makefile \
330         src/tool/Makefile \
331         src/ngircd/Makefile \
332         src/testsuite/Makefile \
333         man/Makefile \
334         contrib/Makefile \
335         contrib/Debian/Makefile \
336         contrib/MacOSX/Makefile \
337 ])
338
339 type dpkg >/dev/null 2>&1
340 if test $? -eq 0; then
341         # Generate debian/ link if the dpkg command exists
342         # (read: if we are running on a debian compatible system)
343         echo "creating Debian-specific links ..."
344         test -f debian/rules || ln -s contrib/Debian debian
345 fi
346
347 # -- Result --
348
349 echo
350 echo "ngIRCd has been configured with the following options:"
351 echo
352
353 # Someone please show me a better way :)  [borrowed by OpenSSH]
354 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
355 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
356 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
357 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
358 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
359
360 echo "             Target: ${target}"
361 test "$target" != "$host" && echo "               Host: ${host}"
362 echo "           Compiler: ${CC}"
363 test -n "$CFLAGS"       && echo "     Compiler flags: ${CFLAGS}"
364 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
365 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
366 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
367 echo
368 echo "    'ngircd' binary: $S"
369 echo " Configuration file: $C"
370 echo "       Manual pages: $M"
371 echo "      Documentation: $D"
372 echo
373
374 echo $ECHO_N "     Syslog support: $ECHO_C"
375 test "$x_syslog_on" = "yes" \
376         && echo $ECHO_N "yes $ECHO_C" \
377         || echo $ECHO_N "no  $ECHO_C"
378 echo $ECHO_N "  Enable debug code: $ECHO_C"
379 test "$x_debug_on" = "yes" \
380         && echo "yes" \
381         || echo "no"
382
383 echo $ECHO_N "   zlib compression: $ECHO_C"
384 test "$x_zlib_on" = "yes" \
385         && echo $ECHO_N "yes $ECHO_C" \
386         || echo $ECHO_N "no  $ECHO_C"
387 echo $ECHO_N "        IRC sniffer: $ECHO_C"
388 test "$x_sniffer_on" = "yes" \
389         && echo "yes" \
390         || echo "no"
391
392 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
393 test "$x_tcpwrap_on" = "yes" \
394         && echo $ECHO_N "yes $ECHO_C" \
395         || echo $ECHO_N "no  $ECHO_C"
396 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
397 test "$x_strict_rfc_on" = "yes" \
398         && echo "yes" \
399         || echo "no"
400
401 echo $ECHO_N " Rendezvous support: $ECHO_C"
402 test "$x_rendezvous_on" = "osx" -o "$x_rendezvous_on" = "howl" \
403         && echo $ECHO_N "yes $ECHO_C" \
404         || echo $ECHO_N "no  $ECHO_C"
405 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
406 test "$x_ircplus_on" = "yes" \
407         && echo "yes" \
408         || echo "no"
409
410 echo $ECHO_N "      IDENT support: $ECHO_C"
411 test "$x_identauth_on" = "yes" \
412         && echo $ECHO_N "yes $ECHO_C" \
413         || echo $ECHO_N "no  $ECHO_C"
414
415 echo; echo
416
417 # -eof-