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)
9 AS_HELP_STRING([--without-gcc],[use CC to compile]))
11 test -n "$CC" && cc_specified=yes
17 dnl * ) AC_PROG_CXX ;;
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"
26 dnl C99 support is required to define LLONG_MAX (at least on CentOS 5.7)
29 # Report more warnings to improve code quality.
30 CFLAGS="${CFLAGS} -Wall"
32 dnl Check for supported compiler options
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}"])
41 # Don't compare signs as it is a mess
42 CFLAGS="${CFLAGS} -Wno-sign-compare"
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}"])
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}"])
60 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
61 CFLAGS="-DSOLARIS ${CFLAGS}"
65 #dnl Checks for programs.
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 \
79 AS_IF([test $ac_cv_header_getopt_h = "no"],[AC_MSG_ERROR("getopt.h is required to compile sarg")])
83 AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
85 AS_IF([test "x$with_gd" != "xno"],
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"],
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"],
93 AC_MSG_ERROR([libgd is required to compile sarg with gd])
104 AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
105 [],[with_ldap=check])
106 AS_IF([test "x$with_ldap" != "xno"],
108 AC_CHECK_HEADERS([ldap_cdefs.h] [ldap_features.h] [ldap.h],,break)
109 AS_IF([test "x$ac_cv_header_ldap_h" = "xyes"],
111 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
113 ldap_status="not found"
116 ldap_status="disabled"
121 AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
122 [],[with_iconv=check])
123 AS_IF([test "x$with_iconv" != "xno"],
127 AS_IF([test -n "$LIBICONV"],[LIBS="$LIBS $LIBICONV"])
128 AC_CHECK_HEADERS(iconv.h)
130 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
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"],
139 AC_CHECK_HEADERS(pcre.h)
140 AS_IF([test "x$ac_cv_header_pcre_h" = "xyes"],
142 LIBS="$LIBS $(pcre-config --libs)"
143 CFLAGS="$CFLAGS $(pcre-config --cflags)"
145 pcre_status="not found"
148 pcre_status="disabled"
151 # Build with file globbing
153 AS_HELP_STRING([--without-glob],[Ignore wildcards in file names]),
155 AS_IF([test "x$with_glob" != "xno"],
157 AC_CHECK_HEADERS([glob.h],[],
159 AS_IF([test "x$with_glob" != "xcheck"],
161 AC_MSG_FAILURE([glob.h not found (use --without-glob to compile without file globbing)])
165 glob_status="disabled"
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" ],
174 AC_CHECK_HEADERS(zlib.h)
175 AS_IF([test "x$ac_cv_header_zlib_h" = "xyes"],
177 AC_CHECK_LIB(z, gzopen,LIBS="-lz ${LIBS}"; HAVE_ZLIB_LIB="yes", HAVE_ZLIB_LIB="")
178 AS_IF([test "x$HAVE_ZLIB_LIB" != "xyes"],[AC_MSG_ERROR([zlib was not found])])
180 zlib_status="not found"
183 zlib_status="disabled"
186 dnl Checks for typedefs, structures, and compiler characteristics.
190 # Change the gettext version according to the available version on your system.
191 # It should not be necessary to change it unless you run autoreconf -fi.
192 AM_GNU_GETTEXT_VERSION([0.18])
193 AM_GNU_GETTEXT([external])
197 # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
198 # needs to be defined for it
199 AC_MSG_CHECKING([for fopen64])
200 AC_CACHE_VAL(bu_cv_have_fopen64,
201 [noerror_CFLAGS=$CFLAGS
202 CFLAGS="$CFLAGS -Werror"
203 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
204 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
205 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
206 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
207 CFLAGS=$noerror_CFLAGS
208 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
209 werror_status="fail"],
210 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
211 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
212 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
213 werror_status="fail",
214 bu_cv_have_fopen64=no)]))
216 CFLAGS=$noerror_CFLAGS])
217 AC_MSG_RESULT($bu_cv_have_fopen64)
218 AS_IF([test "$bu_cv_have_fopen64" != no],
220 AC_DEFINE([HAVE_FOPEN64],1,[Is fopen64 available?])
221 AS_IF([test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"],
223 AC_DEFINE([_LARGEFILE64_SOURCE],1,[Enable LFS])
227 dnl check for functions
228 AC_CHECK_FUNCS(backtrace)
229 AC_CHECK_FUNCS(symlink)
230 AC_CHECK_FUNCS(lstat)
231 AC_CHECK_FUNCS(getnameinfo)
232 AC_CHECK_FUNCS(getaddrinfo)
233 AC_CHECK_FUNCS(mkstemp)
234 AC_CHECK_FUNCS(fnmatch)
236 dnl check for structure members
237 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
239 dnl windows require this library
240 AS_IF([test $ac_cv_header_winsock_h = "yes"],
242 # AC_CHECK_LIBS([ws2_32],[WSAGetLastError]) fails because of the __stdcall in the function prototype
243 LIBS="$LIBS -lws2_32"
246 dnl check for the rlim_t size
247 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
248 #include <sys/resource.h>
251 AS_IF([test $ac_cv_sizeof_rlim_t = "4"],
253 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
254 ],[test $ac_cv_sizeof_rlim_t = "8"],
256 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
258 AC_MSG_WARN([can not detect the size of your system rlim_t type])
261 dnl check for the long long int max constant
262 AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
263 AS_IF([test "x$ac_cv_have_decl_LLONG_MAX" != "xyes"],
265 AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
268 dnl Select sarg-php directory
269 AC_ARG_ENABLE(sargphp,
270 AS_HELP_STRING([--enable-sargphp=sargphpdir],
271 [Select sargphpdir as the directory to install sarg-php into]),
273 AS_IF([test "$enableval" -a "x$enableval" != "xno"],[SARGPHPDIR=$enableval])
274 ],[SARGPHPDIR="/var/www/html"])
275 AS_IF([test "$SARGPHPDIR"],
277 AC_MSG_NOTICE([using $SARGPHPDIR as the directory to install sarg-php])
282 AC_ARG_ENABLE(fontdir,
283 AS_HELP_STRING([--enable-fontdir=fontdir],
284 [Select fontdir as the directory with the fonts to use in the reports]),
286 AS_IF([test "$enableval" -a "x$enableval" != "xno"],[FONTDIR=$enableval])
287 ],[FONTDIR="${datarootdir}/sarg/fonts"])
288 AS_IF([test "$FONTDIR"],
290 AS_IF([test "x$prefix" = "xNONE"],
292 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
294 tempfullpath=`eval "echo $FONTDIR"`
296 AC_MSG_NOTICE([using $tempfullpath as the directory of the fonts])
300 dnl Select images dir
301 AC_ARG_ENABLE(imagedir,
302 AS_HELP_STRING([--enable-imagedir=imagedir],
303 [Select imagedir as the directory with the images to use in the reports]),
305 AS_IF([test "$enableval"],[IMAGEDIR=$enableval])
306 ],[IMAGEDIR="${datarootdir}/sarg/images"])
307 AS_IF([test "x$prefix" = "xNONE"],
309 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
311 tempfullpath=`eval "echo $IMAGEDIR"`
313 AC_MSG_NOTICE([using $tempfullpath as the directory of the images])
316 dnl Enable extra compile and run time protection
317 AC_ARG_ENABLE(extraprotection,
318 AS_HELP_STRING([--enable-extraprotection],
319 [Enable compile and runtime extra protections]),
321 AS_IF([test "$enableval"],
323 # _FORTIFY_SOURCE may have been defined by the system. It must be undefined before it is changed to the value we want.
324 CFLAGS="${CFLAGS} -fstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
325 AS_IF([test "x$werror_status" != "xfail"],[CFLAGS="${CFLAGS} -Werror"])
327 AC_MSG_CHECKING([for format security flag in $CC])
328 saved_CFLAGS="${CFLAGS}"
329 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
330 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
331 AC_MSG_RESULT($have_format_security)
332 AS_IF([test "$have_format_security" = "no"],[CFLAGS="${saved_CFLAGS}"])
334 AC_MSG_CHECKING([for empty body flag in $CC])
335 saved_CFLAGS="${CFLAGS}"
336 CFLAGS="${CFLAGS} -Wempty-body"
337 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
338 AC_MSG_RESULT($have_empty_body)
339 AS_IF([test "$have_empty_body" = "no"],[CFLAGS="${saved_CFLAGS}"])
343 dnl Enable double check of the data written in the reports
344 AC_ARG_ENABLE(doublecheck,
345 AS_HELP_STRING([--enable-doublecheck],
346 [Make sarg double check the data it manipulates and output a warning if an error is found]),
348 AS_IF([test "$enableval"],
350 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
354 dnl Get the xsl stylesheet to produce the manpage
355 AC_ARG_ENABLE(xsl-man,
356 AS_HELP_STRING([--enable-xsl-man=man-xsl-style-sheet],
357 [Select the directory containing the the XSL stylesheets to convert DocBook into man page]),
359 AS_IF([test "$enableval"],
361 XSL_MAN_STYLESHEET=$enableval
362 AC_SUBST(XSL_MAN_STYLESHEET)
365 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl],
368 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl"
369 AC_SUBST(XSL_MAN_STYLESHEET)
372 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl],
375 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl"
376 AC_SUBST(XSL_MAN_STYLESHEET)
380 dnl Get the xsl stylesheet to produce the html page
381 AC_ARG_ENABLE(xsl-html,
382 AS_HELP_STRING([--enable-xsl-html=html-xsl-style-sheet],
383 [Select the directory containing the the XSL stylesheets to convert DocBook into html page]),
385 AS_IF([test "$enableval"],
387 XSL_HTML_STYLESHEET=$enableval
388 AC_SUBST(XSL_HTML_STYLESHEET)
391 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl],
394 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl"
395 AC_SUBST(XSL_HTML_STYLESHEET)
398 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl],
401 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl"
402 AC_SUBST(XSL_HTML_STYLESHEET)
406 AC_SUBST(PACKAGE,"$PACKAGE_NAME")
407 AC_SUBST(VERSION,"$PACKAGE_VERSION")
409 AC_CONFIG_FILES([Makefile po/Makefile.in])
412 AS_IF([test "x$gd_status" = "xdisabled"],[
413 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
414 ],[test "x$gd_status" = "xnot found"],[
415 AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report])
418 AS_IF([test "x$pcre_status" = "xdisabled"],[
419 AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
420 ],[test "x$pcre_status" = "xnot found"],[
421 AC_MSG_NOTICE([pcre.h was not found so the regexp won't be available in hostalias])
424 AS_IF([test "x$ldap_status" = "xdisabled"],[
425 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
426 ],[test "x$ldap_status" = "xnot found"],[
427 AC_MSG_NOTICE([ldap header files not found so LDAP is not available to resolve user's names])
430 AS_IF([test "x$glob_status" = "xdisabled"],[
431 AC_MSG_NOTICE([Not building with file globbing as requested on the configuration command line])
434 AS_IF([test "x$zlib_status" = "xdisabled"],[
435 AC_MSG_NOTICE([Not building with zlib as requested on the configuration command line])
436 ],[test "x$zlib_status" = "xnot found"],[
437 AC_MSG_NOTICE([zlib.h was not found so it won't be possible to process gzipped files])