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 ______________________________________________________________________
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 ______________________________________________________________________
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.
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")
45 CFLAGS=`echo "$CFLAGS" | sed 's/\(^\| \)-g\( \|$\)/ /'`
46 CXXFLAGS=`echo "$CXXFLAGS" | sed 's/\(^\| \)-g\( \|$\)/ /'`
49 if test "$GXX" = yes; then
50 AC_MSG_CHECKING(for GCC version)
51 gccver=`$CXX -dumpversion`
52 AC_MSG_RESULT($gccver);
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)])
68 dnl ____________________
70 dnl Checks for typedefs, structures, and compiler characteristics.
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__
78 #endif], is_windows=yes, is_windows=no)
79 AC_MSG_RESULT($is_windows)
80 if test "$is_windows" = yes; then
95 if test "$is_windows" = "yes"; then
96 if test "$ac_cv_prog_cc_g" = "yes"; then
97 CFLAGS="$CFLAGS -mms-bitfields -march=pentium"
99 if test "$ac_cv_prog_cxx_g" = "yes"; then
100 CXXFLAGS="$CXXFLAGS -mms-bitfields -march=pentium"
103 dnl ____________________
105 AC_CACHE_CHECK(whether the C++ compiler is recent enough,
106 jigdo_cv_prog_cxx_recent,
111 template<typename T = double> struct X {
112 template<class U> void function(T* t, U* u);
114 template<> struct X<void> { void function(void* t, int* u); };
116 void B::X<void>::function(void*, int*) { }
117 },, jigdo_cv_prog_cxx_recent="yes", jigdo_cv_prog_cxx_recent="no")
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.])
126 dnl ________________________________________
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,
132 #if defined(__GNUC__) && __GNUC__ < 3
133 # define debug(_args...) do { } while (false)
135 # define debug(...) do { } while (false)
138 int debug = 0; // No substitution!
142 },, jigdo_cv_prog_cxx_varmacro="yes", jigdo_cv_prog_cxx_varmacro="no")
144 if test "$jigdo_cv_prog_cxx_varmacro" = "yes"; then
145 AC_DEFINE(HAVE_VARMACRO, 1)
147 AC_DEFINE(HAVE_VARMACRO, 0)
149 dnl ________________________________________
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")
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.])
162 dnl ________________________________________
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.])
169 dnl ________________________________________
171 AC_MSG_CHECKING(for value of --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
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)
190 AC_SUBST(IFNOT_DEBUG)
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=""
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"
208 export PKG_CONFIG_PATH="$jigdo_pkg_config_prefix/lib/pkgconfig"
209 jigdo_pkg_config_prefix="--define-variable=prefix=$jigdo_pkg_config_prefix"
212 if test "$is_windows" = yes; then
213 CXXFLAGS="$CXXFLAGS -static"
214 LDFLAGS="$LDFLAGS -static"
218 dnl CPPUNITCFLAGS='# `cppunit-config --cflags`'
219 dnl CPPUNITLIBS='# `cppunit-config --libs`'
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,
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"
242 dnl LIBS="$ORIG_LIBS"
243 dnl if test "$jigdo_cv_prog_cppunit" = "yes"; then
246 dnl AC_MSG_RESULT([ * cppunit does not work - disabled.])
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.])
252 dnl AC_SUBST(IF_CPPUNIT)
253 dnl AC_SUBST(CPPUNITCFLAGS)
254 dnl AC_SUBST(CPPUNITLIBS)
255 dnl ______________________________________________________________________
257 dnl Checks for header files.
259 AC_CHECK_HEADERS(stddef.h unistd.h limits.h string.h)
261 dnl Checks for libraries and accompanying header files
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", )
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"
273 if test "$have_zlib" != "no"; then LIBS="$have_zlib $LIBS"; fi
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", )
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"
287 if test "$have_bzlib" != "no"; then LIBS="$have_bzlib $LIBS"; fi
290 AC_MSG_CHECKING(for value of --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"
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)
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
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.)
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)
333 AC_DEFINE(HAVE_LIBDB, 0)
335 dnl ________________________________________
337 AC_MSG_CHECKING(for value of --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 ____________________
344 if test "$jigdo_gui" = "auto"; then
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.])
352 jigdo_gui_failed() { return; }
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"
364 GTKCFLAGS="# GUI application disabled by configure script"
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])
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`"
386 dnl ____________________
388 AC_MSG_CHECKING(for value of --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
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`
406 case "$1" in [[0-9]*]) ;; *) shift;; esac
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
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"
423 dnl On Windows, no curl-config is supplied
424 if test -n "$jigdo_libcurl"; then
425 have_libcurl="$jigdo_libcurl"
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",)
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.])
442 CURLLIBS="$have_libcurl"
447 if test "$jigdo_gui" = "yes"; then IF_GUI=""; else IF_GUI="#"; fi
452 dnl AC_SUBST(LIBWWWCFLAGS)
453 dnl AC_SUBST(LIBWWWLIBS)
456 dnl ____________________
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)])
466 dnl ____________________
468 AC_MSG_CHECKING(for value of --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\")
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)
481 AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 0)
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'
492 #if test "$jigdo_cv_have_ulonglong" = "yes"; then
493 jigdo_uint64='unsigned long long'
495 # jigdo_uint64='unsigned long'
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])
502 elif test "$jigdo_uint64" = yes -o "$jigdo_uint64" = no; then
503 AC_MSG_ERROR(Invalid argument to --with-uint64 option)
505 jigdo_uint64=`echo $jigdo_uint64 | sed -e 's/_/ /g'`
507 AC_MSG_CHECKING(for 64 bit unsigned integer type)
508 AC_MSG_RESULT($jigdo_uint64)
509 AC_DEFINE_UNQUOTED(TYPE_UINT64, $jigdo_uint64)
511 AC_CACHE_CHECK(for operator<<(uint64),
512 jigdo_cv_prog_cxx_outuint64,
514 [ #include <iostream>
516 using namespace std; ],
518 cout << x << endl; ],
519 jigdo_cv_prog_cxx_outuint64="yes", jigdo_cv_prog_cxx_outuint64="no")
521 if test "$jigdo_cv_prog_cxx_outuint64" = "yes"; then
522 AC_DEFINE(HAVE_OUTUINT64, 1)
524 AC_DEFINE(HAVE_OUTUINT64, 0)
527 AC_CACHE_CHECK([for string::compare(size_t,size_t,string,size_t,size_t)],
528 jigdo_cv_prog_cxx_stringcmp,
532 using namespace std; ],
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")
537 if test "$jigdo_cv_prog_cxx_stringcmp" = "yes"; then
538 AC_DEFINE(HAVE_STRINGCMP, 1)
540 AC_DEFINE(HAVE_STRINGCMP, 0)
542 AC_CACHE_CHECK([for string::compare(size_t,size_t,const char*,size_t)],
543 jigdo_cv_prog_cxx_stringstrcmp,
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")
552 if test "$jigdo_cv_prog_cxx_stringstrcmp" = "yes"; then
553 AC_DEFINE(HAVE_STRINGSTRCMP, 1)
555 AC_DEFINE(HAVE_STRINGSTRCMP, 0)
557 dnl ____________________
559 dnl Checks for library functions.
560 AC_CHECK_FUNCS(lstat truncate ftruncate mmap memcpy fileno snprintf \
563 dnl Check whether reading width of TTY via ioctl() works
564 AC_CACHE_CHECK([for TIOCGWINSZ ioctl],
565 jigdo_cv_ioctl_winsz,
567 [ #include <termio.h>
570 #include <sys/ioctl.h>],
571 [ struct winsize w; int i;
572 ioctl(fileno(stdout), TIOCGWINSZ, &w);
574 jigdo_cv_ioctl_winsz="yes", jigdo_cv_ioctl_winsz="no")
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)
584 AC_DEFINE(HAVE_IOCTL_WINSZ, 0)
587 dnl Check whether getopt_long is present
588 AC_CACHE_CHECK([for getopt_long in <getopt.h>],
589 jigdo_cv_func_getopt_long,
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"
597 if test "$jigdo_cv_func_getopt_long" = "yes"; then
598 AC_DEFINE(HAVE_GETOPT_LONG, 1)
600 AC_DEFINE(HAVE_GETOPT_LONG, 0)
603 dnl Check whether uname() is present
604 AC_CACHE_CHECK([for uname in <sys/utsname.h>],
607 [ #include <sys/utsname.h> ],
608 [ struct utsname ubuf; uname(&ubuf); ],
609 jigdo_cv_func_uname="yes", jigdo_cv_func_uname="no"
612 if test "$jigdo_cv_func_uname" = "yes"; then
613 AC_DEFINE(HAVE_UNAME, 1)
615 AC_DEFINE(HAVE_UNAME, 0)
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)
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)
632 dnl ______________________________________________________________________
634 dnl Check for Native Language Support (gettext)
635 AC_MSG_CHECKING(for value of --enable-nls)
637 [ --disable-nls Disable multi-language support],
638 USE_NLS=$enableval, USE_NLS=yes)
639 AC_MSG_RESULT(\"$USE_NLS\")
642 if test "$USE_NLS" = "yes"; then
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
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)
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.])
663 if test "$USE_NLS" = "yes"; then
664 AC_DEFINE(ENABLE_NLS, 1)
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
671 for provided in $ALL_LINGUAS; do
673 for wanted in $LINGUAS; do
674 case "$provided" in "$wanted"*) x=" $provided";; esac
675 case "$wanted" in "$provided"*) x=" $provided";; esac
677 NEW_LINGUAS="$NEW_LINGUAS$x"
679 LINGUAS="$NEW_LINGUAS"
680 AC_MSG_RESULT(LINGUAS:$LINGUAS)
682 LINGUAS="$ALL_LINGUAS"
683 AC_MSG_RESULT($LINGUAS)
685 for x in $LINGUAS; do CATALOGS="$CATALOGS $x.gmo"; done
687 AC_DEFINE(ENABLE_NLS, 0)
690 dnl ______________________________________________________________________
692 dnl Checks for other --enable-xxx, --with-xxx switches
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)
705 dnl IF_LIBWWW_HACKS="#" # disable hacks, by commenting out Makefile line
707 dnl AC_SUBST(IF_LIBWWW_HACKS)
708 dnl ______________________________________________________________________
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
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
717 if test "$GXX" = "yes"; then
718 CFLAGS="-Wall $CFLAGS -W"
719 CXXFLAGS="$CXXFLAGS -Wall -W -Wpointer-arith -Wconversion -Woverloaded-virtual"
721 dnl ______________________________________________________________________
723 if test "$cross_compiling" = yes; then
725 IFNOT_CROSSCOMPILING="#"
727 IF_CROSSCOMPILING="#"
728 IFNOT_CROSSCOMPILING=""
730 AC_SUBST(IF_CROSSCOMPILING)
731 AC_SUBST(IFNOT_CROSSCOMPILING)
732 dnl ______________________________________________________________________
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"
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"
748 find . -type f '(' -name '*.cc' -o -name '*.c' ')' \
749 | xargs "$ac_cv_prog_AWK" -f ../scripts/depend.awk "$srcdir" $SUBDIRS -
751 rm -f "$SRC_MAKEDEPS.bak" "$srcdir/src/gtk/interface.hh"
753 AC_SUBST_FILE(SRC_MAKEDEPS)
755 dnl Create subdirs in src directory
756 for dir in "" $SUBDIRS; do
757 test ! -d "src/$dir" && mkdir "src/$dir"
759 AC_OUTPUT(Makefile doc/Makefile src/Makefile po/Makefile)