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