1# Process this file with autoconf to produce a configure script.
2
3# also update the version number in the m4 macros below
4
5AC_INIT([vips], [8.12.0], [vipsip@jiscmail.ac.uk])
6# required for gobject-introspection
7AC_PREREQ([2.69])
8
9# gobject-introspection recommends -Wno-portability
10# foreign stops complaints about a missing README (we use README.md instead)
11# and missing INSTALL (the standard Gnu INSTALL is not very useful)
12# subdir-objects lets us have dummy.cc in a subdir
13AM_INIT_AUTOMAKE([-Wno-portability foreign subdir-objects])
14
15AC_CONFIG_HEADERS([config.h])
16AC_CONFIG_MACRO_DIR([m4])
17
18# user-visible library versioning
19m4_define([vips_major_version], [8])
20m4_define([vips_minor_version], [12])
21m4_define([vips_micro_version], [0])
22m4_define([vips_version],
23          [vips_major_version.vips_minor_version.vips_micro_version])
24
25VIPS_MAJOR_VERSION=vips_major_version()
26VIPS_MINOR_VERSION=vips_minor_version()
27VIPS_MICRO_VERSION=vips_micro_version()
28VIPS_VERSION=vips_version()
29VIPS_VERSION_STRING="$VIPS_VERSION-$(date -u -r $srcdir/ChangeLog)"
30
31# packages add to these as we find them
32VIPS_CFLAGS=""
33VIPS_INCLUDES=""
34VIPS_LIBS=""
35
36# libtool library versioning ... not user-visible (except as part of the
37# library file name) and does not correspond to major/minor/micro above
38
39# rules:
40# sources changed: increment revision
41# binary interface changed: increment current, reset revision to 0
42#   binary interface changes backwards compatible?: increment age
43#   binary interface changes not backwards compatible?: reset age to 0
44LIBRARY_REVISION=0
45LIBRARY_CURRENT=56
46LIBRARY_AGE=14
47
48# patched into include/vips/version.h
49AC_SUBST(VIPS_VERSION)
50AC_SUBST(VIPS_VERSION_STRING)
51AC_SUBST(VIPS_MAJOR_VERSION)
52AC_SUBST(VIPS_MINOR_VERSION)
53AC_SUBST(VIPS_MICRO_VERSION)
54
55# put into library name by libsrc/Makefile.am and libsrcCC/Makefile.am
56AC_SUBST(LIBRARY_CURRENT)
57AC_SUBST(LIBRARY_REVISION)
58AC_SUBST(LIBRARY_AGE)
59
60# init introspection support
61GOBJECT_INTROSPECTION_CHECK([1.30.0])
62
63# remove the '(disabled, use --enable-introspection to enable)'
64# suffix from the found_introspection variable
65if test "x$found_introspection" != x"yes"; then
66  found_introspection=no
67fi
68
69# gir needs a list of source files to scan for introspection
70#
71# build with a glob and a list of files to exclude from scanning
72# see also IGNORE_HFILES in doc/Makefile.am
73introspection_sources=$(cd $srcdir/libvips ; find . -path ./deprecated -prune -o -name dummy.c -prune -o -name introspect.c -prune -o \( -name "*.c" -o -name "*.cpp" \) -print)
74for name in $introspection_sources; do
75  vips_introspection_sources="$vips_introspection_sources $name"
76done
77
78# add headers that form the public vips8 API .. don't do a find and exclude,
79# we end up excluding almost everything argh
80headers="\
81        basic.h \
82        vips.h \
83        object.h \
84        image.h \
85        error.h \
86        foreign.h \
87        freqfilt.h \
88        interpolate.h \
89        header.h \
90        histogram.h \
91        operation.h \
92        enumtypes.h \
93        conversion.h \
94        arithmetic.h \
95        colour.h \
96        convolution.h \
97        create.h \
98        draw.h \
99        morphology.h \
100        mosaicing.h \
101        type.h \
102        rect.h \
103        resample.h \
104        memory.h \
105        region.h"
106
107for name in $headers; do
108  vips_introspection_sources="$vips_introspection_sources include/vips/$name"
109done
110
111AC_SUBST(vips_introspection_sources)
112
113AC_CANONICAL_HOST
114
115AC_DEFINE_UNQUOTED(G_LOG_DOMAIN, "VIPS", [Domain for glib logging messages.])
116
117m4_define([debug_default], [no])
118AC_ARG_ENABLE(debug,
119  AS_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],[turn on debugging @<:@default=debug_default()@:>@]),,
120  enable_debug=debug_default())
121
122if test x"$enable_debug" = x"yes"; then
123  VIPS_DEBUG_FLAGS="-DDEBUG_FATAL -DDEBUG_LEAK"
124else
125  VIPS_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"
126
127  if test x"$enable_debug" = x"no"; then
128    VIPS_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
129  fi
130fi
131
132# option to disable deprecated code, shaves a bit off the library size
133AC_ARG_ENABLE(deprecated,
134  AS_HELP_STRING([--enable-deprecated], [build deprecated components (default: yes)]))
135
136VIPS_ENABLE_DEPRECATED=0
137if test x"$enable_deprecated" != x"no"; then
138  VIPS_ENABLE_DEPRECATED=1
139  enable_deprecated=yes
140fi
141AC_DEFINE_UNQUOTED(ENABLE_DEPRECATED,$VIPS_ENABLE_DEPRECATED,[define to build deprecated components])
142AM_CONDITIONAL(ENABLE_DEPRECATED, [test x"$enable_deprecated" = x"yes"])
143
144# this gets pasted into version.h as a #define
145AC_SUBST(VIPS_ENABLE_DEPRECATED)
146
147AC_MSG_CHECKING([for -mms-bitfields support])
148case "$host_os" in
149  mingw*)
150    # makes gcc use win native alignment
151    # GCC >= 4.7 and Clang >= 11 does this automatically, see:
152    # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1510#note_841637
153    VIPS_CFLAGS="-mms-bitfields $VIPS_CFLAGS"
154    AC_MSG_RESULT([yes])
155    ;;
156  *)
157    AC_MSG_RESULT([no])
158    ;;
159esac
160
161# set the default directory for ICC profiles
162case "$host_os" in
163  darwin*)
164    profile_dir="/Library/ColorSync/Profiles"
165    ;;
166  mingw*)
167    # need double escapes since this will get pasted into a #define in a C
168    # header ... the C:\Windows is usually overwritten with the result of
169    # GetWindowsDirectoryW()
170    profile_dir="C:\\\\Windows\\\\System32\\\\spool\\\\drivers\\\\color"
171    ;;
172  *)
173    profile_dir="/usr/share/color/icc"
174    ;;
175esac
176AC_DEFINE_UNQUOTED(VIPS_ICC_DIR,"$profile_dir",[default directory for ICC profiles])
177
178# we want largefile support, if possible
179AC_SYS_LARGEFILE
180
181# we use libtool and can generate DLLs cleanly on win32 if necessary
182LT_INIT([win32-dll])
183
184# Checks for programs.
185AC_PROG_AWK
186AC_PROG_CC
187AC_PROG_CC_STDC
188AC_PROG_CXX
189AC_PROG_INSTALL
190AC_PROG_LN_S
191
192AC_ARG_ENABLE([doxygen],
193  AS_HELP_STRING([--enable-doxygen], [enable C++ doc build (default: no)]),
194  [enable_doxygen="$enableval"],
195  [enable_doxygen=no])
196
197if test x"$enable_doxygen" = x"yes"; then
198  AC_CHECK_PROGS([DOXYGEN], [doxygen])
199  if ! test "$DOXYGEN"; then
200    AC_MSG_WARN([doxygen not found; C++ docs will not be generated])
201    enable_doxygen=no
202  fi
203fi
204AM_CONDITIONAL(HAVE_DOXYGEN, [test x"$enable_doxygen" = x"yes"])
205
206# we need a fully expanded version of $libdir
207# without this we get something like
208#    define VIPS_LIBDIR ${exec_prefix}/lib
209# argh
210test x"$prefix" = x"NONE" && prefix=$ac_default_prefix
211test x"$exec_prefix" = x"NONE" && exec_prefix='${prefix}'
212
213# set $expanded_value to the fully-expanded value of the argument
214expand () {
215    eval expanded_value=$1
216
217    if test x"$expanded_value" != x"$1"; then
218        expand "$expanded_value"
219    fi
220}
221
222expand $libdir
223VIPS_LIBDIR=$expanded_value
224
225# this gets pasted into version.h as a #define
226VIPS_EXEEXT=$EXEEXT
227AC_SUBST(VIPS_EXEEXT)
228
229# vips.c/im_guess_prefix.c need to know the exe suffix and (as a fallback)
230# the configure-time install prefix
231AC_DEFINE_UNQUOTED(VIPS_PREFIX,"$prefix",[configure-time install prefix])
232AC_DEFINE_UNQUOTED(VIPS_LIBDIR,"$VIPS_LIBDIR",[configure-time library directory])
233
234# i18n
235# we need to name our .mo with major.minor so we can have multiple versions
236# installed in parallel on Debian
237expand vips$VIPS_MAJOR_VERSION.$VIPS_MINOR_VERSION
238GETTEXT_PACKAGE=$expanded_value
239
240AC_SUBST(GETTEXT_PACKAGE)
241AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
242        [The prefix for our gettext translation domains.])
243# the 'malkovich' one is there for testing only, remove for release
244#ALL_LINGUAS="en_GB de malkovich"
245ALL_LINGUAS="en_GB de"
246AM_GLIB_GNU_GETTEXT
247
248# Compatibility with pkg.m4 < 0.27
249m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
250         [AC_ARG_WITH([pkgconfigdir],
251                      [AS_HELP_STRING([--with-pkgconfigdir],
252                      [install directory for *.pc pkg-config file])],
253                      [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
254          AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
255
256# Compatibility with pkg.m4 < 0.28
257m4_define_default([PKG_CHECK_VAR],
258                  [AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])
259                   AS_IF([test -z "$$1"], [$1=`$PKG_CONFIG --variable="$3" "$2"`])
260                   AS_IF([test -n "$$1"], [$4], [$5])])
261
262# we need to disable some features on some known-bad gcc versions
263# these will be "" for clang etc.
264#
265# I couldn't get this to work, mysterious! do it ourselves
266#
267# AX_CHECK_COMPILE_FLAG([-dumpversion],
268#   [ax_gcc_version_option=yes],
269#   [ax_gcc_version_option=no]
270# )
271AC_MSG_CHECKING([for $CC version])
272GCC_VERSION=""
273version=$($CC -dumpversion)
274if test $? = 0; then
275  GCC_VERSION=$version
276  AC_MSG_RESULT([$GCC_VERSION])
277else
278  AC_MSG_RESULT([-dumpversion not supported])
279fi
280
281GCC_VERSION_MAJOR=$(echo $GCC_VERSION | cut -d'.' -f1)
282GCC_VERSION_MINOR=$(echo $GCC_VERSION | cut -d'.' -f2)
283GCC_VERSION_PATCH=$(echo $GCC_VERSION | cut -d'.' -f3)
284
285# Checks for libraries.
286
287# build list of pkg-config packages we used here
288PACKAGES_USED=""
289
290# build list of extra libs we need here
291# the main one is jpeg: it does not have a .pc file, so when we make vips.pc
292# we need to put -ljpeg into libs ourselves
293EXTRA_LIBS_USED=""
294
295# Checks for header files.
296AC_HEADER_DIRENT
297AC_HEADER_STDC
298AC_CHECK_HEADERS([errno.h math.h fcntl.h limits.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/time.h sys/mman.h sys/types.h sys/stat.h unistd.h io.h direct.h windows.h])
299
300# Checks for typedefs, structures, and compiler characteristics.
301AC_C_RESTRICT
302AX_GCC_VAR_ATTRIBUTE(vector_size)
303AC_C_CONST
304AC_TYPE_MODE_T
305AC_TYPE_OFF_T
306AC_TYPE_SIZE_T
307
308# g++/gcc 4.x and 5.x have rather broken vector support ... 5.4.1 seems to
309# work, but 5.4.0 fails to even compile
310AC_MSG_CHECKING([for $CC with working vector support])
311if test x"$GCC_VERSION_MAJOR" != x"4" -a x"$GCC_VERSION_MAJOR" != x"5"; then
312  AC_MSG_RESULT([yes])
313else
314  ax_cv_have_var_attribute_vector_size=no
315  AC_MSG_RESULT([no])
316fi
317
318# we need to be able to shuffle vectors in C++
319if test x"$ax_cv_have_var_attribute_vector_size" = x"yes"; then
320  AC_MSG_CHECKING([for C++ vector shuffle])
321  AC_LANG_PUSH([C++])
322  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
323    typedef float v4f __attribute__((vector_size(4 * sizeof(float)),aligned(16)));
324  ]], [[
325    v4f f; f[3] = 99;
326  ]])],[
327    AC_MSG_RESULT([yes])
328    have_vector_shuffle=yes
329  ],[
330    AC_MSG_RESULT([no])
331    have_vector_shuffle=no
332  ])
333  AC_LANG_POP([C++])
334
335  if test x"$have_vector_shuffle" = x"yes"; then
336    AC_DEFINE_UNQUOTED(HAVE_VECTOR_SHUFFLE, 1,
337      [define if your C++ can shuffle vectors])
338  fi
339fi
340
341# we also need to be able to mix vector and scalar arithmetic
342if test x"$have_vector_shuffle" = x"yes"; then
343  AC_MSG_CHECKING([for C++ vector arithmetic])
344  AC_LANG_PUSH([C++])
345  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
346    typedef float v4f __attribute__((vector_size(4 * sizeof(float)),aligned(16)));
347  ]], [[
348    v4f f = {1, 2, 3, 4}; f *= 12.0;
349    v4f g = {5, 6, 7, 8}; f = g > 0 ? g : -1 * g;
350  ]])],[
351    AC_MSG_RESULT([yes])
352    have_vector_arith=yes
353  ],[
354    AC_MSG_RESULT([no])
355    have_vector_arith=no
356  ])
357  AC_LANG_POP([C++])
358fi
359
360# gcc 7.2 seems to work, but then gets confused by signed constants in
361# templates
362if test x"$have_vector_arith" = x"yes"; then
363  AC_MSG_CHECKING([for C++ signed constants in vector templates])
364  AC_LANG_PUSH([C++])
365  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
366    typedef float v4f __attribute__((vector_size(4 * sizeof(float)),aligned(16)));
367    template <typename T>
368    static void
369    h( v4f B )
370    {
371        v4f f;
372        f = -1 * B;
373    }
374  ]], [[
375  ]])],[
376    AC_MSG_RESULT([yes])
377  ],[
378    AC_MSG_RESULT([no])
379    have_vector_arith=no
380  ])
381  AC_LANG_POP([C++])
382
383  if test x"$have_vector_arith" = x"yes"; then
384    AC_DEFINE_UNQUOTED(HAVE_VECTOR_ARITH, 1,
385      [define if your C++ can mix vector and scalar arithmetic])
386  fi
387fi
388
389# Checks for library functions.
390AC_FUNC_MEMCMP
391AC_FUNC_MMAP
392AC_FUNC_VPRINTF
393AC_CHECK_FUNCS([getcwd gettimeofday getwd memset munmap putenv realpath strcasecmp strchr strcspn strdup strerror strrchr strspn vsnprintf realpath mkstemp mktemp random rand sysconf atexit _aligned_malloc posix_memalign memalign])
394AC_CHECK_LIB(m,cbrt,[AC_DEFINE(HAVE_CBRT,1,[have cbrt() in libm.])])
395AC_CHECK_LIB(m,hypot,[AC_DEFINE(HAVE_HYPOT,1,[have hypot() in libm.])])
396AC_CHECK_LIB(m,atan2,[AC_DEFINE(HAVE_ATAN2,1,[have atan2() in libm.])])
397AC_CHECK_LIB(m,asinh,[AC_DEFINE(HAVE_ASINH,1,[have asinh() in libm.])])
398
399# have to have these parts of glib ... we need glib 2.15 for gio
400PKG_CHECK_MODULES(REQUIRED, glib-2.0 >= 2.40 gmodule-no-export-2.0 gobject-2.0 gio-2.0)
401PACKAGES_USED="$PACKAGES_USED glib-2.0 gmodule-no-export-2.0 gobject-2.0 gio-2.0"
402
403# from 2.62 we have datetime
404PKG_CHECK_MODULES(DATE_TIME_FORMAT_ISO8601, glib-2.0 >= 2.62,
405  [AC_DEFINE(HAVE_DATE_TIME_FORMAT_ISO8601,1,
406            [define if your glib has g_date_time_format_iso8601().]
407   )
408  ],
409  [:
410  ]
411)
412
413VIPS_CFLAGS="$VIPS_CFLAGS $GIO_CFLAGS"
414VIPS_LIBS="$VIPS_LIBS $GIO_LIBS"
415
416# if available, we use pthread_setattr_default_np() to raise the per-thread
417# stack size ... musl (libc on Alpine), for example, has a very small stack per
418# thread by default
419save_pthread_LIBS="$LIBS"
420save_pthread_CFLAGS="$CFLAGS"
421LIBS="$LIBS $REQUIRED_LIBS"
422CFLAGS="$CFLAGS $REQUIRED_CFLAGS"
423AC_CHECK_FUNC(pthread_setattr_default_np,
424  [AC_DEFINE(HAVE_PTHREAD_DEFAULT_NP,1,[have pthread_setattr_default_np().])
425  ]
426)
427LIBS="$save_pthread_LIBS"
428CFLAGS="$save_pthread_CFLAGS"
429
430# from 2.48 we have g_uint_checked_mul() etc.
431PKG_CHECK_MODULES(HAVE_CHECKED_MUL, glib-2.0 >= 2.48,
432  [AC_DEFINE(HAVE_CHECKED_MUL,1,[define if your glib has checked multiply.])
433  ],
434  [:
435  ]
436)
437
438AC_MSG_CHECKING([whether to build dynamic modules])
439
440# Disable modules by default when building static libraries
441AS_IF([test x"$enable_static" = x"yes"],
442  [enable_modules_default=no],
443  [enable_modules_default=yes])
444
445AC_ARG_ENABLE([modules],
446  AS_HELP_STRING([--disable-modules], [disable dynamic modules (default: test)]),
447  [enable_modules="$enableval"],
448  [enable_modules="$enable_modules_default"])
449
450gmodule_supported_flag=no
451gmodule_with_flag=yes
452
453if test x"$enable_modules" = x"no"; then
454  AC_MSG_RESULT([no])
455else
456  AC_MSG_RESULT([yes])
457  AC_MSG_CHECKING([whether dynamic modules work])
458  PKG_CHECK_VAR([gmodule_supported], [gmodule-no-export-2.0], [gmodule_supported])
459  if test x"$gmodule_supported" = x"true"; then
460    gmodule_supported_flag=yes
461    gmodule_with_flag='module'
462    AC_DEFINE(ENABLE_MODULES,1,[define to enable loadable module support.])
463    AC_MSG_RESULT([yes])
464  else
465    AC_MSG_RESULT([no])
466  fi
467fi
468
469# check for gtk-doc
470GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
471
472# we need expat ... the .pc file for expat is only available
473# for recent linuxes, so we fall back to AM_WITH_EXPAT
474PKG_CHECK_MODULES(EXPAT, expat,
475  [expat_found=yes
476   PACKAGES_USED="$PACKAGES_USED expat"
477  ],
478  [AM_WITH_EXPAT
479  ]
480)
481
482if test x"$expat_found" = x"no"; then
483  exit 1
484fi
485
486VIPS_CFLAGS="$VIPS_CFLAGS $EXPAT_CFLAGS"
487VIPS_LIBS="$VIPS_LIBS $EXPAT_LIBS"
488
489# optional supporting libraries
490
491AC_ARG_WITH([gsf],
492  AS_HELP_STRING([--without-gsf], [build without libgsf-1 (default: test)]))
493
494# libgsf-1 1.14.21 crashes
495# .27 is known to work well
496# .26 seems OK but has not been tested much
497# not sure about 22-25
498if test x"$with_gsf" != x"no"; then
499  PKG_CHECK_MODULES(GSF, libgsf-1 >= 1.14.26,
500    [AC_DEFINE(HAVE_GSF,1,[define if you have libgsf-1 installed.])
501     with_gsf=yes
502     PACKAGES_USED="$PACKAGES_USED libgsf-1"
503    ],
504    [AC_MSG_WARN([libgsf-1 not found; disabling dzsave support])
505     with_gsf=no
506    ]
507  )
508
509  # zip64 and deflate-level came in .31
510  PKG_CHECK_MODULES(GSF_ZIP64, libgsf-1 >= 1.14.31,
511    [AC_DEFINE(HAVE_GSF_ZIP64,1,[define if your libgsf supports zip64.])
512     AC_DEFINE(HAVE_GSF_DEFLATE_LEVEL,1,
513               [define if your libgsf supports deflate-level.])
514    ],
515    [:
516    ]
517  )
518fi
519
520VIPS_CFLAGS="$VIPS_CFLAGS $GSF_CFLAGS"
521VIPS_LIBS="$VIPS_LIBS $GSF_LIBS"
522
523AC_ARG_WITH([fftw],
524  AS_HELP_STRING([--without-fftw], [build without fftw (default: test)]))
525
526if test x"$with_fftw" != x"no"; then
527  PKG_CHECK_MODULES(FFTW, fftw3,
528    [AC_DEFINE(HAVE_FFTW,1,[define if you have fftw3 installed.])
529     with_fftw=yes
530     PACKAGES_USED="$PACKAGES_USED fftw3"
531    ],
532    [AC_MSG_WARN([fftw not found; disabling fftw support])
533     with_fftw=no
534    ]
535  )
536fi
537
538VIPS_CFLAGS="$VIPS_CFLAGS $FFTW_CFLAGS"
539VIPS_LIBS="$VIPS_LIBS $FFTW_LIBS"
540
541# ImageMagick
542AC_ARG_WITH([magick],
543  AS_HELP_STRING([--without-magick], [build without libMagic (default: test)]),
544    [with_magick=$withval],
545    [with_magick=$gmodule_with_flag])
546
547# libMagic as a dynamically loadable module
548AS_IF([test x"$with_magick" = x"module"],
549  [with_magick_module=$gmodule_supported_flag],
550  [with_magick_module=no])
551
552AC_ARG_WITH([magickpackage],
553  AS_HELP_STRING([--with-magickpackage=PACKAGE],
554    [use magick PACKAGE (default: MagickCore; try GraphicsMagick to build against gm instead)]))
555
556if test x"$with_magickpackage" = x"yes"; then
557  AC_MSG_WARN([--with-magickpackage needs an argument, ignoring])
558  with_magick=no
559  with_magick_module=no
560else
561  if test x"$with_magickpackage" = x""; then
562    # set the default magick package ... very old imagemagicks called it
563    # ImageMagick
564    PKG_CHECK_MODULES(MAGICK_WAND, MagickCore,
565      [with_magickpackage=MagickCore
566      ],
567      [PKG_CHECK_MODULES(IMAGE_MAGICK, ImageMagick,
568         [with_magickpackage=ImageMagick
569         ],
570         [AC_MSG_WARN([neither MagickCore nor ImageMagick found; disabling Magick support])
571          with_magick=no
572          with_magick_module=no
573         ]
574       )
575      ]
576  )
577  fi
578fi
579
580# we have a separate loader for magick7 with fewer ifdef
581# options; only test for features on the magick6 case
582
583magick_version=
584if test x"$with_magick" != x"no"; then
585  PKG_CHECK_MODULES(MAGICK, $with_magickpackage >= 7.0,
586    [AC_DEFINE(HAVE_MAGICK7,1,[define if you have libMagick7 installed.])
587     with_magick=yes
588     magick7=yes
589     magick_version=magick7
590     AS_IF([test x"$with_magick_module" = x"no"],
591       [PACKAGES_USED="$PACKAGES_USED $with_magickpackage"])
592    ],
593    [PKG_CHECK_MODULES(MAGICK, $with_magickpackage,
594       [AC_DEFINE(HAVE_MAGICK6,1,[define if you have libMagick6 installed.])
595        with_magick=yes
596        magick6=yes
597        magick_version=magick6
598        AS_IF([test x"$with_magick_module" = x"no"],
599          [PACKAGES_USED="$PACKAGES_USED $with_magickpackage"])
600       ],
601       [AC_MSG_WARN([$with_magickpackage not found; disabling Magick support])
602        with_magick=no
603        with_magick_module=no
604       ]
605     )
606    ]
607  )
608else
609  with_magick=no
610  with_magick_module=no
611  magick6=no
612  magick_version=none
613  with_magickpackage=none
614fi
615
616if test x"$magick6" = x"yes"; then
617  # do we have number_scenes in image_info ... imagemagick uses this
618  save_CFLAGS="$CFLAGS"
619  CFLAGS="$CFLAGS $MAGICK_CFLAGS"
620  AC_CHECK_MEMBER([struct _ImageInfo.number_scenes],
621    AC_DEFINE(HAVE_NUMBER_SCENES,1,
622              [define if your magick has ImageInfo.number_scenes.]),
623    [],
624    [#include <magick/api.h>])
625  CFLAGS="$save_CFLAGS"
626fi
627
628if test x"$magick6" = x"yes"; then
629  # the magick6 API varies a lot between magick versions, and between GM and IM
630  # set CFLAGS too, since CHECK_FUNCS will try to compile / link / run code.
631  save_LIBS="$LIBS"
632  save_CFLAGS="$CFLAGS"
633  LIBS="$LIBS $MAGICK_LIBS"
634  CFLAGS="$CFLAGS $MAGICK_CFLAGS"
635
636  AC_CHECK_FUNCS([InheritException AcquireExceptionInfo SetImageProperty SetImageExtent AcquireImage GetVirtualPixels ResetImageProfileIterator ResetImageAttributeIterator ResetImagePropertyIterator MagickCoreGenesis SetImageOption BlobToStringInfo OptimizePlusImageLayers OptimizeImageTransparency])
637
638  LIBS="$save_LIBS"
639  CFLAGS="$save_CFLAGS"
640fi
641
642if test x"$magick6" = x"yes"; then
643  save_CFLAGS="$CFLAGS"
644  CFLAGS="$CFLAGS $MAGICK_CFLAGS"
645
646  # the range of ColorspaceType has expanded several times
647  AC_COMPILE_IFELSE(
648    [AC_LANG_PROGRAM(
649      [#include <magick/api.h>],
650      [ColorspaceType colorspace = CMYColorspace]
651    )],
652    [AC_DEFINE(HAVE_CMYCOLORSPACE,1,
653         [define if your Magick has CMYColorspace.])
654    ]
655  )
656
657  AC_COMPILE_IFELSE(
658    [AC_LANG_PROGRAM(
659      [#include <magick/api.h>],
660      [ColorspaceType colorspace = HCLpColorspace]
661    )],
662    [AC_DEFINE(HAVE_HCLPCOLORSPACE,1,
663         [define if your Magick has HCLpColorspace.])
664    ]
665  )
666
667  # GetImageMagick() takes two args under GM, three under IM
668  AC_COMPILE_IFELSE(
669    [AC_LANG_PROGRAM(
670      [#include <magick/api.h>],
671      [(void)GetImageMagick(NULL, 0, NULL)]
672    )],
673    [AC_DEFINE(HAVE_GETIMAGEMAGICK3,1,
674         [define if your GetImageMagick() takes three arguments.])
675    ]
676  )
677
678  CFLAGS="$save_CFLAGS"
679fi
680
681# have flags to turn load and save off independently ... some people will want
682# save but not load, for example
683AC_ARG_ENABLE([magickload],
684  AS_HELP_STRING([--disable-magickload],
685                 [disable libMagic load (default: enabled)]))
686
687AC_ARG_ENABLE([magicksave],
688  AS_HELP_STRING([--disable-magicksave],
689                 [disable libMagic save (default: enabled)]))
690
691if test x"$enable_magicksave" != x"yes"; then
692  # we need ImportImagePixels ... GM is missing this sadly
693  save_LIBS="$LIBS"
694  LIBS="$LIBS $MAGICK_LIBS"
695  AC_CHECK_FUNCS(ImportImagePixels,[
696     AC_DEFINE(HAVE_IMPORTIMAGEPIXELS,1,
697               [define if you have ImportImagePixels.])
698   ],[]
699  )
700  AC_CHECK_FUNCS(ImagesToBlob,[
701     AC_DEFINE(HAVE_IMAGESTOBLOB,1,
702               [define if you have ImagesToBlob.])
703   ],[]
704  )
705  LIBS="$save_LIBS"
706fi
707
708if test x"$with_magick" != x"no"; then
709  if test x"$enable_magickload" != x"no"; then
710    AC_DEFINE(ENABLE_MAGICKLOAD,1,[define to enable load with libMagick])
711    enable_magickload=yes
712  fi
713
714  if test x"$enable_magicksave" != x"no"; then
715    AC_DEFINE(ENABLE_MAGICKSAVE,1,[define to enable save with libMagick])
716    enable_magicksave=yes
717  fi
718else
719  enable_magickload=no
720  enable_magicksave=no
721fi
722
723AS_IF([test x"$with_magick_module" = x"yes"],
724  [AC_DEFINE([MAGICK_MODULE], [1], [define to build libMagic as a dynamically loadable module.])],
725  [VIPS_CFLAGS="$VIPS_CFLAGS $MAGICK_CFLAGS"
726   VIPS_LIBS="$VIPS_LIBS $MAGICK_LIBS"])
727AM_CONDITIONAL(MAGICK_MODULE, [test x"$with_magick_module" = x"yes"])
728
729# orc
730AC_ARG_WITH([orc],
731  AS_HELP_STRING([--without-orc], [build without orc (default: test)]))
732
733if test x"$with_orc" != x"no"; then
734  # we use loadpw etc.
735  PKG_CHECK_MODULES(ORC, orc-0.4 >= 0.4.11,
736    [AC_DEFINE(HAVE_ORC,1,[define if you have orc-0.4.11 or later installed.])
737     with_orc=yes
738     PACKAGES_USED="$PACKAGES_USED orc-0.4"
739     save_LIBS="$LIBS"
740     LIBS="$LIBS $ORC_LIBS"
741     AC_CHECK_FUNCS(orc_program_get_error,
742       AC_DEFINE(HAVE_ORC_PROGRAM_GET_ERROR,1,
743              [define if your orc has orc_program_get_error.]))
744     LIBS="$save_LIBS"
745    ],
746    [AC_MSG_WARN([orc-0.4.11 or later not found; disabling orc support])
747     with_orc=no
748    ]
749  )
750fi
751
752# orc 0.4.30+ works with cf-protection, but 0.4.30 has a bug with multiple
753# definitions of OrcTargetPowerPCFlags, so insist on 0.4.31
754if test x"$with_orc" = x"yes"; then
755  PKG_CHECK_MODULES(ORC_CF_PROTECTION, orc-0.4 >= 0.4.31,
756    [AC_DEFINE(HAVE_ORC_CF_PROTECTION,1,
757               [define if your orc works with cf-protection.]
758     )
759    ],
760    [:
761    ]
762  )
763fi
764
765VIPS_CFLAGS="$VIPS_CFLAGS $ORC_CFLAGS"
766VIPS_LIBS="$VIPS_LIBS $ORC_LIBS"
767
768# lcms ... refuse to use lcms1
769AC_ARG_WITH([lcms],
770  AS_HELP_STRING([--without-lcms], [build without lcms (default: test)]))
771
772if test x"$with_lcms" != x"no"; then
773  PKG_CHECK_MODULES(LCMS, lcms2,
774    [AC_DEFINE(HAVE_LCMS2,1,[define if you have lcms2 installed.])
775     with_lcms="yes (lcms2)"
776     PACKAGES_USED="$PACKAGES_USED lcms2"
777    ],
778    [AC_MSG_WARN([lcms2 not found; disabling ICC profile support])
779     with_lcms=no
780    ]
781  )
782fi
783
784# we need a conditional for this to only compile in fallback profiles if lcms
785# is detected
786AM_CONDITIONAL(ENABLE_LCMS, [test x"$with_lcms" != x"no"])
787
788VIPS_CFLAGS="$VIPS_CFLAGS $LCMS_CFLAGS"
789VIPS_LIBS="$VIPS_LIBS $LCMS_LIBS"
790
791# OpenEXR
792AC_ARG_WITH([OpenEXR],
793  AS_HELP_STRING([--without-OpenEXR], [build without OpenEXR (default: test)]))
794
795# require 1.2.2 since 1.2.1 has a broken ImfCloseTiledInputFile()
796if test x"$with_OpenEXR" != x"no"; then
797  PKG_CHECK_MODULES(OPENEXR, OpenEXR >= 1.2.2,
798    [AC_DEFINE(HAVE_OPENEXR,1,[define if you have OpenEXR >= 1.2.2 installed.])
799     with_OpenEXR=yes
800     PACKAGES_USED="$PACKAGES_USED OpenEXR"
801    ],
802    [AC_MSG_WARN([OpenEXR not found; disabling OpenEXR support])
803     with_OpenEXR=no
804    ]
805  )
806fi
807
808VIPS_CFLAGS="$VIPS_CFLAGS $OPENEXR_CFLAGS"
809VIPS_LIBS="$VIPS_LIBS $OPENEXR_LIBS"
810
811# nifti
812AC_ARG_WITH([nifti],
813  AS_HELP_STRING([--without-nifti], [build without nifti (default: test)]))
814
815if test x"$with_nifti" != x"no"; then
816  FIND_NIFTI([
817     with_nifti=yes
818    ],[
819     with_nifti=no
820    ]
821  )
822fi
823
824VIPS_CFLAGS="$VIPS_CFLAGS $NIFTI_CFLAGS"
825VIPS_INCLUDES="$VIPS_INCLUDES $NIFTI_INCLUDES"
826VIPS_LIBS="$VIPS_LIBS $NIFTI_LIBS"
827
828# jpeg-xl
829AC_ARG_WITH([libjxl],
830  AS_HELP_STRING([--without-libjxl], [build without libjxl (default: test)]),
831  [with_libjxl=$withval],
832  [with_libjxl=$gmodule_with_flag])
833
834# libjxl as a dynamically loadable module
835AS_IF([test x"$with_libjxl" = x"module"],
836  [with_libjxl_module=$gmodule_supported_flag],
837  [with_libjxl_module=no])
838
839if test x"$with_libjxl" != x"no"; then
840  PKG_CHECK_MODULES(LIBJXL, libjxl_threads >= 0.5 libjxl >= 0.5,
841    [AC_DEFINE(HAVE_LIBJXL,1,[define if you have libjxl >= 0.5 installed.])
842     with_libjxl=yes
843     AS_IF([test x"$with_libjxl_module" = x"no"],
844       [PACKAGES_USED="$PACKAGES_USED libjxl"])
845    ],
846    [AC_MSG_WARN([libjxl not found; disabling libjxl support])
847     with_libjxl=no
848     with_libjxl_module=no
849    ]
850  )
851fi
852
853if test x"$with_libjxl" = x"yes"; then
854  save_LIBS="$LIBS"
855  LIBS="$LIBS $LIBJXL_LIBS"
856  # Introduced in 0.6
857  AC_CHECK_FUNCS(JxlEncoderInitBasicInfo,[
858     AC_DEFINE(HAVE_LIBJXL_JXLENCODERINITBASICINFO,1,
859               [define if you have JxlEncoderInitBasicInfo.])
860   ],[]
861  )
862  LIBS="$save_LIBS"
863fi
864
865
866AS_IF([test x"$with_libjxl_module" = x"yes"],
867  [AC_DEFINE([LIBJXL_MODULE], [1], [define to build libjxl as a dynamically loadable module.])],
868  [VIPS_CFLAGS="$VIPS_CFLAGS $LIBJXL_CFLAGS"
869   VIPS_LIBS="$VIPS_LIBS $LIBJXL_LIBS"])
870AM_CONDITIONAL(LIBJXL_MODULE, [test x"$with_libjxl_module" = x"yes"])
871
872# openjpeg
873AC_ARG_WITH([libopenjp2],
874  AS_HELP_STRING([--without-libopenjp2],
875                 [build without libopenjp2 (default: test)]))
876
877# 2.4 is the first one to have working threading and tiling
878if test x"$with_libopenjp2" != x"no"; then
879  PKG_CHECK_MODULES(LIBOPENJP2, libopenjp2 >= 2.4,
880    [AC_DEFINE(HAVE_LIBOPENJP2,1,
881       [define if you have libopenjp2 >= 2.4 installed.])
882     with_libopenjp2=yes
883     PACKAGES_USED="$PACKAGES_USED libopenjp2"
884    ],
885    [AC_MSG_WARN([libopenjp2 not found; disabling libopenjp2 support])
886     with_libopenjp2=no
887    ]
888  )
889fi
890
891VIPS_CFLAGS="$VIPS_CFLAGS $LIBOPENJP2_CFLAGS"
892VIPS_INCLUDES="$VIPS_INCLUDES $LIBOPENJP2_INCLUDES"
893VIPS_LIBS="$VIPS_LIBS $LIBOPENJP2_LIBS"
894
895# libheif
896AC_ARG_WITH([heif],
897  AS_HELP_STRING([--without-heif], [build without libheif (default: test)]),
898  [with_heif=$withval],
899  [with_heif=$gmodule_with_flag])
900
901# libheif as a dynamically loadable module
902AS_IF([test x"$with_heif" = x"module"],
903  [with_heif_module=$gmodule_supported_flag],
904  [with_heif_module=no])
905
906if test x"$with_heif" != x"no"; then
907  PKG_CHECK_MODULES(HEIF, libheif >= 1.3.0,
908    [with_heif=yes
909     PKG_CHECK_VAR([have_h265_decoder], [libheif], [builtin_h265_decoder])
910     PKG_CHECK_VAR([have_avif_decoder], [libheif], [builtin_avif_decoder])
911     # test for !=no so that we work for older libheif which does not have
912     # this variable
913     if test x"$have_h265_decoder" != x"no" -o x"$have_avif_decoder" = x"yes"; then
914        AC_DEFINE(HAVE_HEIF_DECODER,1,
915             [define if your libheif has decode support.])
916     fi
917     PKG_CHECK_VAR([have_h265_encoder], [libheif], [builtin_h265_encoder])
918     PKG_CHECK_VAR([have_avif_encoder], [libheif], [builtin_avif_encoder])
919     if test x"$have_h265_encoder" != x"no" -o x"$have_avif_encoder" = x"yes"; then
920        AC_DEFINE(HAVE_HEIF_ENCODER,1,
921             [define if your libheif has encode support.])
922     fi
923     AS_IF([test x"$with_heif_module" = x"no"],
924       [PACKAGES_USED="$PACKAGES_USED libheif"])
925    ],
926    [AC_MSG_WARN([libheif >= 1.3.0 not found; disabling HEIF support])
927     with_heif=no
928     with_heif_module=no
929     have_h265_decoder=
930     have_h265_encoder=
931     have_avif_decoder=
932     have_avif_encoder=
933    ]
934  )
935fi
936
937AS_IF([test x"$with_heif_module" = x"yes"],
938  [AC_DEFINE([HEIF_MODULE], [1], [define to build libheif as a dynamically loadable module.])],
939  [VIPS_CFLAGS="$VIPS_CFLAGS $HEIF_CFLAGS"
940   VIPS_LIBS="$VIPS_LIBS $HEIF_LIBS"])
941AM_CONDITIONAL(HEIF_MODULE, [test x"$with_heif_module" = x"yes"])
942
943# color profile support added in 1.3.3
944if test x"$with_heif" = x"yes"; then
945  save_LIBS="$LIBS"
946  LIBS="$LIBS $HEIF_LIBS"
947  AC_CHECK_FUNCS(heif_image_handle_get_raw_color_profile,[
948     AC_DEFINE(HAVE_HEIF_COLOR_PROFILE,1,
949               [define if you have heif_image_handle_get_raw_color_profile.])
950   ],[]
951  )
952  LIBS="$save_LIBS"
953fi
954
955# heif_main_brand added in 1.4.0, but heif_avif appeared in 1.7 ... just check
956# the libheif version number since testing for enums is annoying
957if test x"$with_heif" = x"yes"; then
958  PKG_CHECK_MODULES(HEIF_AVIF, libheif >= 1.7.0, [
959    AC_DEFINE(HAVE_HEIF_AVIF,1,[define if you have heif_avif.])
960  ], [
961  ])
962fi
963
964# heif_decoding_options.convert_hdr_to_8bit added in 1.7.0
965if test x"$with_heif" = x"yes"; then
966  save_CFLAGS="$CFLAGS"
967  CFLAGS="$CFLAGS $HEIF_CFLAGS"
968  AC_CHECK_MEMBER([struct heif_decoding_options.convert_hdr_to_8bit],[
969     AC_DEFINE(HAVE_HEIF_DECODING_OPTIONS_CONVERT_HDR_TO_8BIT,1,
970               [define if you have heif_decoding_options.convert_hdr_to_8bit])
971   ],[],
972   [#include <libheif/heif.h>])
973  CFLAGS="$save_CFLAGS"
974fi
975
976# pdfium
977AC_ARG_WITH([pdfium],
978  AS_HELP_STRING([--without-pdfium], [build without pdfium (default: test)]))
979
980# pick 4200 as the starting version number ... no reason, really, it'd
981# probably work with much older versions
982if test x"$with_pdfium" != x"no"; then
983  PKG_CHECK_MODULES(PDFIUM, pdfium >= 4200, [
984    AC_DEFINE(HAVE_PDFIUM,1,[define if you have pdfium > 4200.])
985    if test x"$with_poppler" != x"no"; then
986      AC_MSG_WARN([PDFium found, disabling poppler])
987      with_poppler=no
988    fi
989    with_pdfium=yes
990    PACKAGES_USED="$PACKAGES_USED pdfium"
991  ], [
992    with_pdfium=no
993  ])
994fi
995
996VIPS_CFLAGS="$VIPS_CFLAGS $PDFIUM_CFLAGS"
997VIPS_LIBS="$VIPS_LIBS $PDFIUM_LIBS"
998
999# poppler
1000AC_ARG_WITH([poppler],
1001  AS_HELP_STRING([--without-poppler], [build without poppler (default: test)]),
1002  [with_poppler=$withval],
1003  [with_poppler=$gmodule_with_flag])
1004
1005# poppler as a dynamically loadable module
1006AS_IF([test x"$with_poppler" = x"module"],
1007  [with_poppler_module=$gmodule_supported_flag],
1008  [with_poppler_module=no])
1009
1010if test x"$with_poppler" != x"no"; then
1011  PKG_CHECK_MODULES(POPPLER, [poppler-glib >= 0.16.0 cairo >= 1.2], [
1012    AC_DEFINE(HAVE_POPPLER,1,[define if you have poppler-glib >= 0.16.0 and cairo >= 1.2 installed.])
1013    with_poppler=yes
1014    AS_IF([test x"$with_poppler_module" = x"no"],
1015      [PACKAGES_USED="$PACKAGES_USED poppler-glib cairo"])
1016  ], [
1017    AC_MSG_WARN([poppler-glib >= 0.16.0 or cairo >= 1.2 not found; disabling PDF load via poppler])
1018    with_poppler=no
1019    with_poppler_module=no
1020  ])
1021fi
1022
1023AS_IF([test x"$with_poppler_module" = x"yes"],
1024  [AC_DEFINE([POPPLER_MODULE], [1], [define to build poppler as a dynamically loadable module.])],
1025  [VIPS_CFLAGS="$VIPS_CFLAGS $POPPLER_CFLAGS"
1026   VIPS_LIBS="$VIPS_LIBS $POPPLER_LIBS"])
1027AM_CONDITIONAL(POPPLER_MODULE, [test x"$with_poppler_module" = x"yes"])
1028
1029# librsvg
1030AC_ARG_WITH([rsvg],
1031  AS_HELP_STRING([--without-rsvg], [build without rsvg (default: test)]))
1032
1033# 2.40.3 so we get the UNLIMITED open flag
1034if test x"$with_rsvg" != x"no"; then
1035  PKG_CHECK_MODULES(RSVG, [librsvg-2.0 >= 2.40.3 cairo >= 1.2], [
1036    AC_DEFINE(HAVE_RSVG,1,[define if you have librsvg-2.0 >= 2.40.3 and cairo >= 1.2 installed.])
1037    with_rsvg=yes
1038    PACKAGES_USED="$PACKAGES_USED librsvg-2.0 cairo"
1039
1040    # 2.46 for rsvg_handle_render_document
1041    PKG_CHECK_MODULES(RSVG_HANDLE_RENDER_DOCUMENT, librsvg-2.0 >= 2.46,
1042      [AC_DEFINE(HAVE_RSVG_HANDLE_RENDER_DOCUMENT,1,[define if your librsvg has rsvg_handle_render_document().])
1043      ],
1044      [:
1045      ]
1046    )
1047  ], [
1048    AC_MSG_WARN([librsvg-2.0 >= 2.40.3 or cairo >= 1.2 not found; disabling SVG load via rsvg])
1049    with_rsvg=no
1050  ])
1051fi
1052
1053VIPS_CFLAGS="$VIPS_CFLAGS $RSVG_CFLAGS"
1054VIPS_LIBS="$VIPS_LIBS $RSVG_LIBS"
1055
1056# zlib
1057# some platforms, like macosx, are missing the .pc files for zlib, so
1058# we fall back to FIND_ZLIB
1059AC_ARG_WITH([zlib],
1060  AS_HELP_STRING([--without-zlib], [build without zlib (default: test)]))
1061
1062if test x"$with_zlib" != x"no"; then
1063  PKG_CHECK_MODULES(ZLIB, zlib >= 0.4,
1064    [AC_DEFINE(HAVE_ZLIB,1,[define if you have zlib installed.])
1065     with_zlib=yes
1066     PACKAGES_USED="$PACKAGES_USED zlib"
1067    ],
1068    [FIND_ZLIB(
1069       [with_zlib="yes (found by search)"
1070       ],
1071       [AC_MSG_WARN([zlib not found; disabling SVGZ buffer support])
1072        with_zlib=no
1073       ]
1074     )
1075    ]
1076  )
1077fi
1078
1079VIPS_CFLAGS="$VIPS_CFLAGS $ZLIB_CFLAGS"
1080VIPS_INCLUDES="$VIPS_INCLUDES $ZLIB_INCLUDES"
1081VIPS_LIBS="$VIPS_LIBS $ZLIB_LIBS"
1082
1083# OpenSlide
1084AC_ARG_WITH([openslide],
1085  AS_HELP_STRING([--without-openslide],
1086    [build without OpenSlide (default: test)]),
1087  [with_openslide=$withval],
1088  [with_openslide=$gmodule_with_flag])
1089
1090# OpenSlide as a dynamically loadable module
1091AS_IF([test x"$with_openslide" = x"module"],
1092  [with_openslide_module=$gmodule_supported_flag],
1093  [with_openslide_module=no])
1094
1095if test x"$with_openslide" != x"no"; then
1096  PKG_CHECK_MODULES(OPENSLIDE, [openslide >= 3.4.0],
1097    [AC_DEFINE(HAVE_OPENSLIDE_3_4,1,[define if you have OpenSlide >= 3.4.0 installed.])
1098     AC_DEFINE(HAVE_OPENSLIDE,1,[define if you have OpenSlide >= 3.3.0 installed.])
1099     with_openslide=yes
1100     AS_IF([test x"$with_openslide_module" = x"no"],
1101       [PACKAGES_USED="$PACKAGES_USED openslide"])
1102    ],
1103    [AC_MSG_NOTICE([OpenSlide >= 3.4.0 not found; checking for >= 3.3.0])
1104     PKG_CHECK_MODULES(OPENSLIDE, [openslide >= 3.3.0],
1105       [AC_DEFINE(HAVE_OPENSLIDE,1,[define if you have OpenSlide >= 3.3.0 installed.])
1106        with_openslide=yes
1107        AS_IF([test x"$with_openslide_module" = x"no"],
1108          [PACKAGES_USED="$PACKAGES_USED openslide"])
1109       ],
1110       [AC_MSG_WARN([OpenSlide >= 3.3.0 not found; disabling virtual slide support])
1111        with_openslide=no
1112        with_openslide_module=no
1113       ]
1114     )
1115    ]
1116  )
1117fi
1118
1119AS_IF([test x"$with_openslide_module" = x"yes"],
1120  [AC_DEFINE([OPENSLIDE_MODULE], [1], [define to build OpenSlide as a dynamically loadable module.])],
1121  [VIPS_CFLAGS="$VIPS_CFLAGS $OPENSLIDE_CFLAGS"
1122   VIPS_LIBS="$VIPS_LIBS $OPENSLIDE_LIBS"])
1123AM_CONDITIONAL(OPENSLIDE_MODULE, [test x"$with_openslide_module" = x"yes"])
1124
1125# matio
1126AC_ARG_WITH([matio],
1127  AS_HELP_STRING([--without-matio], [build without matio (default: test)]))
1128
1129if test x"$with_matio" != x"no"; then
1130  PKG_CHECK_MODULES(MATIO, matio,
1131    [AC_DEFINE(HAVE_MATIO,1,[define if you have matio installed.])
1132     with_matio=yes
1133     PACKAGES_USED="$PACKAGES_USED matio"
1134    ],
1135    [AC_MSG_WARN([matio not found; disabling matio support])
1136     with_matio=no
1137    ]
1138  )
1139fi
1140
1141VIPS_CFLAGS="$VIPS_CFLAGS $MATIO_CFLAGS"
1142VIPS_LIBS="$VIPS_LIBS $MATIO_LIBS"
1143
1144# not external libraries, but have options to disable them, helps to
1145# reduce attack surface
1146
1147AC_ARG_WITH([nsgif],
1148  AS_HELP_STRING([--without-nsgif], [build without nsgif load (default: with)]))
1149
1150if test x"$with_nsgif" != x"no"; then
1151  AC_DEFINE(HAVE_NSGIF,1,[define to build nsgif load support.])
1152  with_nsgif=yes
1153fi
1154
1155AM_CONDITIONAL(ENABLE_NSGIF, [test x"$with_nsgif" = x"yes"])
1156
1157AC_ARG_WITH([ppm],
1158  AS_HELP_STRING([--without-ppm], [build without ppm (default: with)]))
1159
1160if test x"$with_ppm" != x"no"; then
1161  AC_DEFINE(HAVE_PPM,1,[define to build ppm support.])
1162  with_ppm=yes
1163fi
1164
1165AC_ARG_WITH([analyze],
1166  AS_HELP_STRING([--without-analyze], [build without analyze (default: with)]))
1167
1168if test x"$with_analyze" != x"no"; then
1169  AC_DEFINE(HAVE_ANALYZE,1,[define to build analyze support.])
1170  with_analyze=yes
1171fi
1172
1173AC_ARG_WITH([radiance],
1174  AS_HELP_STRING([--without-radiance], [build without radiance (default: with)]))
1175
1176if test x"$with_radiance" != x"no"; then
1177  AC_DEFINE(HAVE_RADIANCE,1,[define to build radiance support.])
1178  with_radiance=yes
1179fi
1180
1181# cfitsio
1182AC_ARG_WITH([cfitsio],
1183  AS_HELP_STRING([--without-cfitsio], [build without cfitsio (default: test)]))
1184
1185if test x"$with_cfitsio" != x"no"; then
1186  PKG_CHECK_MODULES(CFITSIO, cfitsio,
1187    [AC_DEFINE(HAVE_CFITSIO,1,[define if you have cfitsio installed.])
1188     with_cfitsio=yes
1189     PACKAGES_USED="$PACKAGES_USED cfitsio"
1190    ],
1191    [AC_MSG_WARN([cfitsio not found; disabling cfitsio support])
1192     with_cfitsio=no
1193    ]
1194  )
1195fi
1196
1197VIPS_CFLAGS="$VIPS_CFLAGS $CFITSIO_CFLAGS"
1198VIPS_LIBS="$VIPS_LIBS $CFITSIO_LIBS"
1199
1200# libwebp ... target 0.6+ to reduce complication
1201# webp has the stuff for handling metadata in two separate libraries  -- we
1202# insit on having all of them
1203AC_ARG_WITH([libwebp],
1204  AS_HELP_STRING([--without-libwebp], [build without libwebp (default: test)]))
1205
1206if test x"$with_libwebp" != x"no"; then
1207  PKG_CHECK_MODULES(LIBWEBP, libwebp >= 0.6 libwebpmux >= 0.6 libwebpdemux >= 0.6,
1208    [AC_DEFINE(HAVE_LIBWEBP,1,[define if you have libwebp/libwebpmux/libwebpdemux installed.])
1209     with_libwebp=yes
1210     PACKAGES_USED="$PACKAGES_USED libwebp libwebpmux libwebpdemux"
1211    ],
1212    [AC_MSG_WARN([libwebp, mux, demux not found; disabling WEBP support])
1213     with_libwebp=no
1214    ]
1215  )
1216fi
1217
1218VIPS_CFLAGS="$VIPS_CFLAGS $LIBWEBP_CFLAGS"
1219VIPS_LIBS="$VIPS_LIBS $LIBWEBP_LIBS"
1220
1221# pangocairo for text rendering
1222AC_ARG_WITH([pangocairo],
1223  AS_HELP_STRING([--without-pangocairo],
1224    [build without pangocairo (default: test)]))
1225
1226if test x"$with_pangocairo" != x"no"; then
1227  PKG_CHECK_MODULES(PANGOCAIRO, pangocairo,
1228    [AC_DEFINE(HAVE_PANGOCAIRO,1,[define if you have pangocairo installed.])
1229     with_pangocairo=yes
1230     PACKAGES_USED="$PACKAGES_USED pangocairo"
1231    ],
1232    [AC_MSG_WARN([pangocairo not found; disabling pangocairo support])
1233     with_pangocairo=no
1234    ]
1235  )
1236fi
1237
1238VIPS_CFLAGS="$VIPS_CFLAGS $PANGOCAIRO_CFLAGS"
1239VIPS_LIBS="$VIPS_LIBS $PANGOCAIRO_LIBS"
1240
1241# font file support with fontconfig
1242AC_ARG_WITH([fontconfig],
1243  AS_HELP_STRING([--without-fontconfig],
1244    [build without fontconfig (default: test)]))
1245
1246if test x"$with_pangocairo" != x"no" -a x"$with_fontconfig" != x"no"; then
1247  PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
1248    [AC_DEFINE(HAVE_FONTCONFIG,1,[define if you have fontconfig installed.])
1249     with_fontconfig=yes
1250     PACKAGES_USED="$PACKAGES_USED fontconfig"
1251    ],
1252    [AC_MSG_WARN([fontconfig not found; disabling fontconfig support])
1253     with_fontconfig=no
1254    ]
1255  )
1256fi
1257
1258VIPS_CFLAGS="$VIPS_CFLAGS $FONTCONFIG_CFLAGS"
1259VIPS_LIBS="$VIPS_LIBS $FONTCONFIG_LIBS"
1260
1261# look for TIFF with pkg-config ... fall back to our tester
1262# pkgconfig support for libtiff starts with libtiff-4
1263AC_ARG_WITH([tiff],
1264  AS_HELP_STRING([--without-tiff], [build without libtiff (default: test)]))
1265
1266if test x"$with_tiff" != x"no"; then
1267  PKG_CHECK_MODULES(TIFF, libtiff-4,
1268    [AC_DEFINE(HAVE_TIFF,1,[define if you have libtiff installed.])
1269     with_tiff="yes (pkg-config libtiff-4)"
1270     PACKAGES_USED="$PACKAGES_USED libtiff-4"
1271    ],
1272    [FIND_TIFF(
1273       with_tiff="yes (found by search)",
1274       [AC_MSG_WARN([libtiff not found; disabling TIFF support])
1275        with_tiff=no
1276       ]
1277     )
1278    ]
1279  )
1280fi
1281
1282# ZSTD and WEBP in TIFF added in libtiff 4.0.10
1283if test x"$with_tiff" != x"no"; then
1284  save_INCLUDES="$INCLUDES"
1285  INCLUDES="$INCLUDES $TIFF_INCLUDES"
1286  AC_CHECK_DECL(COMPRESSION_WEBP,[
1287      AC_DEFINE(HAVE_TIFF_COMPRESSION_WEBP,1,[define if your libtiff has webp.])
1288    ],[
1289    ],[
1290      [#include <tiffio.h>]
1291    ]
1292  )
1293  INCLUDES="$save_INCLUDES"
1294fi
1295
1296VIPS_CFLAGS="$VIPS_CFLAGS $TIFF_CFLAGS"
1297VIPS_INCLUDES="$VIPS_INCLUDES $TIFF_INCLUDES"
1298VIPS_LIBS="$VIPS_LIBS $TIFF_LIBS"
1299
1300# Look for libspng first
1301# 0.6.1 uses "libspng.pc", git master libspng uses "spng.pc"
1302AC_ARG_WITH([libspng],
1303  AS_HELP_STRING([--without-libspng], [build without libspng (default: test)]))
1304
1305if test x"$with_libspng" != x"no"; then
1306  PKG_CHECK_MODULES(SPNG, libspng >= 0.6,
1307    [AC_DEFINE(HAVE_SPNG,1,[define if you have libspng installed.])
1308     with_libspng=yes
1309     PACKAGES_USED="$PACKAGES_USED libspng"
1310    ],
1311    [PKG_CHECK_MODULES(SPNG, spng >= 0.6,
1312      [AC_DEFINE(HAVE_SPNG,1,[define if you have libspng installed.])
1313       with_libspng=yes
1314       PACKAGES_USED="$PACKAGES_USED spng"
1315      ],
1316      [with_libspng=no
1317      ]
1318     )
1319    ]
1320  )
1321fi
1322
1323VIPS_CFLAGS="$VIPS_CFLAGS $SPNG_CFLAGS"
1324VIPS_LIBS="$VIPS_LIBS $SPNG_LIBS"
1325
1326# look for PNG with pkg-config ... fall back to our tester
1327# we can have both PNG and SPNG enabled, with SPNG for read and PNG for
1328# write
1329AC_ARG_WITH([png],
1330  AS_HELP_STRING([--without-png], [build without libpng (default: test)]))
1331
1332if test x"$with_png" != x"no"; then
1333  PKG_CHECK_MODULES(PNG, libpng >= 1.2.9,
1334    [AC_DEFINE(HAVE_PNG,1,[define if you have libpng installed.])
1335     with_png="yes (pkg-config libpng >= 1.2.9)"
1336     PACKAGES_USED="$PACKAGES_USED libpng"
1337    ],
1338    [FIND_PNG(
1339       [with_png="yes (found by search)"
1340       ],
1341       [AC_MSG_WARN([libpng not found; disabling PNG support])
1342        with_png=no
1343       ]
1344     )
1345    ]
1346  )
1347fi
1348
1349if test x"$with_png" != x"no"; then
1350  save_LIBS="$LIBS"
1351  save_CFLAGS="$CFLAGS"
1352  LIBS="$PNG_LIBS $LIBS"
1353  CFLAGS="$PNG_INCLUDES $CFLAGS"
1354  AC_CHECK_FUNCS(png_set_chunk_malloc_max,
1355    AC_DEFINE(HAVE_PNG_SET_CHUNK_MALLOC_MAX,1,
1356              [define if your libpng has png_set_chunk_malloc_max.]))
1357  LIBS="$save_LIBS"
1358  CFLAGS="$save_CFLAGS"
1359fi
1360
1361VIPS_CFLAGS="$VIPS_CFLAGS $PNG_CFLAGS"
1362VIPS_INCLUDES="$VIPS_INCLUDES $PNG_INCLUDES"
1363VIPS_LIBS="$VIPS_LIBS $PNG_LIBS"
1364
1365# look for libimagequant with pkg-config (only if libpng is enabled)
1366AC_ARG_WITH([imagequant],
1367  AS_HELP_STRING([--without-imagequant], [build without imagequant (default: test)]))
1368
1369if test x"$with_imagequant" != x"no"; then
1370  PKG_CHECK_MODULES(IMAGEQUANT, imagequant,
1371    [AC_DEFINE(HAVE_IMAGEQUANT,1,[define if you have imagequant installed.])
1372     with_imagequant=yes
1373     PACKAGES_USED="$PACKAGES_USED imagequant"
1374    ],
1375    [AC_MSG_WARN([libimagequant not found; disabling 8bpp PNG support])
1376     with_imagequant=no
1377    ]
1378  )
1379else
1380  with_imagequant=no
1381fi
1382
1383VIPS_CFLAGS="$VIPS_CFLAGS $IMAGEQUANT_CFLAGS"
1384VIPS_LIBS="$VIPS_LIBS $IMAGEQUANT_LIBS"
1385
1386# look for libjpeg with pkg-config ... fall back to our tester
1387AC_ARG_WITH([jpeg],
1388  AS_HELP_STRING([--without-jpeg], [build without libjpeg (default: test)]))
1389
1390if test x"$with_jpeg" != x"no"; then
1391  PKG_CHECK_MODULES(JPEG, libjpeg,
1392    [AC_DEFINE(HAVE_JPEG,1,[define if you have libjpeg installed.])
1393     with_jpeg="yes (pkg-config)"
1394     PACKAGES_USED="$PACKAGES_USED libjpeg"
1395    ],
1396    [FIND_JPEG(
1397       [with_jpeg="yes (found by search)"
1398        EXTRA_LIBS_USED="$EXTRA_LIBS_USED -ljpeg"
1399       ],
1400       [AC_MSG_WARN([libjpeg not found; disabling JPEG support])
1401        with_jpeg=no
1402       ]
1403     )
1404    ]
1405  )
1406fi
1407
1408# features like trellis quant are exposed as extension parameters ...
1409# mozjpeg 3.2 and later have #define JPEG_C_PARAM_SUPPORTED, but we must
1410# work with earlier versions
1411if test x"$with_jpeg" != x"no"; then
1412  save_LIBS="$LIBS"
1413  save_CFLAGS="$CFLAGS"
1414  LIBS="$JPEG_LIBS $LIBS"
1415  CFLAGS="$JPEG_INCLUDES $CFLAGS"
1416  AC_CHECK_FUNCS(jpeg_c_bool_param_supported,
1417    AC_DEFINE(HAVE_JPEG_EXT_PARAMS,1,
1418              [define if your libjpeg has extension parameters.]))
1419  LIBS="$save_LIBS"
1420  CFLAGS="$save_CFLAGS"
1421fi
1422
1423VIPS_CFLAGS="$VIPS_CFLAGS $JPEG_CFLAGS"
1424VIPS_INCLUDES="$VIPS_INCLUDES $JPEG_INCLUDES"
1425VIPS_LIBS="$VIPS_LIBS $JPEG_LIBS"
1426
1427# libexif
1428AC_ARG_WITH([libexif],
1429  AS_HELP_STRING([--without-libexif], [build without libexif (default: test)]))
1430
1431if test x"$with_libexif" != x"no"; then
1432  PKG_CHECK_MODULES(EXIF, libexif >= 0.6,
1433    [AC_DEFINE(HAVE_EXIF,1,[define if you have libexif >= 0.6 installed.])
1434     with_libexif=yes
1435     PACKAGES_USED="$PACKAGES_USED libexif"
1436    ],
1437    [AC_MSG_WARN([libexif >= 0.6 not found; disabling exif support])
1438     with_libexif=no
1439    ]
1440  )
1441fi
1442
1443# some libexif packages need include <libexif/poop.h>, some just <poop.h>
1444# how annoying
1445if test x"$with_libexif" != x"no"; then
1446  # cppflags not cflags because we want the preproc to see the -I as well
1447  save_CPPFLAGS="$CPPFLAGS"
1448  CPPFLAGS="$EXIF_CFLAGS $CPPFLAGS"
1449  AC_CHECK_HEADER(exif-data.h,
1450    AC_DEFINE(UNTAGGED_EXIF,1,[libexif includes don't need libexif prefix]))
1451  CPPFLAGS="$save_CPPFLAGS"
1452fi
1453
1454VIPS_CFLAGS="$VIPS_CFLAGS $EXIF_CFLAGS"
1455VIPS_LIBS="$VIPS_LIBS $EXIF_LIBS"
1456
1457# GIF save with libcgif (requires libimagequant also)
1458AC_ARG_WITH([cgif],
1459  AS_HELP_STRING([--without-cgif], [build without cgif (default: test)]))
1460
1461if test x"$with_imagequant" == x"yes" && test x"$with_cgif" != x"no"; then
1462  PKG_CHECK_MODULES(CGIF, cgif,
1463    [AC_DEFINE(HAVE_CGIF,1,[define if you have cgif installed.])
1464      with_cgif=yes
1465      PACKAGES_USED="$PACKAGES_USED cgif"
1466    ],
1467    [AC_MSG_WARN([libcgif not found])
1468      with_cgif=no
1469    ]
1470  )
1471else
1472  with_cgif=no
1473fi
1474
1475VIPS_CFLAGS="$VIPS_CFLAGS $CGIF_CFLAGS"
1476VIPS_LIBS="$VIPS_LIBS $CGIF_LIBS"
1477
1478# fuzzing
1479AC_ARG_VAR([LIB_FUZZING_ENGINE],
1480           [fuzzing library, e.g. /path/to/libFuzzer.a])
1481if test x"$LIB_FUZZING_ENGINE" = x; then
1482  LIB_FUZZING_ENGINE="libstandaloneengine.a"
1483fi
1484
1485VIPS_CFLAGS="$VIPS_CFLAGS $VIPS_DEBUG_FLAGS $REQUIRED_CFLAGS"
1486VIPS_LIBS="$VIPS_LIBS $REQUIRED_LIBS -lm"
1487
1488# build options relevant at runtime ... this becomes `vips --vips-config`
1489# output
1490VIPS_CONFIG="\
1491enable debug: $enable_debug, \
1492enable deprecated library components: $enable_deprecated, \
1493enable modules: $gmodule_supported_flag, \
1494use fftw3 for FFT: $with_fftw, \
1495accelerate loops with orc: $with_orc, \
1496ICC profile support with lcms: $with_lcms, \
1497zlib: $with_zlib, \
1498text rendering with pangocairo: $with_pangocairo, \
1499font file support with fontconfig: $with_fontconfig, \
1500RAD load/save: $with_radiance, \
1501Analyze7 load/save: $with_analyze, \
1502PPM load/save: $with_ppm, \
1503GIF load:  $with_nsgif, \
1504EXIF metadata support with libexif: $with_libexif, \
1505JPEG load/save with libjpeg: $with_jpeg, \
1506JXL load/save with libjxl: $with_libjxl (dynamic module: $with_libjxl_module), \
1507JPEG2000 load/save with libopenjp2: $with_libopenjp2, \
1508PNG load with libspng: $with_libspng, \
1509PNG load/save with libpng: $with_png, \
1510quantisation to 8 bit: $with_imagequant, \
1511TIFF load/save with libtiff: $with_tiff, \
1512image pyramid save: $with_gsf, \
1513HEIC/AVIF load/save with libheif: $with_heif (dynamic module: $with_heif_module), \
1514WebP load/save with libwebp: $with_libwebp, \
1515PDF load with PDFium:  $with_pdfium, \
1516PDF load with poppler-glib: $with_poppler (dynamic module: $with_poppler_module), \
1517SVG load with librsvg-2.0: $with_rsvg, \
1518EXR load with OpenEXR: $with_OpenEXR, \
1519OpenSlide load: $with_openslide (dynamic module: $with_openslide_module), \
1520Matlab load with matio: $with_matio, \
1521NIfTI load/save with niftiio: $with_nifti, \
1522FITS load/save with cfitsio: $with_cfitsio, \
1523GIF save with cgif: $with_cgif, \
1524Magick package: $with_magickpackage (dynamic module: $with_magick_module), \
1525Magick API version: $magick_version, \
1526load with libMagickCore: $enable_magickload, \
1527save with libMagickCore: $enable_magicksave"
1528
1529AC_SUBST(VIPS_LIBDIR)
1530
1531AC_SUBST(VIPS_CFLAGS)
1532AC_SUBST(VIPS_INCLUDES)
1533AC_SUBST(VIPS_LIBS)
1534AC_SUBST(VIPS_CONFIG)
1535AC_SUBST(PACKAGES_USED)
1536AC_SUBST(EXTRA_LIBS_USED)
1537
1538AC_CONFIG_FILES([
1539        vips.pc
1540        vips-cpp.pc
1541        Makefile
1542        $srcdir/libvips/include/vips/version.h
1543        libvips/include/Makefile
1544        libvips/include/vips/Makefile
1545        libvips/Makefile
1546        libvips/arithmetic/Makefile
1547        libvips/colour/Makefile
1548        libvips/colour/profiles/Makefile
1549        libvips/conversion/Makefile
1550        libvips/convolution/Makefile
1551        libvips/deprecated/Makefile
1552        libvips/foreign/Makefile
1553        libvips/foreign/libnsgif/Makefile
1554        libvips/freqfilt/Makefile
1555        libvips/histogram/Makefile
1556        libvips/draw/Makefile
1557        libvips/iofuncs/Makefile
1558        libvips/module/Makefile
1559        libvips/morphology/Makefile
1560        libvips/mosaicing/Makefile
1561        libvips/create/Makefile
1562        libvips/resample/Makefile
1563        cplusplus/Doxyfile
1564        cplusplus/include/Makefile
1565        cplusplus/include/vips/Makefile
1566        cplusplus/Makefile
1567        tools/Makefile
1568        tools/batch_crop
1569        tools/batch_image_convert
1570        tools/batch_rubber_sheet
1571        tools/light_correct
1572        tools/shrink_width
1573        test/Makefile
1574        test/variables.sh
1575        test/test-suite/Makefile
1576        test/test-suite/helpers/Makefile
1577        man/Makefile
1578        doc/Makefile
1579        doc/libvips-docs.xml
1580        po/Makefile.in
1581        fuzz/Makefile
1582])
1583AC_OUTPUT
1584
1585# also add any new items to VIPS_CONFIG above
1586AC_MSG_RESULT([dnl
1587## Build options
1588enable debug:                           $enable_debug
1589enable deprecated library components:   $enable_deprecated
1590enable modules:                         $gmodule_supported_flag
1591enable C docs with gtkdoc:              $enable_gtk_doc
1592 (requires gtk-doc 1.14 or later)
1593enable C++ docs with doxygen:           $enable_doxygen
1594gobject introspection:                  $found_introspection
1595 (requires gobject-introspection 1.30 or later)
1596RAD load/save:                          $with_radiance
1597Analyze7 load/save:                     $with_analyze
1598PPM load/save:                          $with_ppm
1599GIF load:                               $with_nsgif
1600
1601## Optional dependencies
1602use fftw3 for FFT:                      $with_fftw
1603accelerate loops with orc:              $with_orc
1604 (requires orc-0.4.11 or later)
1605ICC profile support with lcms:          $with_lcms
1606zlib:                                   $with_zlib
1607text rendering with pangocairo:         $with_pangocairo
1608font file support with fontconfig:      $with_fontconfig
1609EXIF metadata support with libexif:     $with_libexif
1610
1611## File format support
1612JPEG load/save with libjpeg:            $with_jpeg
1613JXL load/save with libjxl:              $with_libjxl (dynamic module: $with_libjxl_module)
1614JPEG2000 load/save with libopenjp2:     $with_libopenjp2
1615 (requires libopenjp2 2.4 or later)
1616PNG load with libspng:                  $with_libspng
1617 (requires libspng-0.6 or later)
1618PNG load/save with libpng:              $with_png
1619 (requires libpng-1.2.9 or later)
1620quantisation to 8 bit:                  $with_imagequant
1621 (requires libimagequant)
1622TIFF load/save with libtiff:            $with_tiff
1623image pyramid save:                     $with_gsf
1624 (requires libgsf-1 1.14.26 or later)
1625HEIC/AVIF load/save with libheif:       $with_heif (dynamic module: $with_heif_module)
1626WebP load/save with libwebp:            $with_libwebp
1627 (requires libwebp, libwebpmux, libwebpdemux 0.6.0 or later)
1628PDF load with PDFium:                   $with_pdfium
1629PDF load with poppler-glib:             $with_poppler (dynamic module: $with_poppler_module)
1630 (requires poppler-glib 0.16.0 or later)
1631SVG load with librsvg-2.0:              $with_rsvg
1632 (requires librsvg-2.0 2.34.0 or later)
1633EXR load with OpenEXR:                  $with_OpenEXR
1634OpenSlide support:                      $with_openslide (dynamic module: $with_openslide_module)
1635 (requires openslide-3.3.0 or later)
1636Matlab load with matio:                 $with_matio
1637NIfTI load/save with niftiio:           $with_nifti
1638FITS load/save with cfitsio:            $with_cfitsio
1639GIF save with cgif:                     $with_cgif
1640 (requires cgif, libimagequant)
1641Magick package:                         $with_magickpackage (dynamic module: $with_magick_module)
1642Magick major API version:               $magick_version
1643load with libMagickCore:                $enable_magickload
1644save with libMagickCore:                $enable_magicksave
1645])
1646