Update build-deps
[jigdo.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl $Id: configure.ac,v 1.25 2006/05/19 16:05:40 atterer Exp $
3 AC_INIT(src/jigdo-file.cc)
4 AC_CONFIG_HEADER(src/config.h)
5 dnl ______________________________________________________________________
6
7 dnl Version number of our program.
8 read tmpa tmpb JIGDO_VERSION < "$srcdir/jigdo.spec"
9 AC_DEFINE_UNQUOTED(JIGDO_VERSION, "$JIGDO_VERSION")
10 AC_SUBST(JIGDO_VERSION)
11 dnl ______________________________________________________________________
12
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
16     installDevel() {
17     AC_MSG_RESULT([   * (Your system appears to be Debian-based; try])
18     AC_MSG_RESULT([   * installing the \`$1-dev' package.)])
19     }
20 elif test -x "/usr/bin/rpm" -o -x "/usr/local/bin/rpm"; then
21     installDevel() {
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.)])
25     }
26 else
27     installDevel() {
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.)])
31     }
32 fi
33 dnl ______________________________________________________________________
34
35 dnl Checks for programs.
36 AC_PROG_AWK
37 AC_LANG_C
38 AC_PROG_CC
39 dnl Add -Wno-unused-parameter to CFLAGS if supported
40 dnl ORIG_CFLAGS="$CFLAGS"
41 dnl CFLAGS="$CFLAGS -Wno-unused-parameter" # GCC >=3.0
42 dnl AC_TRY_COMPILE(, int x = 0, , CFLAGS="$ORIG_CFLAGS")
43 AC_LANG_CPLUSPLUS
44 AC_PROG_CXX
45 CFLAGS=`echo "$CFLAGS" | sed 's/\(^\| \)-g\( \|$\)/ /'`
46 CXXFLAGS=`echo "$CXXFLAGS" | sed 's/\(^\| \)-g\( \|$\)/ /'`
47 IF_GXX2="#"
48 IFNOT_GXX2=""
49 if test "$GXX" = yes; then
50     AC_MSG_CHECKING(for GCC version)
51     gccver=`$CXX -dumpversion`
52     AC_MSG_RESULT($gccver);
53     case "$gccver" in
54         2.*)
55             IF_GXX2=""
56             IFNOT_GXX2="#";;
57         3.0|3.0.*|3.1|3.1.*|3.3|3.3.*)
58         #AC_MSG_RESULT([   * Big file support may be broken in GCC 3.2 and])
59         #AC_MSG_RESULT([   * 3.3! If you compile jigdo on Linux (and maybe])
60         #AC_MSG_RESULT([   * other OSes), it might not be able to create])
61         #AC_MSG_RESULT([   * files bigger than 2 GB, such as DVD images.])
62         #AC_MSG_RESULT([   * (Try GCC 2.95 or GCC 3.4 or later)])
63     esac
64 fi
65 AC_SUBST(IF_GXX2)
66 AC_SUBST(IFNOT_GXX2)
67 AC_PROG_INSTALL
68 dnl ____________________
69
70 dnl Checks for typedefs, structures, and compiler characteristics.
71 AC_TYPE_SIZE_T
72 AC_C_BIGENDIAN
73 AC_MSG_CHECKING(whether we are compiling for Windows)
74 AC_EGREP_CPP(poorsoul, [
75 #if defined WINNT || defined __WINNT || defined __WINNT__ || defined WIN32 \
76     || defined _WIN32 || defined __WIN32 || defined __WIN32__
77   poorsoul
78 #endif], is_windows=yes, is_windows=no)
79 AC_MSG_RESULT($is_windows)
80 if test "$is_windows" = yes; then
81     AC_DEFINE(WINDOWS)
82     exe=".exe"
83     IF_WINDOWS=""
84     IF_UNIX="#"
85 else
86     AC_DEFINE(UNIX)
87     exe=""
88     IF_WINDOWS="#"
89     IF_UNIX=""
90 fi
91 AC_SUBST(exe)
92 AC_SUBST(IF_WINDOWS)
93 AC_SUBST(IF_UNIX)
94
95 if test "$is_windows" = "yes"; then
96     if test "$ac_cv_prog_cc_g" = "yes"; then
97         CFLAGS="$CFLAGS -mms-bitfields -march=pentium"
98     fi
99     if test "$ac_cv_prog_cxx_g" = "yes"; then
100         CXXFLAGS="$CXXFLAGS -mms-bitfields -march=pentium"
101     fi
102 fi
103 dnl ____________________
104
105 AC_CACHE_CHECK(whether the C++ compiler is recent enough,
106                jigdo_cv_prog_cxx_recent,
107     AC_TRY_COMPILE(
108     #include <vector>
109     namespace A {
110       namespace B {
111         template<typename T = double> struct X {
112           template<class U> void function(T* t, U* u);
113         };
114         template<> struct X<void> { void function(void* t, int* u); };
115       }
116       void B::X<void>::function(void*, int*) { }
117     },, jigdo_cv_prog_cxx_recent="yes", jigdo_cv_prog_cxx_recent="no")
118 )
119 if test "$jigdo_cv_prog_cxx_recent" = "no"; then
120     AC_MSG_RESULT([   * Your compiler failed to recognize some advanced C++])
121     AC_MSG_RESULT([   * constructs - it might be too old to compile jigdo.])
122     AC_MSG_RESULT([   * In case compilation fails, try upgrading to a newer])
123     AC_MSG_RESULT([   * compiler, e.g. GCC 2.95 or later.])
124 fi
125 AC_CACHE_SAVE
126 dnl ________________________________________
127
128 dnl C99-style vararg macros are not supported by GCC 2.95
129 AC_CACHE_CHECK([whether the C++ preprocessor supports variable-arg macros],
130                jigdo_cv_prog_cxx_varmacro,
131     AC_TRY_COMPILE(
132     #if defined(__GNUC__) && __GNUC__ < 3
133     #  define debug(_args...) do { } while (false)
134     #else
135     #  define debug(...) do { } while (false)
136     #endif
137     int foo() {
138       int debug = 0; // No substitution!
139       debug("!");
140       debug("%1", debug);
141       return debug;
142     },, jigdo_cv_prog_cxx_varmacro="yes", jigdo_cv_prog_cxx_varmacro="no")
143 )
144 if test "$jigdo_cv_prog_cxx_varmacro" = "yes"; then
145     AC_DEFINE(HAVE_VARMACRO, 1)
146 else
147     AC_DEFINE(HAVE_VARMACRO, 0)
148 fi
149 dnl ________________________________________
150
151 dnl Doesn't work
152 dnl AC_CACHE_CHECK([whether C++ supports accessing files larger than 4 GB],
153 dnl                jigdo_cv_prog_cxx_lfs,
154 dnl     AC_TRY_COMPILE([#include <fstream>],
155 dnl         [using namespace std; ifstream i; i.seekg(0x100000000, ios::beg);],
156 dnl         jigdo_cv_prog_cxx_lfs="yes", jigdo_cv_prog_cxx_lfs="no")
157 dnl )
158 dnl if test "$jigdo_cv_prog_cxx_lfs" = "no"; then
159 dnl     AC_MSG_RESULT([   * There is a problem accessing large files.])
160 dnl     AC_MSG_RESULT([   * jigdo may be unable to work with DVD-sized images.])
161 dnl fi
162 dnl ________________________________________
163
164 AC_CHECK_PROG(have_wget, wget, yes, no)
165 if test "$have_wget" = "no"; then
166     AC_MSG_RESULT([   * wget was not found on your system. Please install])
167     AC_MSG_RESULT([   * it, it is needed by jigdo-lite.])
168 fi
169 dnl ________________________________________
170
171 AC_MSG_CHECKING(for value of --enable-debug)
172 AC_ARG_ENABLE(debug,
173     [  --enable-debug          Compile in lots of additional debugging code],
174     jigdo_debug=$enableval, jigdo_debug=no)
175 AC_MSG_RESULT(\"$jigdo_debug\")
176 if test "$jigdo_debug" = "yes"; then
177     IF_DEBUG=""
178     IFNOT_DEBUG="#"
179     AC_DEFINE(DEBUG, 1)
180     if test "$ac_cv_prog_cc_g" = "yes"; then CFLAGS="$CFLAGS -g"; fi
181     if test "$ac_cv_prog_cxx_g" = "yes"; then CXXFLAGS="$CXXFLAGS -g"; fi
182 elif test "$jigdo_debug" != "no"; then
183     AC_MSG_ERROR(Invalid argument to --enable-debug option)
184 else
185     IF_DEBUG="#"
186     IFNOT_DEBUG=""
187     AC_DEFINE(DEBUG, 0)
188 fi
189 AC_SUBST(IF_DEBUG)
190 AC_SUBST(IFNOT_DEBUG)
191
192 AC_MSG_CHECKING(for value of --with-pkg-config-prefix)
193 AC_ARG_WITH(pkg-config-prefix,
194 [  --with-pkg-config-prefix=PATH  When cross-compiling, specify prefix of
195                           libraries/headers for target architecture [none]],
196     jigdo_pkg_config_prefix="$withval", jigdo_pkg_config_prefix="")
197 if test "$jigdo_pkg_config_prefix" = ""; then
198     AC_MSG_RESULT(not set)
199     jigdo_pkg_config_switch=""
200 else
201     AC_MSG_RESULT(\"$jigdo_pkg_config_prefix\")
202     if test "$GXX" = "yes"; then
203         CFLAGS="$CFLAGS -I$jigdo_pkg_config_prefix/include -L$jigdo_pkg_config_prefix/lib"
204         CXXFLAGS="$CXXFLAGS -I$jigdo_pkg_config_prefix/include -L$jigdo_pkg_config_prefix/lib"
205         CPPFLAGS="$CPPFLAGS -I$jigdo_pkg_config_prefix/include"
206         LDFLAGS="$LDFLAGS -L$jigdo_pkg_config_prefix/lib"
207     fi
208     export PKG_CONFIG_PATH="$jigdo_pkg_config_prefix/lib/pkgconfig"
209     jigdo_pkg_config_prefix="--define-variable=prefix=$jigdo_pkg_config_prefix"
210 fi
211
212 if test "$is_windows" = yes; then
213     CXXFLAGS="$CXXFLAGS -static"
214     LDFLAGS="$LDFLAGS -static"
215 fi
216
217 dnl dnl cppunit
218 dnl CPPUNITCFLAGS='# `cppunit-config --cflags`'
219 dnl CPPUNITLIBS='# `cppunit-config --libs`'
220 dnl IF_CPPUNIT="#"
221 dnl AC_CHECK_PROG(have_cppunit_config, cppunit-config, yes, no)
222 dnl if test "$have_cppunit_config" = "yes"; then
223 dnl     CPPUNITCFLAGS="`cppunit-config --cflags`"
224 dnl     CPPUNITLIBS="`cppunit-config --libs`"
225 dnl     ORIG_LIBS="$LIBS"
226 dnl     LIBS="$LIBS $CPPUNITCFLAGS $CPPUNITLIBS"
227 dnl     AC_CACHE_CHECK([whether cppunit works],
228 dnl                    jigdo_cv_prog_cppunit,
229 dnl         AC_TRY_LINK(
230 dnl             [ #include <cppunit/extensions/TestFactoryRegistry.h>
231 dnl               #include <cppunit/ui/text/TestRunner.h>
232 dnl               #include <cppunit/CompilerOutputter.h>
233 dnl               using namespace CppUnit; ],
234 dnl             [ TextUi::TestRunner runner;
235 dnl               TestFactoryRegistry& registry =
236 dnl                   TestFactoryRegistry::getRegistry();
237 dnl               runner.addTest(registry.makeTest());
238 dnl               runner.run("", false); ],
239 dnl             jigdo_cv_prog_cppunit="yes", jigdo_cv_prog_cppunit="no"
240 dnl         )
241 dnl     )
242 dnl     LIBS="$ORIG_LIBS"
243 dnl     if test "$jigdo_cv_prog_cppunit" = "yes"; then
244 dnl         IF_CPPUNIT=""
245 dnl     else
246 dnl         AC_MSG_RESULT([   * cppunit does not work - disabled.])
247 dnl     fi
248 dnl elif test "$jigdo_debug" = "yes"; then
249 dnl     AC_MSG_RESULT([   * cppunit was not found on your system. Please])
250 dnl     AC_MSG_RESULT([   * install it if you want to run the unit tests.])
251 dnl fi
252 dnl AC_SUBST(IF_CPPUNIT)
253 dnl AC_SUBST(CPPUNITCFLAGS)
254 dnl AC_SUBST(CPPUNITLIBS)
255 dnl ______________________________________________________________________
256
257 dnl Checks for header files.
258 AC_HEADER_STDC
259 AC_CHECK_HEADERS(stddef.h unistd.h limits.h string.h)
260
261 dnl Checks for libraries and accompanying header files
262
263 AC_CHECK_LIB(z, zlibVersion, have_zlib="-lz", have_zlib="no")
264 if test "$is_windows" = yes; then
265     AC_CHECK_LIB(zdll, zlibVersion, have_zlib="-lzdll", )
266 fi
267 AC_CHECK_HEADER(zlib.h, have_zlib_h="yes", have_zlib_h="no")
268 if test "$have_zlib" = "no" -o "$have_zlib_h" = "no"; then
269     AC_MSG_RESULT([   * Please install zlib, it is needed by all of the])
270     AC_MSG_RESULT([   * programs.])
271     installDevel "zlib1g" "zlib"
272 fi
273 if test "$have_zlib" != "no"; then LIBS="$have_zlib $LIBS"; fi
274
275
276 AC_CHECK_LIB(bz2, BZ2_bzCompressInit, have_bzlib="-lbz2", have_bzlib="no")
277 if test "$is_windows" = yes; then
278     dnl For some reason, can't check for BZ2_bzCompressInit without #include <bzlib.h>
279     AC_CHECK_LIB(bz2, main, have_bzlib="-lbz2", )
280 fi
281 AC_CHECK_HEADER(bzlib.h, have_bzlib_h="yes", have_bzlib_h="no")
282 if test "$have_bzlib" = "no" -o "$have_bzlib_h" = "no"; then
283     AC_MSG_RESULT([   * Please install libbz2, it is needed by all of the])
284     AC_MSG_RESULT([   * programs.])
285     installDevel "libbz2" "libbz2"
286 fi
287 if test "$have_bzlib" != "no"; then LIBS="$have_bzlib $LIBS"; fi
288
289
290 AC_MSG_CHECKING(for value of --with-libdb)
291 AC_ARG_WITH(libdb,
292     [  --without-libdb         Don't use libdb (it's necessary for jigdo-file's cache)], #'
293     jigdo_libdb="$withval", jigdo_libdb="yes")
294 AC_MSG_RESULT(\"$jigdo_libdb\")
295 if test "$jigdo_libdb" = "yes"; then
296     AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no")
297     AC_MSG_CHECKING(for libdb version in db.h)
298     printf "#include <db.h>\nDB_VERSION_MAJOR DB_VERSION_MINOR\n" >conftest.c
299     set x `eval $ac_cpp conftest.c | egrep '^ *[[0-9]] *'`; v="$2"; vv="$3"
300     AC_MSG_RESULT($v.$vv)
301     if test "$v" -ne 3 -a "$v" -ne 4; then
302         AC_MSG_RESULT([   * Warning: jigdo is only known to work with libdb])
303         AC_MSG_RESULT([   * version 3 or 4 - maybe you should up/downgrade.])
304         installDevel "libdb4.2" "libdb4"
305     fi
306     for db in "db-$v.$vv" "db$v.$vv" "db-$v" "db$v" "db"; do
307 #       Doesn't work: db.h does a "#define db_create db_create_4002"
308 #       AC_CHECK_LIB($db, db_create, have_libdb="$db", have_libdb="no")
309         AC_MSG_CHECKING(for db_create in lib$db)
310         oldLIBS="$LIBS"
311         LIBS="$LIBS -l$db"
312         AC_TRY_LINK([#include <db.h>], db_create(0, 0, 0),
313                      have_libdb="yes", have_libdb="no")
314         AC_MSG_RESULT($have_libdb)
315         if test "$have_libdb" != "no"; then break; fi
316         LIBS="$oldLIBS"
317     done
318     if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then
319         AC_MSG_RESULT([   * libdb not found - either install it, or use])
320         AC_MSG_RESULT([   * \`configure --without-libdb' to disable the db])
321         AC_MSG_RESULT([   * file cache of jigdo-file. If this check should not])
322         AC_MSG_RESULT([   * have failed, force e.g. -ldb to be used with])
323         AC_MSG_RESULT([   * \`configure --with-libdb=-ldb'])
324         installDevel "libdb4" "libdb4"
325         AC_MSG_ERROR(libdb not found.)
326     fi
327     AC_DEFINE(HAVE_LIBDB, 1) dnl make compilation fail if libdb not there
328 elif test "$jigdo_libdb" != "no" -a "$jigdo_libdb" != "NO"; then
329     dnl Pass argument (e.g. "-ldb") to compiler
330     LIBS="$jigdo_libdb $LIBS"
331     AC_DEFINE(HAVE_LIBDB, 1)
332 else
333     AC_DEFINE(HAVE_LIBDB, 0)
334 fi
335 dnl ________________________________________
336
337 AC_MSG_CHECKING(for value of --with-gui)
338 AC_ARG_WITH(gui,
339     [  --with-gui              Build the jigdo GTK+ GUI application [auto]],
340     jigdo_gui="$withval", jigdo_gui="no")
341 AC_MSG_RESULT(\"$jigdo_gui\")
342 dnl ____________________
343
344 if test "$jigdo_gui" = "auto"; then
345     jigdo_gui="yes"
346     jigdo_gui_failed() {
347     AC_MSG_RESULT([   * Disabling the build of the jigdo GUI application.])
348     AC_MSG_RESULT([   * Use --with-gui=yes to force an attempt to build it.])
349     jigdo_gui="no"
350     }
351 else
352     jigdo_gui_failed() { return; }
353 fi
354
355 if test "$jigdo_gui" = "yes"; then
356     AC_CHECK_PROG(PKGCONFIG, pkg-config, yes, no)
357     if test "$PKGCONFIG" = "no"; then
358         AC_MSG_RESULT([   * GTK+ not installed, or pkg-config not in])
359         AC_MSG_RESULT([   * \$PATH. Please install GTK+ 2.])
360         installDevel "libgtk2.0" "libgtk2.0"
361         jigdo_gui_failed
362     fi
363 fi
364 GTKCFLAGS="# GUI application disabled by configure script"
365 GTKLIBS="$GTKCFLAGS"
366 GLIBLIBS="$GTKCFLAGS"
367 dnl LIBWWWCFLAGS="$GTKCFLAGS"
368 dnl LIBWWWLIBS="$GTKCFLAGS"
369 CURLCFLAGS="$GTKCFLAGS"
370 CURLLIBS="$GTKCFLAGS"
371 dnl The following adds flags for GTK+ and glib
372 if test "$jigdo_gui" = "yes"; then
373     AC_MSG_CHECKING(for GTK+ 2.4.0 or later)
374     gtk_ver="`pkg-config $jigdo_pkg_config_prefix gtk+-2.0 --modversion`"
375     AC_MSG_RESULT($gtk_ver)
376     if pkg-config gtk+-2.0 --atleast-version=2.4.0; then true; else
377         AC_MSG_RESULT([   * Installed version of GTK+ is too old])
378         jigdo_gui_failed
379     fi
380     if test "$is_windows" = yes; then gth="gthread-2.0"; else gth=""; fi
381 dnl gth="gthread-2.0"
382     GTKCFLAGS="`pkg-config $jigdo_pkg_config_prefix gtk+-2.0 $gth --cflags 2>/dev/null`"
383     GTKLIBS="`pkg-config $jigdo_pkg_config_prefix gtk+-2.0 $gth --libs 2>/dev/null`"
384     GLIBLIBS="`pkg-config $jigdo_pkg_config_prefix glib-2.0 $gth --libs 2>/dev/null`"
385 fi
386 dnl ____________________
387
388 AC_MSG_CHECKING(for value of --with-libcurl)
389 AC_ARG_WITH(libcurl,
390     [  --with-libcurl=-lcurl   Use given -l switch instead of trying to
391                           determine the right one],
392     jigdo_libcurl="$withval", jigdo_libcurl="auto")
393 AC_MSG_RESULT(\"$jigdo_libcurl\")
394 if test "$jigdo_libcurl" = "auto" \
395     || test "$jigdo_libcurl" = "yes" \
396     || test "$jigdo_libcurl" = "no"; then
397     jigdo_libcurl=""
398 fi
399
400 dnl The following adds flags for libcurl
401 if test "$jigdo_gui" = "yes"; then
402   if test "$is_windows" = "no"; then
403     AC_MSG_CHECKING(for libcurl 7.11.0 or later)
404     set x `curl-config --version 2>&1`
405     shift
406     case "$1" in [[0-9]*]) ;; *) shift;; esac
407     jigdo_curlver="$1"
408     AC_MSG_RESULT($jigdo_curlver)
409     case "$jigdo_curlver" in
410         [[1-9][0-9].*|[8-9].*|7.1[1-9]*|7.[2-9][0-9]*])
411             CURLCFLAGS="`curl-config --cflags 2>/dev/null`"
412             CURLLIBS="`curl-config --libs 2>/dev/null`"
413             if test -n "$jigdo_libcurl"; then CURLLIBS="$jigdo_libcurl"; fi
414             ;;
415         *)
416         AC_MSG_RESULT([   * libcurl not installed, or the installed version])
417         AC_MSG_RESULT([   * is too old, or curl-config is not in \$PATH.])
418         AC_MSG_RESULT([   * Please install libcurl 7.11.0 or later, it is])
419         AC_MSG_RESULT([   * needed by the jigdo GUI application.])
420         installDevel "libcurl2" "libcurl2"
421     esac
422   else
423     dnl On Windows, no curl-config is supplied
424     if test -n "$jigdo_libcurl"; then
425         have_libcurl="$jigdo_libcurl"
426     else
427         dnl Just -lcurl will attempt static linking. You will need to specify
428         dnl "make X=-DCURL_STATICLIB" for this to work
429         dnl Will try SSL/non-SSL curl
430         AC_CHECK_LIB(curl, curl_global_init, have_libcurl="-lcurl", have_libcurl="no", -lwinmm -lws2_32)
431         AC_CHECK_LIB(curl , curl_global_init, have_libcurl="-lcurl", , -lcurl -lssl -lcrypto -lwinmm -lws2_32)
432         dnl This will pick up DLLs to link against
433         AC_CHECK_LIB(libcurl, curl_global_init, have_libcurl="-llibcurl",)
434         AC_CHECK_LIB(curldll, curl_global_init, have_libcurl="-lcurldll",)
435     fi
436     AC_CHECK_HEADER(curl/curl.h, have_curl_h="yes", have_curl_h="no")
437     if test "$have_libcurl" = "no" -o "$have_curl_h" = "no"; then
438         AC_MSG_RESULT([   * Please install libcurl 7.11.0 or later, it is])
439         AC_MSG_RESULT([   * needed by the jigdo GUI application.])
440     else
441         CURLCFLAGS=""
442         CURLLIBS="$have_libcurl"
443     fi
444   fi
445 fi
446
447 if test "$jigdo_gui" = "yes"; then IF_GUI=""; else IF_GUI="#"; fi
448 AC_SUBST(IF_GUI)
449 AC_SUBST(GTKCFLAGS)
450 AC_SUBST(GTKLIBS)
451 AC_SUBST(GLIBLIBS)
452 dnl AC_SUBST(LIBWWWCFLAGS)
453 dnl AC_SUBST(LIBWWWLIBS)
454 AC_SUBST(CURLCFLAGS)
455 AC_SUBST(CURLLIBS)
456 dnl ____________________
457
458 if test "$jigdo_gui" = "yes" && test ! -e "$srcdir/src/gtk/interface.hh"; then
459   AC_CHECK_PROG(have_glade, glade-2, yes, no)
460   if test "$have_glade" = "no"; then
461     AC_MSG_RESULT([   * glade-2 was not found on your system. Please install])
462     AC_MSG_RESULT([   * it, it is needed to compile the jigdo GUI (actually,])
463     AC_MSG_RESULT([   * to create the file src/gtk/interface.hh)])
464   fi
465 fi
466 dnl ____________________
467
468 AC_MSG_CHECKING(for value of --with-uint64)
469 AC_ARG_WITH(uint64,
470     [  --with-uint64=TYPE      Specify unsigned type of at least 64 bits [auto]
471                           (Replace spaces with underscores in TYPE)],
472     jigdo_uint64="$withval", jigdo_uint64="auto")
473 AC_MSG_RESULT(\"$jigdo_uint64\")
474
475 AC_CACHE_CHECK(for unsigned long long, jigdo_cv_have_ulonglong,
476     AC_TRY_COMPILE(, unsigned long long x = 0,
477                    jigdo_cv_have_ulonglong=yes, jigdo_cv_have_ulonglong=no))
478 if test "$jigdo_cv_have_ulonglong" = "yes"; then
479     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1)
480 else
481     AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 0)
482 fi
483
484 if test "$jigdo_uint64" = auto; then
485     AC_CHECK_SIZEOF(unsigned long, 0)
486     AC_CHECK_SIZEOF(unsigned long long, 0)
487     if test "$ac_cv_sizeof_unsigned_long" -ge 8; then
488         jigdo_uint64='unsigned long'
489     elif test "$ac_cv_sizeof_unsigned_long_long" -ge 8; then
490         jigdo_uint64='unsigned long long'
491     else
492         #if test "$jigdo_cv_have_ulonglong" = "yes"; then
493             jigdo_uint64='unsigned long long'
494         #else
495         #    jigdo_uint64='unsigned long'
496         #fi
497         AC_MSG_RESULT([   * Could not find an unsigned type with at least 64])
498         AC_MSG_RESULT([   * bits (or maybe char has >8 bits?) - defaulting to])
499         AC_MSG_RESULT([   * \`$jigdo_uint64'. You may want to override])
500         AC_MSG_RESULT([   * this using --with-uint64=TYPE])
501     fi
502 elif test "$jigdo_uint64" = yes -o "$jigdo_uint64" = no; then
503     AC_MSG_ERROR(Invalid argument to --with-uint64 option)
504 else
505     jigdo_uint64=`echo $jigdo_uint64 | sed -e 's/_/ /g'`
506 fi
507 AC_MSG_CHECKING(for 64 bit unsigned integer type)
508 AC_MSG_RESULT($jigdo_uint64)
509 AC_DEFINE_UNQUOTED(TYPE_UINT64, $jigdo_uint64)
510
511 AC_CACHE_CHECK(for operator<<(uint64),
512                jigdo_cv_prog_cxx_outuint64,
513     AC_TRY_COMPILE(
514     [ #include <iostream>
515       namespace std { }
516       using namespace std; ],
517     [ $jigdo_uint64 x;
518       cout << x << endl; ],
519     jigdo_cv_prog_cxx_outuint64="yes", jigdo_cv_prog_cxx_outuint64="no")
520 )
521 if test "$jigdo_cv_prog_cxx_outuint64" = "yes"; then
522     AC_DEFINE(HAVE_OUTUINT64, 1)
523 else
524     AC_DEFINE(HAVE_OUTUINT64, 0)
525 fi
526
527 AC_CACHE_CHECK([for string::compare(size_t,size_t,string,size_t,size_t)],
528                jigdo_cv_prog_cxx_stringcmp,
529     AC_TRY_COMPILE(
530     [ #include <string>
531       namespace std { }
532       using namespace std; ],
533     [ string s, t;
534       s.compare(0, std::string::npos, t, 0, std::string::npos); ],
535     jigdo_cv_prog_cxx_stringcmp="yes", jigdo_cv_prog_cxx_stringcmp="no")
536 )
537 if test "$jigdo_cv_prog_cxx_stringcmp" = "yes"; then
538     AC_DEFINE(HAVE_STRINGCMP, 1)
539 else
540     AC_DEFINE(HAVE_STRINGCMP, 0)
541 fi
542 AC_CACHE_CHECK([for string::compare(size_t,size_t,const char*,size_t)],
543                jigdo_cv_prog_cxx_stringstrcmp,
544     AC_TRY_COMPILE(
545     [ #include <string>
546       namespace std { }
547       using namespace std; ],
548     [ string s; const char* t = "x";
549       s.compare(0, std::string::npos, t, 1); ],
550     jigdo_cv_prog_cxx_stringstrcmp="yes", jigdo_cv_prog_cxx_stringstrcmp="no")
551 )
552 if test "$jigdo_cv_prog_cxx_stringstrcmp" = "yes"; then
553     AC_DEFINE(HAVE_STRINGSTRCMP, 1)
554 else
555     AC_DEFINE(HAVE_STRINGSTRCMP, 0)
556 fi
557 dnl ____________________
558
559 dnl Checks for library functions.
560 AC_CHECK_FUNCS(lstat truncate ftruncate mmap memcpy fileno snprintf \
561                _snprintf setenv)
562
563 dnl Check whether reading width of TTY via ioctl() works
564 AC_CACHE_CHECK([for TIOCGWINSZ ioctl],
565                jigdo_cv_ioctl_winsz,
566     AC_TRY_COMPILE(
567         [ #include <termio.h>
568           #include <unistd.h>
569           #include <stdio.h>
570           #include <sys/ioctl.h>],
571         [ struct winsize w; int i;
572           ioctl(fileno(stdout), TIOCGWINSZ, &w);
573           i = w.ws_col; ],
574         jigdo_cv_ioctl_winsz="yes", jigdo_cv_ioctl_winsz="no")
575 )
576 if test "$jigdo_cv_ioctl_winsz" = "yes"; then
577     AC_DEFINE(HAVE_IOCTL_WINSZ, 1)
578 elif test "$is_windows" = "no"; then
579     AC_MSG_RESULT([   * jigdo-file progress reports will not be formatted])
580     AC_MSG_RESULT([   * nicely, because no way has been found to determine])
581     AC_MSG_RESULT([   * the screen width in characters.])
582     AC_DEFINE(HAVE_IOCTL_WINSZ, 0)
583 else
584     AC_DEFINE(HAVE_IOCTL_WINSZ, 0)
585 fi
586
587 dnl Check whether getopt_long is present
588 AC_CACHE_CHECK([for getopt_long in <getopt.h>],
589                jigdo_cv_func_getopt_long,
590     AC_TRY_LINK(
591         [ #include <getopt.h> ],
592         [[ static const struct option longopts[] = { { 0, 0, 0, 0 } };
593           int c = getopt_long(0, 0, "", longopts, 0); ]],
594         jigdo_cv_func_getopt_long="yes", jigdo_cv_func_getopt_long="no"
595     )
596 )
597 if test "$jigdo_cv_func_getopt_long" = "yes"; then
598     AC_DEFINE(HAVE_GETOPT_LONG, 1)
599 else
600     AC_DEFINE(HAVE_GETOPT_LONG, 0)
601 fi
602
603 dnl Check whether uname() is present
604 AC_CACHE_CHECK([for uname in <sys/utsname.h>],
605                jigdo_cv_func_uname,
606     AC_TRY_LINK(
607         [ #include <sys/utsname.h> ],
608         [ struct utsname ubuf; uname(&ubuf); ],
609         jigdo_cv_func_uname="yes", jigdo_cv_func_uname="no"
610     )
611 )
612 if test "$jigdo_cv_func_uname" = "yes"; then
613     AC_DEFINE(HAVE_UNAME, 1)
614 else
615     AC_DEFINE(HAVE_UNAME, 0)
616 fi
617
618 dnl On native Windows (MinGW32), there is no snprintf, just _snprintf
619 if test "$ac_cv_func_snprintf" = no -a "$ac_cv_func__snprintf" = "yes"; then
620     AC_DEFINE(snprintf, _snprintf)
621 fi
622 dnl On native Windows, must use _stati64 for big file support
623 AC_CACHE_CHECK(for _stati64, jigdo_cv_func__stati64,
624     AC_TRY_COMPILE([ #include <sys/types.h>
625                      #include <sys/stat.h>],
626                    [ struct __stati64 buf;
627                      int x = _stati64("file", &buf);],
628                    jigdo_cv_func__stati64=yes, jigdo_cv_func__stati64=no))
629 if test "$is_windows" = "yes" -a "$ac_cv_func__stati64" = "yes"; then
630     AC_DEFINE(stat, _stati64)
631 fi
632 dnl ______________________________________________________________________
633
634 dnl Check for Native Language Support (gettext)
635 AC_MSG_CHECKING(for value of --enable-nls)
636 AC_ARG_ENABLE(nls,
637     [  --disable-nls           Disable multi-language support],
638     USE_NLS=$enableval, USE_NLS=yes)
639 AC_MSG_RESULT(\"$USE_NLS\")
640 AC_SUBST(USE_NLS)
641 CATALOGS=""
642 if test "$USE_NLS" = "yes"; then
643     oldLIBS="$LIBS"
644     AC_MSG_CHECKING(for dgettext in <libintl.h> and libc)
645     AC_TRY_LINK([#include <libintl.h>], dgettext(0, 0),
646                 have_intl="yes", have_intl="no");
647     AC_MSG_RESULT($have_intl)
648     if test "$have_intl" = "no"; then
649         LIBS="$LIBS -lintl";
650         AC_MSG_CHECKING(for dgettext in <libintl.h> and -lintl)
651         AC_TRY_LINK([#include <libintl.h>], dgettext(0, 0),
652                     have_intl="yes", have_intl="no");
653         AC_MSG_RESULT($have_intl)
654     fi
655     if test "$have_intl" = "no"; then
656         AC_MSG_RESULT([   * Disabling gettext support - jigdo will not be])
657         AC_MSG_RESULT([   * able to display translated status/error])
658         AC_MSG_RESULT([   * messages instead of the default English ones.])
659         USE_NLS="no"
660         LIBS="$oldLIBS"
661     fi
662 fi
663 if test "$USE_NLS" = "yes"; then
664     AC_DEFINE(ENABLE_NLS, 1)
665
666     AC_MSG_CHECKING(for catalogs to be installed)
667     ALL_LINGUAS=`(cd "$srcdir/po" && echo *.po *.pox "") \
668         | sed -e "s/\**\.pox* / /g"`
669     if test "$LINGUAS"; then
670         NEW_LINGUAS=""
671         for provided in $ALL_LINGUAS; do
672             x=""
673             for wanted in $LINGUAS; do
674                 case "$provided" in "$wanted"*) x=" $provided";; esac
675                 case "$wanted" in "$provided"*) x=" $provided";; esac
676             done
677             NEW_LINGUAS="$NEW_LINGUAS$x"
678         done
679         LINGUAS="$NEW_LINGUAS"
680         AC_MSG_RESULT(LINGUAS:$LINGUAS)
681     else
682         LINGUAS="$ALL_LINGUAS"
683         AC_MSG_RESULT($LINGUAS)
684     fi
685     for x in $LINGUAS; do CATALOGS="$CATALOGS $x.gmo"; done
686 else
687     AC_DEFINE(ENABLE_NLS, 0)
688 fi
689 AC_SUBST(CATALOGS)
690 dnl ______________________________________________________________________
691
692 dnl Checks for other --enable-xxx, --with-xxx switches
693
694 dnl AC_MSG_CHECKING(for value of --enable-libwww-hacks)
695 dnl AC_ARG_ENABLE(libwww-hacks,
696 dnl     [  --disable-libwww-hacks  Don't compile fixed versions of some libwww
697 dnl                           code (Try this if you see link errors/crashes)],
698 dnl     jigdo_libwww_hacks=$enableval, jigdo_libwww_hacks=yes)
699 dnl AC_MSG_RESULT(\"$jigdo_libwww_hacks\")
700 dnl if test "$jigdo_libwww_hacks" = yes; then
701 dnl     IF_LIBWWW_HACKS="" # enable hacks
702 dnl elif test "$jigdo_libwww_hacks" != no; then
703 dnl     AC_MSG_ERROR(Invalid argument to --enable-libwww-hacks option)
704 dnl else
705 dnl     IF_LIBWWW_HACKS="#" # disable hacks, by commenting out Makefile line
706 dnl fi
707 dnl AC_SUBST(IF_LIBWWW_HACKS)
708 dnl ______________________________________________________________________
709
710 dnl Do this at end in order not to influence other compile tests which
711 dnl might return warnings. Turning the warnings into errors would make
712 dnl the tests fail.
713 dnl if test "$jigdo_debug" = "yes"; then
714 dnl     #if test "$GCC" = yes; then CFLAGS="$CFLAGS -Werror"; fi
715 dnl     if test "$GXX" = yes; then CXXFLAGS="$CXXFLAGS -Werror"; fi
716 dnl fi
717 if test "$GXX" = "yes"; then
718     CFLAGS="-Wall $CFLAGS -W"
719     CXXFLAGS="$CXXFLAGS -Wall -W -Wpointer-arith -Wconversion -Woverloaded-virtual"
720 fi
721 dnl ______________________________________________________________________
722
723 if test "$cross_compiling" = yes; then
724   IF_CROSSCOMPILING=""
725   IFNOT_CROSSCOMPILING="#"
726 else
727   IF_CROSSCOMPILING="#"
728   IFNOT_CROSSCOMPILING=""
729 fi
730 AC_SUBST(IF_CROSSCOMPILING)
731 AC_SUBST(IFNOT_CROSSCOMPILING)
732 dnl ______________________________________________________________________
733
734 dnl Touch TAGS to prevent it from being recreated when a normal user
735 dnl builds the program. TAGS should only be updated once changes are
736 dnl made to the source.
737 touch "$srcdir/src/TAGS"
738
739 SUBDIRS="glibcurl gtk job net util"
740 SRC_MAKEDEPS="$srcdir/src/Makedeps"
741 dnl When bootstrapping from CVS, we need to make sure that correct
742 dnl dependencies cause gtk/interface.hh to be created
743 if test -e "$SRC_MAKEDEPS"; then true; else
744   AC_MSG_RESULT(Creating $SRC_MAKEDEPS)
745   touch "$SRC_MAKEDEPS"
746   echo >"$srcdir/src/gtk/interface.hh"
747   (cd "$srcdir/src"
748    find . -type f '(' -name '*.cc' -o -name '*.c' ')' \
749    | xargs "$ac_cv_prog_AWK" -f ../scripts/depend.awk "$srcdir" $SUBDIRS -
750   )
751   rm -f "$SRC_MAKEDEPS.bak" "$srcdir/src/gtk/interface.hh"
752 fi
753 AC_SUBST_FILE(SRC_MAKEDEPS)
754
755 dnl Create subdirs in src directory
756 for dir in "" $SUBDIRS; do
757     test ! -d "src/$dir" && mkdir "src/$dir"
758 done
759 AC_OUTPUT(Makefile doc/Makefile src/Makefile po/Makefile)