From 585469b192cf58d048fa7629a26dd9bd7d56dba9 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 23 Dec 2017 16:57:36 +0000 Subject: [PATCH] add configure flags for magick load and save so you can turn load and save on and off independently --- configure.ac | 30 +++++++++++++++++++++++++++--- libvips/foreign/foreign.c | 29 ++++++++++++----------------- libvips/foreign/magick2vips.c | 8 +++----- libvips/foreign/magick7load.c | 8 +++----- libvips/foreign/magickload.c | 8 +++----- libvips/foreign/magicksave.c | 7 ++----- 6 files changed, 50 insertions(+), 40 deletions(-) diff --git a/configure.ac b/configure.ac index d97e6714..be8785f6 100644 --- a/configure.ac +++ b/configure.ac @@ -551,6 +551,7 @@ fi # ImageMagick AC_ARG_WITH([magick], AS_HELP_STRING([--without-magick], [build without libMagic (default: test)])) + AC_ARG_WITH([magickpackage], AS_HELP_STRING([--with-magickpackage], [magickpackage to use (default: MagickCore; try GraphicsMagick to build against gm instead)])) @@ -575,17 +576,20 @@ fi # we have a separate loader for magick7 with fewer ifdef # options; only test for features on the magick6 case +magick_version= if test x"$with_magick" != x"no"; then PKG_CHECK_MODULES(MAGICK, $with_magickpackage >= 7.0, [AC_DEFINE(HAVE_MAGICK7,1,[define if you have libMagick7 installed.]) - with_magick="yes (magick7)" + with_magick=yes magick7=yes + magick_version=magick7 PACKAGES_USED="$PACKAGES_USED $with_magickpackage" ], [PKG_CHECK_MODULES(MAGICK, $with_magickpackage, [AC_DEFINE(HAVE_MAGICK,1,[define if you have libMagick installed.]) - with_magick="yes (magick6)" + with_magick=yes magick6=yes + magick_version=magick6 PACKAGES_USED="$PACKAGES_USED $with_magickpackage" ], [AC_MSG_WARN([$with_magickpackage not found; disabling Magick support]) @@ -661,6 +665,24 @@ if test x"$magick6" = x"yes"; then CFLAGS="$save_CFLAGS" fi +# have flags to turn load and save off independently ... some people will want +# save but not load, for example +AC_ARG_ENABLE([magickload], + AS_HELP_STRING([--disable-magickload], + [disable libMagic load (default: enabled)])) +if test x"$enable_magickload" != x"no"; then + AC_DEFINE(ENABLE_MAGICKLOAD,1,[define to enable load with libMagick]) + enable_magickload=yes +fi + +AC_ARG_ENABLE([magicksave], + AS_HELP_STRING([--disable-magicksave], + [disable libMagic save (default: enabled)])) +if test x"$enable_magicksave" != x"no"; then + AC_DEFINE(ENABLE_MAGICKSAVE,1,[define to enable save with libMagick]) + enable_magicksave=yes +fi + # orc AC_ARG_WITH([orc], AS_HELP_STRING([--without-orc], [build without orc (default: test)])) @@ -1191,7 +1213,9 @@ build PPM support: $with_ppm * optional dependencies use fftw3 for FFT: $with_fftw Magick package: $with_magickpackage -file import with libMagick: $with_magick +Magick API version: $magick_version +load with libMagick: $enable_magickload +save with libMagick: $enable_magicksave accelerate loops with orc: $with_orc (requires orc-0.4.11 or later) ICC profile support with lcms: $with_lcms diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 73e39c49..d2efdf8b 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -1879,27 +1879,22 @@ vips_foreign_operation_init( void ) vips_foreign_load_openslide_get_type(); #endif /*HAVE_OPENSLIDE*/ -/* Should be removed and added as a configure option */ -#define HAVE_MAGICKLOAD 1 -#define HAVE_MAGICKSAVE 1 -/* Should be removed and added as a configure option */ +#ifdef ENABLE_MAGICKLOAD +#ifdef HAVE_MAGICK + vips_foreign_load_magick_file_get_type(); + vips_foreign_load_magick_buffer_get_type(); +#endif /*HAVE_MAGICK*/ -#ifdef HAVE_MAGICKLOAD - #ifdef HAVE_MAGICK - vips_foreign_load_magick_file_get_type(); - vips_foreign_load_magick_buffer_get_type(); - #endif /*HAVE_MAGICK*/ +#ifdef HAVE_MAGICK7 + vips_foreign_load_magick7_file_get_type(); + vips_foreign_load_magick7_buffer_get_type(); +#endif /*HAVE_MAGICK7*/ +#endif /*ENABLE_MAGICKLOAD*/ - #ifdef HAVE_MAGICK7 - vips_foreign_load_magick7_file_get_type(); - vips_foreign_load_magick7_buffer_get_type(); - #endif /*HAVE_MAGICK7*/ -#endif /*HAVE_MAGICKLOAD*/ - -#ifdef HAVE_MAGICKSAVE +#ifdef ENABLE_MAGICKSAVE vips_foreign_save_magick_file_get_type(); vips_foreign_save_magick_buffer_get_type(); -#endif /*HAVE_MAGICKSAVE*/ +#endif /*ENABLE_MAGICKSAVE*/ #ifdef HAVE_CFITSIO vips_foreign_load_fits_get_type(); diff --git a/libvips/foreign/magick2vips.c b/libvips/foreign/magick2vips.c index ae1b7888..9c90a7b0 100644 --- a/libvips/foreign/magick2vips.c +++ b/libvips/foreign/magick2vips.c @@ -93,11 +93,8 @@ #endif /*HAVE_CONFIG_H*/ #include -/* Should be removed and added as a configure option */ -#define HAVE_MAGICKLOAD 1 -/* Should be removed and added as a configure option */ +#ifdef ENABLE_MAGICKLOAD -#ifdef HAVE_MAGICKLOAD #ifdef HAVE_MAGICK #include @@ -898,4 +895,5 @@ vips__magick_read_buffer_header( const void *buf, const size_t len, } #endif /*HAVE_MAGICK*/ -#endif /*HAVE_MAGICKLOAD*/ + +#endif /*ENABLE_MAGICKLOAD*/ diff --git a/libvips/foreign/magick7load.c b/libvips/foreign/magick7load.c index 820d641a..01be0930 100644 --- a/libvips/foreign/magick7load.c +++ b/libvips/foreign/magick7load.c @@ -50,11 +50,8 @@ #include #include -/* Should be removed and added as a configure option */ -#define HAVE_MAGICKLOAD 1 -/* Should be removed and added as a configure option */ +#ifdef ENABLE_MAGICKLOAD -#ifdef HAVE_MAGICKLOAD #ifdef HAVE_MAGICK7 #include @@ -916,4 +913,5 @@ vips_foreign_load_magick7_buffer_init( VipsForeignLoadMagick7Buffer *buffer ) } #endif /*HAVE_MAGICK7*/ -#endif /*HAVE_MAGICKLOAD*/ \ No newline at end of file + +#endif /*ENABLE_MAGICKLOAD*/ diff --git a/libvips/foreign/magickload.c b/libvips/foreign/magickload.c index 957e4ded..3a684a77 100644 --- a/libvips/foreign/magickload.c +++ b/libvips/foreign/magickload.c @@ -58,11 +58,8 @@ #include #include -/* Should be removed and added as a configure option */ -#define HAVE_MAGICKLOAD 1 -/* Should be removed and added as a configure option */ +#ifdef ENABLE_MAGICKLOAD -#ifdef HAVE_MAGICKLOAD #ifdef HAVE_MAGICK #include "pforeign.h" @@ -330,7 +327,8 @@ vips_foreign_load_magick_buffer_init( VipsForeignLoadMagickBuffer *buffer ) } #endif /*HAVE_MAGICK*/ -#endif /*HAVE_MAGICKLOAD*/ + +#endif /*ENABLE_MAGICKLOAD*/ /** * vips_magickload: diff --git a/libvips/foreign/magicksave.c b/libvips/foreign/magicksave.c index fed63226..9195738b 100644 --- a/libvips/foreign/magicksave.c +++ b/libvips/foreign/magicksave.c @@ -35,10 +35,7 @@ #endif /*HAVE_CONFIG_H*/ #include -/* Should be removed and added as a configure option */ -#define HAVE_MAGICKSAVE 1 - -#ifdef HAVE_MAGICKSAVE +#ifdef ENABLE_MAGICKSAVE #include #include @@ -503,4 +500,4 @@ vips_foreign_save_magick_buffer_init( VipsForeignSaveMagickBuffer *buffer ) { } -#endif /*HAVE_MAGICKSAVE*/ +#endif /*ENABLE_MAGICKSAVE*/