1 dnl Process this file with autoconf or autoreconf to produce a configure script.
2 AC_INIT([sarg],[2.3.3-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 -Wno-sign-compare"
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 if test "$have_extra_warnings" == "no" ; then
40 CFLAGS="${saved_CFLAGS}"
43 AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC])
44 saved_CFLAGS="${CFLAGS}"
45 CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
46 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
47 AC_MSG_RESULT($have_implicit_function_declaration)
48 if test "$have_implicit_function_declaration" == "no" ; then
49 CFLAGS="${saved_CFLAGS}"
52 AC_MSG_CHECKING([for format error flag in $CC])
53 saved_CFLAGS="${CFLAGS}"
54 CFLAGS="${CFLAGS} -Werror=format"
55 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
56 AC_MSG_RESULT($have_error_format)
57 if test "$have_error_format" == "no" ; then
58 CFLAGS="${saved_CFLAGS}"
63 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
64 CFLAGS="-DSOLARIS ${CFLAGS}"
68 #dnl Checks for programs.
76 AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
77 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
78 ctype.h errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \
79 execinfo.h math.h libintl.h libgen.h stdbool.h getopt.h fcntl.h)
81 if test $ac_cv_header_getopt_h = "no" ; then
82 AC_MSG_ERROR("getopt.h is required to compile sarg")
87 AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
89 if ( test "x$with_gd" != "xno" ) ; then
90 AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
91 if ( test "x$ac_cv_header_gd_h" == "xyes" ) ; then
92 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
93 if ( test "x$HAVE_GD_LIB" != "xyes" ) ; then
94 AC_MSG_ERROR([ligbd is required to compile sarg with gd])
105 AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
106 [],[with_ldap=check])
107 if ( test "x$with_ldap" != "xno" ) ; then
108 AC_CHECK_HEADERS(ldap.h)
109 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
111 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
116 AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
117 [],[with_iconv=check])
118 if ( test "x$with_iconv" != "xno" ) ; then
121 if test -n "$LIBICONV" ; then
122 LIBS="$LIBS $LIBICONV"
124 AC_CHECK_HEADERS(iconv.h)
126 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
131 AS_HELP_STRING([--with-pcre],[Compile with support for the Perl Compatible Regular Expressions library]),
132 [],[with_pcre=check])
133 if ( test "x$with_pcre" != "xno" ) ; then
134 AC_CHECK_HEADERS(pcre.h)
135 if ( test "x$ac_cv_header_pcre_h" == "xyes" ) ; then
136 LDFLAGS="$LDFLAGS $(pcre-config --libs)"
137 CFLAGS="$CFLAGS $(pcre-config --cflags)"
139 pcre_status="not found"
142 pcre_status="disabled"
145 dnl Checks for typedefs, structures, and compiler characteristics.
149 # Change the gettext version according to the available version on your system.
150 # It should not be necessary to change it unless you run autoreconf -fi.
151 AM_GNU_GETTEXT_VERSION([0.18])
152 AM_GNU_GETTEXT([external])
156 # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
157 # needs to be defined for it
158 AC_MSG_CHECKING([for fopen64])
159 AC_CACHE_VAL(bu_cv_have_fopen64,
160 [noerror_CFLAGS=$CFLAGS
161 CFLAGS="$CFLAGS -Werror"
162 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
163 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
164 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
165 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
166 CFLAGS=$noerror_CFLAGS
167 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
168 werror_status="fail"],
169 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
170 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
171 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
172 werror_status="fail",
173 bu_cv_have_fopen64=no)]))
175 CFLAGS=$noerror_CFLAGS])
176 AC_MSG_RESULT($bu_cv_have_fopen64)
177 if test "$bu_cv_have_fopen64" != no; then
178 AC_DEFINE([HAVE_FOPEN64], 1,
179 [Is fopen64 available?])
180 if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then
181 AC_DEFINE([_LARGEFILE64_SOURCE], 1,
186 dnl check for functions
187 AC_CHECK_FUNCS(bzero)
188 AC_CHECK_FUNCS(backtrace)
189 AC_CHECK_FUNCS(symlink)
190 AC_CHECK_FUNCS(lstat)
191 AC_CHECK_FUNCS(getnameinfo)
192 AC_CHECK_FUNCS(getaddrinfo)
193 AC_CHECK_FUNCS(mkstemp)
195 dnl check for structure members
196 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
198 dnl check for the rlim_t size
199 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
200 #include <sys/resource.h>
203 if test $ac_cv_sizeof_rlim_t = "4"; then
204 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
205 elif test $ac_cv_sizeof_rlim_t = "8"; then
206 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
208 AC_MSG_WARN([can not detect the size of your system\'s rlim_t type])
211 dnl check for the long long int max constant
212 AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
213 if ( test "x$ac_cv_have_decl_LLONG_MAX" != "xyes" ) ; then
214 AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
217 dnl Select sarg-php directory
218 AC_ARG_ENABLE(sargphp,
219 AS_HELP_STRING([--enable-sargphp=sargphpdir],
220 [Select sargphpdir as the directory to install sarg-php into]),
222 if test "$enableval" -a "x$enableval" != "xno" ; then
223 SARGPHPDIR=$enableval
225 ],[SARGPHPDIR="/var/www/html"])
226 if test "$SARGPHPDIR" ; then
227 echo "using $SARGPHPDIR as the directory to install sarg-php"
232 AC_ARG_ENABLE(fontdir,
233 AS_HELP_STRING([--enable-fontdir=fontdir],
234 [Select fontdir as the directory with the fonts to use in the reports]),
236 if test "$enableval" -a "x$enableval" != "xno" ; then
239 ],[FONTDIR="${datarootdir}/sarg/fonts"])
240 if test "$FONTDIR" ; then
241 if test "x$prefix" == "xNONE" ; then
242 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
244 tempfullpath=`eval "echo $FONTDIR"`
246 echo "using $tempfullpath as the directory of the fonts"
250 dnl Select images dir
251 AC_ARG_ENABLE(imagedir,
252 AS_HELP_STRING([--enable-imagedir=imagedir],
253 [Select imagedir as the directory with the images to use in the reports]),
255 if test "$enableval"; then
258 ],[IMAGEDIR="${datarootdir}/sarg/images"])
259 if test "x$prefix" == "xNONE" ; then
260 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
262 tempfullpath=`eval "echo $IMAGEDIR"`
264 echo "using $tempfullpath as the directory of the images"
267 dnl Enable extra compile and run time protection
268 AC_ARG_ENABLE(extraprotection,
269 AS_HELP_STRING([--enable-extraprotection],
270 [Enable compile and runtime extra protections]),
272 if test "$enableval"; then
273 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
274 if test "x$werror_status" != "xfail" ; then
275 CFLAGS="${CFLAGS} -Werror"
278 AC_MSG_CHECKING([for format security flag in $CC])
279 saved_CFLAGS="${CFLAGS}"
280 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
281 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
282 AC_MSG_RESULT($have_format_security)
283 if test "$have_format_security" == "no" ; then
284 CFLAGS="${saved_CFLAGS}"
287 AC_MSG_CHECKING([for empty body flag in $CC])
288 saved_CFLAGS="${CFLAGS}"
289 CFLAGS="${CFLAGS} -Wempty-body"
290 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
291 AC_MSG_RESULT($have_empty_body)
292 if test "$have_empty_body" == "no" ; then
293 CFLAGS="${saved_CFLAGS}"
298 dnl Enable double check of the data written in the reports
299 AC_ARG_ENABLE(doublecheck,
300 AS_HELP_STRING([--enable-doublecheck],
301 [Make sarg double check the data it manipulates and output a warning if an error is found]),
303 if test "$enableval"; then
304 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
308 AC_SUBST(PACKAGE,"$PACKAGE_NAME")
309 AC_SUBST(VERSION,"$PACKAGE_VERSION")
311 AC_CONFIG_FILES([Makefile po/Makefile.in])
314 if ( test "x$gd_status" == "xdisabled" ) ; then
315 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
316 elif ( test "x$gd_status" == "xnot found" ) ; then
317 AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report])
320 if ( test "x$pcre_status" == "xdisabled" ) ; then
321 AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
322 elif ( test "x$pcre_status" == "xnot found" ) ; then
323 AC_MSG_NOTICE([pcre.h was not found so the regexp won't be available in the hostalias])