1# Configuration for ht://Dig 3.x
2#
3# Part of the ht://Dig package   <http://www.htdig.org/>
4# Copyright (c) 1999-2004 The ht://Dig Group
5# For copyright details, see the file COPYING in your distribution
6# or the GNU Library General Public License (LGPL) version 2 or later
7# <http://www.gnu.org/copyleft/lgpl.html>
8
9AC_PREREQ(2.57)
10AC_INIT
11
12#
13# ht://Dig's version
14#
15VERSION=`cat ${srcdir}/.version`
16HTDIG_MAJOR_VERSION=[`expr $VERSION : '\([0-9][0-9]*\)'`]
17AC_SUBST(HTDIG_MAJOR_VERSION)
18HTDIG_MINOR_VERSION=[`expr $VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\)'`]
19AC_SUBST(HTDIG_MINOR_VERSION)
20HTDIG_MICRO_VERSION=[`expr $VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\)'`]
21AC_SUBST(HTDIG_MICRO_VERSION)
22
23AM_INIT_AUTOMAKE([htdig], $VERSION)
24AC_CONFIG_SRCDIR([htdig/htdig.cc])
25AM_CONFIG_HEADER([include/config.h])
26AC_CONFIG_LIBOBJ_DIR([htlib])
27AC_PREFIX_DEFAULT([/opt/www])
28
29# Initialize maintainer mode
30AM_MAINTAINER_MODE
31
32AC_ARG_WITH(config-dir, [AC_HELP_STRING([--with-config-dir=DIR],
33	[where your config directory is @<:@PREFIX/conf@:>@])],
34 CONFIG_DIR="$withval", CONFIG_DIR='${prefix}/conf')
35AC_SUBST(CONFIG_DIR)
36
37# In the below, the strings @<:@ and @:>@ expand to [ and ]
38AC_ARG_WITH(default-config-file,
39	[AC_HELP_STRING([--with-default-config-file=FILE],
40	[where the various programs will look for a configuration file
41	@<:@PREFIX/conf/htdig.conf@:>@])],
42 DEFAULT_CONFIG_FILE="$withval", DEFAULT_CONFIG_FILE='${CONFIG_DIR}/htdig.conf')
43AC_SUBST(DEFAULT_CONFIG_FILE)
44
45AC_ARG_WITH(common-dir, [AC_HELP_STRING([--with-common-dir=DIR],
46	[where your .html templates are stored
47	@<:@PREFIX/share/htdig@:>@])],
48 COMMON_DIR="$withval", COMMON_DIR='${datadir}/htdig')
49AC_SUBST(COMMON_DIR)
50
51AC_ARG_WITH(database-dir, [AC_HELP_STRING([--with-database-dir=DIR],
52	[where your database directory is
53	@<:@PREFIX/var/htdig@:>@])],
54 DATABASE_DIR="$withval", DATABASE_DIR='${localstatedir}/htdig')
55AC_SUBST(DATABASE_DIR)
56
57AC_ARG_WITH(cgi-bin-dir, [AC_HELP_STRING([--with-cgi-bin-dir=DIR],
58	[where your web server cgi-bin directory is
59	@<:@PREFIX/cgi-bin@:>@])],
60 CGIBIN_DIR="$withval", CGIBIN_DIR='${prefix}/cgi-bin')
61AC_SUBST(CGIBIN_DIR)
62
63AC_ARG_WITH(search-dir, [AC_HELP_STRING([--with-search-dir=DIR],
64	[where the sample search form should be installed
65	@<:@PREFIX/htdocs/htdig@:>@])],
66 SEARCH_DIR="$withval", SEARCH_DIR='${prefix}/htdocs/htdig')
67AC_SUBST(SEARCH_DIR)
68
69AC_ARG_WITH(search-form, [AC_HELP_STRING([--with-search-form=FILE],
70	[the name for the sample search form @<:@search.html@:>@])],
71 SEARCH_FORM="$withval", SEARCH_FORM='search.html')
72AC_SUBST(SEARCH_FORM)
73
74AC_ARG_WITH(image-dir, [AC_HELP_STRING([--with-image-dir=DIR],
75	[where the ht://Dig images are installed
76	@<:@PREFIX/htdocs/htdig@:>@])],
77 IMAGE_DIR="$withval", IMAGE_DIR='${prefix}/htdocs/htdig')
78AC_SUBST(IMAGE_DIR)
79
80AC_ARG_WITH(image-url-prefix,
81	[AC_HELP_STRING([--with-image-url-prefix=LOCATION],
82	[the URL path to the installed images @<:@/htdig@:>@])],
83 IMAGE_URL_PREFIX="$withval", IMAGE_URL_PREFIX='/htdig')
84AC_SUBST(IMAGE_URL_PREFIX)
85
86AC_ARG_WITH(rx, [AC_HELP_STRING([--with-rx],
87	[with system rx instead of regex @<:@no@:>@])],
88 WITH_RX="$withval", WITH_RX='no')
89
90# If the user doesn't want tests
91AC_ARG_ENABLE(tests,
92	[AC_HELP_STRING([--enable-tests],
93		[do build a version with run-time tests.])],
94	[htdig_cv_tests="$enable_tests"], [htdig_cv_tests="no"])
95AM_CONDITIONAL(TESTS, test x$htdig_cv_tests = xyes)
96
97# Checks for programs.
98AC_PROG_CXX
99AC_PROG_CC
100AC_PROG_CPP
101AC_AIX
102AM_PROG_LEX
103AC_PROG_YACC
104AC_PROG_INSTALL
105AC_PROG_LN_S
106AC_PROG_MAKE_SET
107AC_PROG_LIBTOOL
108AC_COMPILE_WARNINGS
109NO_RTTI
110NO_EXCEPTIONS
111AC_PATH_PROG(AR, ar, ar)
112AC_PATH_PROG(SHELL, sh, /bin/sh)
113AC_PATH_PROG(SED, sed, /bin/sed)
114AC_PATH_PROG(PERL, perl, /usr/bin/perl)
115AC_PATH_PROG(FIND, find, /bin/find)
116AC_PATH_PROG(GUNZIP, gunzip, /bin/gunzip)
117AC_CHECK_PROGS(RRDTOOL, rrdtool)
118AC_CHECK_PROGS(TAR, tar gtar gnutar, tar)
119AC_PATH_PROG(MV, mv, /bin/mv)
120AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
121   $PATH:/usr/libexec:/usr/sbin:/usr/lib:/usr/etc:etc)
122AM_PROG_TIME
123
124
125# Checks for libraries.
126#AC_CHECK_LIB([z], [main])
127AC_CHECK_LIB(socket, socket)
128AC_CHECK_LIB(nsl, t_accept)
129CHECK_SSL
130CHECK_ZLIB
131AC_SUBST(CXXFLAGS)
132AC_SUBST(LDFLAGS)
133
134
135# Checks for header files.
136AC_HEADER_STDBOOL
137AC_HEADER_TIME
138AC_FUNC_ALLOCA
139AC_HEADER_DIRENT
140AC_HEADER_STDC
141AC_HEADER_SYS_WAIT
142AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h wchar.h wctype.h])
143#AC_CHECK_HEADERS([zlib.h sys/wait.h wait.h alloca.h])
144AC_CHECK_HEADERS([sys/wait.h wait.h alloca.h])
145#AC_CHECK_HEADERS(ssl.h)
146
147# Checks for typedefs, structures, and compiler characteristics.
148AC_HEADER_STAT
149AC_HEADER_STDBOOL
150AC_C_CONST
151AC_C_INLINE
152AC_TYPE_OFF_T
153AC_TYPE_SIZE_T
154AC_CHECK_MEMBERS([struct stat.st_blksize])
155AC_HEADER_TIME
156AC_STRUCT_TM
157AC_CHECK_SIZEOF(unsigned long long int, 8)
158AC_CHECK_SIZEOF(unsigned long int, 4)
159AC_CHECK_SIZEOF(unsigned int, 4)
160AC_CHECK_SIZEOF(unsigned short int, 2)
161AC_CHECK_SIZEOF(unsigned char, 1)
162
163# Checks for library functions.
164AC_FUNC_CLOSEDIR_VOID
165#AC_FUNC_ERROR_AT_LINE
166#AC_FUNC_LSTAT
167#AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
168AC_FUNC_MALLOC
169AC_FUNC_MBRTOWC
170AC_FUNC_MEMCMP
171AC_FUNC_MMAP
172AC_FUNC_REALLOC
173AC_FUNC_SELECT_ARGTYPES
174AC_TYPE_SIGNAL
175#AC_FUNC_STAT
176AC_FUNC_STRFTIME
177AC_FUNC_STRPTIME
178AC_FUNC_VPRINTF
179AC_CHECK_FUNCS([alarm btowc bzero ftime getcwd gettimeofday localtime_r memcmp memcpy memmove memset mkstemp munmap pstat_getdynamic raise re_comp regcomp select setlocale strchr strcspn strdup strerror strrchr strstr strtol strtoul timegm])
180AC_REPLACE_FUNCS(snprintf vsnprintf)
181
182# More header checks--here use C++
183AC_LANG([C++])
184AC_CXX_HAVE_STD
185
186AC_MSG_CHECKING(whether we need gethostname() prototype?)
187AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
188#include <unistd.h>
189#include <stdio.h>
190#include <sys/types.h>
191#include <sys/socket.h>
192#include <netinet/in.h>
193#include <sys/ioctl.h>
194#include <sys/uio.h>
195#include <sys/file.h>
196#include <fcntl.h>
197#include <netdb.h>
198#include <stdlib.h>
199extern "C" int gethostname(char *, int);
200]],[[
201gethostname("sdsu.edu", (int) 8);
202]])],[AC_MSG_RESULT(yes);AC_DEFINE([NEED_PROTO_GETHOSTNAME],,[Define if you need a prototype for gethostname()])],[AC_MSG_RESULT(no)])
203
204# We're still using the C++ compiler for this test
205AC_MSG_CHECKING(how to call getpeername?)
206for sock_t in 'struct sockaddr' 'void'; do
207  for getpeername_length_t in 'size_t' 'int' 'unsigned int' 'long unsigned int' 'socklen_t'
208  do
209    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
210#include <sys/socket.h>
211 extern "C" int getpeername(int, $sock_t *, $getpeername_length_t *);
212 $sock_t s;  $getpeername_length_t l; ]], [[ getpeername(0, &s, &l); ]])],[ac_found=yes ; break 2],[ac_found=no])
213  done
214done
215
216if test "$ac_found" = no
217then
218  AC_MSG_WARN([can't determine, using size_t])
219  getpeername_length_t="size_t"
220else
221  AC_MSG_RESULT($getpeername_length_t)
222fi
223AC_DEFINE_UNQUOTED([GETPEERNAME_LENGTH_T],[$getpeername_length_t],[Define this to the type of the third argument of getpeername()])
224
225AC_MSG_CHECKING(how to call select?)
226for fd_set_t in 'fd_set' 'int'
227  do
228  for timeval_t in 'struct timeval' 'const struct timeval'
229  do
230    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>
231#include <sys/types.h>
232#include <unistd.h>
233 extern "C" int select(int, $fd_set_t *, $fd_set_t *, $fd_set_t *, $timeval_t *);
234 $fd_set_t fd; ]], [[ select(0, &fd, 0, 0, 0); ]])],[ac_found=yes ; break 2],[ac_found=no])
235 done
236done
237
238if test "$ac_found" = no
239then
240  AC_MSG_WARN([can't determine argument type using int])
241  fd_set_t="int"
242else
243  AC_MSG_RESULT($fd_set_t)
244fi
245AC_DEFINE_UNQUOTED([FD_SET_T],[$fd_set_t],[Define this to the type of the second argument of select()])
246
247# Replacements for the library functions (i.e. regex)
248# Regex is compiled by the C compiler so we need to do it before we switch
249if test $WITH_RX = yes; then
250 AC_CHECK_HEADER(rxposix.h, AC_DEFINE(USE_RX,,[Use posix regexp]), WITH_RX='no')
251fi
252if test $WITH_RX = no; then
253 AC_MSG_CHECKING(if we should use the included regex?)
254 OLD_CFLAGS=$CFLAGS
255 CFLAGS="$CFLAGS -I${srcdir}/htlib"
256
257AC_RUN_IFELSE([AC_LANG_SOURCE([[
258#include "${srcdir}/htlib/regex.c"
259int main() {
260    regex_t re;
261    return regcomp(&re, "ht.*Dig", REG_ICASE);
262}
263]])],
264   [AC_MSG_RESULT(yes);AC_LIBOBJ([regex])],
265   [AC_MSG_RESULT(no);AC_DEFINE(HAVE_BROKEN_REGEX,,[Broken regexp])],
266   [AC_MSG_RESULT(unknown);AC_DEFINE(HAVE_BROKEN_REGEX,,[Unknown regexp])])
267 CFLAGS=$OLD_CFLAGS
268fi
269
270# Enable big files?
271AC_MSG_CHECKING(if --enable-bigfile option specified)
272AC_ARG_ENABLE(bigfile,
273	[AC_HELP_STRING([--enable-bigfile], [enable Linux, AIX, HP/UX, Solaris big files.])],
274	[db_cv_bigfile="$enable_bigfile"], [db_cv_bigfile="yes"])
275AC_MSG_RESULT($db_cv_bigfile)
276
277# Vendors are doing 64-bit lseek in different ways.
278# Linux, AIX, HP/UX and Solaris all use _FILE_OFFSET_BITS to specify a "big-file"
279# environment.
280if test "$db_cv_bigfile" = yes; then
281	case "$host_os" in
282	bsdi*|aix*|hpux*|solaris*)	AC_DEFINE(HAVE_FILE_OFFSET_BITS,,['big-file' environment]);;
283	linux*)	AC_DEFINE(HAVE_FILE_OFFSET_BITS,,['big-file' environment])
284		AC_DEFINE(HAVE_LARGEFILE_SOURCE,,[large file sources])
285		;;
286	esac
287fi
288
289# Add the -mimpure-text option on Solaris with GCC and libstc++ that is not shared
290if test "$GXX" = "yes"
291then
292  case "$host" in
293    *-sun-solaris* ) extra_ldflags="-mimpure-text";;
294  esac
295fi
296
297AC_SUBST(extra_ldflags)
298# Define to the syslog level for htsearch logging
299AC_DEFINE([LOG_LEVEL],[LOG_INFO],[Define to the syslog level for htsearch logging])
300
301# Define to the syslog facility for htsearch logging
302AC_DEFINE([LOG_FACILITY],[LOG_LOCAL5],[Define to the syslog facility for htsearch logging])
303
304# Any remaining tests probably want the C compiler
305AC_LANG_C
306if test ! -d "./db"; then
307    mkdir db
308fi
309
310if test x$htdig_cv_tests = xyes
311then
312    CHECK_USER
313    AC_PROG_APACHE(1.3.1)
314fi
315
316echo configuring ht://Dig version $VERSION
317
318AC_CONFIG_SUBDIRS(db)
319
320### HACK: copied from  autoconf  output, to ensure the expansion below works
321test "x$prefix" = xNONE && prefix=$ac_default_prefix
322# Let make expand exec_prefix.
323test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
324
325# expand variables which appear in  attrs.html  and the man pages
326while echo $bindir | grep '\$' >/dev/null ; do
327  eval "bindir=$bindir"
328done
329while echo $COMMON_DIR | grep '\$' >/dev/null ; do
330  eval "COMMON_DIR=$COMMON_DIR"
331done
332while echo $CONFIG_DIR | grep '\$' >/dev/null ; do
333  eval "CONFIG_DIR=$CONFIG_DIR"
334done
335while echo $DEFAULT_CONFIG_FILE | grep '\$' >/dev/null ; do
336  eval "DEFAULT_CONFIG_FILE=$DEFAULT_CONFIG_FILE"
337done
338while echo $DATABASE_DIR | grep '\$' >/dev/null ; do
339  eval "DATABASE_DIR=$DATABASE_DIR"
340done
341while echo $IMAGE_URL_PREFIX | grep '\$' >/dev/null ; do
342  eval "IMAGE_URL_PREFIX=$IMAGE_URL_PREFIX"
343done
344while echo $VERSION | grep '\$' >/dev/null ; do
345  eval "VERSION=$VERSION"
346done
347
348AC_CONFIG_FILES([Makefile
349                 htcommon/Makefile
350                 htdb/Makefile
351                 htdig/Makefile
352                 htdoc/Makefile
353                 htdoc/attrs.html
354                 installdir/htdig.1
355                 installdir/htdig-pdfparser.1
356                 installdir/htfuzzy.1
357                 installdir/htmerge.1
358                 installdir/htpurge.1
359                 installdir/htstat.1
360                 installdir/htdigconfig.8
361                 installdir/htdump.1
362                 installdir/htload.1
363                 installdir/htnotify.1
364                 installdir/htsearch.1
365                 installdir/rundig.1
366                 htfuzzy/Makefile
367                 htlib/Makefile
368                 htnet/Makefile
369                 htsearch/Makefile
370                 httools/Makefile
371                 htword/Makefile
372                 include/Makefile installdir/Makefile
373                 test/Makefile
374                 test/test_functions])
375AC_OUTPUT
376
377echo ""
378echo ""
379echo "Now you must run 'make' followed by 'make install'"
380echo ""
381