Fixed new 'alloc_length' resizing code.
[captive.git] / configure.in
index 81c18d3..a12a314 100644 (file)
@@ -19,7 +19,7 @@
 AC_INIT(src/libcaptive/Makefile-libcaptive.am)
 dnl 2.53 for AM_GLIB_GNU_GETTEXT:
 AC_PREREQ(2.53)
-AM_INIT_AUTOMAKE(captive,0.9cvs)
+AM_INIT_AUTOMAKE(captive,1.0.2cvs)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 dnl Call AC_PROG_CC before AC_ISC_POSIX.
@@ -34,10 +34,15 @@ dnl Prevent "AC_TRY_COMPILE was called before AC_ISC_POSIX":
 AC_ISC_POSIX
 AC_SYS_LARGEFILE
 AM_PROG_AS
-AM_ENABLE_STATIC
-AM_DISABLE_SHARED
+AM_DISABLE_STATIC
+AM_ENABLE_SHARED
 AM_PROG_LIBTOOL
 
+dnl Workaround for autoconf-2.57:
+m4_pattern_allow([AC_MSG_WARN])
+m4_pattern_allow([AC_CHECK_LIB])
+m4_pattern_allow([AC_CHECK_HEADERS])
+
 dnl gettext localization.
 dnl Use simpler AM_GLIB_GNU_GETTEXT instead of AM_GNU_GETTEXT
 dnl as we depend on glib and glib requires system installed gettext anyway.
@@ -176,6 +181,14 @@ AH_BOTTOM([
 #include <glib/gtypes.h>       /* for 'gchar' */
 #define G_LOG_DOMAIN ((const gchar *)"Captive")
 
+/* Ensure we have proper -I options: */
+#if defined(CAPTIVE_USE_GNOME_VFS_MODULE) || defined(CAPTIVE_USE_GNOME_VFS)
+#ifndef HAVE_GNOME_VFS_READ_ENTIRE_FILE
+#include <libgnomevfs/gnome-vfs-result.h>
+GnomeVFSResult gnome_vfs_read_entire_file(const char *uri,int *file_size,char **file_contents);
+#endif
+#endif
+
 /* Supplemental definitions not possible in this file. */
 #ifdef LIBCAPTIVE
 #include "captive/config2.h"
@@ -184,7 +197,8 @@ AH_BOTTOM([
 #endif /* !_CAPTIVE_CONFIG_H */
 ])
 
-AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([Captive requires glib-2.0 library.])],[gmodule gobject])
+dnl Do not use PKG_CHECK_MODULES() as it would not set 'GLIB_GENMARSHAL' etc.
+AM_PATH_GLIB_2_0(,,[AC_MSG_ERROR([Captive requires glib-2.0 library.])],[gmodule gobject gthread])
 dnl Force glib for the whole package
 CFLAGS="$CFLAGS $GLIB_CFLAGS"
 LIBS="$LIBS $GLIB_LIBS"
@@ -253,9 +267,11 @@ AC_SUBST(READLINE_LIBS)
 AC_SUBST(READLINE_LDFLAGS)
 
 PKG_CHECK_MODULES(GNOME_VFS_MODULE,gnome-vfs-module-2.0)
+GNOME_VFS_MODULE_CFLAGS="$GNOME_VFS_MODULE_CFLAGS -DCAPTIVE_USE_GNOME_VFS_MODULE=1"
 AC_SUBST(GNOME_VFS_MODULE_CFLAGS)
 AC_SUBST(GNOME_VFS_MODULE_LIBS)
 PKG_CHECK_MODULES(GNOME_VFS,gnome-vfs-2.0)
+GNOME_VFS_CFLAGS="$GNOME_VFS_CFLAGS -DCAPTIVE_USE_GNOME_VFS=1"
 AC_SUBST(GNOME_VFS_CFLAGS)
 AC_SUBST(GNOME_VFS_LIBS)
 
@@ -292,6 +308,8 @@ AC_SUBST(OPENSSL_CFLAGS)
 AC_SUBST(OPENSSL_LIBS)
 
 # AC_ARG_ENABLE(lufs,[--enable-lufs=[no/yes/auto]],,enable_lufs=auto)
