1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT([sarg],[2.4-pre1])
3 AC_CONFIG_SRCDIR([log.c])
4 AC_CONFIG_AUX_DIR(cfgaux)
9 [ --without-gcc use CC to compile])
11 test -n "$CC" && cc_specified=yes
17 dnl * ) AC_PROG_CXX ;;
20 if test "${CC}" = "cc" ; then
21 CFLAGS="${CFLAGS} -g -O2 -Aa"
23 CFLAGS="${CFLAGS} -Wall -Wno-sign-compare"
25 dnl Check for supported compiler options
27 AC_MSG_CHECKING([for extra warnings flag in $CC])
28 saved_CFLAGS="${CFLAGS}"
29 CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter"
30 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_extra_warnings="yes"],[have_extra_warnings="no"])
31 AC_MSG_RESULT($have_extra_warnings)
32 if test "$have_extra_warnings" == "no" ; then
33 CFLAGS="${saved_CFLAGS}"
36 AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC])
37 saved_CFLAGS="${CFLAGS}"
38 CFLAGS="${CFLAGS} -Werror=implicit-function-declaration"
39 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_implicit_function_declaration="yes"],[have_implicit_function_declaration="no"])
40 AC_MSG_RESULT($have_implicit_function_declaration)
41 if test "$have_implicit_function_declaration" == "no" ; then
42 CFLAGS="${saved_CFLAGS}"
45 AC_MSG_CHECKING([for format error flag in $CC])
46 saved_CFLAGS="${CFLAGS}"
47 CFLAGS="${CFLAGS} -Werror=format"
48 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_error_format="yes"],[have_error_format="no"])
49 AC_MSG_RESULT($have_error_format)
50 if test "$have_error_format" == "no" ; then
51 CFLAGS="${saved_CFLAGS}"
56 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
57 CFLAGS="-DSOLARIS ${CFLAGS}"
61 #dnl Checks for programs.
70 if test -n "$LIBICONV" ; then
71 LIBS="$LIBS $LIBICONV"
74 AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
75 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
76 ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
77 errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h \
78 execinfo.h ldap.h math.h libintl.h libgen.h stdbool.h getopt.h)
80 if test $ac_cv_header_getopt_h = "no" ; then
81 AC_MSG_ERROR("getopt.h is required to compile sarg")
84 AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
85 AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
87 dnl Checks for typedefs, structures, and compiler characteristics.
91 # Change the gettext version according to the available version on your system.
92 # It should not be necessary to change it unless you run autoreconf -fi.
93 AM_GNU_GETTEXT_VERSION([0.18])
94 AM_GNU_GETTEXT([external])
98 # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
99 # needs to be defined for it
100 AC_MSG_CHECKING([for fopen64])
101 AC_CACHE_VAL(bu_cv_have_fopen64,
102 [noerror_CFLAGS=$CFLAGS
103 CFLAGS="$CFLAGS -Werror"
104 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],
105 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
106 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
107 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
108 CFLAGS=$noerror_CFLAGS
109 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror"
110 werror_status="fail"],
111 [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
112 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);],
113 bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
114 werror_status="fail",
115 bu_cv_have_fopen64=no)]))
117 CFLAGS=$noerror_CFLAGS])
118 AC_MSG_RESULT($bu_cv_have_fopen64)
119 if test "$bu_cv_have_fopen64" != no; then
120 AC_DEFINE([HAVE_FOPEN64], 1,
121 [Is fopen64 available?])
122 if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then
123 AC_DEFINE([_LARGEFILE64_SOURCE], 1,
128 dnl check for functions
129 AC_CHECK_FUNCS(bzero)
130 AC_CHECK_FUNCS(backtrace)
131 AC_CHECK_FUNCS(symlink)
132 AC_CHECK_FUNCS(lstat)
133 AC_CHECK_FUNCS(getnameinfo)
134 AC_CHECK_FUNCS(getaddrinfo)
136 dnl check for structure members
137 AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
139 dnl check for the rlim_t size
140 AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
141 #include <sys/resource.h>
144 if test $ac_cv_sizeof_rlim_t = "4"; then
145 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
146 elif test $ac_cv_sizeof_rlim_t = "8"; then
147 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
149 AC_MSG_WARN([can not detect the size of your system\'s rlim_t type])
152 dnl Select sarg-php directory
153 AC_ARG_ENABLE(sargphp,
154 [ --enable-sargphp=sargphpdir
155 Select sargphpdir as the directory to install sarg-php into ],
157 if test "$enableval" -a "x$enableval" != "xno" ; then
158 SARGPHPDIR=$enableval
160 ],[SARGPHPDIR="/var/www/html"])
161 if test "$SARGPHPDIR" ; then
162 echo "using $SARGPHPDIR as the directory to install sarg-php"
167 AC_ARG_ENABLE(fontdir,
168 [ --enable-fontdir=fontdir
169 Select fontdir as the directory with the fonts to use in the reports ],
171 if test "$enableval" -a "x$enableval" != "xno" ; then
174 ],[FONTDIR="${datarootdir}/sarg/fonts"])
175 if test "$FONTDIR" ; then
176 if test "x$prefix" == "xNONE" ; then
177 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
179 tempfullpath=`eval "echo $FONTDIR"`
181 echo "using $tempfullpath as the directory of the fonts"
185 dnl Select images dir
186 AC_ARG_ENABLE(imagedir,
187 [ --enable-imagedir=imagedir
188 Select imagedir as the directory with the images to use in the reports ],
190 if test "$enableval"; then
193 ],[IMAGEDIR="${datarootdir}/sarg/images"])
194 if test "x$prefix" == "xNONE" ; then
195 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
197 tempfullpath=`eval "echo $IMAGEDIR"`
199 echo "using $tempfullpath as the directory of the images"
202 dnl Enable extra compile and run time protection
203 AC_ARG_ENABLE(extraprotection,
204 [ --enable-extraprotection
205 Enable compile and runtime extra protections ],
207 if test "$enableval"; then
208 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
209 if test "x$werror_status" != "xfail" ; then
210 CFLAGS="${CFLAGS} -Werror"
213 AC_MSG_CHECKING([for format security flag in $CC])
214 saved_CFLAGS="${CFLAGS}"
215 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
216 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
217 AC_MSG_RESULT($have_format_security)
218 if test "$have_format_security" == "no" ; then
219 CFLAGS="${saved_CFLAGS}"
222 AC_MSG_CHECKING([for empty body flag in $CC])
223 saved_CFLAGS="${CFLAGS}"
224 CFLAGS="${CFLAGS} -Wempty-body"
225 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_empty_body="yes"],[have_empty_body="no"])
226 AC_MSG_RESULT($have_empty_body)
227 if test "$have_empty_body" == "no" ; then
228 CFLAGS="${saved_CFLAGS}"
233 dnl Enable double check of the data written in the reports
234 AC_ARG_ENABLE(doublecheck,
235 [ --enable-doublecheck
236 Make sarg double check the data it manipulates and output a warning if an error is found ],
238 if test "$enableval"; then
239 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
243 AC_SUBST(PACKAGE,"$PACKAGE_NAME")
244 AC_SUBST(VERSION,"$PACKAGE_VERSION")
246 AC_CONFIG_FILES([Makefile po/Makefile.in])