]>
Commit | Line | Data |
---|---|---|
11cb1341 | 1 | dnl Process this file with autoconf or autoreconf to produce a configure script. |
2de2339c | 2 | AC_INIT([sarg],[2.4-pre1]) |
0743911c | 3 | AC_CONFIG_SRCDIR([log.c]) |
25697a35 GS |
4 | AC_CONFIG_AUX_DIR(cfgaux) |
5 | ||
25697a35 GS |
6 | AC_CANONICAL_HOST |
7 | ||
8 | AC_ARG_WITH(gcc, | |
2020ec6f | 9 | AS_HELP_STRING([--without-gcc],[use CC to compile])) |
25697a35 GS |
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 | ||
ff0eb6c5 FM |
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 | ||
2b17869b FM |
26 | dnl C99 support is required to define LLONG_MAX (at least on CentOS 5.7) |
27 | AC_PROG_CC_C99 | |
28 | ||
ff0eb6c5 | 29 | # Report more warnings to improve code quality. |
7c9980f1 | 30 | CFLAGS="${CFLAGS} -Wall -Wno-sign-compare" |
05b90947 | 31 | |
f6614448 | 32 | dnl Check for supported compiler options |
4782357f | 33 | |
f6614448 FM |
34 | AC_MSG_CHECKING([for extra warnings flag in $CC]) |
35 | saved_CFLAGS="${CFLAGS}" | |
7c9980f1 | 36 | CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter" |
f6614448 FM |
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]) | |
4782357f FM |
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 | ||
f6614448 | 52 | AC_MSG_CHECKING([for format error flag in $CC]) |
4782357f FM |
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) | |
bdaa13d3 | 57 | if test "$have_error_format" == "no" ; then |
4782357f FM |
58 | CFLAGS="${saved_CFLAGS}" |
59 | fi | |
25697a35 GS |
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 | ||
d6e703cc | 75 | |
25697a35 | 76 | AC_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 | |
81 | if test $ac_cv_header_getopt_h = "no" ; then | |
82 | AC_MSG_ERROR("getopt.h is required to compile sarg") | |
83 | fi | |
25697a35 | 84 | |
1c72006e FM |
85 | # Build with gd |
86 | AC_ARG_WITH([gd], | |
2020ec6f | 87 | AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]), |
1c72006e FM |
88 | [],[with_gd=check]) |
89 | if ( 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 | 99 | else |
8ddc656a | 100 | gd_status="disabled" |
1c72006e FM |
101 | fi |
102 | ||
103 | # Build with LDAP | |
104 | AC_ARG_WITH([ldap], | |
2020ec6f | 105 | AS_HELP_STRING([--with-ldap],[Compile with LDAP support]), |
1c72006e FM |
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="") | |
110 | else | |
111 | AC_MSG_NOTICE([Not building with LDAP support as requested on the configuration command line]) | |
112 | fi | |
113 | ||
114 | # Build with iconv | |
115 | AC_ARG_WITH([iconv], | |
2020ec6f | 116 | AS_HELP_STRING([--with-iconv],[Compile with support for iconv]), |
1c72006e FM |
117 | [],[with_iconv=check]) |
118 | if ( 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) | |
125 | else | |
126 | AC_MSG_NOTICE([Not building with iconv as requested on the configuration command line]) | |
127 | fi | |
25697a35 | 128 | |
6e24f222 FM |
129 | # Build with pcre |
130 | AC_ARG_WITH([pcre], | |
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)" | |
138 | else | |
139 | pcre_status="not found" | |
140 | fi | |
141 | else | |
142 | pcre_status="disabled" | |
143 | fi | |
25697a35 GS |
144 | |
145 | dnl Checks for typedefs, structures, and compiler characteristics. | |
146 | AC_C_CONST | |
147 | AC_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. | |
c8aad602 | 151 | AM_GNU_GETTEXT_VERSION([0.18]) |
095bc6be FM |
152 | AM_GNU_GETTEXT([external]) |
153 | ||
32e71fa4 | 154 | AC_SYS_LARGEFILE |
d6e703cc | 155 | |
25697a35 GS |
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, | |
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 | 165 | bu_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);], | |
171 | bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror" | |
172 | werror_status="fail", | |
173 | bu_cv_have_fopen64=no)])) | |
174 | ]) | |
175 | CFLAGS=$noerror_CFLAGS]) | |
25697a35 GS |
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, | |
182 | [Enable LFS]) | |
183 | fi | |
184 | fi | |
185 | ||
40d681bc FM |
186 | dnl check for functions |
187 | AC_CHECK_FUNCS(bzero) | |
e6414a9d | 188 | AC_CHECK_FUNCS(backtrace) |
b5f13803 | 189 | AC_CHECK_FUNCS(symlink) |
d9c45e9c | 190 | AC_CHECK_FUNCS(lstat) |
72c27633 | 191 | AC_CHECK_FUNCS(getnameinfo) |
4afbb7a5 | 192 | AC_CHECK_FUNCS(getaddrinfo) |
d7cb0aec | 193 | AC_CHECK_FUNCS(mkstemp) |
32e71fa4 | 194 | |
a50c6319 FM |
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])]) | |
197 | ||
32e71fa4 FM |
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> | |
201 | #endif | |
202 | ]) | |
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]) | |
207 | else | |
740f9162 | 208 | AC_MSG_WARN([can not detect the size of your system\'s rlim_t type]) |
32e71fa4 FM |
209 | fi |
210 | ||
2b17869b FM |
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.]) | |
215 | fi | |
216 | ||
7bbc1de4 FM |
217 | dnl Select sarg-php directory |
218 | AC_ARG_ENABLE(sargphp, | |
2020ec6f FM |
219 | AS_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 | 226 | if test "$SARGPHPDIR" ; then |
2e598081 | 227 | echo "using $SARGPHPDIR as the directory to install sarg-php" |
7bbc1de4 FM |
228 | AC_SUBST(SARGPHPDIR) |
229 | fi | |
25697a35 | 230 | |
b3695c67 FM |
231 | dnl Select fonts dir |
232 | AC_ARG_ENABLE(fontdir, | |
2020ec6f FM |
233 | AS_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 | 240 | if 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) | |
248 | fi | |
b3695c67 FM |
249 | |
250 | dnl Select images dir | |
251 | AC_ARG_ENABLE(imagedir, | |
2020ec6f FM |
252 | AS_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 |
259 | if test "x$prefix" == "xNONE" ; then |
260 | tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"` | |
261 | else | |
262 | tempfullpath=`eval "echo $IMAGEDIR"` | |
263 | fi | |
3becf85c | 264 | echo "using $tempfullpath as the directory of the images" |
b3695c67 FM |
265 | AC_SUBST(IMAGEDIR) |
266 | ||
05b90947 FM |
267 | dnl Enable extra compile and run time protection |
268 | AC_ARG_ENABLE(extraprotection, | |
2020ec6f FM |
269 | AS_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 | |
65b4ec2c FM |
298 | dnl Enable double check of the data written in the reports |
299 | AC_ARG_ENABLE(doublecheck, | |
2020ec6f FM |
300 | AS_HELP_STRING([--enable-doublecheck], |
301 | [Make sarg double check the data it manipulates and output a warning if an error is found]), | |
65b4ec2c FM |
302 | [ |
303 | if test "$enableval"; then | |
304 | AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA) | |
305 | fi | |
306 | ]) | |
307 | ||
b6b2e9a9 FM |
308 | AC_SUBST(PACKAGE,"$PACKAGE_NAME") |
309 | AC_SUBST(VERSION,"$PACKAGE_VERSION") | |
310 | ||
095bc6be | 311 | AC_CONFIG_FILES([Makefile po/Makefile.in]) |
0743911c | 312 | AC_OUTPUT |
8ddc656a FM |
313 | |
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]) | |
318 | fi | |
6e24f222 FM |
319 | |
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]) | |
324 | fi |