]> git.ipfire.org Git - thirdparty/sarg.git/blame - configure.in
A temporary file could be left in place by sarg
[thirdparty/sarg.git] / configure.in
CommitLineData
11cb1341 1dnl Process this file with autoconf or autoreconf to produce a configure script.
5461b894 2AC_INIT([sarg],[2.3.3-pre2])
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.
7c9980f1 30CFLAGS="${CFLAGS} -Wall -Wno-sign-compare"
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)
39if test "$have_extra_warnings" == "no" ; then
40 CFLAGS="${saved_CFLAGS}"
41fi
42
43AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC])
4782357f
FM
44saved_CFLAGS="${CFLAGS}"
45CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
46AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
47AC_MSG_RESULT($have_implicit_function_declaration)
48if test "$have_implicit_function_declaration" == "no" ; then
49 CFLAGS="${saved_CFLAGS}"
50fi
51
f6614448 52AC_MSG_CHECKING([for format error flag in $CC])
4782357f
FM
53saved_CFLAGS="${CFLAGS}"
54CFLAGS="${CFLAGS} -Werror=format"
55AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
56AC_MSG_RESULT($have_error_format)
bdaa13d3 57if test "$have_error_format" == "no" ; then
4782357f
FM
58 CFLAGS="${saved_CFLAGS}"
59fi
25697a35
GS
60
61case "$host" in
62 *-solaris*)
63 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
64 CFLAGS="-DSOLARIS ${CFLAGS}"
65 ;;
66esac
67
68#dnl Checks for programs.
69#AC_PROG_CC
70
71dnl Check for headers
72AC_HEADER_DIRENT
73AC_HEADER_STDC
74
d6e703cc 75
25697a35 76AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
a50c6319 77 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
1c72006e
FM
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)
9b179eb0
FM
80
81if test $ac_cv_header_getopt_h = "no" ; then
82 AC_MSG_ERROR("getopt.h is required to compile sarg")
83fi
25697a35 84
1c72006e
FM
85# Build with gd
86AC_ARG_WITH([gd],
2020ec6f 87AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
1c72006e
FM
88[],[with_gd=check])
89if ( test "x$with_gd" != "xno" ) ; then
90 AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
8ddc656a
FM
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])
95 fi
96 else
97 gd_status="not found"
98 fi
1c72006e 99else
8ddc656a 100 gd_status="disabled"
1c72006e
FM
101fi
102
103# Build with LDAP
104AC_ARG_WITH([ldap],
2020ec6f 105AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
1c72006e
FM
106[],[with_ldap=check])
107if ( 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="")
110else
111 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
112fi
113
114# Build with iconv
115AC_ARG_WITH([iconv],
2020ec6f 116AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
1c72006e
FM
117[],[with_iconv=check])
118if ( test "x$with_iconv" != "xno" ) ; then
119 dnl Check for iconv
120 AM_ICONV
121 if test -n "$LIBICONV" ; then
122 LIBS="$LIBS $LIBICONV"
123 fi
124 AC_CHECK_HEADERS(iconv.h)
125else
126 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
127fi
25697a35 128
6e24f222
FM
129# Build with pcre
130AC_ARG_WITH([pcre],
131AS_HELP_STRING([--with-pcre],[Compile with support for the Perl Compatible Regular Expressions library]),
132[],[with_pcre=check])
133if ( 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)"
138 else
139 pcre_status="not found"
140 fi
141else
142 pcre_status="disabled"
143fi
144
25697a35
GS
145dnl Checks for typedefs, structures, and compiler characteristics.
146AC_C_CONST
147AC_STRUCT_TM
148
5963cdcd
FM
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.
151AM_GNU_GETTEXT_VERSION([0.18])
095bc6be
FM
152AM_GNU_GETTEXT([external])
153
32e71fa4 154AC_SYS_LARGEFILE
d6e703cc 155
25697a35
GS
156# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
157# needs to be defined for it
158AC_MSG_CHECKING([for fopen64])
159AC_CACHE_VAL(bu_cv_have_fopen64,
a61fe05c
FM
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);],
25697a35 165bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
a61fe05c
FM
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);],
171bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
172werror_status="fail",
173bu_cv_have_fopen64=no)]))
174 ])
175 CFLAGS=$noerror_CFLAGS])
25697a35
GS
176AC_MSG_RESULT($bu_cv_have_fopen64)
177if 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,
182 [Enable LFS])
183 fi
184fi
185
40d681bc
FM
186dnl check for functions
187AC_CHECK_FUNCS(bzero)
e6414a9d 188AC_CHECK_FUNCS(backtrace)
b5f13803 189AC_CHECK_FUNCS(symlink)
d9c45e9c 190AC_CHECK_FUNCS(lstat)
72c27633 191AC_CHECK_FUNCS(getnameinfo)
4afbb7a5 192AC_CHECK_FUNCS(getaddrinfo)
d7cb0aec 193AC_CHECK_FUNCS(mkstemp)
32e71fa4 194
a50c6319
FM
195dnl check for structure members
196AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
197
32e71fa4
FM
198dnl check for the rlim_t size
199AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
200#include <sys/resource.h>
201#endif
202])
203if test $ac_cv_sizeof_rlim_t = "4"; then
204 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
205elif test $ac_cv_sizeof_rlim_t = "8"; then
206 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
207else
740f9162 208 AC_MSG_WARN([can not detect the size of your system\'s rlim_t type])
32e71fa4
FM
209fi
210
2b17869b
FM
211dnl check for the long long int max constant
212AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
213if ( test "x$ac_cv_have_decl_LLONG_MAX" != "xyes" ) ; then
214 AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
215fi
216
7bbc1de4
FM
217dnl Select sarg-php directory
218AC_ARG_ENABLE(sargphp,
2020ec6f
FM
219AS_HELP_STRING([--enable-sargphp=sargphpdir],
220[Select sargphpdir as the directory to install sarg-php into]),
25697a35 221[
7bbc1de4
FM
222 if test "$enableval" -a "x$enableval" != "xno" ; then
223 SARGPHPDIR=$enableval
25697a35 224 fi
b51e26ba 225],[SARGPHPDIR="/var/www/html"])
7bbc1de4 226if test "$SARGPHPDIR" ; then
2e598081 227 echo "using $SARGPHPDIR as the directory to install sarg-php"
7bbc1de4
FM
228 AC_SUBST(SARGPHPDIR)
229fi
25697a35 230
b3695c67
FM
231dnl Select fonts dir
232AC_ARG_ENABLE(fontdir,
2020ec6f
FM
233AS_HELP_STRING([--enable-fontdir=fontdir],
234[Select fontdir as the directory with the fonts to use in the reports]),
b3695c67 235[
3becf85c 236 if test "$enableval" -a "x$enableval" != "xno" ; then
b3695c67
FM
237 FONTDIR=$enableval
238 fi
239],[FONTDIR="${datarootdir}/sarg/fonts"])
3becf85c 240if test "$FONTDIR" ; then
2e598081
FM
241 if test "x$prefix" == "xNONE" ; then
242 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
243 else
244 tempfullpath=`eval "echo $FONTDIR"`
245 fi
3becf85c
FM
246 echo "using $tempfullpath as the directory of the fonts"
247 AC_SUBST(FONTDIR)
248fi
b3695c67
FM
249
250dnl Select images dir
251AC_ARG_ENABLE(imagedir,
2020ec6f
FM
252AS_HELP_STRING([--enable-imagedir=imagedir],
253[Select imagedir as the directory with the images to use in the reports]),
b3695c67
FM
254[
255 if test "$enableval"; then
256 IMAGEDIR=$enableval
257 fi
258],[IMAGEDIR="${datarootdir}/sarg/images"])
2e598081
FM
259if test "x$prefix" == "xNONE" ; then
260 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
261else
262 tempfullpath=`eval "echo $IMAGEDIR"`
263fi
3becf85c 264echo "using $tempfullpath as the directory of the images"
b3695c67
FM
265AC_SUBST(IMAGEDIR)
266
05b90947
FM
267dnl Enable extra compile and run time protection
268AC_ARG_ENABLE(extraprotection,
2020ec6f
FM
269AS_HELP_STRING([--enable-extraprotection],
270[Enable compile and runtime extra protections]),
05b90947
FM
271[
272 if test "$enableval"; then
a61fe05c
FM
273 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
274 if test "x$werror_status" != "xfail" ; then
275 CFLAGS="${CFLAGS} -Werror"
276 fi
dcb54d06 277
f6614448 278 AC_MSG_CHECKING([for format security flag in $CC])
dcb54d06 279 saved_CFLAGS="${CFLAGS}"
d9c45e9c 280 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
dcb54d06 281 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
d9c45e9c 282 AC_MSG_RESULT($have_format_security)
dcb54d06
FM
283 if test "$have_format_security" == "no" ; then
284 CFLAGS="${saved_CFLAGS}"
285 fi
53aaf897
FM
286
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}"
294 fi
05b90947 295 fi
feba7d37 296])
05b90947 297
04a01ed3
FM
298dnl Enable double check of the data written in the reports
299AC_ARG_ENABLE(doublecheck,
2020ec6f
FM
300AS_HELP_STRING([--enable-doublecheck],
301[Make sarg double check the data it manipulates and output a warning if an error is found]),
04a01ed3
FM
302[
303 if test "$enableval"; then
304 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
305 fi
306])
307
b6b2e9a9
FM
308AC_SUBST(PACKAGE,"$PACKAGE_NAME")
309AC_SUBST(VERSION,"$PACKAGE_VERSION")
310
095bc6be 311AC_CONFIG_FILES([Makefile po/Makefile.in])
0743911c 312AC_OUTPUT
8ddc656a
FM
313
314if ( test "x$gd_status" == "xdisabled" ) ; then
315 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
316elif ( 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])
318fi
6e24f222
FM
319
320if ( test "x$pcre_status" == "xdisabled" ) ; then
321 AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
322elif ( 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])
324fi