Provide statical linking of GnomeVFS "libntfs" method for: --enable-standalone
authorlace <>
Tue, 27 Dec 2005 09:05:29 +0000 (09:05 +0000)
committerlace <>
Tue, 27 Dec 2005 09:05:29 +0000 (09:05 +0000)
12 files changed:
build-static
captive.spec.in
configure.ac
src/install/acquire/Makefile.am
src/install/acquire/main.c
src/install/acquire/standalone-libntfs.c [new file with mode: 0644]
src/install/acquire/standalone-libntfs.h [new file with mode: 0644]
src/libcaptive/captivemodid/Makefile.am
src/libcaptive/client/options-module.c
src/libcaptive/client/options.c
src/libcaptive/include/captive/captivemodid.h
src/libcaptive/include/captive/options.h

index b2c905c..7dc82d5 100755 (executable)
 STATIC_PATH=/usr/local/devel-static
 
 
-set -e
+set -e -o pipefail
 if test "$1" != link;then
        set -x
        ./autogen.pl --dist
-       (set -x;CFLAGS="-O2" ./configure --enable-maintainer-mode --disable-shared --enable-static --enable-install-pkg \
+       (set -x;CFLAGS="-O2" CPPFLAGS="-I$STATIC_PATH/include/gnome-vfs-module-2.0" \
+                       ./configure --enable-maintainer-mode --disable-shared --enable-static --enable-install-pkg \
                        --enable-standalone \
                        --enable-standalone-fonts=/usr/local/share/captive/fonts \
                        --disable-standalone-yum \
@@ -70,7 +71,7 @@ print_objects:
 HERE
 )"
 #      set -x
-       gcc -O2 -static -Wall -Wstrict-prototypes -Wsign-compare -o $target $objects `pkg-config --cflags gmodule-2.0 gthread-2.0` $STATIC_PATH/src/*.c -L$STATIC_PATH/lib/ -L./src/install/libcaptive-install/ -lcaptive-install -L./src/libcaptive/.libs/ -lcaptive -L/usr/X11R6/lib -lgnomevfs-2 -lreadline -ltermcap -lcrypto -lntfs -lfuse -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangoft2-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lxml2 -lbonobo-2 -lgconf-2 -lbonobo-activation -lORBitCosNaming-2 -lORBit-2 -lm -lgthread-2.0 -lXft -lfontconfig -lfreetype -lexpat -lXrandr -lXinerama -lXfixes -lXcursor -lXext -lXrender -lX11 -lpng -lz -lglib-2.0 -lc -lnss_files -lnss_dns -lresolv
+       gcc -O2 -static -Wall -Wstrict-prototypes -Wsign-compare -o $target $objects `pkg-config --cflags gmodule-2.0 gthread-2.0` $STATIC_PATH/src/*.c -L$STATIC_PATH/lib/ -L./src/install/libcaptive-install/ -lcaptive-install -L./src/libcaptive/.libs/ -lcaptive -L/usr/X11R6/lib -L/usr/lib/gnome-vfs-2.0/modules -lgnomevfs-2 -lreadline -ltermcap -lcrypto -lntfs-gnomevfs -lntfs -lfuse -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangoft2-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lxml2 -lbonobo-2 -lgconf-2 -lbonobo-activation -lORBitCosNaming-2 -lORBit-2 -lm -lgthread-2.0 -lXft -lfontconfig -lfreetype -lexpat -lXrandr -lXinerama -lXfixes -lXcursor -lXext -lXrender -lX11 -lpng -lz -lglib-2.0 -lc -lnss_files -lnss_dns -lresolv
        set +x
        done) 2>&1|tee errs2
 echo OK
index d317444..6cabdbe 100644 (file)
@@ -164,6 +164,7 @@ NTFS disks will become mount(8)able at directories: /mnt/captive-VOLUME_NAME
 %endif
 # 'define' of rpm(1) does not accept line-continuation backslashes ('\').
 %if %{static}
+export CPPFLAGS="-I/usr/local/devel-static/include/gnome-vfs-module-2.0"
 %configure \
                --disable-shared --enable-static \
                --enable-standalone \
index 9fa79c3..98fabc2 100644 (file)
@@ -381,6 +381,62 @@ if test "x$found_orbit_line" = "xlinc";then
        PKG_CHECK_MODULES(LINC,linc)
 fi
 
+captive_save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $LIBXML_CFLAGS"
+have_libxml_xmlreader_h=false
+AC_CHECK_HEADERS(libxml/xmlreader.h,[ have_libxml_xmlreader_h=true ],
+       [ AC_MSG_WARN([Captive requires libxml >= 2.4.29 for --enable-install-pkg.]) ])
+AM_CONDITIONAL(HAVE_LIBXML_XMLREADER_H,[ $have_libxml_xmlreader_h ])
+CPPFLAGS="$captive_save_CPPFLAGS"
+
+have_libntfs_includes=true
+# '#include "config.h"' may be required by <ntfs/*> include files.
+# "config.h" may be already present while not yet being compilable.
+rm -f config.h-ntfs_save
+mv -f config.h config.h-ntfs_save 2>/dev/null
+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
+       AC_MSG_WARN([Captive requires ntfs/* include files (of ntfsprogs-devel) for --enable-install-pkg.])
+       ])
+CPPFLAGS="$captive_save_CPPFLAGS"
+rm -f config.h
+mv -f config.h-ntfs_save config.h 2>/dev/null
+
+LIBNTFS_LIBS=""
+AC_CHECK_LIB(ntfs,ntfs_mount,[ LIBNTFS_LIBS="-lntfs" ],
+       [ AC_MSG_WARN([Captive requires libntfs (of ntfsprogs-devel) for --enable-install-pkg.]) ])
+AC_SUBST(LIBNTFS_LIBS)
+
+have_libgnomevfs_gnome_vfs_filesystem_entry_h=false
+if test x$enable_standalone = xyes;then
+       captive_save_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $GNOME_VFS_MODULE_CFLAGS"
+       AC_CHECK_HEADERS(libgnomevfs/gnome-vfs-filesystem-entry.h,
+               [ have_libgnomevfs_gnome_vfs_filesystem_entry_h=true ],
+               [ AC_MSG_WARN([Captive --enable-install-pkg with --enable-standalone requires patched GnomeVFS. See:
+       http://bugzilla.gnome.org/show_bug.cgi?id=47053]) ])
+       CPPFLAGS="$captive_save_CPPFLAGS"
+fi
+
+LIBNTFS_GNOMEVFS_LIBS=""
+if test x$enable_standalone = xyes;then
+       LIBNTFS_GNOMEVFS_LIBS="-L/usr/lib/gnome-vfs-2.0/modules -lntfs-gnomevfs"
+       captive_save_CFLAGS="$CFLAGS"
+       captive_save_LIBS="$LIBS"
+       CFLAGS="$CFLAGS $GNOME_VFS_MODULE_CFLAGS"
+       LIBS="  $LIBS   $GNOME_VFS_MODULE_LIBS   $LIBNTFS_GNOMEVFS_LIBS"
+       AC_CHECK_FUNCS(vfs_module_init,,[
+               LIBNTFS_GNOMEVFS_LIBS=""
+               AC_MSG_WARN([Captive --enable-install-pkg with --enable-standalone requires GnomeVFS libntfs-gnomevfs.])
+               ])
+       CFLAGS="$captive_save_CFLAGS"
+       LIBS="$captive_save_LIBS"
+fi
+AC_SUBST(LIBNTFS_GNOMEVFS_LIBS)
+
 # AC_ARG_ENABLE(install-pkg,[--enable-install-pkg=[no/yes/auto]],,enable_install_pkg=auto)
 GLADE_W_INIT([
        ./src/install/acquire/ui-gnome-interface.c
@@ -389,42 +445,23 @@ GLADE_W_INIT([
        ./src/install/acquire/ui-gnome-support.c
        ./src/install/acquire/ui-gnome-support.h
        ],[$enable_install_pkg],[
-               AC_CHECK_LIB(ntfs,ntfs_mount,[
-                       LIBNTFS_LIBS="-lntfs"
-
-                       have_libntfs_includes=true
-                       AC_CHECK_HEADERS
-                       # '#include "config.h"' may be required by <ntfs/*> include files.
-                       # "config.h" may be already present while not yet being compilable.
-                       rm -f config.h-ntfs_save
-                       mv -f config.h config.h-ntfs_save 2>/dev/null
-                       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"
-                       rm -f config.h
-                       mv -f config.h-ntfs_save config.h 2>/dev/null
-                       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.]) ])
+               if true \
+                               && $have_libxml_xmlreader_h \
+                               && $have_libntfs_includes \
+                               && test -n "$LIBNTFS_LIBS" \
+                               && ( test x$enable_standalone != xyes || ( true \
+                                       && $have_libgnomevfs_gnome_vfs_filesystem_entry_h \
+                                       && test -n "$LIBNTFS_GNOMEVFS_LIBS" \
+                                       ) ) \
+                               ;then
+                       glade_addon=yes
+               fi
                ])
 if $have_gnome;then
        GNOMEUI_CFLAGS="$GNOMEUI_CFLAGS -DCAPTIVE_USING_GNOMEUI"
 fi
 AC_SUBST(GNOMEUI_CFLAGS)
 AC_SUBST(GNOMEUI_LIBS)
-AC_SUBST(LIBNTFS_LIBS)
 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" ])
index d306a28..82d5d77 100644 (file)
@@ -30,6 +30,12 @@ GLADE_OUT= \
                ui-gnome-support.c \
                ui-gnome-support.h
 
+if ENABLE_STANDALONE
+standalone_libntfs_cond= \
+               standalone-libntfs.c \
+               standalone-libntfs.h
+endif
+
 captive_install_acquire_SOURCES= \
                cabextract/cabextract.c \
                cabextract/cabextract.h \
@@ -51,6 +57,7 @@ captive_install_acquire_SOURCES= \
                ui-line.h \
                ui-gnome.c \
                ui-gnome.h \
+               $(standalone_libntfs_cond) \
                $(GLADE_OUT)
 
 EXTRA_captive_install_acquire_SOURCES= \
@@ -83,10 +90,11 @@ CLEANFILES+= \
                ui-gnome.glade.bak \
                ui-gnome.gladep.bak
 
-captive_install_acquire_CFLAGS=$(GNOME_VFS_CFLAGS) $(LIBXML_CFLAGS) $(OPENSSL_CFLAGS)
-captive_install_acquire_LDADD+=$(GNOME_VFS_LIBS)   $(LIBXML_LIBS)   $(OPENSSL_LIBS)
-captive_install_acquire_LDADD+= $(READLINE_LIBS)    $(LIBNTFS_LIBS) $(POPT_LIBS) $(INTLLIBS) $(captive_library)
+captive_install_acquire_CFLAGS=$(GNOME_VFS_MODULE_CFLAGS) $(LIBXML_CFLAGS) $(OPENSSL_CFLAGS)
+captive_install_acquire_LDADD+=$(GNOME_VFS_MODULE_LIBS)   $(LIBXML_LIBS)   $(OPENSSL_LIBS)
+captive_install_acquire_LDADD+= $(READLINE_LIBS)    $(LIBNTFS_LIBS) $(LIBNTFS_GNOMEVFS_LIBS)
 captive_install_acquire_LDFLAGS=$(READLINE_LDFLAGS)
+captive_install_acquire_LDADD+=$(POPT_LIBS) $(INTLLIBS) $(captive_library)
 
 # FIXME: /usr/include/gtk-2.0/gtk/gtkitemfactory.h:51: warning: function declaration isn't a prototype
 # /* We use () here to mean unspecified arguments. This is deprecated
index 260e821..26447f4 100644 (file)
 #include <setjmp.h>
 #include "ui-gnome.h"
 
+#ifdef ENABLE_STANDALONE
+#include "standalone-libntfs.h"
+#endif
+
 #include <captive/macros.h>
 #include <captive/client.h>
 #include <captive/captivemodid.h>
@@ -205,6 +209,10 @@ gboolean no_gnome;
        if (!gnome_vfs_init())
                g_error(_("GnomeVFS failed to initialize"));
 
+#ifdef ENABLE_STANDALONE
+       standalone_libntfs_init();
+#endif
+
        if (argv[1] && !strcmp(argv[1],"--text"))
                optarg_text=1;
 
diff --git a/src/install/acquire/standalone-libntfs.c b/src/install/acquire/standalone-libntfs.c
new file mode 100644 (file)
index 0000000..05c3388
--- /dev/null
@@ -0,0 +1,62 @@
+/* $Id$
+ * "libntfs" GnomeVFS method linked statically
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "standalone-libntfs.h"        /* self */
+
+/* This include file is present only in GnomeVFS include-filesystems patched
+ * version. See:
+ *     http://bugzilla.gnome.org/show_bug.cgi?id=47053
+ */
+#include <libgnomevfs/gnome-vfs-filesystem-entry.h>
+
+
+GnomeVFSMethod *vfs_module_init(const char *method_name, const char *args);
+GnomeVFSTransform *vfs_module_transform(const char *method_name, const char *config_args);
+void vfs_module_shutdown(GnomeVFSMethod *method);
+
+GnomeVFSTransform *vfs_module_transform(const char *method_name, const char *config_args)
+{
+       return NULL;
+}
+
+static const GnomeVFSIncludedFilesystem libntfs_gnomevfs={
+       "libntfs",      /* filesystem_name */
+       NULL,           /* filesystem_args */
+       FALSE,          /* run_in_daemon */
+       vfs_module_init,
+       vfs_module_transform,
+       vfs_module_shutdown,
+       };
+
+
+void standalone_libntfs_init(void)
+{
+       gnome_vfs_register_included_filesystem(&libntfs_gnomevfs);
+}
+
+/* This GCC version check is not exact or even right in any way. */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+void gnome_vfs_register_included_filesystem(const GnomeVFSIncludedFilesystem *included_filesystem) __attribute__((__weak__));
+void gnome_vfs_register_included_filesystem(const GnomeVFSIncludedFilesystem *included_filesystem)
+{
+       g_error("Executable must be relinked with patched GnomeVFS: http://bugzilla.gnome.org/show_bug.cgi?id=47053");
+}
+#endif
diff --git a/src/install/acquire/standalone-libntfs.h b/src/install/acquire/standalone-libntfs.h
new file mode 100644 (file)
index 0000000..304f94e
--- /dev/null
@@ -0,0 +1,31 @@
+/* $Id$
+ * Include file for "libntfs" GnomeVFS method linked statically
+ * Copyright (C) 2005 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _CAPTIVE_INSTALL_ACQUIRE_STANDALONE_LIBNTFS_H
+#define _CAPTIVE_INSTALL_ACQUIRE_STANDALONE_LIBNTFS_H 1
+
+
+G_BEGIN_DECLS
+
+void standalone_libntfs_init(void);
+
+G_END_DECLS
+
+
+#endif /* _CAPTIVE_INSTALL_ACQUIRE_STANDALONE_LIBNTFS_H */
index 622fe34..b6a135e 100644 (file)
@@ -20,11 +20,13 @@ include $(top_srcdir)/Makefile-head.am
 include $(top_srcdir)/src/libcaptive/Makefile-libcaptive.am
 
 noinst_LTLIBRARIES=libcaptivemodid.la
+
+if HAVE_LIBXML_XMLREADER_H
+captivemodid_cond=captivemodid.c
+endif
+
 libcaptivemodid_la_SOURCES= \
-               captivemodid.c \
-               captivemodid-list.pl \
-               captivemodid-print.pl \
-               compatibility-test.sh
+               $(captivemodid_cond)
 libcaptivemodid_la_CFLAGS=$(GNOME_VFS_CFLAGS) $(LIBXML_CFLAGS) $(OPENSSL_CFLAGS)
 libcaptivemodid_la_LIBADD=$(GNOME_VFS_LIBS)   $(LIBXML_LIBS)   $(OPENSSL_LIBS)
 
@@ -33,3 +35,8 @@ libcaptivemodid_la_CFLAGS+=-DSYSCONFDIR="$(sysconfdir)"
 sysconf_DATA= \
                w32-mod-id.captivemodid.xml
 EXTRA_DIST+=$(sysconf_DATA)
+
+EXTRA_DIST+= \
+               captivemodid-list.pl \
+               captivemodid-print.pl \
+               compatibility-test.sh
index bd89bc3..a33ec6c 100644 (file)
@@ -37,6 +37,7 @@
 
 static void module_check_captivemodid(struct captive_options_module *options_module,const gchar *pathname_utf8)
 {
+#ifdef HAVE_LIBXML_XMLREADER_H
        if (!captive_options->captivemodid) {
                if (!captive_options->load_untested)
                        g_error(_(
@@ -59,6 +60,7 @@ static void module_check_captivemodid(struct captive_options_module *options_mod
                        "Loading UNTESTED and possibly INCOMPATIBLE module: %s\n"
                        "Although forced by --load-untested you really should get more recent modid database: %s\n"),
                        pathname_utf8,captive_captivemodid_get_pathname_loaded(captive_options->captivemodid));
+#endif /* HAVE_LIBXML_XMLREADER_H */
 }
 
 gboolean captive_options_module_load(struct captive_options_module *options_module,const gchar *pathname_utf8)
index 703a84c..cdad5d3 100644 (file)
@@ -43,7 +43,9 @@ void captive_options_init(struct captive_options *options)
        options->load_module=NULL;
        options->sandbox=FALSE;
        options->syslog_facility=-1;
+#ifdef HAVE_LIBXML_XMLREADER_H
        options->captivemodid=NULL;
+#endif /* HAVE_LIBXML_XMLREADER_H */
        options->load_untested=FALSE;
 }
 
@@ -94,8 +96,10 @@ char **sp;
        if (src->bug_pathname)
                dest->bug_pathname=g_strdup(src->bug_pathname);
 
+#ifdef HAVE_LIBXML_XMLREADER_H
        if (dest->captivemodid)
                g_object_ref(dest->captivemodid);
+#endif /* HAVE_LIBXML_XMLREADER_H */
 }
 
 
@@ -116,8 +120,10 @@ void captive_options_free(struct captive_options *options)
        g_free(options->sandbox_server_ior);
        g_free(options->bug_pathname);
 
+#ifdef HAVE_LIBXML_XMLREADER_H
        if (options->captivemodid)
                g_object_unref(options->captivemodid);
+#endif /* HAVE_LIBXML_XMLREADER_H */
 }
 
 
