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