]>
Commit | Line | Data |
---|---|---|
1 | dnl Process this file with autoconf to produce a configure script. | |
2 | AC_INIT([sarg],[2.3.3-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 | # Report more warnings to improve code quality. | |
27 | CFLAGS="${CFLAGS} -Wall -Wno-sign-compare" | |
28 | ||
29 | dnl Check for supported compiler options | |
30 | ||
31 | AC_MSG_CHECKING([for extra warnings flag in $CC]) | |
32 | saved_CFLAGS="${CFLAGS}" | |
33 | CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter" | |
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]) | |
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 | ||
49 | AC_MSG_CHECKING([for format error flag in $CC]) | |
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) | |
54 | if test "$have_error_format" == "no" ; then | |
55 | CFLAGS="${saved_CFLAGS}" | |
56 | fi | |
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 | ||
72 | ||
73 | AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \ | |
74 | dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \ | |
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) | |
77 | ||
78 | if test $ac_cv_header_getopt_h = "no" ; then | |
79 | AC_MSG_ERROR("getopt.h is required to compile sarg") | |
80 | fi | |
81 | ||
82 | # Build with gd | |
83 | AC_ARG_WITH([gd], | |
84 | AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]), | |
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], | |
95 | AS_HELP_STRING([--with-ldap],[Compile with LDAP support]), | |
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], | |
106 | AS_HELP_STRING([--with-iconv],[Compile with support for iconv]), | |
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 | |
118 | ||
119 | dnl Checks for typedefs, structures, and compiler characteristics. | |
120 | AC_C_CONST | |
121 | AC_STRUCT_TM | |
122 | ||
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]) | |
126 | AM_GNU_GETTEXT([external]) | |
127 | ||
128 | AC_SYS_LARGEFILE | |
129 | ||
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, | |
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);], | |
139 | bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE", | |
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]) | |
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 | ||
160 | dnl check for functions | |
161 | AC_CHECK_FUNCS(bzero) | |
162 | AC_CHECK_FUNCS(backtrace) | |
163 | AC_CHECK_FUNCS(symlink) | |
164 | AC_CHECK_FUNCS(lstat) | |
165 | AC_CHECK_FUNCS(getnameinfo) | |
166 | AC_CHECK_FUNCS(getaddrinfo) | |
167 | AC_CHECK_FUNCS(mkstemp) | |
168 | ||
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 | ||
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 | |
182 | AC_MSG_WARN([can not detect the size of your system\'s rlim_t type]) | |
183 | fi | |
184 | ||
185 | dnl Select sarg-php directory | |
186 | AC_ARG_ENABLE(sargphp, | |
187 | AS_HELP_STRING([--enable-sargphp=sargphpdir], | |
188 | [Select sargphpdir as the directory to install sarg-php into]), | |
189 | [ | |
190 | if test "$enableval" -a "x$enableval" != "xno" ; then | |
191 | SARGPHPDIR=$enableval | |
192 | fi | |
193 | ],[SARGPHPDIR="/var/www/html"]) | |
194 | if test "$SARGPHPDIR" ; then | |
195 | echo "using $SARGPHPDIR as the directory to install sarg-php" | |
196 | AC_SUBST(SARGPHPDIR) | |
197 | fi | |
198 | ||
199 | dnl Select fonts dir | |
200 | AC_ARG_ENABLE(fontdir, | |
201 | AS_HELP_STRING([--enable-fontdir=fontdir], | |
202 | [Select fontdir as the directory with the fonts to use in the reports]), | |
203 | [ | |
204 | if test "$enableval" -a "x$enableval" != "xno" ; then | |
205 | FONTDIR=$enableval | |
206 | fi | |
207 | ],[FONTDIR="${datarootdir}/sarg/fonts"]) | |
208 | if test "$FONTDIR" ; then | |
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 | |
214 | echo "using $tempfullpath as the directory of the fonts" | |
215 | AC_SUBST(FONTDIR) | |
216 | fi | |
217 | ||
218 | dnl Select images dir | |
219 | AC_ARG_ENABLE(imagedir, | |
220 | AS_HELP_STRING([--enable-imagedir=imagedir], | |
221 | [Select imagedir as the directory with the images to use in the reports]), | |
222 | [ | |
223 | if test "$enableval"; then | |
224 | IMAGEDIR=$enableval | |
225 | fi | |
226 | ],[IMAGEDIR="${datarootdir}/sarg/images"]) | |
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 | |
232 | echo "using $tempfullpath as the directory of the images" | |
233 | AC_SUBST(IMAGEDIR) | |
234 | ||
235 | dnl Enable extra compile and run time protection | |
236 | AC_ARG_ENABLE(extraprotection, | |
237 | AS_HELP_STRING([--enable-extraprotection], | |
238 | [Enable compile and runtime extra protections]), | |
239 | [ | |
240 | if test "$enableval"; then | |
241 | CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2" | |
242 | if test "x$werror_status" != "xfail" ; then | |
243 | CFLAGS="${CFLAGS} -Werror" | |
244 | fi | |
245 | ||
246 | AC_MSG_CHECKING([for format security flag in $CC]) | |
247 | saved_CFLAGS="${CFLAGS}" | |
248 | CFLAGS="${CFLAGS} -Wformat -Werror=format-security" | |
249 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"]) | |
250 | AC_MSG_RESULT($have_format_security) | |
251 | if test "$have_format_security" == "no" ; then | |
252 | CFLAGS="${saved_CFLAGS}" | |
253 | fi | |
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 | |
263 | fi | |
264 | ]) | |
265 | ||
266 | dnl Enable double check of the data written in the reports | |
267 | AC_ARG_ENABLE(doublecheck, | |
268 | AS_HELP_STRING([--enable-doublecheck], | |
269 | [Make sarg double check the data it manipulates and output a warning if an error is found]), | |
270 | [ | |
271 | if test "$enableval"; then | |
272 | AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA) | |
273 | fi | |
274 | ]) | |
275 | ||
276 | AC_SUBST(PACKAGE,"$PACKAGE_NAME") | |
277 | AC_SUBST(VERSION,"$PACKAGE_VERSION") | |
278 | ||
279 | AC_CONFIG_FILES([Makefile po/Makefile.in]) | |
280 | AC_OUTPUT |