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