]> git.ipfire.org Git - thirdparty/sarg.git/blame - configure.in
Fixes to compile sarg with mingw32
[thirdparty/sarg.git] / configure.in
CommitLineData
25697a35 1dnl Process this file with autoconf to produce a configure script.
a9341a7c 2AC_INIT([sarg],[2.3.2-pre2])
0743911c 3AC_CONFIG_SRCDIR([log.c])
25697a35
GS
4AC_CONFIG_AUX_DIR(cfgaux)
5
25697a35
GS
6AC_CANONICAL_HOST
7
8AC_ARG_WITH(gcc,
9[ --without-gcc use CC to compile])
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
FM
68dnl Check for iconv
69AM_ICONV
70if test -n "$LIBICONV" ; then
71 LIBS="$LIBS $LIBICONV"
72fi
73
25697a35 74AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
a50c6319 75 dirent.h sys/types.h sys/socket.h netdb.h arpa/inet.h netinet/in.h sys/stat.h \
e6414a9d
FM
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 \
9b179eb0
FM
78 execinfo.h ldap.h math.h libintl.h libgen.h stdbool.h getopt.h)
79
80if test $ac_cv_header_getopt_h = "no" ; then
81 AC_MSG_ERROR("getopt.h is required to compile sarg")
82fi
25697a35 83
2824ec9b 84AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="")
e3af0ae9 85AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="")
25697a35
GS
86
87dnl Checks for typedefs, structures, and compiler characteristics.
88AC_C_CONST
89AC_STRUCT_TM
90
5963cdcd
FM
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.
93AM_GNU_GETTEXT_VERSION([0.18])
095bc6be
FM
94AM_GNU_GETTEXT([external])
95
32e71fa4 96AC_SYS_LARGEFILE
d6e703cc 97
25697a35
GS
98# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
99# needs to be defined for it
100AC_MSG_CHECKING([for fopen64])
101AC_CACHE_VAL(bu_cv_have_fopen64,
a61fe05c
FM
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);],
25697a35 107bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
a61fe05c
FM
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);],
113bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror"
114werror_status="fail",
115bu_cv_have_fopen64=no)]))
116 ])
117 CFLAGS=$noerror_CFLAGS])
25697a35
GS
118AC_MSG_RESULT($bu_cv_have_fopen64)
119if 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,
124 [Enable LFS])
125 fi
126fi
127
40d681bc
FM
128dnl check for functions
129AC_CHECK_FUNCS(bzero)
e6414a9d 130AC_CHECK_FUNCS(backtrace)
b5f13803 131AC_CHECK_FUNCS(symlink)
d9c45e9c 132AC_CHECK_FUNCS(lstat)
72c27633 133AC_CHECK_FUNCS(getnameinfo)
4afbb7a5 134AC_CHECK_FUNCS(getaddrinfo)
32e71fa4 135
a50c6319
FM
136dnl check for structure members
137AC_CHECK_MEMBER([struct sockaddr_storage.ss_len],[AC_DEFINE([HAVE_SOCKADDR_SA_LEN],1,[ss_len in sockaddr_storage])])
138
32e71fa4
FM
139dnl check for the rlim_t size
140AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H
141#include <sys/resource.h>
142#endif
143])
144if test $ac_cv_sizeof_rlim_t = "4"; then
145 AC_DEFINE(RLIM_STRING, "%d", [Rlim string])
146elif test $ac_cv_sizeof_rlim_t = "8"; then
147 AC_DEFINE(RLIM_STRING, "%lli", [Rlim string])
148else
740f9162 149 AC_MSG_WARN([can not detect the size of your system\'s rlim_t type])
32e71fa4
FM
150fi
151
7bbc1de4
FM
152dnl Select sarg-php directory
153AC_ARG_ENABLE(sargphp,
154[ --enable-sargphp=sargphpdir
155 Select sargphpdir as the directory to install sarg-php into ],
25697a35 156[
7bbc1de4
FM
157 if test "$enableval" -a "x$enableval" != "xno" ; then
158 SARGPHPDIR=$enableval
25697a35 159 fi
b51e26ba 160],[SARGPHPDIR="/var/www/html"])
7bbc1de4 161if test "$SARGPHPDIR" ; then
2e598081 162 echo "using $SARGPHPDIR as the directory to install sarg-php"
7bbc1de4
FM
163 AC_SUBST(SARGPHPDIR)
164fi
25697a35 165
b3695c67
FM
166dnl Select fonts dir
167AC_ARG_ENABLE(fontdir,
168[ --enable-fontdir=fontdir
169 Select fontdir as the directory with the fonts to use in the reports ],
170[
3becf85c 171 if test "$enableval" -a "x$enableval" != "xno" ; then
b3695c67
FM
172 FONTDIR=$enableval
173 fi
174],[FONTDIR="${datarootdir}/sarg/fonts"])
3becf85c 175if test "$FONTDIR" ; then
2e598081
FM
176 if test "x$prefix" == "xNONE" ; then
177 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"`
178 else
179 tempfullpath=`eval "echo $FONTDIR"`
180 fi
3becf85c
FM
181 echo "using $tempfullpath as the directory of the fonts"
182 AC_SUBST(FONTDIR)
183fi
b3695c67
FM
184
185dnl Select images dir
186AC_ARG_ENABLE(imagedir,
187[ --enable-imagedir=imagedir
188 Select imagedir as the directory with the images to use in the reports ],
189[
190 if test "$enableval"; then
191 IMAGEDIR=$enableval
192 fi
193],[IMAGEDIR="${datarootdir}/sarg/images"])
2e598081
FM
194if test "x$prefix" == "xNONE" ; then
195 tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"`
196else
197 tempfullpath=`eval "echo $IMAGEDIR"`
198fi
3becf85c 199echo "using $tempfullpath as the directory of the images"
b3695c67
FM
200AC_SUBST(IMAGEDIR)
201
05b90947
FM
202dnl Enable extra compile and run time protection
203AC_ARG_ENABLE(extraprotection,
204[ --enable-extraprotection
205 Enable compile and runtime extra protections ],
206[
207 if test "$enableval"; then
a61fe05c
FM
208 CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2"
209 if test "x$werror_status" != "xfail" ; then
210 CFLAGS="${CFLAGS} -Werror"
211 fi
dcb54d06 212
f6614448 213 AC_MSG_CHECKING([for format security flag in $CC])
dcb54d06 214 saved_CFLAGS="${CFLAGS}"
d9c45e9c 215 CFLAGS="${CFLAGS} -Wformat -Werror=format-security"
dcb54d06 216 AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
d9c45e9c 217 AC_MSG_RESULT($have_format_security)
dcb54d06
FM
218 if test "$have_format_security" == "no" ; then
219 CFLAGS="${saved_CFLAGS}"
220 fi
53aaf897
FM
221
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}"
229 fi
05b90947 230 fi
feba7d37 231])
05b90947 232
04a01ed3
FM
233dnl Enable double check of the data written in the reports
234AC_ARG_ENABLE(doublecheck,
235[ --enable-doublecheck
236 Make sarg double check the data it manipulates and output a warning if an error is found ],
237[
238 if test "$enableval"; then
239 AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA)
240 fi
241])
242
b6b2e9a9
FM
243AC_SUBST(PACKAGE,"$PACKAGE_NAME")
244AC_SUBST(VERSION,"$PACKAGE_VERSION")
245
095bc6be 246AC_CONFIG_FILES([Makefile po/Makefile.in])
0743911c 247AC_OUTPUT