diff --git a/configure.ac b/configure.ac index 3c99ab52..7d74f24e 100644 --- a/configure.ac +++ b/configure.ac @@ -399,8 +399,8 @@ AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])]) AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])]) # have to have these parts of glib ... we need glib 2.15 for gio -PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.40 gmodule-2.0 gobject-2.0 gio-2.0) -PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-2.0 gobject-2.0 gio-2.0" +PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.40 gmodule-no-export-2.0 gobject-2.0 gio-2.0) +PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-no-export-2.0 gobject-2.0 gio-2.0" # from 2.62 we have datetime PKG_CHECK_MODULES(DATE_TIME_FORMAT_ISO8601, glib-2.0 >= 2.62, @@ -437,6 +437,30 @@ PKG_CHECK_MODULES(HAVE_CHECKED_MUL, glib-2.0 >= 2.48, ] ) +AC_MSG_CHECKING([whether to build dynamic modules]) + +AC_ARG_ENABLE([modules], + AS_HELP_STRING([--disable-modules], [disable dynamic modules (default: enabled)])) + +gmodule_supported_bool=false +gmodule_supported_flag=no +gmodule_with_flag=yes + +if test x"$enable_modules" = x"no"; then + AC_MSG_RESULT(no) +else + AC_MSG_RESULT(yes) + AC_MSG_CHECKING(whether dynamic modules work) + gmodule_supported_bool=`$PKG_CONFIG gmodule-no-export-2.0 --variable gmodule_supported` + if $gmodule_supported_bool; then + gmodule_supported_flag=yes + gmodule_with_flag='module' + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi +fi + # check for gtk-doc GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) @@ -1334,6 +1358,7 @@ VIPS_LIBS="$VIPS_LIBS $REQUIRED_LIBS -lm" VIPS_CONFIG="\ enable debug: $enable_debug, \ enable deprecated library components: $enable_deprecated, \ +enable modules: $gmodule_supported_flag, \ enable docs with gtkdoc: $enable_gtk_doc, \ gobject introspection: $found_introspection, \ RAD load/save: $with_radiance, \ @@ -1434,6 +1459,7 @@ AC_MSG_RESULT([dnl ## Build options enable debug: $enable_debug enable deprecated library components: $enable_deprecated +enable modules: $gmodule_supported_flag enable docs with gtkdoc: $enable_gtk_doc gobject introspection: $found_introspection RAD load/save: $with_radiance diff --git a/libvips/Makefile.am b/libvips/Makefile.am index 212dc491..fa113418 100644 --- a/libvips/Makefile.am +++ b/libvips/Makefile.am @@ -61,6 +61,7 @@ libvips_la_LDFLAGS = \ -version-info @LIBRARY_CURRENT@:@LIBRARY_REVISION@:@LIBRARY_AGE@ EXTRA_DIST = \ + module \ $(OPTIONAL_DIST_DIR) CLEANFILES = @@ -72,6 +73,35 @@ install-exec-hook: cp soname.h $(DESTDIR)$(pkgincludedir) && \ rm soname.h +# Modules + +module_LTLIBRARIES = + +# All modules within the $VIPSHOME/lib/vips-modules-MAJOR.MINOR +# directory are automatically loaded on vips_init. + +moduledir = @VIPS_LIBDIR@/vips-modules-@VIPS_MAJOR_VERSION@.@VIPS_MINOR_VERSION@ + +MODULE_CPPFLAGS = \ + -I${top_srcdir}/libvips/include \ + $(REQUIRED_CFLAGS) + +MODULE_LDFLAGS = \ + -no-undefined \ + -shared \ + -module \ + -avoid-version + +MODULE_LIBADD = \ + libvips.la \ + $(REQUIRED_LIBS) + +# Note that only the GObject part should be included in a +# dynamically loadable module. The C definitions are always +# included in the main library. + +# Introspection + -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) diff --git a/libvips/foreign/Makefile.am b/libvips/foreign/Makefile.am index afe30463..bab9fb7b 100644 --- a/libvips/foreign/Makefile.am +++ b/libvips/foreign/Makefile.am @@ -72,6 +72,9 @@ libforeign_la_SOURCES = \ webpload.c \ webpsave.c +# We still need to include the GObject part of a loader/saver +# if it is not built as a dynamically loadable module. + EXTRA_DIST = libnsgif AM_CPPFLAGS = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libvips/iofuncs/init.c b/libvips/iofuncs/init.c index b14564db..1503fd61 100644 --- a/libvips/iofuncs/init.c +++ b/libvips/iofuncs/init.c @@ -510,13 +510,18 @@ vips_init( const char *argv0 ) vips_mosaicing_operation_init(); vips_g_input_stream_get_type(); - /* Load any vips8 plugins from the vips libdir. Keep going, even if - * some plugins fail to load. + /* Load any vips8 modules from the vips libdir. Keep going, even if + * some modules fail to load. + */ + (void) vips_load_plugins( "%s/vips-modules-%d.%d", + libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ); + +#if ENABLE_DEPRECATED + /* Load any vips8 plugins from the vips libdir. */ (void) vips_load_plugins( "%s/vips-plugins-%d.%d", libdir, VIPS_MAJOR_VERSION, VIPS_MINOR_VERSION ); -#if ENABLE_DEPRECATED /* Load up any vips7 plugins in the vips libdir. We don't error on * failure, it's too annoying to have VIPS refuse to start because of * a broken plugin. diff --git a/libvips/module/.gitkeep b/libvips/module/.gitkeep new file mode 100644 index 00000000..e69de29b