]> git.ipfire.org Git - thirdparty/sarg.git/blob - configure.ac
Generate redirector log even if -d is not given
[thirdparty/sarg.git] / configure.ac
1 dnl Process this file with autoconf or autoreconf to produce a configure script.
2 AC_INIT([sarg],[2.4.0-pre2])
3 AC_CONFIG_SRCDIR([log.c])
4 AC_CONFIG_AUX_DIR([cfgaux])
5 AC_CONFIG_MACRO_DIR([m4])
6
7 dnl We don't use automake but the following macro is required to
8 dnl install "install-sh" that is required by configure.
9 dnl I may be a bug in autoconf 2.69...
10 dnl But if it is enabled, the AM_GNU_GETTEXT produce a warning!
11 dnl The solution for now is to manually run automake -a before
12 dnl running the configure script
13 dnl AM_INIT_AUTOMAKE
14
15 AC_CANONICAL_HOST
16
17 AC_ARG_WITH(gcc,
18 AS_HELP_STRING([--without-gcc],[use CC to compile]))
19
20 test -n "$CC" && cc_specified=yes
21 case ${with_gcc} in
22 yes ) CC=gcc ;;
23 dnl yes ) CC=g++ ;;
24 no ) CC=cc ;;
25 * ) AC_PROG_CC;;
26 dnl * ) AC_PROG_CXX ;;
27 esac
28
29 dnl The purpose of the following condition is unknown but it is obsolete as it is.
30 dnl The -Aa option produces an error claiming that some argument are missing.
31 dnl if test "${CC}" = "cc" ; then
32 dnl CFLAGS="${CFLAGS} -g -O2 -Aa"
33 dnl fi
34
35 dnl C99 support is required to define LLONG_MAX (at least on CentOS 5.7)
36 AC_PROG_CC_C99
37
38 # Report more warnings to improve code quality.
39 CFLAGS="${CFLAGS} -Wall"
40
41 dnl Check for supported compiler options
42
43 AC_MSG_CHECKING([for extra warnings flag in $CC])
44 saved_CFLAGS="${CFLAGS}"
45 CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
46 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_extra_warnings="yes"],[have_extra_warnings="no"])
47 AC_MSG_RESULT($have_extra_warnings)
48 AS_IF([test "$have_extra_warnings" = "no"],[CFLAGS="${saved_CFLAGS}"])
49
50 # Don't compare signs as it is a mess
51 CFLAGS="${CFLAGS} -Wno-sign-compare"
52
53 AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC])
54 saved_CFLAGS="${CFLAGS}"
55 CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
56 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
57 AC_MSG_RESULT($have_implicit_function_declaration)
58 AS_IF([test "$have_implicit_function_declaration" = "no"],[CFLAGS="${saved_CFLAGS}"])
59
60 AC_MSG_CHECKING([for format error flag in $CC])
61 saved_CFLAGS="${CFLAGS}"
62 CFLAGS="${CFLAGS} -Werror=format"
63 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
64 AC_MSG_RESULT($have_error_format)
65 AS_IF([test "$have_error_format" = "no"],[CFLAGS="${saved_CFLAGS}"])
66
67 case "$host" in
68 *-solaris*)
69 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
70 CFLAGS="-DSOLARIS ${CFLAGS}"
71 ;;
72 esac
73
74 #dnl Checks for programs.
75 #AC_PROG_CC
76
77 dnl Check for headers
78 AC_HEADER_DIRENT
79 AC_HEADER_STDC
80
81
82 AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
83 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
84 ctype.h errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \
85 execinfo.h math.h libintl.h libgen.h stdbool.h getopt.h fcntl.h fnmatch.h \
86 winsock.h)
87
88 AS_IF([test $ac_cv_header_getopt_h = "no"],[AC_MSG_ERROR("getopt.h is required to compile sarg")])
89
90 # Build with gd
91 AC_ARG_WITH([gd],
92 AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
93 [],[with_gd=check])
94 AS_IF([test "x$with_gd" != "xno"],
95 [
96 AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
97 AS_IF([test "x$ac_cv_header_gd_h" = "xyes"],
98 [
99 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
100 AS_IF([test "x$HAVE_GD_LIB" != "xyes"],
101 [
102 AC_MSG_ERROR([libgd is required to compile sarg with gd])
103 ])
104 ],[
105 gd_status="not found"
106 ])
107 ],[
108 gd_status="disabled"
109 ])
110
111 # Build with LDAP
112 AC_ARG_WITH([ldap],
113 AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
114 [],[with_ldap=check])
115 AS_IF([test "x$with_ldap" != "xno"],
116 [
117 AC_CHECK_HEADERS([ldap_cdefs.h] [ldap_features.h] [ldap.h],,break)
118 AS_IF([test "x$ac_cv_header_ldap_h" = "xyes"],
119 [
120 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
121 ],[
122 ldap_status="not found"
123 ])
124 ],[
125 ldap_status="disabled"
126 ])
127
128 # Build with iconv
129 AC_ARG_WITH([iconv],
130 AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
131 [],[with_iconv=check])
132 AS_IF([test "x$with_iconv" != "xno"],
133 [
134 dnl Check for iconv
135 AM_ICONV
136 AS_IF([test -n "$LIBICONV"],[LIBS="$LIBS $LIBICONV"])
137 AC_CHECK_HEADERS(iconv.h)
138 ],[
139 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
140 ])
141
142 # Build with pcre
143 AC_ARG_WITH([pcre],
144 AS_HELP_STRING([--with-pcre],[Compile with support for the Perl Compatible Regular Expressions library]),
145 [],[with_pcre=check])
146 AS_IF([test "x$with_pcre" != "xno"],
147 [
148 AC_CHECK_HEADERS(pcre.h)
149 AS_IF([test "x$ac_cv_header_pcre_h" = "xyes"],
150 [
151 LIBS="$LIBS $(pcre-config --libs)"
152 CFLAGS="$CFLAGS $(pcre-config --cflags)"
153 ],[
154 pcre_status="not found"
155 ])
156 ],[
157 pcre_status="disabled"
158 ])
159
160 # Build with file globbing
161 AC_ARG_WITH([glob],
162 AS_HELP_STRING([--without-glob],[Ignore wildcards in file names]),
163 [],[with_glob=yes])
164 AS_IF([test "x$with_glob" != "xno"],
165 [
166 AC_CHECK_HEADERS([glob.h],[],
167 [
168 AS_IF([test "x$with_glob" != "xcheck"],
169 [
170 AC_MSG_FAILURE([glob.h not found (use --without-glob to compile without file globbing)])
171 ])
172 ])
173 ],[
174 glob_status="disabled"
175 ])
176
177 # Build with zlib
178 AC_ARG_WITH([zlib],
179 AS_HELP_STRING([--with-zlib],[Compile with support to decompress gz files]),
180 [],[with_zlib=check])
181 AS_IF([test "x$with_zlib" != "xno" ],
182 [
183 AC_CHECK_HEADERS(zlib.h)
184 AS_IF([test "x$ac_cv_header_zlib_h" = "xyes"],
185 [
186 AC_CHECK_LIB([z],[gzopen],
187 [
188 LIBS="-lz ${LIBS}"
189 HAVE_ZLIB_LIB="yes"
190 ],[
191 HAVE_ZLIB_LIB=""
192 ])
193 AS_IF([test "x$HAVE_ZLIB_LIB" != "xyes"],[AC_MSG_ERROR([zlib was not found])])
194 ],[
195 zlib_status="not found"
196 ])
197 ],[
198 zlib_status="disabled"
199 ])
200
201 # Build with bzlib
202 AC_ARG_WITH([bzlib],
203 AS_HELP_STRING([--with-bzlib],[Compile with support to decompress bz2 files]),
204 [],[with_bzlib=check])
205 AS_IF([test "x$with_bzlib" != "xno" ],
206 [
207 AC_CHECK_HEADERS(bzlib.h)
208 AS_IF([test "x$ac_cv_header_bzlib_h" = "xyes"],
209 [
210 AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
211 [
212 LIBS="-lbz2 ${LIBS}"
213 HAVE_BZLIB_LIB="yes"
214 ],[
215 HAVE_BZLIB_LIB=""
216 ])
217 AS_IF([test "x$HAVE_BZLIB_LIB" != "xyes"],[AC_MSG_ERROR([bzlib was not found])])
218 ],[
219 bzlib_status="not found"
220 ])
221 ],[
222 bzlib_status="disabled"
223 ])
224
225 dnl Checks for typedefs, structures, and compiler characteristics.
226 AC_C_CONST
227 AC_STRUCT_TM
228
229 # Change the gettext version according to the available version on your system.
230 # It should not be necessary to change it unless you run autoreconf -fi.
231 AM_GNU_GETTEXT_VERSION([0.18])
232 AM_GNU_GETTEXT([external])
233
234 AC_SYS_LARGEFILE
235
236 # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
237 # needs to be defined for it
238 AC_MSG_CHECKING([for fopen64])
239 AC_CACHE_VAL(bu_cv_have_fopen64,
240 [noerror_CFLAGS=$CFLAGS
241 CFLAGS="$CFLAGS -Werror"
242 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
243 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
244 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
245 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
246 CFLAGS=$noerror_CFLAGS
247 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
248 werror_status="fail"],
249 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
250 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
251 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
252 werror_status="fail",
253 bu_cv_have_fopen64=no)]))
254 ])
255 CFLAGS=$noerror_CFLAGS])
256 AC_MSG_RESULT($bu_cv_have_fopen64)
257 AS_IF([test "$bu_cv_have_fopen64" != no],
258 [
259 AC_DEFINE([HAVE_FOPEN64],1,[Is fopen64 available?])
260 AS_IF([test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"],
261 [
262 AC_DEFINE([_LARGEFILE64_SOURCE],1,[Enable LFS])
263 ])
264 ])
265
266 dnl check for functions
267 AC_CHECK_FUNCS(backtrace)
268 AC_CHECK_FUNCS(symlink)
269 AC_CHECK_FUNCS(lstat)
270 AC_CHECK_FUNCS(getnameinfo)
271 AC_CHECK_FUNCS(getaddrinfo)
272 AC_CHECK_FUNCS(mkstemp)
273 AC_CHECK_FUNCS(fnmatch)
274
275 dnl check for structure members
276 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
277
278 dnl windows require this library
279 AS_IF([test $ac_cv_header_winsock_h = "yes"],
280 [
281 # AC_CHECK_LIBS([ws2_32],[WSAGetLastError]) fails because of the __stdcall in the function prototype
282 LIBS="$LIBS -lws2_32"
283 ])
284
285 dnl check for the rlim_t size
286 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
287 #include <sys/resource.h>
288 #endif
289 ])
290 AS_IF([test $ac_cv_sizeof_rlim_t = "4"],
291 [
292 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
293 ],[test $ac_cv_sizeof_rlim_t = "8"],
294 [
295 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
296 ],[
297 AC_MSG_WARN([can not detect the size of your system rlim_t type])
298 ])
299
300 dnl check for the long long int max constant
301 AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
302 AS_IF([test "x$ac_cv_have_decl_LLONG_MAX" != "xyes"],
303 [
304 AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
305 ])
306
307 dnl Select sarg-php directory
308 AC_ARG_ENABLE(sargphp,
309 AS_HELP_STRING([--enable-sargphp=sargphpdir],
310 [Select sargphpdir as the directory to install sarg-php into]),
311 [
312 AS_IF([test "$enableval" -a "x$enableval" != "xno"],[SARGPHPDIR=$enableval])
313 ],[SARGPHPDIR="/var/www/html"])
314 AS_IF([test "$SARGPHPDIR"],
315 [
316 AC_MSG_NOTICE([using $SARGPHPDIR as the directory to install sarg-php])
317 AC_SUBST(SARGPHPDIR)
318 ])
319
320 dnl Select fonts dir
321 AC_ARG_ENABLE(fontdir,
322 AS_HELP_STRING([--enable-fontdir=fontdir],
323 [Select fontdir as the directory with the fonts to use in the reports]),
324 [
325 AS_IF([test "$enableval" -a "x$enableval" != "xno"],[FONTDIR=$enableval])
326 ],[FONTDIR="${datarootdir}/sarg/fonts"])
327 AS_IF([test "$FONTDIR"],
328 [
329 AS_IF([test "x$prefix" = "xNONE"],
330 [
331 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
332 ],[
333 tempfullpath=`eval "echo $FONTDIR"`
334 ])
335 AC_MSG_NOTICE([using $tempfullpath as the directory of the fonts])
336 AC_SUBST(FONTDIR)
337 ])
338
339 dnl Select images dir
340 AC_ARG_ENABLE(imagedir,
341 AS_HELP_STRING([--enable-imagedir=imagedir],
342 [Select imagedir as the directory with the images to use in the reports]),
343 [
344 AS_IF([test "$enableval"],[IMAGEDIR=$enableval])
345 ],[IMAGEDIR="${datarootdir}/sarg/images"])
346 AS_IF([test "x$prefix" = "xNONE"],
347 [
348 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
349 ],[
350 tempfullpath=`eval "echo $IMAGEDIR"`
351 ])
352 AC_MSG_NOTICE([using $tempfullpath as the directory of the images])
353 AC_SUBST(IMAGEDIR)
354
355 dnl Enable extra compile and run time protection
356 AC_ARG_ENABLE(extraprotection,
357 AS_HELP_STRING([--enable-extraprotection],
358 [Enable compile and runtime extra protections]),
359 [
360 AS_IF([test "$enableval"],
361 [
362 # _FORTIFY_SOURCE may have been defined by the system. It must be undefined before it is changed to the value we want.
363 CFLAGS="${CFLAGS} -fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
364 AS_IF([test "x$werror_status" != "xfail"],[CFLAGS="${CFLAGS} -Werror"])
365
366 AC_MSG_CHECKING([for format security flag in $CC])
367 saved_CFLAGS="${CFLAGS}"
368 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
369 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
370 AC_MSG_RESULT($have_format_security)
371 AS_IF([test "$have_format_security" = "no"],[CFLAGS="${saved_CFLAGS}"])
372
373 AC_MSG_CHECKING([for empty body flag in $CC])
374 saved_CFLAGS="${CFLAGS}"
375 CFLAGS="${CFLAGS} -Wempty-body"
376 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
377 AC_MSG_RESULT($have_empty_body)
378 AS_IF([test "$have_empty_body" = "no"],[CFLAGS="${saved_CFLAGS}"])
379 ])
380 ])
381
382 dnl Enable double check of the data written in the reports
383 AC_ARG_ENABLE(doublecheck,
384 AS_HELP_STRING([--enable-doublecheck],
385 [Make sarg double check the data it manipulates and output a warning if an error is found]),
386 [
387 AS_IF([test "$enableval"],
388 [
389 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
390 ])
391 ])
392
393 dnl Get the xsl stylesheet to produce the manpage
394 AC_ARG_ENABLE(xsl-man,
395 AS_HELP_STRING([--enable-xsl-man=man-xsl-style-sheet],
396 [Select the directory containing the the XSL stylesheets to convert DocBook into man page]),
397 [
398 AS_IF([test "$enableval"],
399 [
400 XSL_MAN_STYLESHEET=$enableval
401 AC_SUBST(XSL_MAN_STYLESHEET)
402 ])
403 ],
404 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl],
405 [
406 # debian
407 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl"
408 AC_SUBST(XSL_MAN_STYLESHEET)
409 ],[
410 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl],
411 [
412 # gentoo
413 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl"
414 AC_SUBST(XSL_MAN_STYLESHEET)
415 ])
416 ]))
417
418 dnl Get the xsl stylesheet to produce the html page
419 AC_ARG_ENABLE(xsl-html,
420 AS_HELP_STRING([--enable-xsl-html=html-xsl-style-sheet],
421 [Select the directory containing the the XSL stylesheets to convert DocBook into html page]),
422 [
423 AS_IF([test "$enableval"],
424 [
425 XSL_HTML_STYLESHEET=$enableval
426 AC_SUBST(XSL_HTML_STYLESHEET)
427 ])
428 ],
429 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl],
430 [
431 # debian
432 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl"
433 AC_SUBST(XSL_HTML_STYLESHEET)
434 ],
435 [
436 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl],
437 [
438 # gentoo
439 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl"
440 AC_SUBST(XSL_HTML_STYLESHEET)
441 ])
442 ]))
443
444 AC_SUBST(PACKAGE,"$PACKAGE_NAME")
445 AC_SUBST(VERSION,"$PACKAGE_VERSION")
446
447 AC_CONFIG_FILES([Makefile po/Makefile.in])
448 AC_OUTPUT
449
450 AS_IF([test "x$gd_status" = "xdisabled"],[
451 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
452 ],[test "x$gd_status" = "xnot found"],[
453 AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report])
454 ])
455
456 AS_IF([test "x$pcre_status" = "xdisabled"],[
457 AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
458 ],[test "x$pcre_status" = "xnot found"],[
459 AC_MSG_NOTICE([pcre.h was not found so the regexp won't be available in hostalias])
460 ])
461
462 AS_IF([test "x$ldap_status" = "xdisabled"],[
463 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
464 ],[test "x$ldap_status" = "xnot found"],[
465 AC_MSG_NOTICE([ldap header files not found so LDAP is not available to resolve user's names])
466 ])
467
468 AS_IF([test "x$glob_status" = "xdisabled"],[
469 AC_MSG_NOTICE([Not building with file globbing as requested on the configuration command line])
470 ])
471
472 AS_IF([test "x$zlib_status" = "xdisabled"],[
473 AC_MSG_NOTICE([Not building with zlib as requested on the configuration command line])
474 ],[test "x$zlib_status" = "xnot found"],[
475 AC_MSG_NOTICE([zlib.h was not found so it won't be possible to process gzipped files])
476 ])
477
478 AS_IF([test "x$bzlib_status" = "xdisabled"],[
479 AC_MSG_NOTICE([Not building with bzlib as requested on the configuration command line])
480 ],[test "x$bzlib_status" = "xnot found"],[
481 AC_MSG_NOTICE([bzlib.h was not found so it won't be possible to process bzipped files])
482 ])