]>
Commit | Line | Data |
---|---|---|
25697a35 | 1 | dnl Process this file with autoconf to produce a configure script. |
2141e6ca | 2 | AC_INIT([sarg],[2.3.1-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, | |
9 | [ --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 | if test "${CC}" = "cc" ; then | |
05b90947 | 21 | CFLAGS="${CFLAGS} -g -O2 -Aa" |
25697a35 | 22 | fi |
7c9980f1 | 23 | CFLAGS="${CFLAGS} -Wall -Wno-sign-compare" |
05b90947 | 24 | |
f6614448 | 25 | dnl Check for supported compiler options |
4782357f | 26 | |
f6614448 FM |
27 | AC_MSG_CHECKING([for extra warnings flag in $CC]) |
28 | saved_CFLAGS="${CFLAGS}" | |
7c9980f1 | 29 | CFLAGS="${CFLAGS} -Wextra -Wno-unused-parameter" |
f6614448 FM |
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}" | |
34 | fi | |
35 | ||
36 | AC_MSG_CHECKING([for implicit-function-declaration error flag in $CC]) | |
4782357f FM |
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}" | |
43 | fi | |
44 | ||
f6614448 | 45 | AC_MSG_CHECKING([for format error flag in $CC]) |
4782357f FM |
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_implicit_function_declaration" == "no" ; then | |
51 | CFLAGS="${saved_CFLAGS}" | |
52 | fi | |
25697a35 GS |
53 | |
54 | case "$host" in | |
55 | *-solaris*) | |
56 | LDFLAGS="${LDFLAGS} -lsocket -lnsl" | |
57 | CFLAGS="-DSOLARIS ${CFLAGS}" | |
58 | ;; | |
59 | esac | |
60 | ||
61 | #dnl Checks for programs. | |
62 | #AC_PROG_CC | |
63 | ||
64 | dnl Check for headers | |
65 | AC_HEADER_DIRENT | |
66 | AC_HEADER_STDC | |
67 | ||
d6e703cc FM |
68 | dnl Check for iconv |
69 | AM_ICONV | |
70 | if test -n "$LIBICONV" ; then | |
71 | LIBS="$LIBS $LIBICONV" | |
72 | fi | |
73 | ||
25697a35 | 74 | AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \ |
e6414a9d FM |
75 | dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.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 \ | |
9b179eb0 FM |
78 | execinfo.h ldap.h math.h libintl.h libgen.h stdbool.h getopt.h) |
79 | ||
80 | if test $ac_cv_header_getopt_h = "no" ; then | |
81 | AC_MSG_ERROR("getopt.h is required to compile sarg") | |
82 | fi | |
25697a35 | 83 | |
2824ec9b | 84 | AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="") |
e3af0ae9 | 85 | AC_CHECK_LIB(ldap, ldap_init,LIBS="-lldap ${LIBS}"; HAVE_LDAP="yes", HAVE_LDAP="") |
25697a35 GS |
86 | |
87 | dnl Checks for typedefs, structures, and compiler characteristics. | |
88 | AC_C_CONST | |
89 | AC_STRUCT_TM | |
90 | ||
095bc6be FM |
91 | AM_GNU_GETTEXT_VERSION([0.17]) |
92 | AM_GNU_GETTEXT([external]) | |
93 | ||
32e71fa4 | 94 | AC_SYS_LARGEFILE |
d6e703cc | 95 | |
25697a35 GS |
96 | # Check whether fopen64 is available and whether _LARGEFILE64_SOURCE |
97 | # needs to be defined for it | |
98 | AC_MSG_CHECKING([for fopen64]) | |
99 | AC_CACHE_VAL(bu_cv_have_fopen64, | |
a61fe05c FM |
100 | [noerror_CFLAGS=$CFLAGS |
101 | CFLAGS="$CFLAGS -Werror" | |
102 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes], | |
103 | [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" | |
104 | AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);], | |
25697a35 | 105 | bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE", |
a61fe05c FM |
106 | CFLAGS=$noerror_CFLAGS |
107 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64="yes without -Werror" | |
108 | werror_status="fail"], | |
109 | [CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" | |
110 | AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");fclose(f);], | |
111 | bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE and no -Werror" | |
112 | werror_status="fail", | |
113 | bu_cv_have_fopen64=no)])) | |
114 | ]) | |
115 | CFLAGS=$noerror_CFLAGS]) | |
25697a35 GS |
116 | AC_MSG_RESULT($bu_cv_have_fopen64) |
117 | if test "$bu_cv_have_fopen64" != no; then | |
118 | AC_DEFINE([HAVE_FOPEN64], 1, | |
119 | [Is fopen64 available?]) | |
120 | if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE"; then | |
121 | AC_DEFINE([_LARGEFILE64_SOURCE], 1, | |
122 | [Enable LFS]) | |
123 | fi | |
124 | fi | |
125 | ||
40d681bc FM |
126 | dnl check for functions |
127 | AC_CHECK_FUNCS(bzero) | |
e6414a9d | 128 | AC_CHECK_FUNCS(backtrace) |
b5f13803 | 129 | AC_CHECK_FUNCS(symlink) |
d9c45e9c | 130 | AC_CHECK_FUNCS(lstat) |
72c27633 | 131 | AC_CHECK_FUNCS(getnameinfo) |
32e71fa4 FM |
132 | |
133 | dnl check for the rlim_t size | |
134 | AC_CHECK_SIZEOF(rlim_t,1,[#if HAVE_SYS_RESOURCE_H | |
135 | #include <sys/resource.h> | |
136 | #endif | |
137 | ]) | |
138 | if test $ac_cv_sizeof_rlim_t = "4"; then | |
139 | AC_DEFINE(RLIM_STRING, "%d", [Rlim string]) | |
140 | elif test $ac_cv_sizeof_rlim_t = "8"; then | |
141 | AC_DEFINE(RLIM_STRING, "%lli", [Rlim string]) | |
142 | else | |
740f9162 | 143 | AC_MSG_WARN([can not detect the size of your system\'s rlim_t type]) |
32e71fa4 FM |
144 | fi |
145 | ||
7bbc1de4 FM |
146 | dnl Select sarg-php directory |
147 | AC_ARG_ENABLE(sargphp, | |
148 | [ --enable-sargphp=sargphpdir | |
149 | Select sargphpdir as the directory to install sarg-php into ], | |
25697a35 | 150 | [ |
7bbc1de4 FM |
151 | if test "$enableval" -a "x$enableval" != "xno" ; then |
152 | SARGPHPDIR=$enableval | |
25697a35 | 153 | fi |
b51e26ba | 154 | ],[SARGPHPDIR="/var/www/html"]) |
7bbc1de4 | 155 | if test "$SARGPHPDIR" ; then |
2e598081 | 156 | echo "using $SARGPHPDIR as the directory to install sarg-php" |
7bbc1de4 FM |
157 | AC_SUBST(SARGPHPDIR) |
158 | fi | |
25697a35 | 159 | |
b3695c67 FM |
160 | dnl Select fonts dir |
161 | AC_ARG_ENABLE(fontdir, | |
162 | [ --enable-fontdir=fontdir | |
163 | Select fontdir as the directory with the fonts to use in the reports ], | |
164 | [ | |
3becf85c | 165 | if test "$enableval" -a "x$enableval" != "xno" ; then |
b3695c67 FM |
166 | FONTDIR=$enableval |
167 | fi | |
168 | ],[FONTDIR="${datarootdir}/sarg/fonts"]) | |
3becf85c | 169 | if test "$FONTDIR" ; then |
2e598081 FM |
170 | if test "x$prefix" == "xNONE" ; then |
171 | tempfullpath=`prefix=$ac_default_prefix ; eval "echo $FONTDIR"` | |
172 | else | |
173 | tempfullpath=`eval "echo $FONTDIR"` | |
174 | fi | |
3becf85c FM |
175 | echo "using $tempfullpath as the directory of the fonts" |
176 | AC_SUBST(FONTDIR) | |
177 | fi | |
b3695c67 FM |
178 | |
179 | dnl Select images dir | |
180 | AC_ARG_ENABLE(imagedir, | |
181 | [ --enable-imagedir=imagedir | |
182 | Select imagedir as the directory with the images to use in the reports ], | |
183 | [ | |
184 | if test "$enableval"; then | |
185 | IMAGEDIR=$enableval | |
186 | fi | |
187 | ],[IMAGEDIR="${datarootdir}/sarg/images"]) | |
2e598081 FM |
188 | if test "x$prefix" == "xNONE" ; then |
189 | tempfullpath=`prefix=$ac_default_prefix ; eval "echo $IMAGEDIR"` | |
190 | else | |
191 | tempfullpath=`eval "echo $IMAGEDIR"` | |
192 | fi | |
3becf85c | 193 | echo "using $tempfullpath as the directory of the images" |
b3695c67 FM |
194 | AC_SUBST(IMAGEDIR) |
195 | ||
05b90947 FM |
196 | dnl Enable extra compile and run time protection |
197 | AC_ARG_ENABLE(extraprotection, | |
198 | [ --enable-extraprotection | |
199 | Enable compile and runtime extra protections ], | |
200 | [ | |
201 | if test "$enableval"; then | |
a61fe05c FM |
202 | CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2" |
203 | if test "x$werror_status" != "xfail" ; then | |
204 | CFLAGS="${CFLAGS} -Werror" | |
205 | fi | |
dcb54d06 | 206 | |
f6614448 | 207 | AC_MSG_CHECKING([for format security flag in $CC]) |
dcb54d06 | 208 | saved_CFLAGS="${CFLAGS}" |
d9c45e9c | 209 | CFLAGS="${CFLAGS} -Wformat -Werror=format-security" |
dcb54d06 | 210 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"]) |
d9c45e9c | 211 | AC_MSG_RESULT($have_format_security) |
dcb54d06 FM |
212 | if test "$have_format_security" == "no" ; then |
213 | CFLAGS="${saved_CFLAGS}" | |
214 | fi | |
05b90947 | 215 | fi |
feba7d37 | 216 | ]) |
05b90947 | 217 | |
04a01ed3 FM |
218 | dnl Enable double check of the data written in the reports |
219 | AC_ARG_ENABLE(doublecheck, | |
220 | [ --enable-doublecheck | |
221 | Make sarg double check the data it manipulates and output a warning if an error is found ], | |
222 | [ | |
223 | if test "$enableval"; then | |
224 | AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA) | |
225 | fi | |
226 | ]) | |
227 | ||
b6b2e9a9 FM |
228 | AC_SUBST(PACKAGE,"$PACKAGE_NAME") |
229 | AC_SUBST(VERSION,"$PACKAGE_VERSION") | |
230 | ||
095bc6be | 231 | AC_CONFIG_FILES([Makefile po/Makefile.in]) |
0743911c | 232 | AC_OUTPUT |