1dnl
2dnl The Webalizer - A web server log file analysis program
3dnl Copyright (C) 1997-2013 by Bradford L. Barrett
4dnl
5dnl configure.in template for The Webalizer Version 2.23
6dnl Process this file with autoconf to produce a configure script.
7dnl
8
9AC_INIT(webalizer,V2.23)
10
11OPTS=${DEFS}
12LIBS=${LIBS}
13AC_SUBST(OPTS)
14AC_SUBST(WCMGR_LIBS)
15
16dnl ------------------------------------------
17dnl default language (don't change!)
18dnl ------------------------------------------
19
20DEFAULT_LANG="english"
21AC_SUBST(DEFAULT_LANG)
22
23dnl ------------------------------------------
24dnl Checks for required programs.
25dnl ------------------------------------------
26
27IN_CFLAGS=${CFLAGS}
28AC_PROG_CC
29AC_PROG_LN_S
30AC_PROG_INSTALL
31
32dnl ------------------------------------------
33dnl check for platform specific settings
34dnl ------------------------------------------
35
36AC_SYS_LARGEFILE
37AC_C_CHAR_UNSIGNED
38AC_CHECK_TYPE(u_int64_t, unsigned long long)
39AC_CHECK_DECL(altzone,OPTS="-DHAVE_ALTZONE ${OPTS}",,[#include <time.h>])
40
41dnl ------------------------------------------
42dnl force our own CFLAGS defaults if GCC
43dnl ------------------------------------------
44
45if test "$GCC" = "yes"; then
46
47  AC_ARG_ENABLE(static,
48  [  --enable-static         Build as static executable       [[default=no]]],
49  LDFLAGS="--static ${LDFLAGS}")
50
51  if test "$IN_CFLAGS" = ""; then
52    CFLAGS="-Wall -O2"
53  fi
54  if test "$ac_cv_c_char_unsigned" = "yes"; then
55    CFLAGS="-fsigned-char ${CFLAGS}"
56  fi
57
58  AC_ARG_ENABLE(debug,
59  [  --enable-debug          Compile with debugging code      [[default=no]]],
60  CFLAGS="-g ${CFLAGS}")
61
62else
63  if test "$IN_CFLAGS" = ""; then
64    CFLAGS="-g"
65  fi
66fi
67
68dnl ------------------------------------------
69dnl check command line arguments
70dnl ------------------------------------------
71
72AC_ARG_WITH(gd,
73  [  --with-gd=DIR           Alternate location for gd header files],
74  S_GD="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
75AC_ARG_WITH(gdlib,
76  [  --with-gdlib=DIR        Alternate location for gd library],
77  S_GDLIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
78AC_ARG_WITH(png,
79  [  --with-png=DIR          Alternate location for png header files],
80  S_PNG="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
81AC_ARG_WITH(pnglib,
82  [  --with-pnglib=DIR       Alternate location for png library],
83  S_PNGLIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
84AC_ARG_WITH(z,
85  [  --with-z=DIR            Alternate location for libz header files],
86  S_Z="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
87AC_ARG_WITH(zlib,
88  [  --with-zlib=DIR         Alternate location for z library],
89  S_ZLIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
90AC_ARG_WITH(db,
91  [  --with-db=DIR           Alternate location for libdb header files],
92  S_DB="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
93AC_ARG_WITH(dblib,
94  [  --with-dblib=DIR        Alternate location for db library],
95  S_DBLIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
96
97dnl ------------------------------------------
98dnl these are needed on some platforms
99dnl ------------------------------------------
100
101AC_CHECK_LIB(44bsd, main, LIBS="-l44bsd ${LIBS}")
102AC_CHECK_HEADERS(getopt.h)
103AC_CHECK_LIB(m, main, LIBS="-lm ${LIBS}"; HAVE_LIBM="1")
104if test "${HAVE_LIBM}" = "1"; then
105  AC_CHECK_HEADERS(math.h)
106fi
107
108dnl ------------------------------------------
109dnl ensure current libz is present - required!
110dnl ------------------------------------------
111
112AC_CHECK_LIB(z, main, LIBZ="yes"; LIBS="-lz ${LIBS}")
113if test "${LIBZ}" = "yes"; then
114  AC_CHECK_LIB(z, gzrewind,LIBZ="yes",LIBZ="no")
115  if test "${LIBZ}" = "no"; then
116    AC_MSG_ERROR(Old version of libz found.. please upgrade!)
117  fi
118else
119  AC_MSG_ERROR(z library not found.. please install libz)
120fi
121
122AC_CHECK_HEADER(zlib.h, HDR="yes", HDR="no")
123if test "${HDR}" = "no"; then
124  AC_MSG_ERROR(zlib.h header not found.. please install)
125fi
126
127dnl ------------------------------------------
128dnl ensure libpng is present - required!
129dnl ------------------------------------------
130
131AC_CHECK_LIB(png, main, LIBPNG="yes"; LIBS="-lpng ${LIBS}",LIBPNG="no")
132if test "${LIBPNG}" = "no"; then
133  AC_MSG_ERROR(png library not found.. please install libpng)
134fi
135
136dnl ------------------------------------------
137dnl ensure libgd is present - required!
138dnl ------------------------------------------
139
140AC_CHECK_LIB(gd, main, LIBGD="yes"; LIBS="-lgd ${LIBS}")
141if test "${LIBGD}" = "yes"; then
142  AC_CHECK_LIB(gd, gdImagePng, LIBGD="yes", LIBGD="no")
143  if test "${LIBGD}" = "no"; then
144    AC_MSG_ERROR(Old version of libgd found.. please upgrade!)
145  fi
146else
147  AC_MSG_ERROR(gd library not found.. please install libgd)
148fi
149
150AC_CHECK_HEADER(gd.h, HDR="yes", HDR="no")
151if test "${HDR}" = "no"; then
152  AC_MSG_ERROR(gd.h header not found.. please install)
153fi
154
155dnl ------------------------------------------
156dnl DNS/GeoDB lookup specific tests
157dnl ------------------------------------------
158
159AC_ARG_ENABLE(dns,
160  [  --enable-dns            Enable DNS/GeoDB lookup code     [[default=yes]]],
161  USE_DNS="${enableval}", USE_DNS="yes")
162
163if test "${USE_DNS}" = "yes"; then
164  AC_CHECK_LIB(db, main, USE_DNS="yes",
165    USE_DNS="no"; AC_MSG_WARN(libdb not found.. DNS/GeoDB code disabled!))
166fi
167
168if test "${USE_DNS}" = "yes"; then
169  AC_CHECK_HEADER(db.h, USE_DNS="yes",
170    USE_DNS="no"; AC_MSG_WARN(db.h not found.. DNS/GeoDB code disabled!))
171fi
172
173if test "${USE_DNS}" = "yes"; then
174  dnl we have both library and header.. proceed
175  OPTS="-DUSE_DNS ${OPTS}"
176  LIBS="-ldb ${LIBS}"
177  WCMGR_LIBS="-ldb"
178  AC_CHECK_FUNC(fdatasync,DUMMY="")
179  if test "$ac_cv_func_fdatasync" = "no"; then
180    AC_CHECK_LIB(rt, fdatasync,
181      LIBS="-lrt ${LIBS}";WCMGR_LIBS="-lrt ${WCMGR_LIBS}")
182  fi
183  AC_CHECK_FUNC(socket,DUMMY="",DUMMY="")
184  if test "$ac_cv_func_socket" = "no"; then
185    AC_CHECK_LIB(socket, main, LIBS="-lsocket ${LIBS}")
186  fi
187  AC_CHECK_HEADERS(sys/socket.h)
188  AC_CHECK_FUNC(inet_pton,DUMMY="",DUMMY="")
189  if test "$ac_cv_func_inet_pton" = "no"; then
190    AC_CHECK_LIB(nsl,inet_pton, LIBS="-lnsl ${LIBS}")
191  fi
192fi
193
194dnl ------------------------------------------
195dnl BZip2 code specific tests
196dnl ------------------------------------------
197
198AC_ARG_ENABLE(bz2,
199  [  --enable-bz2            Enable BZip2 decompression code  [[default=no]]],
200  USE_BZIP="${enableval}", USE_BZIP="no")
201
202AC_ARG_WITH(bz2,
203  [  --with-bz2=DIR          Alternate location for bz2 header files],
204  S_BZ2="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
205AC_ARG_WITH(bz2lib,
206  [  --with-bz2lib=DIR       Alternate location for bz2 library],
207  S_BZ2LIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
208
209if test "${USE_BZIP}" = "yes"; then
210  AC_CHECK_LIB(bz2, main, USE_BZIP="yes",
211    USE_BZIP="no"; AC_MSG_WARN(libbz2 not found.. bzip2 code will will be disabled!))
212fi
213
214if test "${USE_BZIP}" = "yes"; then
215  AC_CHECK_LIB(bz2, BZ2_bzopen, USE_BZIP="yes",
216    USE_BZIP="no"; AC_MSG_WARN(Old bz2 library found.. bzip2 code will be disabled!))
217fi
218
219if test "${USE_BZIP}" = "yes"; then
220  AC_CHECK_HEADER(bzlib.h, USE_BZIP="yes",
221    USE_BZIP="no"; AC_MSG_WARN(bzlib.h not found.. bzip2 code will be disabled!))
222fi
223
224if test "${USE_BZIP}" = "yes"; then
225  dnl we have both library and header.. proceed
226  OPTS="-DUSE_BZIP ${OPTS}"
227  LIBS="-lbz2 ${LIBS}"
228fi
229
230dnl ------------------------------------------
231dnl GeoIP code specific tests
232dnl ------------------------------------------
233
234AC_ARG_ENABLE(geoip,
235  [  --enable-geoip          Enable GeoIP geolocation code    [[default=no]]],
236  USE_GEOIP="${enableval}", USE_GEOIP="no")
237
238AC_ARG_WITH(geoip,
239  [  --with-geoip=DIR        Alternate location for libGeoIP header files],
240  S_GEOIP="${withval}"; CPPFLAGS="${CPPFLAGS} -I${withval}")
241AC_ARG_WITH(geoiplib,
242  [  --with-geoiplib=DIR     Alternate location for geoip library],
243  S_GEOIPLIB="${withval}"; LDFLAGS="-L${withval} ${LDFLAGS}")
244
245if test "${USE_GEOIP}" = "yes"; then
246  AC_CHECK_LIB(GeoIP, main, USE_GEOIP="yes",
247    USE_GEOIP="no"; AC_MSG_WARN(libGeoIP not found.. GeoIP code will be disabled!))
248fi
249
250if test "${USE_GEOIP}" = "yes"; then
251  AC_CHECK_HEADER(GeoIP.h, USE_GEOIP="yes",
252    USE_GEOIP="no"; AC_MSG_WARN(GeoIP.h not found.. GeoIP code will be disabled!))
253fi
254
255if test "${USE_GEOIP}" = "yes"; then
256  dnl we have both library and header.. proceed
257  OPTS="-DUSE_GEOIP ${OPTS}"
258  LIBS="-lGeoIP ${LIBS}"
259fi
260
261dnl ------------------------------------------
262dnl check for default GeoDB directory
263dnl ------------------------------------------
264
265AC_ARG_WITH(geodb,
266  [  --with-geodb=DIR        Default GeoDB data dir [[/usr/share/GeoDB]]],
267  GEODB_LOC="${withval}", GEODB_LOC="/usr/share/GeoDB")
268AC_SUBST(GEODB_LOC)
269
270dnl ------------------------------------------
271dnl check which hash function to use
272dnl ------------------------------------------
273AC_ARG_ENABLE(oldhash,
274  [  --enable-oldhash        Use old hash function (slower)   [[default=no]]],
275  OLDHASH=${enableval}, OLDHASH="no")
276  if test "$OLDHASH" = "yes"; then OPTS="-DUSE_OLDHASH"; fi
277
278dnl ------------------------------------------
279dnl check language to use (default is english)
280dnl ------------------------------------------
281
282LANG_CACHE=yes
283AC_ARG_WITH(language,
284  [  --with-language=name    Use language 'name' (default is english)],
285  WEBALIZER_LANG="${withval}"; LANG_CACHE=no, LANG_CACHE=yes)
286if test "$WEBALIZER_LANG" = "no"; then WEBALIZER_LANG=english; fi
287
288dnl ------------------------------------------
289dnl check if specfied language is valid
290dnl ------------------------------------------
291
292AC_MSG_CHECKING(for language file)
293if test "$LANG_CACHE" = "yes"; then
294  AC_CACHE_VAL(ac_cv_language, ac_cv_language=$DEFAULT_LANG)
295  WEBALIZER_LANG=$ac_cv_language
296fi
297
298if test -f lang/webalizer_lang.${WEBALIZER_LANG}; then
299AC_MSG_RESULT(yes - ${WEBALIZER_LANG})
300else
301 if test -f lang/webalizer_lang.${DEFAULT_LANG}; then
302  AC_MSG_RESULT('${WEBALIZER_LANG}' not found - using ${DEFAULT_LANG})
303  WEBALIZER_LANG=${DEFAULT_LANG}
304 else
305  AC_MSG_RESULT(no)
306  AC_MSG_ERROR(language files not found... fix before continuing)
307 fi
308fi
309ac_cv_language=${WEBALIZER_LANG}
310
311dnl ------------------------------------------
312dnl create link to language file
313dnl ------------------------------------------
314
315AC_LINK_FILES(lang/webalizer_lang.${WEBALIZER_LANG}, webalizer_lang.h)
316
317dnl ------------------------------------------
318dnl done.. write out our Makefile
319dnl ------------------------------------------
320
321AC_OUTPUT(Makefile)
322AC_MSG_NOTICE(Done.  Type 'make' to continue with build.)
323