]> git.ipfire.org Git - thirdparty/sarg.git/blame - configure.in
Speed up the second stage of the report generation
[thirdparty/sarg.git] / configure.in
CommitLineData
25697a35 1dnl Process this file with autoconf to produce a configure script.
04786bf9 2AC_INIT([sarg],[2.3.3-pre1])
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
20if test "${CC}" = "cc" ; then
05b90947 21 CFLAGS="${CFLAGS} -g -O2 -Aa"
25697a35 22fi
7c9980f1 23CFLAGS="${CFLAGS} -Wall -Wno-sign-compare"
05b90947 24
f6614448 25dnl Check for supported compiler options
4782357f 26
f6614448
FM
27AC_MSG_CHECKING([for extra warnings flag in $CC])
28saved_CFLAGS="${CFLAGS}"
7c9980f1 29CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
f6614448
FM
30AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_extra_warnings="yes"],[have_extra_warnings="no"])
31AC_MSG_RESULT($have_extra_warnings)
32if test "$have_extra_warnings" == "no" ; then
33 CFLAGS="${saved_CFLAGS}"
34fi
35
36AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC])
4782357f
FM
37saved_CFLAGS="${CFLAGS}"
38CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
39AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
40AC_MSG_RESULT($have_implicit_function_declaration)
41if test "$have_implicit_function_declaration" == "no" ; then
42 CFLAGS="${saved_CFLAGS}"
43fi
44
f6614448 45AC_MSG_CHECKING([for format error flag in $CC])
4782357f
FM
46saved_CFLAGS="${CFLAGS}"
47CFLAGS="${CFLAGS} -Werror=format"
48AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
49AC_MSG_RESULT($have_error_format)
bdaa13d3 50if test "$have_error_format" == "no" ; then
4782357f
FM
51 CFLAGS="${saved_CFLAGS}"
52fi
25697a35
GS
53
54case "$host" in
55 *-solaris*)
56 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
57 CFLAGS="-DSOLARIS ${CFLAGS}"
58 ;;
59esac
60
61#dnl Checks for programs.
62#AC_PROG_CC
63
64dnl Check for headers
65AC_HEADER_DIRENT
66AC_HEADER_STDC
67
d6e703cc 68
25697a35 69AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
a50c6319 70 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
1c72006e
FM
71 ctype.h errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \
72 execinfo.h math.h libintl.h libgen.h stdbool.h getopt.h fcntl.h)
9b179eb0
FM
73
74if test $ac_cv_header_getopt_h = "no" ; then
75 AC_MSG_ERROR("getopt.h is required to compile sarg")
76fi
25697a35 77
1c72006e
FM
78# Build with gd
79AC_ARG_WITH([gd],
2020ec6f 80AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]),
1c72006e
FM
81[],[with_gd=check])
82if ( test "x$with_gd" != "xno" ) ; then
83 AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h)
84 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
85else
86 AC_MSG_NOTICE([Not building with gd as requested on the configuration command line])
87fi
88
89# Build with LDAP
90AC_ARG_WITH([ldap],
2020ec6f 91AS_HELP_STRING([--with-ldap],[Compile with LDAP support]),
1c72006e
FM
92[],[with_ldap=check])
93if ( test "x$with_ldap" != "xno" ) ; then
94 AC_CHECK_HEADERS(ldap.h)
95 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
96else
97 AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line])
98fi
99
100# Build with iconv
101AC_ARG_WITH([iconv],
2020ec6f 102AS_HELP_STRING([--with-iconv],[Compile with support for iconv]),
1c72006e
FM
103[],[with_iconv=check])
104if ( test "x$with_iconv" != "xno" ) ; then
105 dnl Check for iconv
106 AM_ICONV
107 if test -n "$LIBICONV" ; then
108 LIBS="$LIBS $LIBICONV"
109 fi
110 AC_CHECK_HEADERS(iconv.h)
111else
112 AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line])
113fi
25697a35
GS
114
115dnl Checks for typedefs, structures, and compiler characteristics.
116AC_C_CONST
117AC_STRUCT_TM
118
5963cdcd
FM
119# Change the gettext version according to the available version on your system.
120# It should not be necessary to change it unless you run autoreconf -fi.
121AM_GNU_GETTEXT_VERSION([0.18])
095bc6be
FM
122AM_GNU_GETTEXT([external])
123
32e71fa4 124AC_SYS_LARGEFILE
d6e703cc 125
25697a35
GS
126# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
127# needs to be defined for it
128AC_MSG_CHECKING([for fopen64])
129AC_CACHE_VAL(bu_cv_have_fopen64,
a61fe05c
FM
130[noerror_CFLAGS=$CFLAGS
131 CFLAGS="$CFLAGS -Werror"
132 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
133 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
134 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
25697a35 135bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
a61fe05c
FM
136 CFLAGS=$noerror_CFLAGS
137 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
138 werror_status="fail"],
139 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
140 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
141bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
142werror_status="fail",
143bu_cv_have_fopen64=no)]))
144 ])
145 CFLAGS=$noerror_CFLAGS])
25697a35
GS
146AC_MSG_RESULT($bu_cv_have_fopen64)
147if test "$bu_cv_have_fopen64" != no; then
148 AC_DEFINE([HAVE_FOPEN64], 1,
149 [Is fopen64 available?])
150 if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then
151 AC_DEFINE([_LARGEFILE64_SOURCE], 1,
152 [Enable LFS])
153 fi
154fi
155
40d681bc
FM
156dnl check for functions
157AC_CHECK_FUNCS(bzero)
e6414a9d 158AC_CHECK_FUNCS(backtrace)
b5f13803 159AC_CHECK_FUNCS(symlink)
d9c45e9c 160AC_CHECK_FUNCS(lstat)
72c27633 161AC_CHECK_FUNCS(getnameinfo)
4afbb7a5 162AC_CHECK_FUNCS(getaddrinfo)
d7cb0aec 163AC_CHECK_FUNCS(mkstemp)
32e71fa4 164
a50c6319
FM
165dnl check for structure members
166AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
167
32e71fa4
FM
168dnl check for the rlim_t size
169AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
170#include <sys/resource.h>
171#endif
172])
173if test $ac_cv_sizeof_rlim_t = "4"; then
174 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
175elif test $ac_cv_sizeof_rlim_t = "8"; then
176 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
177else
740f9162 178 AC_MSG_WARN([can not detect the size of your system\'s rlim_t type])
32e71fa4
FM
179fi
180
7bbc1de4
FM
181dnl Select sarg-php directory
182AC_ARG_ENABLE(sargphp,
2020ec6f
FM
183AS_HELP_STRING([--enable-sargphp=sargphpdir],
184[Select sargphpdir as the directory to install sarg-php into]),
25697a35 185[
7bbc1de4
FM
186 if test "$enableval" -a "x$enableval" != "xno" ; then
187 SARGPHPDIR=$enableval
25697a35 188 fi
b51e26ba 189],[SARGPHPDIR="/var/www/html"])
7bbc1de4 190if test "$SARGPHPDIR" ; then
2e598081 191 echo "using $SARGPHPDIR as the directory to install sarg-php"
7bbc1de4
FM
192 AC_SUBST(SARGPHPDIR)
193fi
25697a35 194
b3695c67
FM
195dnl Select fonts dir
196AC_ARG_ENABLE(fontdir,
2020ec6f
FM
197AS_HELP_STRING([--enable-fontdir=fontdir],
198[Select fontdir as the directory with the fonts to use in the reports]),
b3695c67 199[
3becf85c 200 if test "$enableval" -a "x$enableval" != "xno" ; then
b3695c67
FM
201 FONTDIR=$enableval
202 fi
203],[FONTDIR="${datarootdir}/sarg/fonts"])
3becf85c 204if test "$FONTDIR" ; then
2e598081
FM
205 if test "x$prefix" == "xNONE" ; then
206 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
207 else
208 tempfullpath=`eval "echo $FONTDIR"`
209 fi
3becf85c
FM
210 echo "using $tempfullpath as the directory of the fonts"
211 AC_SUBST(FONTDIR)
212fi
b3695c67
FM
213
214dnl Select images dir
215AC_ARG_ENABLE(imagedir,
2020ec6f
FM
216AS_HELP_STRING([--enable-imagedir=imagedir],
217[Select imagedir as the directory with the images to use in the reports]),
b3695c67
FM
218[
219 if test "$enableval"; then
220 IMAGEDIR=$enableval
221 fi
222],[IMAGEDIR="${datarootdir}/sarg/images"])
2e598081
FM
223if test "x$prefix" == "xNONE" ; then
224 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
225else
226 tempfullpath=`eval "echo $IMAGEDIR"`
227fi
3becf85c 228echo "using $tempfullpath as the directory of the images"
b3695c67
FM
229AC_SUBST(IMAGEDIR)
230
05b90947
FM
231dnl Enable extra compile and run time protection
232AC_ARG_ENABLE(extraprotection,
2020ec6f
FM
233AS_HELP_STRING([--enable-extraprotection],
234[Enable compile and runtime extra protections]),
05b90947
FM
235[
236 if test "$enableval"; then
a61fe05c
FM
237 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
238 if test "x$werror_status" != "xfail" ; then
239 CFLAGS="${CFLAGS} -Werror"
240 fi
dcb54d06 241
f6614448 242 AC_MSG_CHECKING([for format security flag in $CC])
dcb54d06 243 saved_CFLAGS="${CFLAGS}"
d9c45e9c 244 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
dcb54d06 245 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
d9c45e9c 246 AC_MSG_RESULT($have_format_security)
dcb54d06
FM
247 if test "$have_format_security" == "no" ; then
248 CFLAGS="${saved_CFLAGS}"
249 fi
53aaf897
FM
250
251 AC_MSG_CHECKING([for empty body flag in $CC])
252 saved_CFLAGS="${CFLAGS}"
253 CFLAGS="${CFLAGS} -Wempty-body"
254 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
255 AC_MSG_RESULT($have_empty_body)
256 if test "$have_empty_body" == "no" ; then
257 CFLAGS="${saved_CFLAGS}"
258 fi
05b90947 259 fi
feba7d37 260])
05b90947 261
04a01ed3
FM
262dnl Enable double check of the data written in the reports
263AC_ARG_ENABLE(doublecheck,
2020ec6f
FM
264AS_HELP_STRING([--enable-doublecheck],
265[Make sarg double check the data it manipulates and output a warning if an error is found]),
04a01ed3
FM
266[
267 if test "$enableval"; then
268 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
269 fi
270])
271
b6b2e9a9
FM
272AC_SUBST(PACKAGE,"$PACKAGE_NAME")
273AC_SUBST(VERSION,"$PACKAGE_VERSION")
274
095bc6be 275AC_CONFIG_FILES([Makefile po/Makefile.in])
0743911c 276AC_OUTPUT