1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id: configure.in,v 1.63 2002/04/10 20:07:40 richard Exp $
3 AC_INIT(src/jigdo-file.cc)
4 AC_CONFIG_HEADER(src/config.h)
5 dnl ______________________________________________________________________
7 dnl Version number of our program.
8 read JIGDO_VERSION < "$srcdir/VERSION"
9 AC_DEFINE_UNQUOTED(JIGDO_VERSION, "$JIGDO_VERSION")
10 AC_SUBST(JIGDO_VERSION)
11 dnl ______________________________________________________________________
13 dnl installDevel is given 2 arguments: Name of "devel" package on
14 dnl Debian-based systems, name on RPM-based systems
15 if test -f "/etc/debian_version"; then
17 AC_MSG_RESULT([ * (Your system appears to be Debian-based; try])
18 AC_MSG_RESULT([ * installing the \`$1-dev' package.)])
20 elif test -x "/usr/bin/rpm" -o -x "/usr/local/bin/rpm"; then
22 AC_MSG_RESULT([ * (Your system appears to be RPM-based; try])
23 AC_MSG_RESULT([ * installing the package named \`$2-devel' or])
24 AC_MSG_RESULT([ * similar.)])
28 AC_MSG_RESULT([ * (If the software on your system is managed by a])
29 AC_MSG_RESULT([ * package manager like RPM, try installing the])
30 AC_MSG_RESULT([ * package named \`$2-devel' or similar.)])
33 dnl ______________________________________________________________________
35 dnl Checks for programs.
41 if test "$GXX" = "yes"; then
42 CFLAGS="$CFLAGS -Wall -W"
43 CXXFLAGS="$CXXFLAGS -Wall -W -Wpointer-arith -Wconversion -Wmissing-prototypes -Woverloaded-virtual"
46 dnl ____________________
48 AC_CACHE_CHECK(whether the C++ compiler is recent enough,
49 jigdo_cv_prog_cxx_recent,
54 template<typename T = double> struct X {
55 template<class U> void function(T* t, U* u);
58 template<> void B::X<void>::function(void* t, int* u);
59 },, jigdo_cv_prog_cxx_recent="yes", jigdo_cv_prog_cxx_recent="no")
61 if test "$jigdo_cv_prog_cxx_recent" = "no"; then
62 AC_MSG_RESULT([ * Your compiler failed to recognize some advanced C++])
63 AC_MSG_RESULT([ * constructs - it might be too old to compile jigdo.])
64 AC_MSG_RESULT([ * In case compilation fails, try upgrading to a newer])
65 AC_MSG_RESULT([ * compiler, e.g. GCC 2.95 or later.])
68 dnl ______________________________________________________________________
70 dnl Checks for header files.
72 AC_CHECK_HEADERS(stddef.h getopt.h unistd.h limits.h string.h)
74 dnl Checks for libraries and accompanying header files
75 AC_CHECK_LIB(z, zlibVersion, have_zlib="yes", have_zlib="no")
76 AC_CHECK_HEADER(zlib.h, have_zlib_h="yes", have_zlib_h="no")
77 if test "$have_zlib" = "no" -o "$have_zlib_h" = "no"; then
78 AC_MSG_RESULT([ * Please install zlib, it is needed by all of the])
79 AC_MSG_RESULT([ * programs.])
80 installDevel "zlib1g" "zlib"
85 AC_MSG_CHECKING(for value of --with-libdb)
87 [ --with-libdb Use libdb3 (necessary for jigdo-file's cache) [yes]], #'
88 jigdo_libdb="$withval", jigdo_libdb="yes")
89 AC_MSG_RESULT(\"$jigdo_libdb\")
90 if test "$jigdo_libdb" = "yes"; then
91 dnl libdb V3 by "Sleepycat". Apparently the only -l switch
92 dnl compatible across RedHat and Debian is -ldb. In case -ldb isn't
93 dnl there or is V2 or V1, try a few alternative locations. db_create
94 dnl is only available in the lib from V3 onwards.
95 for db in "db" "db3" "db-3" "db-3.1" "db-3.2" "db-3.3"; do
96 AC_CHECK_LIB($db, db_create, have_libdb="$db", have_libdb="no")
97 if test "$have_libdb" != "no"; then break; fi
99 AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no")
100 if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then
101 AC_MSG_RESULT([ * libdb3 not found - either install it, or use])
102 AC_MSG_RESULT([ * \`configure --without-libdb' to disable the db3])
103 AC_MSG_RESULT([ * file cache of jigdo-file. If this check should not])
104 AC_MSG_RESULT([ * have failed, force e.g. -ldb to be used with])
105 AC_MSG_RESULT([ * \`configure --with-libdb=-ldb'])
106 installDevel "libdb3" "libdb3.3"
107 AC_MSG_ERROR(libdb3 not found.)
109 LIBS="-l$have_libdb $LIBS"
111 AC_DEFINE(HAVE_LIBDB, 1) dnl make compilation fail if libdb not there
112 elif test "$jigdo_libdb" != "no" -a "$jigdo_libdb" != "NO"; then
113 dnl Pass argument (e.g. "-ldb") to compiler
114 LIBS="$jigdo_libdb $LIBS"
115 AC_DEFINE(HAVE_LIBDB, 1)
117 AC_DEFINE(HAVE_LIBDB, 0)
119 dnl ________________________________________
121 AC_MSG_CHECKING(for value of --with-gui)
123 [ --with-gui Build the jigdo GUI application [yes]],
124 jigdo_gui="$withval", jigdo_gui="yes")
125 AC_MSG_RESULT(\"$jigdo_gui\")
126 dnl ____________________
129 AC_MSG_CHECKING(for GTK+ version)
130 jigdo_gtkver="`gtk-config --version 2>&1`"
131 AC_MSG_RESULT($jigdo_gtkver)
132 case "$jigdo_gtkver" in
135 if test "$jigdo_gui" = "yes"; then
136 AC_MSG_RESULT([ * GTK+ not installed, or the installed version is not])
137 AC_MSG_RESULT([ * 1.2.x, or gtk-config is not in \$PATH. Please])
138 AC_MSG_RESULT([ * install GTK+ 1.2, it is needed by \`jigdo'.])
139 installDevel "libgtk1.2" "libgtk1.2"
142 noConfig="# gtk-config not found - add compiler switches here"
143 GTKCFLAGS="`gtk-config --cflags 2>/dev/null || echo $noConfig`"
144 GTKLIBS="`gtk-config --libs 2>/dev/null || echo $noConfig`"
147 dnl ____________________
150 AC_MSG_CHECKING(for libwww version)
151 jigdo_libwwwver="`libwww-config --version 2>&1`"
152 AC_MSG_RESULT($jigdo_libwwwver)
153 LIBWWWCFLAGS="# libwww-config not found - add compiler switches here"
154 LIBWWWLIBS="$LIBWWWCFLAGS"
155 case "$jigdo_libwwwver" in
156 dnl Extra [] around [0-9] style wildcards, or M4 swallows them
157 [[6-9]*|5.[4-9]*|5.[1-9][0-9]*|5.3.[2-9]*|5.3.[1-9][0-9]*])
158 LIBWWWCFLAGS="`libwww-config --cflags 2>/dev/null`"
159 LIBWWWLIBS="`libwww-config --libs 2>/dev/null`"
160 dnl Some versions of libwww-config include "-I/usr/include" in their
161 dnl --cflags output, which completely upsets some versions of GCC.
162 LIBWWWCFLAGS=`echo " $LIBWWWCFLAGS " | sed -e 's% -I/usr/include/* % %'`
165 if test "$jigdo_gui" = "yes"; then
166 AC_MSG_RESULT([ * libwww not installed, or the installed version is])
167 AC_MSG_RESULT([ * too old, or libwww-config is not in \$PATH. Please])
168 AC_MSG_RESULT([ * install libwww 5.3.2 or later, it is needed by the])
169 AC_MSG_RESULT([ * \`jigdo' program.])
170 installDevel "libwww" "w3c-libwww-devel/libopenssl0"
173 AC_SUBST(LIBWWWCFLAGS)
175 dnl ____________________
177 dnl Checks for typedefs, structures, and compiler characteristics.
179 AC_MSG_CHECKING(whether we are compiling for Windows)
180 AC_EGREP_CPP(poorsoul, [
181 #if defined WINNT || defined __WINNT || defined __WINNT__ || defined WIN32 \
182 || defined _WIN32 || defined __WIN32 || defined __WIN32__
184 #endif], is_windows=yes, is_windows=no)
185 AC_MSG_RESULT($is_windows)
186 if test "$is_windows" = yes; then
194 dnl ____________________
196 dnl Both MinGW32 and glib declare 'struct dirent' and 'struct DIR'. If
197 dnl there are problems using the relevant headers together, do some
198 dnl really dirty things with the preprocessor to disable the glib
201 if test "$is_windows" = yes; then
202 CPPFLAGS_orig="$CPPFLAGS"
203 CPPFLAGS="$CPPFLAGS $GTKCFLAGS"
204 AC_MSG_CHECKING(for conflicting 'struct dirent' in dirent.h and glib.h)
205 AC_TRY_COMPILE([#include <dirent.h>
206 #include <glib.h>], , dirent_hack="no",dirent_hack="yes")
207 if test "$dirent_hack" = "yes"; then
208 AC_TRY_COMPILE([#include <dirent.h>
209 #define dirent other_dirent
210 #define DIR other_DIR
211 #include <glib.h>], , , dirent_hack="no")
213 AC_MSG_RESULT($dirent_hack)
214 CPPFLAGS="$CPPFLAGS_orig"
216 if test "$dirent_hack" = "yes"; then
217 AC_DEFINE(DIRENT_HACK, 1)
219 AC_DEFINE(DIRENT_HACK, 0)
221 dnl ____________________
223 AC_MSG_CHECKING(for value of --with-uint64)
225 [ --with-uint64=TYPE Specify unsigned type of at least 64 bits [auto]
226 (Replace spaces with underscores in TYPE)],
227 jigdo_uint64="yes", jigdo_uint64="auto")
228 AC_MSG_RESULT(\"$jigdo_uint64\")
230 AC_CACHE_CHECK(for unsigned long long, jigdo_cv_have_ulonglong,
231 AC_TRY_COMPILE(, unsigned long long x = 0,
232 jigdo_cv_have_ulonglong=yes, jigdo_cv_have_ulonglong=no))
233 if test "$jigdo_cv_have_ulonglong" = "yes"; then
234 AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
236 AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 0)
239 if test "$jigdo_uint64" = auto; then
240 AC_CHECK_SIZEOF(unsigned long, 0)
241 AC_CHECK_SIZEOF(unsigned long long, 0)
242 if test "$ac_cv_sizeof_unsigned_long" -ge 8; then
243 jigdo_uint64='unsigned long'
244 elif test "$ac_cv_sizeof_unsigned_long_long" -ge 8; then
245 jigdo_uint64='unsigned long long'
247 if test "$jigdo_cv_have_ulonglong" = "yes"; then
248 jigdo_uint64='unsigned long long'
250 jigdo_uint64='unsigned long'
252 AC_MSG_RESULT([ * Could not find an unsigned type with at least 64])
253 AC_MSG_RESULT([ * bits (or maybe char has >8 bits?) - defaulting to])
254 AC_MSG_RESULT([ * \`$jigdo_uint64'. You may want to override])
255 AC_MSG_RESULT([ * this using --with-uint64=TYPE])
257 elif test "$jigdo_uint64" = yes -o "$jigdo_uint64" = no; then
258 AC_MSG_ERROR(Invalid argument to --with-uint64 option)
260 jigdo_uint64=`echo $jigdo_uint64 | sed -e 's/_/ /g'`
262 AC_MSG_CHECKING(for 64 bit unsigned integer type)
263 AC_MSG_RESULT($jigdo_uint64)
264 AC_DEFINE_UNQUOTED(TYPE_UINT64, $jigdo_uint64)
266 AC_CACHE_CHECK(whether operator <<(uint64) works,
267 jigdo_cv_prog_cxx_outuint64,
269 [ #include <iostream>
271 using namespace std; ],
273 cout << x << endl; ],
274 jigdo_cv_prog_cxx_outuint64="yes", jigdo_cv_prog_cxx_outuint64="no")
276 if test "$jigdo_cv_prog_cxx_outuint64" = "yes"; then
277 AC_DEFINE(HAVE_OUTUINT64, 1)
279 AC_DEFINE(HAVE_OUTUINT64, 0)
281 dnl ____________________
283 dnl Checks for library functions.
284 AC_CHECK_FUNCS(lstat truncate ftruncate mmap fileno snprintf _snprintf)
286 dnl Check whether reading width of TTY via ioctl() works
287 AC_MSG_CHECKING(for TIOCGWINSZ ioctl)
290 #include <sys/ioctl.h>],
291 [ struct winsize w; int i;
292 ioctl(fileno(stdout), TIOCGWINSZ, &w);
294 jigdo_have_ioctl_winsz="yes", jigdo_have_ioctl_winsz="no")
295 AC_MSG_RESULT($jigdo_have_ioctl_winsz)
296 if test "$jigdo_have_ioctl_winsz" = "yes"; then
297 AC_DEFINE(HAVE_IOCTL_WINSZ, 1)
298 elif test "$is_windows" = no; then
299 AC_MSG_RESULT([ * jigdo-file progress reports will not be formatted])
300 AC_MSG_RESULT([ * nicely, because no way has been found to determine])
301 AC_MSG_RESULT([ * the screen width in characters.])
302 AC_DEFINE(HAVE_IOCTL_WINSZ, 0)
304 AC_DEFINE(HAVE_IOCTL_WINSZ, 0)
307 dnl On native Windows (MinGW32), there is no snprintf, just _snprintf
308 if test "$ac_cv_func_snprintf" = "no" -a "$ac_cv_func__snprintf" = "yes"; then
309 AC_DEFINE(snprintf, _snprintf)
311 dnl ______________________________________________________________________
313 dnl Check for Native Language Support (gettext)
314 AC_MSG_CHECKING(for value of --enable-nls)
316 [ --enable-nls Use Native Language Support [yes]],
317 USE_NLS=$enableval, USE_NLS=yes)
318 AC_MSG_RESULT(\"$USE_NLS\")
321 if test "$USE_NLS" = "yes"; then
322 AC_DEFINE(ENABLE_NLS, 1)
324 AC_CHECK_LIB(intl, dgettext, x="yes", x="no")
325 if test "$x" = "yes"; then
327 AC_CHECK_LIB(iconv, iconv, LIBS="$LIBS -liconv")
329 AC_CHECK_HEADER(libintl.h, x="yes", x="no")
330 if test "$x" = "no"; then
331 AC_MSG_RESULT([ * Make sure gettext is installed, or use])
332 AC_MSG_RESULT([ * --disable-nls to switch off gettext support.])
333 AC_MSG_ERROR(libintl.h not found.)
335 AC_MSG_CHECKING(whether dgettext works)
336 AC_TRY_LINK([#include <libintl.h>], [dgettext("", "")], x="yes", x="no")
338 if test "$x" = "no"; then
339 AC_MSG_RESULT([ * Make sure gettext is installed, or use])
340 AC_MSG_RESULT([ * --disable-nls to switch off gettext support.])
341 AC_MSG_ERROR(dgettext() call could not be linked.)
343 dnl ____________________
345 AC_MSG_CHECKING(for catalogs to be installed)
346 ALL_LINGUAS=`(cd "$srcdir/po" && echo *.po *.pox "") \
347 | sed -e "s/\**\.pox* / /g"`
348 if test "$LINGUAS"; then
350 for provided in $ALL_LINGUAS; do
352 for wanted in $LINGUAS; do
353 case "$provided" in "$wanted"*) x=" $provided";; esac
354 case "$wanted" in "$provided"*) x=" $provided";; esac
356 NEW_LINGUAS="$NEW_LINGUAS$x"
358 LINGUAS="$NEW_LINGUAS"
359 AC_MSG_RESULT(LINGUAS:$LINGUAS)
361 LINGUAS="$ALL_LINGUAS"
362 AC_MSG_RESULT($LINGUAS)
364 for x in $LINGUAS; do CATALOGS="$CATALOGS $x.gmo"; done
366 AC_DEFINE(ENABLE_NLS, 0)
369 dnl ______________________________________________________________________
371 dnl Checks for other --enable-xxx, --with-xxx switches
372 AC_MSG_CHECKING(for value of --enable-debug)
374 [ --enable-debug Compile in lots of additional debugging code [no]],
375 jigdo_debug=$enableval, jigdo_debug=no)
376 AC_MSG_RESULT(\"$jigdo_debug\")
378 if test "$jigdo_debug" = yes; then
380 DEBUG_PROGRAMS='$(debug-programs)'
381 elif test "$jigdo_debug" != no; then
382 AC_MSG_ERROR(Invalid argument to --enable-debug option)
386 AC_SUBST(DEBUG_PROGRAMS)
387 dnl ________________________________________
389 AC_MSG_CHECKING(for value of --enable-ccmalloc)
390 AC_ARG_ENABLE(ccmalloc,
391 [ --enable-ccmalloc Use the ccmalloc memory leak detector [no]],
392 jigdo_ccmalloc=$enableval, jigdo_ccmalloc=no)
393 AC_MSG_RESULT(\"$jigdo_ccmalloc\")
395 if test "$jigdo_ccmalloc" = yes; then
396 AC_DEFINE(CCMALLOC, 1)
397 CCMALLOC='$(CCMALLOC)'
398 elif test "$jigdo_ccmalloc" != no; then
399 AC_MSG_ERROR(Invalid argument to --enable-ccmalloc option)
401 AC_DEFINE(CCMALLOC, 0)
404 dnl ______________________________________________________________________
406 dnl Touch TAGS to prevent it from being recreated when a normal user
407 dnl builds the program. TAGS should only be updated once changes are
408 dnl made to the source.
409 touch "$srcdir/src/TAGS"
411 dnl Now that both jigdo_gui and exe are set, build list of programs to
413 if test "$jigdo_gui" = "yes"; then
414 BUILD_TARGETS="jigdo-file$exe jigdo$exe #"
415 INSTALL_TARGETS="install-jigdo-file install-jigdo-lite install-jigdo #"
417 BUILD_TARGETS="jigdo-file$exe # jigdo$exe"
418 INSTALL_TARGETS="install-jigdo-file install-jigdo-lite # install-jigdo"
420 AC_SUBST(BUILD_TARGETS)
421 AC_SUBST(INSTALL_TARGETS)
423 SRC_MAKEDEPS="$srcdir/src/Makedeps"
424 AC_SUBST_FILE(SRC_MAKEDEPS)
426 AC_OUTPUT(Makefile doc/Makefile src/Makefile po/Makefile)