+have_lufs_includes=false
+PATH_LUFSMOUNT=""
 if test x$enable_lufs != no;then
        have_lufs_includes=true
        dnl If ACTION-IF-NOT-FOUND is given, it is executed when one of the header
@@ -312,16 +330,44 @@ if test x$enable_lufs != no;then
                        AC_MSG_WARN([Although LUFS include files were found they are too old. df(1) will not show available NTFS disk space.])
                fi
                ],[#include <lufs/proto.h>])
+       AC_PATH_PROGS(PATH_LUFSMOUNT,lufsmount)
+       if test x$PATH_LUFSMOUNT = x;then
+               if test x$enable_lufs = xyes;then
+                       AC_MSG_ERROR([LUFS client was requested (--enable-lufs) but no lufsmount(1) binary was found. Install 'lufs-*-*captive*' package.])
+               else
+                       AC_MSG_WARN([LUFS client not being compiled as no lufsmount(1) binary was found. Install 'lufs-*-*captive*' package.])
+               fi
+       fi
 fi
-AM_CONDITIONAL(ENABLE_LUFS,[ $have_lufs_includes && test x$enable_lufs != no ])
-
-dnl for $(top_srcdir)/src/libcaptive/sandbox/split-sandbox.c
-AM_PATH_LINC(,,[AC_MSG_ERROR([Captive requires linc library used by ORBit.])])
+AM_CONDITIONAL(ENABLE_LUFS,[ $have_lufs_includes && test x$PATH_LUFSMOUNT != x -a x$enable_lufs != no ])
+AC_SUBST(PATH_LUFSMOUNT)
 
 dnl for $(top_srcdir)/src/libcaptive/client/
 dnl Do not use '[client server]' as $4 to prevent: configure: test: too many arguments
 dnl  - currently this argument is not used by 'orbit2-config' in any way anyway
-AM_PATH_ORBIT2(,,[AC_MSG_ERROR([Captive requires ORBit library.])])
+dnl Do not use PKG_CHECK_MODULES() as it would not set 'ORBIT_IDL' etc.
+AM_PATH_ORBIT2(,,[AC_MSG_ERROR([Captive requires ORBit2 library.])])
+
+AC_ARG_WITH(orbit-line,[  --with-orbit-line=[link/linc/auto]   Use 'link' for ORBit2 >=2.7.x+ (def.=auto)],,with_orbit_line=auto)
+captive_save_CFLAGS="$CFLAGS"
+captive_save_LIBS="$LIBS"
+CFLAGS="$CFLAGS $ORBIT_CFLAGS"
+LIBS="$LIBS $ORBIT_LIBS"
+AC_CHECK_FUNC(link_get_tmpdir,[
+               AC_DEFINE(HAVE_ORBIT_LINK,,[ORBit2 is 2.7.x+ and therefore includes its own 'link' library])
+               found_orbit_line=link
+               ],
+       found_orbit_line=linc
+       )
+CFLAGS="$captive_save_CFLAGS"
+LIBS="$captive_save_LIBS"
+if test "x$with_orbit_line" != "xauto" -a "x$with_orbit_line" != "x$found_orbit_line";then
+       AC_MSG_ERROR([--with-orbit-line=$with_orbit_line specified but the detected line is $found_orbit_line])
+fi
+
+if test "x$found_orbit_line" = "xlinc";then
+       PKG_CHECK_MODULES(LINC,linc)
+fi
 
 # AC_ARG_ENABLE(install-pkg,[--enable-install-pkg=[no/yes/auto]],,enable_install_pkg=auto)
 GLADE_W_INIT([
@@ -333,25 +379,57 @@ GLADE_W_INIT([
        ],[$enable_install_pkg],[
                AC_CHECK_LIB(ntfs,ntfs_mount,[
                        LIBNTFS_LIBS="-lntfs"
-                       glade_addon=yes
-                       ])
+
+                       have_libntfs_includes=true
+                       AC_CHECK_HEADERS
+                       # '#include "config.h"' may be required by <ntfs/*> include files.
+                       test -r config.h || touch config.h
+                       captive_save_CPPFLAGS="$CPPFLAGS"
+                       CPPFLAGS="$CPPFLAGS -I."        # for "config.h" touched above
+                       AC_CHECK_HEADERS(ntfs/types.h ntfs/volume.h,,[ have_libntfs_includes=false ])
+                       CPPFLAGS="$captive_save_CPPFLAGS"
+                       if $have_libntfs_includes;then
+
+                               captive_save_CPPFLAGS="$CPPFLAGS"
+                               CPPFLAGS="$CPPFLAGS $LIBXML_CFLAGS"
+                               AC_CHECK_HEADERS(libxml/xmlreader.h,
+                                       [ glade_addon=yes ],
+                                       [ AC_MSG_WARN([Captive requires libxml >= 2.4.29 for --enable-install-pkg.]) ])
+                               CPPFLAGS="$captive_save_CPPFLAGS"
+
+                       else
+                               AC_MSG_WARN([Captive requires ntfs/* include files (of ntfsprogs-devel) for --enable-install-pkg.])
+                       fi
+                       ],[ AC_MSG_WARN([Captive requires libntfs (of ntfsprogs-devel) for --enable-install-pkg.]) ])
                ])
 AC_SUBST(GNOMEUI_CFLAGS)
 AC_SUBST(GNOMEUI_LIBS)
 AC_SUBST(LIBNTFS_LIBS)
-# Do not: AM_CONDITIONAL(HAVE_LIBNTFS,[ test -n "$LIBNTFS_LIBS" ])
-# as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
+dnl Do not: AM_CONDITIONAL(HAVE_LIBNTFS,[ test -n "$LIBNTFS_LIBS" ])
+dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
 AM_CONDITIONAL(HAVE_GLADE_WRITESOURCE,[ test "x$PATH_GLADE" != "x" ])
-# Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
-# as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
+dnl Do not: AM_CONDITIONAL(BUILD_GLADESRC,[ test "xyes" = "x$BUILD_GLADESRC" ])
+dnl as we do not need it as we are conditioned by ENABLE_INSTALL_PKG
 GNOME_ADDON_LIBS=""
 if test "x$BUILD_GLADESRC_TRUE" = "x"
 then
        AC_CHECK_LIB(Xi,XOpenDevice,GNOME_ADDON_LIBS="$GNOME_ADDON_LIBS -lXi")
 fi
 AC_SUBST(GNOME_ADDON_LIBS)
+dnl $BUILD_GLADESRC is already conditioned by $enable_install_pkg by GLADE_W_INIT()
 AM_CONDITIONAL(ENABLE_INSTALL_PKG,[ test "xyes" = "x$BUILD_GLADESRC" ])
 
+dnl Do not use AC_REPLACE_FUNCS() as we need to link it selectively:
+GNOME_VFS_READ_ENTIRE_FILE_O=""
+captive_save_CFLAGS="$CFLAGS"
+captive_save_LIBS="$LIBS"
+CFLAGS="$CFLAGS $GNOME_VFS_MODULE_CFLAGS"
+LIBS="$LIBS $GNOME_VFS_MODULE_LIBS"
+AC_CHECK_FUNCS(gnome_vfs_read_entire_file,,
+       [ GNOME_VFS_READ_ENTIRE_FILE_O='gnome_vfs_read_entire_file.$(OBJEXT)' ])
+CFLAGS="$captive_save_CFLAGS"
+LIBS="$captive_save_LIBS"
+AC_SUBST(GNOME_VFS_READ_ENTIRE_FILE_O)
 
 AC_SUBST(CFLAGS)
 AC_SUBST(LIBS)
@@ -372,6 +450,7 @@ captive.spec
 ./src/client/gnomevfs/captive.conf
 ./po/Makefile.in
 ./macros/glade-w.sh
+./debian/changelog
 Makefile
 ./macros/Makefile
 ./src/Makefile