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