]> arthur.barton.de Git - ngircd-alex.git/blob - configure.in
Use "-pipe" when compiling with gcc, speeds things up a little :-)
[ngircd-alex.git] / configure.in
1 #
2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2003 by 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.95 2003/10/19 23:03:34 alex Exp $
12 #
13
14 # -- Initialisierung --
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 fuer 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([USE_SYSLOG], [Define if syslog should be used for logging])
30 AH_TEMPLATE([USE_ZLIB], [Define if zlib compression should be enabled])
31 AH_TEMPLATE([USE_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
35 AH_TEMPLATE([TARGET_OS], [Target operating system name])
36 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
37 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
38
39 # -- C Compiler --
40
41 AC_PROG_CC
42
43 # -- Hilfsprogramme --
44
45 AC_PROG_AWK
46 AC_PROG_INSTALL
47 AC_PROG_LN_S
48 AC_PROG_MAKE_SET
49 AC_PROG_RANLIB
50
51 # -- Compiler Features --
52
53 AC_LANG_C
54
55 AM_C_PROTOTYPES
56 AC_C_CONST
57
58 # -- Defines --
59
60 os=`uname`
61
62 if test "$os" = "Linux" -o $os = "GNU"; then
63         # define _POSIX_SOURCE, _GNU_SOURCE and _BSD_SOURCE when compiling
64         # on Linux or Hurd (glibc-based systems):
65         AC_MSG_RESULT([detected ${os}, defining _POSIX_SOURCE, _GNU_SOURCE and _BSD_SOURCE])
66         add_DEFINES="-D_POSIX_SOURCE -D_GNU_SOURCE -D_BSD_SOURCE $add_DEFINES"
67 fi
68
69 if test "$os" = "A/UX"; then
70         # define _POSIX_SOURCE when compiling on A/UX:
71         AC_MSG_RESULT([detected A/UX, defining _POSIX_SOURCE])
72         add_DEFINES="-D_POSIX_SOURCE $add_DEFINES"
73 fi
74
75 if test "$os" = "HP-UX"; then
76         # define _XOPEN_SOURCE_EXTENDED when compiling on HP-UX (11.11):
77         AC_MSG_RESULT([detected HP-UX, defining _XOPEN_SOURCE_EXTENDED])
78         add_DEFINES="-D_XOPEN_SOURCE_EXTENDED $add_DEFINES"
79 fi
80
81 if test "$os" = "SunOS"; then
82         # define _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED=1 and __EXTENSIONS__
83         # when compiling on SunOS (tested with 5.6):
84         AC_MSG_RESULT([detected SunOS, defining _XOPEN_SOURCE, _XOPEN_SOURCE_EXTENDED=1 and __EXTENSIONS__])
85         add_DEFINES="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__ $add_DEFINES"
86 fi
87
88 # -- Header --
89
90 AC_HEADER_STDC
91
92 AC_HEADER_TIME
93
94 AC_HEADER_SYS_WAIT
95
96 AC_CHECK_HEADERS([ \
97         ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
98         strings.h sys/socket.h sys/time.h unistd.h \
99         ],,AC_MSG_ERROR([required C header missing!]))
100
101 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdint.h varargs.h])
102
103 # -- Datentypen --
104
105 AC_MSG_CHECKING(whether socklen_t exists)
106 AC_TRY_COMPILE([
107         #include <sys/socket.h>
108         #include <sys/types.h>
109         ],[
110         socklen_t a, b;
111         a = 2; b = 4; a += b;
112         ],[
113         AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
114         ],[
115         AC_MSG_RESULT(no)
116 ])
117
118 AC_TYPE_SIGNAL
119
120 AC_TYPE_SIZE_T
121
122 # -- Libraries --
123
124 AC_CHECK_LIB(UTIL,memmove)
125 AC_CHECK_LIB(socket,bind)
126 AC_CHECK_LIB(nsl,gethostent)
127
128 # -- Funktionen --
129
130 AC_FUNC_MALLOC
131
132 AC_FUNC_FORK
133
134 AC_FUNC_STRFTIME
135
136 AC_CHECK_FUNCS([ \
137         bind gethostbyaddr gethostbyname gethostname inet_ntoa memmove \
138         memset setsockopt socket strcasecmp strchr strerror strstr waitpid \
139         ],,AC_MSG_ERROR([required function missing!]))
140
141 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strlcpy strlcat)
142
143 AC_CHECK_FUNCS(select,[AC_CHECK_HEADERS(sys/select.h)],
144         AC_MSG_ERROR([required function select() is missing!])
145 )
146
147 # -- Konfigurationsoptionen --
148
149 x_syslog_on=no
150 AC_ARG_WITH(syslog,
151         [  --without-syslog        disable syslog (autodetected by default)],
152         [       if test "$withval" = "yes"; then
153                         AC_CHECK_LIB(be, syslog)
154                         AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
155                                 AC_MSG_ERROR([Can't enable syslog!])
156                         )
157                 fi
158         ],
159         [
160                 AC_CHECK_LIB(be, syslog)
161                 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
162         ]
163 )
164 if test "$x_syslog_on" = "yes"; then
165         AC_DEFINE(USE_SYSLOG, 1)
166         AC_CHECK_HEADERS(syslog.h)
167 fi
168
169 x_zlib_on=no
170 AC_ARG_WITH(zlib,
171         [  --without-zlib          disable zlib compression (autodetected by default)],
172         [       if test "$withval" = "yes"; then
173                         AC_CHECK_LIB(z, deflate)
174                         AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
175                                 AC_MSG_ERROR([Can't enable zlib!])
176                         )
177                 fi
178         ],
179         [       AC_CHECK_LIB(z, deflate)
180                 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
181         ]
182 )
183 if test "$x_zlib_on" = "yes"; then
184         AC_DEFINE(USE_ZLIB, 1)
185         AC_CHECK_HEADERS(zlib.h)
186 fi
187
188 x_tcpwrap_on=no
189 AC_ARG_WITH(tcp-wrappers,
190         [  --with-tcp-wrappers     enable TCP wrappers support],
191         [       if test "$withval" = "yes"; then
192                         AC_CHECK_LIB(wrap, tcpd_warn)
193                         AC_MSG_CHECKING(for hosts_access)
194                         AC_TRY_LINK([
195                                 #include <tcpd.h>
196                                 ],[
197                                 void *ptr;
198                                 ptr = hosts_access;
199                                 ],[
200                                 AC_MSG_RESULT(yes)
201                                 AC_DEFINE(USE_TCPWRAP, 1)
202                                 x_tcpwrap_on=yes
203                                 ],[
204                                 AC_MSG_RESULT(no)
205                                 AC_MSG_ERROR([Can't enable TCP wrappers!])
206                         ])
207                 fi
208         ]
209 )
210
211 x_rendezvous_on=no
212 AC_ARG_WITH(rendezvous,
213         [  --with-rendezvous       enable support for "Rendezvous"],
214         [       if test "$withval" = "yes"; then
215                         AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_rendezvous_on=yes,
216                                 AC_MSG_ERROR([Can't enable Rendezvous!])
217                         )
218                 fi
219         ]
220 )
221 if test "$x_rendezvous_on" = "yes"; then
222         AC_DEFINE(RENDEZVOUS, 1)
223         AC_CHECK_HEADERS(DNSServiceDiscovery/DNSServiceDiscovery.h mach/port.h)
224 fi
225
226 x_ircplus_on=yes
227 AC_ARG_ENABLE(ircplus,
228         [  --disable-ircplus       disable IRC+ protocol],
229         if test "$enableval" = "no"; then x_ircplus_on=no; fi
230 )
231 if test "$x_ircplus_on" = "yes"; then
232         AC_DEFINE(IRCPLUS, 1)
233 fi
234
235 x_sniffer_on=no; x_debug_on=no
236 AC_ARG_ENABLE(sniffer,
237         [  --enable-sniffer        enable IRC traffic sniffer (enables debug mode)],
238         if test "$enableval" = "yes"; then
239                 AC_DEFINE(SNIFFER, 1)
240                 x_sniffer_on=yes; x_debug_on=yes
241         fi
242 )
243
244 AC_ARG_ENABLE(debug,
245         [  --enable-debug          show additional debug output],
246         if test "$enableval" = "yes"; then x_debug_on=yes; fi
247 )
248 if test "$x_debug_on" = "yes"; then
249         AC_DEFINE(DEBUG, 1)
250 fi
251
252 x_strict_rfc_on=no
253 AC_ARG_ENABLE(strict-rfc,
254         [  --enable-strict-rfc     strict RFC conformance -- may break clients!],
255         if test "$enableval" = "yes"; then
256                 AC_DEFINE(STRICT_RFC, 1)
257                 x_strict_rfc_on=yes
258         fi
259 )
260
261 # -- Definitionen --
262
263 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
264 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
265 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
266
267 # -- Variablen --
268
269 if test "$GCC" = "yes"; then
270         the_CFLAGS="-Wmissing-declarations -Wpointer-arith -Wstrict-prototypes"
271         ansi=" -ansi"
272         pedantic=" -pedantic"
273
274         $CC --version | grep 20020420 > /dev/null 2>&1
275         if test $? -eq 0; then
276                 # Mac OS X (and Darwin?) ship with a slightly broken
277                 # prerelease of GCC 3.1 which don't like -pedantic:
278                 AC_MSG_RESULT([detected broken GNU C compiler, disabling "-pedantic"])
279                 pedantic=""
280         fi
281
282         uname | grep "CYGWIN" > /dev/null 2>&1
283         if test $? -eq 0; then
284                 # The include files of Cygwin don't like -ansi,
285                 # so we disable it:
286                 AC_MSG_RESULT([detected Cygwin, disabling "-ansi"])
287                 ansi=""
288         fi
289
290         add_CFLAGS="-pipe -Wall -W${ansi}${pedantic} $CFLAGS $CFLAGS_ADD"
291 else
292         the_CFLAGS="$CFLAGS"
293         add_CFLAGS="$CFLAGS_ADD"
294 fi
295
296 CFLAGS="$the_CFLAGS $add_CFLAGS $add_DEFINES -DSYSCONFDIR='\"\$(sysconfdir)\"'"
297
298 # -- Ausgabe der Dateien --
299
300 AC_OUTPUT([ \
301         Makefile \
302         doc/Makefile \
303         MacOSX/Makefile \
304         MacOSX/ngircd.pbproj/Makefile \
305         src/Makefile \
306         src/portab/Makefile \
307         src/tool/Makefile \
308         src/ngircd/Makefile \
309         src/testsuite/Makefile \
310         man/Makefile \
311         contrib/Makefile \
312         debian/Makefile \
313 ])
314
315 # -- Result --
316
317 echo
318 echo "ngIRCd has been configured with the following options:"
319 echo
320
321 # Someone please show me a better way :)  [borrowed by OpenSSH]
322 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
323 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
324 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
325 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
326 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
327
328 echo "               Host: ${host}"
329 echo "           Compiler: ${CC}"
330 echo "     Compiler flags: ${the_CFLAGS}"
331 test -n "$add_CFLAGS"   && echo "                     ${add_CFLAGS}"
332 test -n "$add_DEFINES"  && echo "                     ${add_DEFINES}"
333 test -n "$CPPFLAGS"     && echo " Preprocessor flags: ${CPPFLAGS}"
334 test -n "$LDFLAGS"      && echo "       Linker flags: ${LDFLAGS}"
335 test -n "$LIBS"         && echo "          Libraries: ${LIBS}"
336 echo
337 echo "    'ngircd' binary: $S"
338 echo " Configuration file: $C"
339 echo "       Manual pages: $M"
340 echo "      Documentation: $D"
341 echo
342
343 echo $ECHO_N "     Syslog support: $ECHO_C"
344 test "$x_syslog_on" = "yes" \
345         && echo $ECHO_N "yes $ECHO_C" \
346         || echo $ECHO_N "no  $ECHO_C"
347 echo $ECHO_N "  Enable debug code: $ECHO_C"
348 test "$x_debug_on" = "yes" \
349         && echo "yes" \
350         || echo "no"
351
352 echo $ECHO_N "   zlib compression: $ECHO_C"
353 test "$x_zlib_on" = "yes" \
354         && echo $ECHO_N "yes $ECHO_C" \
355         || echo $ECHO_N "no  $ECHO_C"
356 echo $ECHO_N "        IRC sniffer: $ECHO_C"
357 test "$x_sniffer_on" = "yes" \
358         && echo "yes" \
359         || echo "no"
360
361 echo $ECHO_N "   Use TCP Wrappers: $ECHO_C"
362 test "$x_tcpwrap_on" = "yes" \
363         && echo $ECHO_N "yes $ECHO_C" \
364         || echo $ECHO_N "no  $ECHO_C"
365 echo $ECHO_N "    Strict RFC mode: $ECHO_C"
366 test "$x_strict_rfc_on" = "yes" \
367         && echo "yes" \
368         || echo "no"
369
370 echo $ECHO_N " Rendezvous support: $ECHO_C"
371 test "$x_rendezvous_on" = "yes" \
372         && echo $ECHO_N "yes $ECHO_C" \
373         || echo $ECHO_N "no  $ECHO_C"
374 echo $ECHO_N "      IRC+ protocol: $ECHO_C"
375 test "$x_ircplus_on" = "yes" \
376         && echo "yes" \
377         || echo "no"
378 echo
379
380 # -eof-