@@ -147,10 +153,14 @@ gboolean errbool;
 
 static void arg_modid_path(void)
 {
+#ifdef HAVE_LIBXML_XMLREADER_H
        if (captive_options->captivemodid)
                g_object_unref(captive_options->captivemodid);
        if (!(captive_options->captivemodid=captive_captivemodid_load(captive_popt_optarg)))
                g_error(_("Unable to load modid database: %s"),captive_popt_optarg);
+#else
+       g_message(_("Compiled without captivemodid support (no <libxml/xmlreader.h>), ignoring: %s"),captive_popt_optarg);
+#endif /* HAVE_LIBXML_XMLREADER_H */
 }
 
 static void arg_load_untested(void)
index 592c689..7b274f7 100644 (file)
@@ -21,6 +21,8 @@
 #define _CAPTIVE_CAPTIVEMODID_H 1
 
 
+#ifdef HAVE_LIBXML_XMLREADER_H
+
 #include <glib/gtypes.h>
 #include <glib-object.h>
 #include <libgnomevfs/gnome-vfs-file-size.h>
@@ -70,5 +72,7 @@ gchar *captive_calc_md5(gconstpointer base,size_t length);
 
 G_END_DECLS
 
+#endif /* HAVE_LIBXML_XMLREADER_H */
+
 
 #endif /* _CAPTIVE_CAPTIVEMODID_H */
index d6d97b0..a1ea994 100644 (file)
@@ -62,7 +62,9 @@ struct captive_options {
        gchar *sandbox_server_ior;
        gchar *bug_pathname;
        int syslog_facility;    /* LOG_*; -1 if not used */
+#ifdef HAVE_LIBXML_XMLREADER_H
        CaptiveCaptivemodidObject *captivemodid;
+#endif /* HAVE_LIBXML_XMLREADER_H */
        gboolean load_untested;
        };