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