]> git.ipfire.org Git - thirdparty/sarg.git/blob - configure.in
Create multiple per_user_limit files
[thirdparty/sarg.git] / configure.in
1 dnl Process this file with autoconf or autoreconf to produce a configure script.
2 AC_INIT([sarg],[2.4.0-pre1])
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 -Wno-sign-compare"
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 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}"
50 fi
51
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}"
59 fi
60
61 case "$host" in
62 *-solaris*)
63 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
64 CFLAGS="-DSOLARIS ${CFLAGS}"
65 ;;
66 esac
67
68 #dnl Checks for programs.
69 #AC_PROG_CC
70
71 dnl Check for headers
72 AC_HEADER_DIRENT
73 AC_HEADER_STDC
74
75
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 fnmatch.h \
80 winsock.h)
81
82 if test $ac_cv_header_getopt_h = "no" ; then
83 AC_MSG_ERROR("getopt.h is required to compile sarg")
84 fi
85
86 # Build with gd
87 AC_ARG_WITH([gd],
88 AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
89 [],[with_gd=check])
90 if ( test "x$with_gd" != "xno" ) ; then
91 AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
92 if ( test "x$ac_cv_header_gd_h" = "xyes" ) ; then
93 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
94 if ( test "x$HAVE_GD_LIB" != "xyes" ) ; then
95 AC_MSG_ERROR([ligbd is required to compile sarg with gd])
96 fi
97 else
98 gd_status="not found"
99 fi
100 else
101 gd_status="disabled"
102 fi
103
104 # Build with LDAP
105 AC_ARG_WITH([ldap],
106 AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
107 [],[with_ldap=check])
108 if ( test "x$with_ldap" != "xno" ) ; then
109 AC_CHECK_HEADERS(ldap.h)
110 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
111 else
112 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
113 fi
114
115 # Build with iconv
116 AC_ARG_WITH([iconv],
117 AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
118 [],[with_iconv=check])
119 if ( test "x$with_iconv" != "xno" ) ; then
120 dnl Check for iconv
121 AM_ICONV
122 if test -n "$LIBICONV" ; then
123 LIBS="$LIBS $LIBICONV"
124 fi
125 AC_CHECK_HEADERS(iconv.h)
126 else
127 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
128 fi
129
130 # Build with pcre
131 AC_ARG_WITH([pcre],
132 AS_HELP_STRING([--with-pcre],[Compile with support for the Perl Compatible Regular Expressions library]),
133 [],[with_pcre=check])
134 if ( test "x$with_pcre" != "xno" ) ; then
135 AC_CHECK_HEADERS(pcre.h)
136 if ( test "x$ac_cv_header_pcre_h" = "xyes" ) ; then
137 LDFLAGS="$LDFLAGS $(pcre-config --libs)"
138 CFLAGS="$CFLAGS $(pcre-config --cflags)"
139 else
140 pcre_status="not found"
141 fi
142 else
143 pcre_status="disabled"
144 fi
145
146 dnl Checks for typedefs, structures, and compiler characteristics.
147 AC_C_CONST
148 AC_STRUCT_TM
149
150 # Change the gettext version according to the available version on your system.
151 # It should not be necessary to change it unless you run autoreconf -fi.
152 AM_GNU_GETTEXT_VERSION([0.18])
153 AM_GNU_GETTEXT([external])
154
155 AC_SYS_LARGEFILE
156
157 # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
158 # needs to be defined for it
159 AC_MSG_CHECKING([for fopen64])
160 AC_CACHE_VAL(bu_cv_have_fopen64,
161 [noerror_CFLAGS=$CFLAGS
162 CFLAGS="$CFLAGS -Werror"
163 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
164 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
165 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
166 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
167 CFLAGS=$noerror_CFLAGS
168 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
169 werror_status="fail"],
170 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
171 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
172 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
173 werror_status="fail",
174 bu_cv_have_fopen64=no)]))
175 ])
176 CFLAGS=$noerror_CFLAGS])
177 AC_MSG_RESULT($bu_cv_have_fopen64)
178 if test "$bu_cv_have_fopen64" != no; then
179 AC_DEFINE([HAVE_FOPEN64], 1,
180 [Is fopen64 available?])
181 if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then
182 AC_DEFINE([_LARGEFILE64_SOURCE], 1,
183 [Enable LFS])
184 fi
185 fi
186
187 dnl check for functions
188 AC_CHECK_FUNCS(bzero)
189 AC_CHECK_FUNCS(backtrace)
190 AC_CHECK_FUNCS(symlink)
191 AC_CHECK_FUNCS(lstat)
192 AC_CHECK_FUNCS(getnameinfo)
193 AC_CHECK_FUNCS(getaddrinfo)
194 AC_CHECK_FUNCS(mkstemp)
195 AC_CHECK_FUNCS(fnmatch)
196
197 dnl check for structure members
198 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
199
200 dnl windows require this library
201 if test $ac_cv_header_winsock_h = "yes" ; then
202 # AC_CHECK_LIBS([ws2_32],[WSAGetLastError]) fails because of the __stdcall in the function prototype
203 LIBS="$LIBS -lws2_32"
204 fi
205
206 dnl check for the rlim_t size
207 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
208 #include <sys/resource.h>
209 #endif
210 ])
211 if test $ac_cv_sizeof_rlim_t = "4"; then
212 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
213 elif test $ac_cv_sizeof_rlim_t = "8"; then
214 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
215 else
216 AC_MSG_WARN([can not detect the size of your system rlim_t type])
217 fi
218
219 dnl check for the long long int max constant
220 AC_CHECK_DECL(LLONG_MAX,HAVE_LLONG_MAX="yes",HAVE_LLONG_MAX="no",[[#include <limits.h>]])
221 if ( test "x$ac_cv_have_decl_LLONG_MAX" != "xyes" ) ; then
222 AC_MSG_ERROR([LLONG_MAX is not defined on your system.])
223 fi
224
225 dnl Select sarg-php directory
226 AC_ARG_ENABLE(sargphp,
227 AS_HELP_STRING([--enable-sargphp=sargphpdir],
228 [Select sargphpdir as the directory to install sarg-php into]),
229 [
230 if test "$enableval" -a "x$enableval" != "xno" ; then
231 SARGPHPDIR=$enableval
232 fi
233 ],[SARGPHPDIR="/var/www/html"])
234 if test "$SARGPHPDIR" ; then
235 AC_MSG_NOTICE([using $SARGPHPDIR as the directory to install sarg-php])
236 AC_SUBST(SARGPHPDIR)
237 fi
238
239 dnl Select fonts dir
240 AC_ARG_ENABLE(fontdir,
241 AS_HELP_STRING([--enable-fontdir=fontdir],
242 [Select fontdir as the directory with the fonts to use in the reports]),
243 [
244 if test "$enableval" -a "x$enableval" != "xno" ; then
245 FONTDIR=$enableval
246 fi
247 ],[FONTDIR="${datarootdir}/sarg/fonts"])
248 if test "$FONTDIR" ; then
249 if test "x$prefix" = "xNONE" ; then
250 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
251 else
252 tempfullpath=`eval "echo $FONTDIR"`
253 fi
254 AC_MSG_NOTICE([using $tempfullpath as the directory of the fonts])
255 AC_SUBST(FONTDIR)
256 fi
257
258 dnl Select images dir
259 AC_ARG_ENABLE(imagedir,
260 AS_HELP_STRING([--enable-imagedir=imagedir],
261 [Select imagedir as the directory with the images to use in the reports]),
262 [
263 if test "$enableval"; then
264 IMAGEDIR=$enableval
265 fi
266 ],[IMAGEDIR="${datarootdir}/sarg/images"])
267 if test "x$prefix" = "xNONE" ; then
268 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
269 else
270 tempfullpath=`eval "echo $IMAGEDIR"`
271 fi
272 AC_MSG_NOTICE([using $tempfullpath as the directory of the images])
273 AC_SUBST(IMAGEDIR)
274
275 dnl Enable extra compile and run time protection
276 AC_ARG_ENABLE(extraprotection,
277 AS_HELP_STRING([--enable-extraprotection],
278 [Enable compile and runtime extra protections]),
279 [
280 if test "$enableval"; then
281 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
282 if test "x$werror_status" != "xfail" ; then
283 CFLAGS="${CFLAGS} -Werror"
284 fi
285
286 AC_MSG_CHECKING([for format security flag in $CC])
287 saved_CFLAGS="${CFLAGS}"
288 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
289 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
290 AC_MSG_RESULT($have_format_security)
291 if test "$have_format_security" = "no" ; then
292 CFLAGS="${saved_CFLAGS}"
293 fi
294
295 AC_MSG_CHECKING([for empty body flag in $CC])
296 saved_CFLAGS="${CFLAGS}"
297 CFLAGS="${CFLAGS} -Wempty-body"
298 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
299 AC_MSG_RESULT($have_empty_body)
300 if test "$have_empty_body" = "no" ; then
301 CFLAGS="${saved_CFLAGS}"
302 fi
303 fi
304 ])
305
306 dnl Enable double check of the data written in the reports
307 AC_ARG_ENABLE(doublecheck,
308 AS_HELP_STRING([--enable-doublecheck],
309 [Make sarg double check the data it manipulates and output a warning if an error is found]),
310 [
311 if test "$enableval"; then
312 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
313 fi
314 ])
315
316 dnl Get the xsl stylesheet to produce the manpage
317 AC_ARG_ENABLE(xsl-man,
318 AS_HELP_STRING([--enable-xsl-man=man-xsl-style-sheet],
319 [Select the directory containing the the XSL stylesheets to convert DocBook into man page]),
320 [
321 if test "$enableval"; then
322 XSL_MAN_STYLESHEET=$enableval
323 AC_SUBST(XSL_MAN_STYLESHEET)
324 fi
325 ],
326 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl],
327 [
328 # debian
329 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl"
330 AC_SUBST(XSL_MAN_STYLESHEET)
331 ],
332 [
333 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl],
334 [
335 # gentoo
336 XSL_MAN_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl"
337 AC_SUBST(XSL_MAN_STYLESHEET)
338 ],)
339 ]))
340
341 dnl Get the xsl stylesheet to produce the html page
342 AC_ARG_ENABLE(xsl-html,
343 AS_HELP_STRING([--enable-xsl-html=html-xsl-style-sheet],
344 [Select the directory containing the the XSL stylesheets to convert DocBook into html page]),
345 [
346 if test "$enableval"; then
347 XSL_HTML_STYLESHEET=$enableval
348 AC_SUBST(XSL_HTML_STYLESHEET)
349 fi
350 ],
351 AC_CHECK_FILES([/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl],
352 [
353 # debian
354 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/html/onechunk.xsl"
355 AC_SUBST(XSL_HTML_STYLESHEET)
356 ],
357 [
358 AC_CHECK_FILES([/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl],
359 [
360 # gentoo
361 XSL_HTML_STYLESHEET="/usr/share/sgml/docbook/xsl-stylesheets/html/onechunk.xsl"
362 AC_SUBST(XSL_HTML_STYLESHEET)
363 ],)
364 ]))
365
366 AC_SUBST(PACKAGE,"$PACKAGE_NAME")
367 AC_SUBST(VERSION,"$PACKAGE_VERSION")
368
369 AC_CONFIG_FILES([Makefile po/Makefile.in])
370 AC_OUTPUT
371
372 if ( test "x$gd_status" = "xdisabled" ) ; then
373 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
374 elif ( test "x$gd_status" = "xnot found" ) ; then
375 AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report])
376 fi
377
378 if ( test "x$pcre_status" = "xdisabled" ) ; then
379 AC_MSG_NOTICE([Not building with pcre as requested on the configuration command line])
380 elif ( test "x$pcre_status" = "xnot found" ) ; then
381 AC_MSG_NOTICE([pcre.h was not found so the regexp won't be available in the hostalias])
382 fi