configure.ac 114 KB
Newer Older
cristy's avatar
cristy committed
1
#  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization
cristy's avatar
cristy committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#  dedicated to making software imaging solutions freely available.
#
#  You may not use this file except in compliance with the License.  You may
#  obtain a copy of the License at
#
#    http://www.imagemagick.org/script/license.php
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
#  Copyright (C) 2003 - 2008 GraphicsMagick Group

cristy's avatar
cristy committed
17
AC_PREREQ(2.64)
cristy's avatar
cristy committed
18
AC_INIT([ImageMagick],[6.6.4],[http://www.imagemagick.org],[ImageMagick])
cristy's avatar
cristy committed
19 20 21 22 23 24 25 26 27 28 29 30
AC_CONFIG_SRCDIR([magick/MagickCore.h])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_LIBOBJ_DIR([ltdl])
AC_CONFIG_HEADERS([config/config.h])
AX_PREFIX_CONFIG_H([magick/magick-config.h],[MagickCore])
AC_CONFIG_FILES([\
    config/configure.xml \
    config/delegates.xml \
    config/ImageMagick.rdf \
    config/MagickCore.dox \
    config/MagickWand.dox \
cristy's avatar
cristy committed
31
    config/type-dejavu.xml \
cristy's avatar
cristy committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    config/type-ghostscript.xml \
    config/type-windows.xml \
    config/type.xml \
    ImageMagick.spec \
    Magick++/bin/Magick++-config \
    magick/ImageMagick.pc \
    Magick++/lib/ImageMagick++.pc \
    Magick++/lib/Magick++.pc \
    magick/Magick-config \
    magick/MagickCore-config \
    magick/MagickCore.pc \
    magick/version.h \
    Makefile \
    magick.sh \
    PerlMagick/Magick.pm \
    PerlMagick/Makefile.PL \
    PerlMagick/check.sh \
    utilities/animate.1 \
    utilities/compare.1 \
    utilities/composite.1 \
    utilities/conjure.1 \
    utilities/convert.1 \
    utilities/display.1 \
    utilities/identify.1 \
    utilities/ImageMagick.1 \
    utilities/import.1 \
    utilities/mogrify.1 \
    utilities/montage.1 \
    utilities/stream.1 \
    wand/MagickWand-config \
    wand/MagickWand.pc \
    wand/Wand-config \
    wand/Wand.pc ])

#
# Save initial user-tunable values
#
USER_LIBS=$LIBS
for var in CC CFLAGS CPPFLAGS CXX CXXCPP LDFLAGS LIBS ; do
  eval isset=\${$var+set}
    if test "$isset" = 'set'; then
        eval val=$`echo $var`
        DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS}'${var}=${val}' "
    fi
done
AC_SUBST(DISTCHECK_CONFIG_FLAGS)

CONFIGURE_ARGS="$0 ${ac_configure_args}"
AC_SUBST(CONFIGURE_ARGS)

# Source file containing package/library versioning information.
. ${srcdir}/version.sh

cristy's avatar
cristy committed
85
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}${PACKAGE_VERSION_ADDENDUM}"
cristy's avatar
cristy committed
86
AC_CANONICAL_SYSTEM
cristy's avatar
cristy committed
87 88
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
cristy's avatar
cristy committed
89 90
AC_CANONICAL_TARGET([])

cristy's avatar
cristy committed
91 92 93 94 95 96 97 98 99
MAGICK_TARGET_CPU=$target_cpu
AC_SUBST(MAGICK_TARGET_CPU)

MAGICK_TARGET_VENDOR=$target_vendor
AC_SUBST(MAGICK_TARGET_VENDOR)

MAGICK_TARGET_OS=$target_os
AC_SUBST(MAGICK_TARGET_OS)

cristy's avatar
cristy committed
100 101 102 103
# Substitute library versioning
AC_SUBST(MAGICK_LIBRARY_CURRENT)dnl
AC_SUBST(MAGICK_LIBRARY_REVISION)dnl
AC_SUBST(MAGICK_LIBRARY_AGE)dnl
cristy's avatar
cristy committed
104 105 106 107
AC_SUBST([MAGICK_LIBRARY_CURRENT_MIN],
         [`expr $MAGICK_LIBRARY_CURRENT - $MAGICK_LIBRARY_AGE`])
AC_SUBST([MAGICK_LIBRARY_VERSION_INFO],
         [$MAGICK_LIBRARY_CURRENT:$MAGICK_LIBRARY_REVISION:$MAGICK_LIBRARY_AGE])
cristy's avatar
cristy committed
108 109 110 111 112 113 114 115

AC_SUBST(PACKAGE_NAME)dnl
AC_SUBST(PACKAGE_VERSION)dnl
AC_SUBST(PACKAGE_RELEASE)dnl
AC_SUBST(PACKAGE_CHANGE_DATE)dnl
AC_SUBST(PACKAGE_LIB_VERSION)dnl
AC_SUBST(PACKAGE_LIB_VERSION_NUMBER)dnl
AC_SUBST(PACKAGE_RELEASE_DATE)dnl
cristy's avatar
cristy committed
116
AC_SUBST(PACKAGE_VERSION_ADDENDUM)dnl
cristy's avatar
cristy committed
117 118 119 120

# Ensure that make can run correctly
AM_SANITY_CHECK

cristy's avatar
cristy committed
121
AM_INIT_AUTOMAKE($PACKAGE_NAME,"${PACKAGE_VERSION}${PACKAGE_VERSION_ADDENDUM}", ' ')
cristy's avatar
cristy committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158

# Enable support for silent build rules
AM_SILENT_RULES([yes])

MAGICK_LIB_VERSION="0x"
if test ${MAGICK_LIBRARY_CURRENT} -lt 10 ; then
  MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}0
fi
MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}${MAGICK_LIBRARY_CURRENT}
if test ${MAGICK_LIBRARY_AGE} -lt 10 ; then
  MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}0
fi
MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}${MAGICK_LIBRARY_AGE}
if test ${MAGICK_LIBRARY_REVISION} -lt 10 ; then
  MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}0
fi
MAGICK_LIB_VERSION=${MAGICK_LIB_VERSION}${MAGICK_LIBRARY_REVISION}
AC_SUBST(MAGICK_LIB_VERSION)

# Definition used to define MagickLibVersionText in version.h
MAGICK_LIB_VERSION_TEXT="${PACKAGE_VERSION}"
AC_SUBST(MAGICK_LIB_VERSION_TEXT)

# Definition used to define MagickLibVersionNumber in version.h
MAGICK_LIB_VERSION_NUMBER="${MAGICK_LIBRARY_CURRENT},${MAGICK_LIBRARY_AGE},${MAGICK_LIBRARY_REVISION}"
AC_SUBST(MAGICK_LIB_VERSION_NUMBER)

# Regenerate config.status if ChangeLog or version.sh is updated.
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/version.sh'])

PERLMAINCC=$CC

MAGICK_CFLAGS=''
MAGICK_CPPFLAGS=$CPPFLAGS_USER
MAGICK_PCFLAGS=$CPPFLAGS_USER
MAGICK_LDFLAGS=''
MAGICK_LIBS=''
cristy's avatar
cristy committed
159
MAGICK_FEATURES=''
cristy's avatar
cristy committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233

#
# Evaluate shell variable equivalents to Makefile directory variables
#
if test "x$prefix" = xNONE; then
    prefix=$ac_default_prefix
fi
# Let make expand exec_prefix.
if test "x$exec_prefix" = xNONE; then
    exec_prefix='${prefix}'
fi

#
eval "eval PREFIX_DIR=${prefix}"
AC_SUBST(PREFIX_DIR)
eval "eval EXEC_PREFIX_DIR=${exec_prefix}"
AC_SUBST(EXEC_PREFIX_DIR)
eval "eval BIN_DIR=$bindir"
AC_SUBST(BIN_DIR)
eval "eval SBIN_DIR=$sbindir"
AC_SUBST(SBIN_DIR)
eval "eval LIBEXEC_DIR=$libexecdir"
AC_SUBST(LIBEXEC_DIR)
eval "eval DATA_DIR=$datadir"
AC_SUBST(DATA_DIR)
eval "eval SYSCONF_DIR=$sysconfdir"
AC_SUBST(SYSCONF_DIR)
eval "eval SHAREDSTATE_DIR=$sharedstatedir"
AC_SUBST(SHAREDSTATE_DIR)
eval "eval LOCALSTATE_DIR=$localstatedir"
AC_SUBST(LOCALSTATE_DIR)
eval "eval LIB_DIR=$libdir"
AC_SUBST(LIB_DIR)
eval "eval INCLUDE_DIR=$includedir"
AC_SUBST(INCLUDE_DIR)
eval "eval PERSISTINCLUDE_DIR=$oldincludedir"
AC_SUBST(PERSISTINCLUDE_DIR)
eval "eval INFO_DIR=$infodir"
AC_SUBST(INFO_DIR)
eval "eval MAN_DIR=$mandir"
AC_SUBST(MAN_DIR)

# Get full paths to source and build directories
srcdirfull="`cd $srcdir && pwd`"
builddir="`pwd`"

#
# Compute variables useful for running uninstalled software.
#
MAGICK_CODER_MODULE_PATH="${builddir}/coders"
MAGICK_CONFIGURE_SRC_PATH="${srcdirfull}/config"
MAGICK_CONFIGURE_BUILD_PATH="${builddir}/config"
MAGICK_FILTER_MODULE_PATH="${builddir}/filters"
DIRSEP=':'
case "${build_os}" in
    mingw* )
        MAGICK_CODER_MODULE_PATH=`$WinPathScript "${MAGICK_CODER_MODULE_PATH}" 0`
        MAGICK_CONFIGURE_SRC_PATH=`$WinPathScript "${MAGICK_CONFIGURE_SRC_PATH}" 0`
        MAGICK_CONFIGURE_BUILD_PATH=`$WinPathScript "${MAGICK_CONFIGURE_BUILD_PATH}" 0`
        MAGICK_FILTER_MODULE_PATH=`$WinPathScript "${MAGICK_FILTER_MODULE_PATH}" 0`
        DIRSEP=';'
    ;;
esac
case "${host_os}" in
  mingw* )
    DIRSEP=';'
    ;;
esac
AC_SUBST(MAGICK_CODER_MODULE_PATH)
AC_SUBST(MAGICK_CONFIGURE_SRC_PATH)
AC_SUBST(MAGICK_CONFIGURE_BUILD_PATH)
AC_SUBST(MAGICK_FILTER_MODULE_PATH)
AC_SUBST(DIRSEP)

cristy's avatar
cristy committed
234 235 236 237 238 239

#
# Enable OS features.
#
AC_USE_SYSTEM_EXTENSIONS

cristy's avatar
cristy committed
240 241
# Check for programs
AC_PROG_CC
cristy's avatar
cristy committed
242
AC_PROG_CXX
cristy's avatar
cristy committed
243 244 245 246
AC_PROG_CC_STDC
AC_PROG_CPP
AC_PROG_LD
AC_SUBST(LD)
cristy's avatar
cristy committed
247
AC_PROG_CC_C99
cristy's avatar
cristy committed
248
AM_PROG_CC_C_O
cristy's avatar
cristy committed
249
AX_CFLAGS_WARN_ALL
cristy's avatar
cristy committed
250 251 252 253
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S
AM_WITH_DMALLOC
cristy's avatar
cristy committed
254
AX_C___ATTRIBUTE__
cristy's avatar
cristy committed
255
PKG_PROG_PKG_CONFIG
cristy's avatar
cristy committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

#
# Enable run-time checking.
#
AC_ARG_ENABLE([bounds-checking],
    [AC_HELP_STRING([--bounds-checking],
                    [enable run-time bounds-checking])],
    [enable_bounds_checking=$enableval],
    [enable_bounds_checking='no'])

if test "$enable_bounds_checking" = yes; then
  AC_DEFINE([_FORTIFY_SOURCE], [2],
    [enable run-time bounds-checking])
fi

#
# Tests for Windows
#
AC_EXEEXT
AC_OBJEXT
cristy's avatar
cristy committed
276
AX_LANG_COMPILER_MS
cristy's avatar
cristy committed
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350

GDI32_LIBS=''
native_win32_build='no'
cygwin_build='no'
case "${host_os}" in
    cygwin* )
        cygwin_build='yes'
        GDI32_LIBS='-lgdi32'
    ;;
    mingw* )
        native_win32_build='yes'
        GDI32_LIBS='-lgdi32'
    ;;
esac
if test "${GDI32_LIBS}x" != 'x'; then
    AC_DEFINE(WINGDI32_DELEGATE,1,Define to use the Windows GDI32 library)
fi
AC_SUBST(GDI32_LIBS)
AM_CONDITIONAL(WINGDI32_DELEGATE, test "${GDI32_LIBS}x" != 'x' )
AM_CONDITIONAL(WIN32_NATIVE_BUILD, test "${native_win32_build}" = 'yes' )
AM_CONDITIONAL(CYGWIN_BUILD, test "${cygwin_build}" = 'yes' )
AM_CONDITIONAL(USING_CL, test "x${CC}" = 'xcl.exe' )

WinPathScript="${srcdirfull}/winpath.sh"
AC_SUBST(WinPathScript)

#
# Compiler flags tweaks
#
if test "${GCC}" != "yes"; then
    case "${host}" in
        *-*-hpux* )
            # aCC: HP ANSI C++ B3910B A.03.34
            CFLAGS="${CFLAGS} -Wp,-H30000"
            if test -n "${CXXFLAGS}"; then
                CXXFLAGS='-AA'
            else
                CXXFLAGS="${CXXFLAGS} -AA"
            fi
        ;;
        *-dec-osf5.* )
            # Compaq alphaev68-dec-osf5.1 compiler
            if test -n "${CXXFLAGS}"; then
                CXXFLAGS='-std strict_ansi -noimplicit_include'
            else
                CXXFLAGS="${CXXFLAGS} -std strict_ansi -noimplicit_include"
            fi
  esac
fi

# Check for lazy-loading.
AC_CACHE_CHECK([for linker lazyload option],[im_cv_ld_lazyload],
[
im_cv_ld_lazyload='none'
case "${host}" in
  *-*-solaris2.8 | *-*-solaris2.9 | *-*-solaris2.1? )
    if test "$lt_cv_prog_gnu_ld" != 'yes' ; then
       im_cv_ld_lazyload='-Wl,-zlazyload'
    fi
    ;;
esac
])
if test "${im_cv_ld_lazyload}" != 'none' ; then
  if test -z "${LDFLAGS}" ; then
    LDFLAGS="${im_cv_ld_lazyload}"
  else
    LDFLAGS="${im_cv_ld_lazyload} ${LDFLAGS}"
  fi
fi

dnl Platform-specific stuff
case "$host" in
*darwin* | *-macos10*)
  dnl OS X universal binary support, requires --disable-dependency-tracking
cristy's avatar
cristy committed
351
  AC_ARG_ENABLE([osx-universal-binary],
cristy's avatar
cristy committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
        AC_HELP_STRING([--enable-osx-universal-binary],
           [build universal binary on OS X [[default=no]]]),
        [build_osxuniversal="${enableval}"], [build_osxuniversal=no])

  if test "${build_osxuniversal}" != no ; then
    if test "$enable_dependency_tracking" != no ; then
      AC_MSG_ERROR([--enable-osx-universal-binary requires --disable-dependency-tracking.
Please re-run configure with these options:
  --disable-dependency-tracking --enable-osx-universal-binary
        ])
    fi
    CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
    CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
    LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
  fi
  ;;
esac

# Enable support for threads
AC_ARG_WITH([threads],
cristy's avatar
cristy committed
372
    [AC_HELP_STRING([--without-threads], [disable threads support])],
cristy's avatar
cristy committed
373 374 375 376 377
    [with_threads=$withval],
    [with_threads='yes'])

have_threads=no
if test "$with_threads" != 'no'; then
cristy's avatar
cristy committed
378
    AX_PTHREAD()
cristy's avatar
cristy committed
379
    if test "$ax_pthread_ok" = yes; then
cristy's avatar
cristy committed
380 381 382 383 384 385 386 387
        have_threads=yes
        DEF_THREAD="$PTHREAD_CFLAGS"
        CFLAGS="$CFLAGS $DEF_THREAD"
        CXXFLAGS="$CXXFLAGS $DEF_THREAD"
        if test "$CC" != "$PTHREAD_CC"; then
            AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
            CC="$PTHREAD_CC"
        fi
cristy's avatar
cristy committed
388 389 390 391
        if test "$CXX" != "$PTHREAD_CXX"; then
          AC_MSG_WARN([Replacing compiler $CXX with compiler $PTHREAD_CXX to support pthreads.])
          CXX="$PTHREAD_CXX"
        fi
cristy's avatar
cristy committed
392
        AC_DEFINE(THREAD_SUPPORT,1,[Define if you have POSIX threads libraries and header files.])
cristy's avatar
cristy committed
393 394 395 396 397 398 399 400 401 402 403
    fi
fi

# Enable support for OpenMP
if test "$have_threads" != 'yes'; then
  ac_cv_prog_c_openmp=unsupported
fi
AC_OPENMP([C])
CFLAGS="$OPENMP_CFLAGS $CFLAGS"
MAGICK_PCFLAGS="$MAGICK_PCFLAGS $OPENMP_CFLAGS"
AC_SUBST(OPENMP_CFLAGS)
cristy's avatar
cristy committed
404 405 406 407 408
if test "$enable_openmp" != no; then
  if test "$ac_cv_prog_c_openmp" != 'unsupported'; then
    MAGICK_FEATURES="OpenMP $MAGICK_FEATURES"
  fi
fi
cristy's avatar
cristy committed
409

cristy's avatar
cristy committed
410
# Enable support for OpenCL
cristy's avatar
cristy committed
411
AX_OPENCL([C])
cristy's avatar
cristy committed
412 413
CFLAGS="$CL_CFLAGS $CFLAGS"
LIBS="$CL_LIBS $LIBS"
cristy's avatar
cristy committed
414
AC_SUBST(CL_CFLAGS)
cristy's avatar
cristy committed
415 416 417 418
if test "$enable_opencl" != no; then
  if test "_OPENCL" = '1'; then
    MAGICK_FEATURES="OpenCL $MAGICK_FEATURES"
  fi
cristy's avatar
cristy committed
419
fi
cristy's avatar
cristy committed
420

cristy's avatar
cristy committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
########
#
# Check for large file support
#
########
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
LFS_CPPFLAGS=''
if test "$enable_largefile" != no; then
    if test "$ac_cv_sys_file_offset_bits" != 'no'; then
        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
    else
        AC_MSG_CHECKING([for native large file support])
        AC_RUN_IFELSE([#include <unistd.h>
          main () {
          exit(!(sizeof(off_t) == 8));
        }],
        [ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
         AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])])
    fi
    if test "$ac_cv_sys_large_files" != 'no'; then
        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_LARGE_FILES=1"
    fi
    if test "$ac_cv_sys_largefile_source" != 'no'; then
        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_LARGEFILE_SOURCE=1"
    fi
fi
AC_SUBST(LFS_CPPFLAGS)

#
# Configure libtool & libltdl
#
# Configure libtool
AC_LIBTOOL_DLOPEN
LT_INIT([win32-dll])
LT_LANG([C++])
AC_SUBST(LIBTOOL_DEPS)

# Configure libltdl
LT_CONFIG_LTDL_DIR([ltdl])
LTDL_INIT([convenience nonrecursive])

# Check to see if building shared libraries
libtool_build_shared_libs='no'
if test "$enable_shared" = 'yes'; then
    libtool_build_shared_libs='yes'
fi

# Check to see if building static libraries
libtool_build_static_libs='no'
if test "$enable_static" = 'yes'; then
    libtool_build_static_libs='yes'
fi

cristy's avatar
cristy committed
476
AM_CONDITIONAL(WITH_SHARED_LIBS, test "${libtool_build_shared_libs}" = 'yes')
cristy's avatar
cristy committed
477 478 479 480 481 482 483
#
# Enable support for building loadable modules
#
AC_ARG_WITH([modules],
    [AC_HELP_STRING([--with-modules],
                    [enable building dynamically loadable modules])],
    [with_modules=$withval],
cristy's avatar
cristy committed
484
    [with_modules='no'])
cristy's avatar
cristy committed
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516

# Only allow building loadable modules if we are building shared libraries
if test "$with_modules" != 'no' ; then
    if test "$libtool_build_shared_libs" = 'no'; then
        AC_MSG_WARN([Modules may only be built if building shared libraries is enabled.])
        with_modules='no'
    fi
fi
if test "$with_modules" != 'no'; then
    AC_DEFINE(BUILD_MODULES,1,Define if coders and filters are to be built as modules.)
fi
AM_CONDITIONAL(WITH_MODULES, test "$with_modules" != 'no')

# Enable building/use of libltdl if we are building shared libraries regardless
# of whether modules are built or not.
with_ltdl='no'
if test "$libtool_build_shared_libs" != 'no'; then
    with_ltdl='yes'
fi

AM_CONDITIONAL(WITH_LTDL, test "$with_ltdl" != 'no')
if test "$with_ltdl" != 'no'; then
    AC_DEFINE(LTDL_DELEGATE,1,Define if using libltdl to support dynamically loadable modules)

    # Set DLLDFLAGS
    if test X"$enable_shared" = Xyes; then
        DLLDFLAGS=-export-dynamic
        AC_SUBST(DLLDFLAGS)
    fi
fi

# Enable build using delegate libraries built in subdirectories rather than installed
cristy's avatar
cristy committed
517
# delegate libraries (bzlib fftw fpx gslib jp2 jbig jpeg lcms png tiff ttf wmf xml zlib)
cristy's avatar
cristy committed
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
AC_ARG_ENABLE([delegate-build],
    [AC_HELP_STRING([--enable-delegate-build],
                    [look for delegate libraries in build directory])],
    [enable_delegate_build=$enableval],
    [enable_delegate_build='no'])

AC_ARG_ENABLE([deprecated],
    [AC_HELP_STRING([--disable-deprecated],
                    [exclude deprecated methods in MagickCore and MagickWand API's])],
    [enable_deprecated=$enableval],
    [enable_deprecated='no'])

if test "$enable_deprecated" = 'yes'; then
  AC_DEFINE(EXCLUDE_DEPRECATED,1,[exclude deprecated methods in MagickCore API])
else
  DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --disable-deprecated "
fi

# Build a version of ImageMagick which operates uninstalled.
# Used to build distributions located via MAGICK_HOME / executable path
AC_ARG_ENABLE([installed],
    [AC_HELP_STRING([--disable-installed],
                    [Formally install ImageMagick under PREFIX])],
    [enable_installed=$enableval],
    [enable_installed='yes'])

if test "$enable_installed" = 'yes'; then
    AC_DEFINE(INSTALLED_SUPPORT,1,[ImageMagick is formally installed under prefix])
else
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --disable-installed "
fi

# Permit enciphering and deciphering image pixels.
AC_ARG_ENABLE([cipher],
    [AC_HELP_STRING([--disable-cipher],
                    [disable enciphering and deciphering image pixels])],
    [enable_cipher=$enableval],
    [enable_cipher='yes'])

if test "$enable_cipher" = 'yes'; then
    AC_DEFINE(CIPHER_SUPPORT,1,[permit enciphering and deciphering image pixels])
fi

# Build an embeddable version of ImageMagick.
AC_ARG_ENABLE([embeddable],
    [AC_HELP_STRING([--enable-embeddable],
                    [enable self-contained, embeddable, zero-configuration ImageMagick])],
    [enable_embeddable=$enableval],
    [enable_embeddable='no'])

if test "$enable_embeddable" = 'yes'; then
cristy's avatar
cristy committed
569
    AC_DEFINE(EMBEDDABLE_SUPPORT,1,[Build self-contained, embeddable, zero-configuration ImageMagick])
cristy's avatar
cristy committed
570 571 572 573 574 575 576 577 578 579 580 581
fi

# Build a high dynamic range version of ImageMagick.
AC_ARG_ENABLE([hdri],
    [AC_HELP_STRING([--enable-hdri],
                    [accurately represent the wide range of intensity levels found in real scenes])],
    [enable_hdri=$enableval],
    [enable_hdri='no'])

MAGICK_HDRI=""
if test "$enable_hdri" = 'yes'; then
    MAGICK_HDRI="HDRI"
cristy's avatar
cristy committed
582
    AC_DEFINE(HDRI_SUPPORT,1,[accurately represent the wide range of intensity levels in real scenes])
cristy's avatar
cristy committed
583
    MAGICK_FEATURES="HDRI $MAGICK_FEATURES"
cristy's avatar
cristy committed
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
fi
AC_SUBST(MAGICK_HDRI)dnl

# Build a version of ImageMagick with assert statements.
AC_ARG_ENABLE([assert],
    [AC_HELP_STRING([--disable-assert],
                    [disable assert() statements in build])],
    [enable_assert=$enableval],
    [enable_assert='yes'])

if test "$enable_assert" = 'no'; then
    AC_DEFINE(NDEBUG,1,[Turn off assert statements])
fi

# Add configure option --enable-maintainer-mode which enables dependency
# checking and generation useful to package maintainers.  This is made an
# option to avoid confusing end users.
AM_MAINTAINER_MODE


# Enable ccmalloc memory debugging support
AC_ARG_ENABLE([ccmalloc],
    [AC_HELP_STRING([--enable-ccmalloc],
                    [enable 'ccmalloc' memory debug support])],
    [enable_ccmalloc=$enableval],
    [enable_ccmalloc='no'])

# Enable Electric Fence memory debugging support
AC_ARG_ENABLE([efence],
    [AC_HELP_STRING([--enable-efence],
                    [enable 'efence' memory debug support])],
    [enable_efence=$enableval],
    [enable_efence='no'])

# Enable prof-based profiling support
AC_ARG_ENABLE([prof],
    [AC_HELP_STRING([--enable-prof],
                    [enable 'prof' profiling support])],
    [enable_prof=$enableval],
    [enable_prof='no'])

# Enable gprof-based profiling support
AC_ARG_ENABLE([gprof],
    [AC_HELP_STRING([--enable-gprof],
                    [enable 'gprof' profiling support])],
    [enable_gprof=$enableval],
    [enable_gprof='no'])

# Enable gcov-based profiling support
AC_ARG_ENABLE([gcov],
    [AC_HELP_STRING([--enable-gcov],
                    [enable 'gcov' profiling support])],
    [enable_gcov=$enableval],
    [enable_gcov='no'])

enable_profiling='no'
if test "$enable_prof" = 'yes' || test "$enable_gprof" = 'yes' || test "$enable_gcov" = 'yes'; then
    enable_profiling='yes'
    if test "$libtool_build_shared_libs" = 'yes'; then
        echo "Warning: Can not profile code using shared libraries"
    fi
fi

# Magick API method prefix
AC_ARG_WITH([method-prefix],
    [AC_HELP_STRING([--with-method-prefix=PREFIX],
                    [prefix MagickCore API methods])],
    [with_method_prefix=$enableval],
    [with_method_prefix=''])

if test "$with_method_prefix" != ''; then
    AC_DEFINE_UNQUOTED(NAMESPACE_PREFIX,$with_method_prefix,[Magick API method prefix])
fi

# Number of bits in a Quantum
AC_ARG_WITH([quantum-depth],
    [AC_HELP_STRING([--with-quantum-depth=DEPTH],
                    [number of bits in a pixel quantum (default 16)])],
    [with_quantum_depth=$withval],
    [with_quantum_depth=16])

if test "$with_quantum_depth" != '8'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-quantum-depth=$with_quantum_depth "
fi

case "${with_quantum_depth}" in
    8 ) ;;
    16 ) ;;
    32 ) ;;
    64 ) ;;
cristy's avatar
cristy committed
674
    * ) AC_MSG_ERROR("Pixel quantum depth must have value of 8, 16, 32, or 64") ;;
cristy's avatar
cristy committed
675
esac
cristy's avatar
cristy committed
676 677 678
if test "$enable_hdri" = 'yes'; then
  with_quantum_depth=16
fi
cristy's avatar
cristy committed
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
QUANTUM_DEPTH="$with_quantum_depth"
AC_DEFINE_UNQUOTED(QUANTUM_DEPTH,$QUANTUM_DEPTH,[Number of bits in a pixel Quantum (8/16/32/64)])
AC_SUBST(QUANTUM_DEPTH)dnl

# Set pixel cache threshold
AC_ARG_WITH([cache],
    [AC_HELP_STRING([--with-cache=THRESHOLD],
                    [set pixel cache threshhold in MB (default available memory)])],
    [with_cache=$withval],
    [with_cache=''])

if test "$with_cache" != ''; then
    AC_DEFINE_UNQUOTED(PixelCacheThreshold,$with_cache,[Pixel cache threshold in MB (defaults to available memory)])
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-cache=$with_cache "
fi

# Disable/Enable support for full delegate paths
AC_ARG_WITH([frozenpaths],
    [AC_HELP_STRING([--with-frozenpaths],
                    [freeze delegate paths])],
    [with_frozenpaths=$withval],
    [with_frozenpaths='no'])

# Enable build/install of Magick++
AC_ARG_WITH([magick-plus-plus],
    [AC_HELP_STRING([--without-magick-plus-plus],
                    [disable build/install of Magick++])],
    [with_magick_plus_plus=$withval],
    [with_magick_plus_plus='yes'])

# Disable build/install of PerlMagick.
AC_ARG_WITH([perl],
    [AC_HELP_STRING([--with-perl],
                    [enable build/install of PerlMagick])],
    [with_perl=$withval],
cristy's avatar
cristy committed
714
    [with_perl='no'])
cristy's avatar
cristy committed
715 716 717 718

# Options to pass when configuring PerlMagick
AC_ARG_WITH([perl-options],
    [AC_HELP_STRING([--with-perl-options=OPTIONS],
cristy's avatar
cristy committed
719 720
                    [options to pass on command-line when generating PerlMagick's build file])],
PERL_MAKE_OPTIONS=$withval)
cristy's avatar
cristy committed
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
AC_SUBST(PERL_MAKE_OPTIONS)

# Enable umem, object-caching memory allocation library.
AC_ARG_WITH(umem,
        [  --with-umem             enable umem memory allocation library support],
        [with_umem=$withval],
        [with_umem='no'])
if test "$with_umem" != 'yes' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-umem=$with_umem "
fi

#
# Specify path to shared libstdc++ if not in normal location
#
AC_ARG_WITH([libstdc],
    [AC_HELP_STRING([--with-libstdc=DIR],
                    [ use libstdc++ in DIR (for GNU C++)])],
    [with_libstdc=$withval],
    [with_libstdc=''])

if test "$with_libstdc" != ''; then
    if test -d "$with_libstdc"; then
        LIBSTDCLDFLAGS="-L$with_libstdc"
    fi
fi
AC_SUBST(LIBSTDCLDFLAGS)

# Does gcc required -traditional?
AC_PROG_GCC_TRADITIONAL

########
#
# Set defines required to build DLLs and modules using MinGW
#
########
# These options are set for multi-thread DLL module build
#  libMagickCore:           _DLL _MAGICKMOD_ _MAGICKLIB_
#  module:              _DLL
#  executable/Magick++: _DLL _MAGICKMOD_
MODULE_EXTRA_CPPFLAGS=''
LIBRARY_EXTRA_CPPFLAGS=''
if test "${native_win32_build}" = 'yes'; then
    if test "${libtool_build_shared_libs}" = 'yes'; then
        CPPFLAGS="$CPPFLAGS -D_DLL"
        MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_DLL"
        MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_DLL"
        LIBRARY_EXTRA_CPPFLAGS="$LIBRARY_EXTRA_CPPFLAGS -D_MAGICKLIB_"
        if test "$with_modules" = 'yes'; then
            LIBRARY_EXTRA_CPPFLAGS="$LIBRARY_EXTRA_CPPFLAGS -D_MAGICKMOD_"
        else
            MODULE_EXTRA_CPPFLAGS="$MODULE_EXTRA_CPPFLAGS -D_MAGICKLIB_"
        fi
    else
        CPPFLAGS="$CPPFLAGS -D_LIB"
        MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_LIB"
        MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_LIB"
    fi
    if test "$with_threads" = 'yes'; then
         CPPFLAGS="$CPPFLAGS -D_MT"
         MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_MT"
         MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_MT"
    fi
fi
AC_SUBST(MODULE_EXTRA_CPPFLAGS)
AC_SUBST(LIBRARY_EXTRA_CPPFLAGS)

# Check standard headers
AC_HEADER_STDC
if ! test x"$ac_cv_header_stdc" = x"yes"; then
    AC_MSG_WARN([configure has detected that you do not have the ANSI standard C
    header files.  Compilation cannot proceed.  Please install the ANSI C
    headers and rerun this script.]);
fi
cristy's avatar
cristy committed
794
AC_HEADER_ASSERT
cristy's avatar
cristy committed
795 796 797
AC_HEADER_DIRENT

# Check additional headers
cristy's avatar
cristy committed
798
AC_CHECK_HEADERS(arm/limits.h complex.h errno.h fcntl.h limits.h linux/unistd.h locale.h machine/param.h mach-o/dyld.h OS.h process.h stdarg.h sys/ipc.h sys/resource.h sys/syslimits.h sys/time.h sys/timeb.h sys/times.h sys/wait.h wchar.h)
cristy's avatar
cristy committed
799 800 801 802 803 804 805 806 807 808 809 810 811

########
#
# Checks for typedefs, structures, and compiler characteristics.
#
########

AC_HEADER_STDBOOL
AC_C_VOLATILE
AC_C_STRINGIZE
AC_HEADER_STAT
AC_HEADER_TIME
AC_STRUCT_TM
cristy's avatar
cristy committed
812
AC_STRUCT_TIMEZONE
cristy's avatar
cristy committed
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
AC_SYS_INTERPRETER

# If the C compiler supports the keyword inline, do nothing. Otherwise
# define inline to __inline__ or __inline if it accepts one of those,
# otherwise define inline to be empty.
AC_C_INLINE

# If the C compiler supports the keyword restrict, do nothing. Otherwise
# define restrict to __restrict__ or __restrict if it accepts one of those,
# otherwise define restrict to be empty.
AC_C_RESTRICT

# If words are stored with the most significant byte first (like
# Motorola and SPARC CPUs), define `WORDS_BIGENDIAN'.
AC_C_BIGENDIAN

# Define mode_t to a suitable type, if standard headers do not define it.
AC_TYPE_MODE_T

# Define off_t to a suitable type, if standard headers do not define it.
AC_TYPE_OFF_T

# Define pid_t to a suitable type, if standard headers do not define it.
AC_TYPE_PID_T

# Define size_t to a suitable type, if standard headers do not define it.
AC_TYPE_SIZE_T

# Define ssize_t to a suitable type, if standard headers do not define it.
AC_TYPE_SSIZE_T

# If the C compiler supports a working long double type with more range
# or precision than the double type, define HAVE_LONG_DOUBLE.
AC_TYPE_LONG_DOUBLE_WIDER

# If the C type char is unsigned, define __CHAR_UNSIGNED__, unless the
# C compiler predefines it.
AC_C_CHAR_UNSIGNED

# Obtain size of an 'signed short' and define as SIZEOF_SIGNED_SHORT
AC_CHECK_SIZEOF(signed short)

# Obtain size of an 'unsigned short' and define as SIZEOF_UNSIGNED_SHORT
AC_CHECK_SIZEOF(unsigned short)

# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT
AC_CHECK_SIZEOF(signed int)

# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT
AC_CHECK_SIZEOF(unsigned int)

# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG
AC_CHECK_SIZEOF(signed long)

# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG
AC_CHECK_SIZEOF(unsigned long)

# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG.  If
# 'signed long long' is not supported then the value defined is zero.
AC_CHECK_SIZEOF(signed long long)

# Obtain size of a 'unsigned long long' and define as
# SIZEOF_UNSIGNED_LONG_LONG.  If 'unsigned long long' is not
# supported then the value defined is zero.
AC_CHECK_SIZEOF(unsigned long long)

# Obtain size of off_t and define as SIZEOF_OFF_T
AC_CHECK_SIZEOF(off_t)

# Obtain size of size_t and define as SIZEOF_SIZE_T
AC_CHECK_SIZEOF(size_t)

cristy's avatar
cristy committed
885 886 887
# Obtain size of ssize_t and define as SIZEOF_SSIZE_T
AC_CHECK_SIZEOF(ssize_t)

cristy's avatar
cristy committed
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
# Obtain size of an unsigned int pointer and define as SIZEOF_UNSIGNED_INTP
AC_CHECK_SIZEOF(unsigned int*)

#
# Compute sized types for current CPU and compiler options.
#

AC_MSG_CHECKING(for signed 8-bit type)
INT8_T='signed char'
AC_MSG_RESULT($INT8_T)
AC_SUBST(INT8_T)

AC_MSG_CHECKING(for unsigned 8-bit type)
UINT8_T='unsigned char'
AC_MSG_RESULT($UINT8_T)
AC_SUBST(UINT8_T)

AC_MSG_CHECKING(for signed 16-bit type)
INT16_T='signed short'
AC_MSG_RESULT($INT16_T)
AC_SUBST(INT16_T)

AC_MSG_CHECKING(for unsigned 16-bit type)
UINT16_T='unsigned short'
AC_MSG_RESULT($UINT16_T)
AC_SUBST(UINT16_T)

AC_MSG_CHECKING(for signed 32-bit type)
INT32_T='none'
if test $ac_cv_sizeof_signed_int -eq 4; then
  INT32_T='signed int'
elif test $ac_cv_sizeof_signed_long -eq 4; then
  INT32_T='signed long'
fi
AC_MSG_RESULT($INT32_T)
AC_SUBST(INT32_T)

AC_MSG_CHECKING(for unsigned 32-bit type)
UINT32_T='none'
if test $ac_cv_sizeof_unsigned_int -eq 4; then
  UINT32_T='unsigned int'
elif test $ac_cv_sizeof_unsigned_long -eq 4; then
  UINT32_T='unsigned long'
fi
AC_MSG_RESULT($UINT32_T)
AC_SUBST(UINT32_T)

AC_MSG_CHECKING(for signed 64-bit type)
INT64_T='none'
if test $ac_cv_sizeof_signed_long -eq 8; then
  INT64_T='signed long'
elif test $ac_cv_sizeof_signed_long_long -eq 8; then
  INT64_T='signed long long'
fi
AC_MSG_RESULT($INT64_T)
AC_SUBST(INT64_T)

AC_MSG_CHECKING(for unsigned 64-bit type)
UINT64_T='none'
if test $ac_cv_sizeof_unsigned_long -eq 8; then
  UINT64_T='unsigned long'
elif test $ac_cv_sizeof_unsigned_long_long -eq 8; then
  UINT64_T='unsigned long long'
fi
AC_MSG_RESULT($UINT64_T)
AC_SUBST(UINT64_T)

AC_MSG_CHECKING(for unsigned maximum type)
UINTMAX_T='none'
if test "$UINT64_T" != 'none'; then
  UINTMAX_T=$UINT64_T
elif test "$UINT32_T" != 'none'; then
  UINTMAX_T=$UINT32_T
fi
AC_MSG_RESULT($UINTMAX_T)
AC_SUBST(UINTMAX_T)

AC_MSG_CHECKING(for pointer difference type)
UINTPTR_T='none'
if test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_unsigned_intp; then
  UINTPTR_T='unsigned long'
elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_unsigned_intp; then
  UINTPTR_T='unsigned long long'
fi
AC_MSG_RESULT($UINTPTR_T)
AC_SUBST(UINTPTR_T)

AC_MSG_CHECKING([whether our compiler supports __func__])
AC_TRY_COMPILE([],
 [{ const char *func = __func__; return(func != 0 ? 0 : 1); }],
 AC_MSG_RESULT([yes]),
 AC_MSG_RESULT([no])
 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
 AC_TRY_COMPILE([],
   [{ const char *func = __FUNCTION__; return(func != 0 ? 0 : 1); }],
   AC_MSG_RESULT([yes])
   AC_DEFINE(__func__, __FUNCTION__,
     [Define to appropriate substitue if compiler does not have __func__]),
   AC_MSG_RESULT([no])
   AC_DEFINE(__func__, __FILE__,
     [Define to appropriate substitue if compiler does not have __func__])))

########
#
# Check for functions
#
########
MAGICK_FUNC_MMAP_FILEIO
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_MMAP
AC_FUNC_FORK
AC_FUNC_MEMCMP
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STRTOD
AC_FUNC_VPRINTF

cristy's avatar
cristy committed
1006 1007 1008 1009 1010 1011 1012 1013
#
# Find math library
#
MATH_LIBS=''
AC_CHECK_LIB(m,sqrt,MATH_LIBS="-lm",,)
LIBS="$MATH_LIBS $LIBS"
AC_SUBST(MATH_LIBS)

cristy's avatar
cristy committed
1014
AC_CHECK_FUNCS([atoll atexit cimag clock ctime_r directio _exit execvp fchmod floor fork ftime ftruncate getc_unlocked getcwd getpid getexecname getdtablesize getpagesize getrlimit getrusage gettimeofday gmtime_r j0 j1 lltostr localtime_r lstat memmove memset mkstemp munmap nanosleep _NSGetExecutablePath pclose _pclose poll popen _popen posix_fadvise posix_fallocate posix_madvise posix_memalign posix_spawnp pow pread pwrite qsort_r raise rand_r readlink readdir_r realpath select seekdir setlocale sqrt setvbuf stat strchr strerror_r strrchr strcspn strdup strpbrk strspn strstr strtol strtoul symlink sysconf sigemptyset sigaction spawnvp strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times ulltostr usleep utime vsprintf vsnprintf waitpid _wfopen _wstat])
cristy's avatar
cristy committed
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038

#
# Check for clock_gettime().
#
AC_SEARCH_LIBS(clock_gettime, rt,
[
  AC_DEFINE([HAVE_CLOCK_GETTIME],[1],[Define to 1 if you have clock_gettime.])
  AC_MSG_CHECKING([whether clock_gettime supports CLOCK_REALTIME])
  AC_COMPILE_IFELSE(
    AC_LANG_PROGRAM(
      [[#include <time.h>]],
       [[clockid_t clockType = CLOCK_REALTIME;]]),
      [
        AC_MSG_RESULT(yes)
      	AC_DEFINE([HAVE_CLOCK_REALTIME],[1],
          [Define to 1 if clock_gettime supports CLOCK_REALTIME.])
      ],
      AC_MSG_RESULT(no)
    )
  ],
  [
    AC_CHECK_FUNCS([gettimeofday ftime], [break])
  ]
)
cristy's avatar
cristy committed
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071

########
#
# Check for function prototypes
#
########

AC_CHECK_DECLS([pread, pwrite],[],[],[
#include <unistd.h>])

AC_CHECK_DECLS([strlcpy],[],[],[
#include <strings.h>])

AC_CHECK_DECLS([vsnprintf],[],[],[
#include <stdio.h>
#include <stdarg.h>])

########
#
# C++ Support Tests (For Magick++)
#
########
have_magick_plus_plus='no'
if test "$with_magick_plus_plus" = 'yes'; then
    OLIBS="$LIBS"
    LIBS=''
    AC_LANG_PUSH(C++)

    # Full set of headers used...
    # algorithm cctype cerrno cmath cstdio cstdlib cstring ctime exception
    # functional iomanip iosfwd iostream iterator list string strstream utility
    AC_LANG([C++])
    AC_PROG_CXX
cristy's avatar
cristy committed
1072 1073 1074
    AX_CXX_BOOL
    AX_CXX_NAMESPACES
    AX_CXX_NAMESPACE_STD
cristy's avatar
cristy committed
1075 1076 1077 1078 1079 1080 1081
    AC_CXX_HAVE_STD_LIBS
    AC_CXX_HAVE_LSTRING
    AC_OPENMP([C++])
    AC_LANG_POP

    AC_MSG_CHECKING([whether C++ compiler is sufficient for Magick++])
    if \
cristy's avatar
cristy committed
1082
        test $ax_cv_cxx_bool = 'yes' && \
cristy's avatar
cristy committed
1083
        test $ac_cv_cxx_have_lstring = 'yes' && \
cristy's avatar
cristy committed
1084
        test $ax_cv_cxx_namespaces = 'yes' && \
cristy's avatar
cristy committed
1085
        test $ac_cv_cxx_have_std_libs = 'yes' && \
cristy's avatar
cristy committed
1086
        test $ax_cv_cxx_have_std_namespace = 'yes'; then
cristy's avatar
cristy committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
        have_magick_plus_plus='yes'
    else
        have_magick_plus_plus='no (failed tests)'
    fi
    AC_MSG_RESULT([$have_magick_plus_plus])
    LIBS="$OLIBS"
fi
AM_CONDITIONAL(WITH_MAGICK_PLUS_PLUS, test "$have_magick_plus_plus" = 'yes')

# Only check for delegate libraries in subdirectories if requested.
if test "$enable_delegate_build" != 'no'; then
    # Check for delegate sub-directories and add -I & -L options as required.
    # This presumes that delegates are installed as detailed in the ImageMagick
    # README. If delegates are installed in a standard location where the
    # compiler will automatically find them then these options should not be
    # required.

    #
    # Most delegates have includes in the same directory as the library, but not all...
    #
    # Includes
cristy's avatar
cristy committed
1108
    for dir in bzlib fftw fpx gslib/src jp2 jp2/src/libjasper/include jbig/libjbig jpeg lcms/include magick png tiff/libtiff ttf/include wand wmf/include xml/include zlib; do
cristy's avatar
cristy committed
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
        if test -d "$builddir/$dir"; then
            CPPFLAGS="$CPPFLAGS -I$builddir/$dir"
        else
            if test -d "$srcdirfull/$dir"; then
                CPPFLAGS="$CPPFLAGS -I$srcdirfull/$dir"
            fi
        fi
    done

    # Libraries
cristy's avatar
cristy committed
1119
    for dir in bzlib fftw fpx gslib/src jp2 jp2/src/libjasper jbig/libjbig jpeg lcms/src magick png tiff/libtiff ttf/objs wand wmf/src xml zlib; do
cristy's avatar
cristy committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618
    if test -d "$builddir/$dir/.libs"; then
        LDFLAGS="$LDFLAGS -L$builddir/$dir/.libs"
    else
        if test -d "$srcdirfull/$dir/.libs"; then
            LDFLAGS="$LDFLAGS -L$srcdirfull/$dir/.libs"
        fi
    fi
    if test -d "$builddir/$dir"; then
        LDFLAGS="$LDFLAGS -L$builddir/$dir"
    else
        if test -d "$srcdirfull/$dir"; then
            LDFLAGS="$LDFLAGS -L$srcdirfull/$dir"
        fi
    fi
  done
fi

# Assume that delegate headers reside under same directory as ImageMagick
# installation prefix.
MAGICK_CPPFLAGS="-I$INCLUDE_DIR/ImageMagick $MAGICK_CPPFLAGS"

#
# Find the X11 RGB database
#
AC_CACHE_CHECK(for X11 configure files,im_cv_x_configure,
[# Look for the header file in a standard set of common directories.
# Check X11 before X11Rn because it is often a symlink to the current release.
    for ac_dir in          \
    /lib/usr/lib/X11       \
    /usr/X11/lib           \
    /usr/X11R4/lib         \
    /usr/X11R5/lib         \
    /usr/X11R6/lib         \
    /usr/X11R7/lib         \
    /usr/X386/lib          \
    /usr/XFree86/lib/X11   \
    /usr/athena/lib        \
    /usr/lib               \
    /usr/lib/X11           \
    /usr/lib/X11R4         \
    /usr/lib/X11R5         \
    /usr/lib/X11R6         \
    /usr/lib/X11R7         \
    /usr/local/X11/lib     \
    /usr/local/X11R4/lib   \
    /usr/local/X11R5/lib   \
    /usr/local/X11R6/lib   \
    /usr/local/lib         \
    /usr/local/lib/X11     \
    /usr/local/lib/X11R4   \
    /usr/local/lib/X11R5   \
    /usr/local/lib/X11R6   \
    /usr/local/lib/X11R7   \
    /usr/local/x11r5/lib   \
    /usr/lpp/Xamples/lib   \
    /usr/openwin/lib       \
    /usr/openwin/share/lib \
    /usr/unsupported/lib   \
    /usr/x386/lib          \
    ; do
    if test -f "$ac_dir/X11/rgb.txt"; then
      im_cv_x_configure="$ac_dir/X11/"
      break
    elif test -f "$ac_dir/rgb.txt"; then
      im_cv_x_configure="$ac_dir/"
      break
    fi

  done])
X11_CONFIGURE_PATH="$im_cv_x_configure"
case "${build_os}" in
  mingw* )
    X11ConfigurePath=`$WinPathScript "$X11ConfigurePath=" 1`
  ;;
esac
AC_DEFINE_UNQUOTED(X11_CONFIGURE_PATH,"$X11ConfigurePath",Location of X11 configure files)

#
# Find OpenMP library
#
GOMP_LIBS=''
if test "$enable_openmp" != 'no'; then
  if test "${GCC}" = "yes"; then
    AC_CHECK_LIB(gomp,GOMP_parallel_start,GOMP_LIBS="-lgomp",,)  # gcc
  else
    AC_CHECK_LIB(mtsk,sunw_mp_register_warn,GOMP_LIBS="-lmtsk",,)  # solaris cc
    AC_CHECK_LIB(xlsmp,_xlsmpFlush,GOMP_LIBS="-lxlsmp",,)  # AIX xlc
    AC_CHECK_LIB(mp,mp_destroy,GOMP_LIBS="-lmp",,)  # SGI IRIX 6.5 MIPSpro C/C++
  fi
  LIBS="$GOMP_LIBS $LIBS"
fi
AC_SUBST(GOMP_LIBS)

#
# Find Posix threads library
#
THREAD_LIBS=''
if test "$with_threads" != 'no' && test "$have_threads" = 'yes'; then

    if test "x$PTHREAD_LIBS" = "x"; then
    case "${host_cpu}-${host_os}" in
      *-freebsd*)
        MAGICK_CHECK_PTHREAD_LIB(c_r,PTHREAD_LIBS=-lc_r) ;;
    esac
    fi

    for lib in pthread pthreads; do
        if test "x$PTHREAD_LIBS" = "x"; then
            MAGICK_CHECK_PTHREAD_LIB([$lib],[PTHREAD_LIBS=-l$lib])
        fi
    done

    THREAD_LIBS="$PTHREAD_LIBS"
    LIBS="$LIBS $THREAD_LIBS"
fi
AC_SUBST(THREAD_LIBS)

#
# Check for umem.
#
have_umem='no'
UMEM_LIBS=''
if test "$with_umem" != 'no'; then
  AC_MSG_CHECKING(for UMEM support )
  AC_MSG_RESULT()
  failed=0
  passed=0
  AC_CHECK_HEADER(umem.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
  AC_CHECK_LIB(umem,umem_alloc,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
  AC_CHECK_LIB(umem,umem_free,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
  AC_MSG_CHECKING(if umem memory allocation library is complete)
  if test $passed -gt 0; then
    if test $failed -gt 0; then
      AC_MSG_RESULT(no -- some components failed test)
      have_umem='no (failed tests)'
    else
      UMEM_LIBS='-lumem'
      LIBS="$UMEM_LIBS $LIBS"
      AC_DEFINE(HasUMEM,1,Define if you have umem memory allocation library)
      AC_MSG_RESULT(yes)
      have_umem='yes'
    fi
  else
    AC_MSG_RESULT(no)
  fi
fi
AM_CONDITIONAL(HasUMEM, test "$have_umem" = 'yes')
AC_SUBST(UMEM_LIBS)

#
# Add support for ccmalloc memory debugging library if requested
#
have_ccmalloc='no'
CCMALLOC_LIBS=''
if test "$enable_ccmalloc" = 'yes'; then
    AC_PATH_PROG(CCMALLOCDelegate,ccmalloc,)
    if test -n "$CCMALLOCDelegate"; then
        eval `grep PREFIX= $CCMALLOCDelegate | sed -e 's/PREFIX/CCMALLOC_PREFIX/'`
        OLIBS="$LIBS"
        # Assume that gcc is used with ccmalloc.
        LIBS="$LIBS $CCMALLOC_PREFIX/lib/ccmalloc-gcc.o"
       AC_CHECK_LIB(ccmalloc,ccmalloc_malloc,CCMALLOC_LIBS="$CCMALLOC_PREFIX/lib/ccmalloc-gcc.o -lccmalloc -ldl",,-ldl)
        if test -n "$CCMALLOC_LIBS"; then
            LIBS="$OLIBS"
            LIBS="$LIBS $CCMALLOC_LIBS"
            have_ccmalloc='yes'
        else
            LIBS="$OLIBS"
        fi
    fi
fi

#
# Add support for efence memory debugging library if requested
#
if test "$enable_efence" = 'yes'; then
    EFENCE_LIBS='-lefence'
    LIBS="$EFENCE_LIBS $LIBS"
fi

dnl ===========================================================================

#
# Check for BZLIB
#

AC_ARG_WITH([bzlib],
    [AC_HELP_STRING([--without-bzlib],
                    [disable BZLIB support])],
    [with_bzlib=$withval],
    [with_bzlib='yes'])

if test "$with_bzlib" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-bzlib=$with_bzlib "
fi

have_bzlib='no'
if test "$with_bzlib" != 'no'; then
    BZLIB_LIBS=''
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for BZLIB])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    found_libbz=0
    AC_CHECK_HEADER(bzlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(bz2,BZ2_bzDecompress,found_libbz=`expr $found_libbz + 1`,,)
    if test "$native_win32_build" = 'yes'; then
      AC_CHECK_LIB(bz2,_imp__BZ2_decompress,found_libbz=`expr $found_libbz + 1`,,)
    fi
    if test $found_libbz -gt 0; then
      passed=`expr $passed + 1`
    else
      failed=`expr $failed + 1`
    fi
    AC_MSG_CHECKING(if BZLIB package is complete)
    if test $passed -gt 0; then
      if test $failed -gt 0; then
        AC_MSG_RESULT(no -- some components failed test)
        have_bzlib='no (failed tests)'
      else
        BZLIB_LIBS='-lbz2'
        LIBS="$BZLIB_LIBS $LIBS"
        AC_DEFINE(BZLIB_DELEGATE,1,Define if you have the bzip2 library)
        AC_MSG_RESULT(yes)
        have_bzlib='yes'
      fi
    else
      AC_MSG_RESULT(no)
    fi
fi
AM_CONDITIONAL(BZLIB_DELEGATE, test "$have_bzlib" = 'yes')
AC_SUBST(BZLIB_LIBS)

#
# Find the X11 include and library directories.
#
IPC_LIBS=''
X11_LIBS=''
XEXT_LIBS=''
XT_LIBS=''
AC_PATH_XTRA
if test "$no_x" != 'yes'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for X11])
    AC_MSG_RESULT([])
    LDFLAGS="$LDFLAGS $X_LIBS"
    X11_LIBS="$X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
    LIBS="$X11_LIBS $LIBS"
    CPPFLAGS="$CPPFLAGS $X_CFLAGS"

    AC_DEFINE(X11_DELEGATE,1,Define if you have X11 library)dnl

    #
    # Check for X11 shared memory extension
    #
    # shmctl is required to support the shared memory extension
    AC_CHECK_FUNC([shmctl],[have_shmctl='yes'],[])
    if test "$have_shmctl" != 'yes'; then
        PERSIST_LIBS=$LIBS
        LIBS="$LIBS -lcygipc"
        AC_TRY_LINK_FUNC([shmctl],[have_shmctl='yes'; IPC_LIBS='-lcygipc'],[])
        LIBS=$PERSIST_LIBS
    fi

    if test "$have_shmctl" = 'yes'; then
        AC_CHECK_LIB([Xext],[XShmAttach],[XEXT_LIBS='-lXext' ; AC_DEFINE(HAVE_SHARED_MEMORY,1,X11 server supports shared memory extension)],[],[])
    fi

    #
    # Check for X11 shape extension
    #
    AC_CHECK_LIB([Xext],[XShapeCombineMask],[XEXT_LIBS='-lXext' ; AC_DEFINE(HAVE_SHAPE,1,X11 server supports shape extension)],[],[])
    AC_CHECK_LIB(Xt,XtSetEventDispatcher,XT_LIBS='-lXt',,)
    LIBS="$XEXT_LIBS $XT_LIBS $LIBS"
fi
if test "$no_x" != 'yes'; then
  have_x='yes'
else
  have_x='no'
fi
AM_CONDITIONAL(X11_DELEGATE, test "$have_x" = 'yes')
AC_SUBST(X11_LIBS)
AC_SUBST(XEXT_LIBS)

dnl ===========================================================================

#
# Check for ZLIB
#
AC_ARG_WITH([zlib],
    [AC_HELP_STRING([--without-zlib],
                    [disable ZLIB support])],
    [with_zlib=$withval],
    [with_zlib='yes'])

if test "$with_zlib" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zlib=$with_zlib "
fi

have_zlib='no'
ZLIB_LIBS=''
dnl PNG requires zlib so enable zlib check if PNG is requested
if test "$with_zlib" != 'no' || test "$with_png" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for ZLIB])
    AC_MSG_RESULT([])
    ZLIB_LIBS=''
    failed=0
    passed=0
    AC_CHECK_HEADER(zconf.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_HEADER(zlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(z,compress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(z,uncompress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(z,deflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(z,inflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(z,gzseek,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(z,gztell,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if ZLIB package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_zlib='no (failed tests)'
        else
            ZLIB_LIBS='-lz'
            LIBS="$ZLIB_LIBS $LIBS"
            AC_DEFINE(ZLIB_DELEGATE,1,Define if you have zlib compression library)
            AC_MSG_RESULT([yes])
            have_zlib='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(ZLIB_DELEGATE, test "$have_zlib" = 'yes')
AC_SUBST(ZLIB_LIBS)

#
# If profiling, then check for -ldl and dlopen (required for Solaris & gcc)
#
LIB_DL=''
if test "$enable_profiling" = 'yes'; then
    AC_CHECK_LIB(dl,dlopen,LIB_DL='-ldl',,)
    LIBS="$LIB_DL $LIBS"
fi
AC_SUBST(LIB_DL)

dnl ===========================================================================

#
# Check for Autotrace delegate library.
#
AC_ARG_WITH([autotrace],
    [AC_HELP_STRING([--with-autotrace],
                    [enable autotrace support])],
        [with_autotrace=$withval],
        [with_autotrace='no'])

if test "$with_autotrace" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-autotrace=$with_autotrace "
fi

have_autotrace='no'
AUTOTRACE_CFLAGS=""
AUTOTRACE_LIBS=""
AUTOTRACE_PKG=""
if test "x$with_autotrace" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(AUTOTRACE,[autotrace >= 0.31.1], have_autotrace=yes, have_autotrace=no)
    AC_MSG_RESULT([])
fi

if test "$have_autotrace" = 'yes'; then
    failed=0
    AC_DEFINE(AUTOTRACE_DELEGATE,1,Define if you have AUTOTRACE library)
    if test "$with_modules" = 'no'; then
    CPPFLAGS="$AUTOTRACE_CFLAGS $CPPFLAGS"
    fi
fi

AM_CONDITIONAL(AUTOTRACE_DELEGATE,test "$have_autotrace" = 'yes')
AC_SUBST(AUTOTRACE_CFLAGS)
AC_SUBST(AUTOTRACE_LIBS)

dnl ===========================================================================

#
# Check for Display Postscript delegate library.
#
AC_ARG_WITH([dps],
    [AC_HELP_STRING([--without-dps],
                    [disable Display Postscript support])],
    [with_dps=$withval],
    [with_dps='yes'])

if test "$with_dps" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-dps=$with_dps "
fi

have_dps='no'
DPS_LIBS=''
if test "$with_dps" != 'no' && test "$with_x" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for DPS])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    PERSIST_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS -I${ac_x_includes}/X11"
    AC_CHECK_HEADER(DPS/dpsXclient.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    # DPS issues:
    # XFree86-4.x needs -lXt to provide XtMalloc for -ldps.
    # Cygwin doesn't deliver -lXt as a DLL, which prevents a DLL build.
    # Adobe DPS (as delivered on Solaris) doesn't require -lXt.
    # ImageMagick itself doesn't use -lXt.
    have_libdps='no'
    LIBDPS_XT=''
    AC_CHECK_LIB(dps,DPSInitialize,have_libdps='yes',have_libdps='no',)
    if test "$have_libdps" != 'yes'; then
        # Unset cache variable so we can try again.
        unset ac_cv_lib_dps_DPSInitialize
        AC_CHECK_LIB(dps,DPSInitialize,have_libdps='yes',have_libdps='no',-lXt)
        if test "$have_libdps" = 'yes'; then
            LIBDPS_XT='-lXt'
        fi
    fi
    if test "$have_libdps" = 'yes'; then
        passed=`expr $passed + 1`
    else
        failed=`expr $failed + 1`
    fi
    AC_CHECK_LIB(dpstk,XDPSPixelsPerPoint,passed=`expr $passed + 1`,failed=`expr $failed + 1`,-ldps $LIBDPS_XT)
    AC_MSG_CHECKING([if DPS package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_dps='no (failed tests)'
            CPPFLAGS="$PERSIST_CPPFLAGS"
        else
            DPS_LIBS="-ldpstk -ldps ${LIBDPS_XT}"
            LIBS="$DPS_LIBS $LIBS"
            AC_DEFINE(DPS_DELEGATE,1,Define if you have Display Postscript)
            AC_MSG_RESULT([yes])
            have_dps='yes'
        fi
    else
        AC_MSG_RESULT([no])
        CPPFLAGS=$PERSIST_CPPFLAGS
    fi
fi
AM_CONDITIONAL(DPS_DELEGATE, test "$have_dps" = 'yes')
AC_SUBST(DPS_LIBS)

dnl ===========================================================================

#
# Check for DJVU delegate library.
#
AC_ARG_WITH([djvu],
    [AC_HELP_STRING([--without-djvu],
                    [disable DjVu support])],
    [with_djvu=$withval],
    [with_djvu='yes'])

if test "$with_djvu" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-djvu=$with_djvu "
fi

have_djvu='no'
DJVU_LIBS=''
if test "$with_djvu" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for DJVU])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(libdjvu/ddjvuapi.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(djvulibre,ddjvu_context_create,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if DJVU package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_djvu='no (failed tests)'
        else
            DJVU_LIBS='-ldjvulibre'
            LIBS="$DJVU_LIBS $LIBS"
            AC_DEFINE(DJVU_DELEGATE,1,Define if you have DJVU library)
            AC_MSG_RESULT([yes])
            have_djvu='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(DJVU_DELEGATE, test "$have_djvu" = 'yes')
AC_SUBST(DJVU_LIBS)

dnl ===========================================================================

cristy's avatar
cristy committed
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633
#
# Set DejaVu font directory.
#
AC_ARG_WITH([dejavu-font-dir],
    [AC_HELP_STRING([--with-dejavu-font-dir=DIR],
                    [DejaVu font directory])],
    [with_dejavu_font_dir=$withval],
    [with_dejavu_font_dir='default'])

if test "$with_dejavu_font_dir" != 'default'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-dejavu-font-dir=$with_dejavu_font_dir "
fi

dnl ===========================================================================

cristy's avatar
cristy committed
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747
#
# Check for FFTW delegate library.
#
AC_ARG_WITH([fftw],
    [AC_HELP_STRING([--without-fftw],
                    [disable FFTW support])],
    [with_fftw=$withval],
    [with_fftw='yes'])

if test "$with_fftw" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fftw=$with_fftw "
fi

have_fftw='no'
FFTW_LIBS=''
if test "$with_fftw" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for FFTW])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(fftw3.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(fftw3,fftw_execute,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if FFTW package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_fftw='no (failed tests)'
        else
            FFTW_LIBS='-lfftw3'
            LIBS="$FFTW_LIBS $LIBS"
            AC_DEFINE(FFTW_DELEGATE,1,Define if you have FFTW library)
            AC_MSG_RESULT([yes])
            have_fftw='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(FFTW_DELEGATE, test "$have_fftw" = 'yes')
AC_SUBST(FFTW_LIBS)

dnl ===========================================================================

#
# Check for FlashPIX delegate library.
#
AC_ARG_WITH([fpx],
    [AC_HELP_STRING([--without-fpx],
                    [disable FlashPIX support])],
    [with_fpx=$withval],
    [with_fpx='yes'])

if test "$with_fpx" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fpx=$with_fpx "
fi

have_fpx='no'
FPX_LIBS=''
if test "$with_fpx" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for FlashPIX])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_LANG_PUSH(C++)
    AC_CHECK_HEADER(fpxlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(fpx,FPX_OpenImageByFilename,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_LANG_POP
    AC_MSG_CHECKING([if FlashPIX package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_fpx='no (failed tests)'
        else
            FPX_LIBS='-lfpx'
            AC_DEFINE(FPX_DELEGATE,1,Define if you have FlashPIX library)
            AC_MSG_RESULT([yes])
            have_fpx='yes'
            PERLMAINCC="$CXX"
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(FPX_DELEGATE, test "$have_fpx" = 'yes')
AC_SUBST(FPX_LIBS)

dnl ===========================================================================

#
# Check for fontconfig delegate library.
#
AC_ARG_WITH([fontconfig],
    [AC_HELP_STRING([--without-fontconfig],
                    [disable fontconfig support])],
        [with_fontconfig=$withval],
        [with_fontconfig=$have_x])

if test "$with_fontconfig" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fontconfig=$with_fontconfig "
fi

have_fontconfig='no'
FONTCONFIG_CFLAGS=""
FONTCONFIG_LIBS=""
FONTCONFIG_PKG=""
if test "x$with_fontconfig" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(FONTCONFIG,[fontconfig >= 2.1.0], have_fontconfig=yes, have_fontconfig=no)
    AC_MSG_RESULT([])
fi

if test "$have_fontconfig" = 'yes'; then
cristy's avatar
cristy committed
1748 1749
  AC_DEFINE(FONTCONFIG_DELEGATE,1,Define if you have FONTCONFIG library)
  if test "$with_modules" = 'no'; then
cristy's avatar
cristy committed
1750
    CPPFLAGS="$FONTCONFIG_CFLAGS $CPPFLAGS"
cristy's avatar
cristy committed
1751
  fi
cristy's avatar
cristy committed
1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781
fi

AM_CONDITIONAL(FONTCONFIG_DELEGATE,test "$have_fontconfig" = 'yes')
AC_SUBST(FONTCONFIG_CFLAGS)
AC_SUBST(FONTCONFIG_LIBS)

dnl ===========================================================================

#
# Check for freetype delegate library.
#
AC_ARG_WITH([freetype],
    [AC_HELP_STRING([--without-freetype],
                    [disable Freetype support])],
    [with_freetype=$withval],
    [with_freetype='yes'])


if test "$with_freetype" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-freetype=$with_freetype "
fi

have_freetype='no'
FREETYPE_LIBS=''
if test "$with_freetype" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for FreeType 2.0])
    AC_MSG_RESULT([])
    failed=0
    passed=0
cristy's avatar
cristy committed
1782
    PERSIST_LIBS="$LIBS"
cristy's avatar
cristy committed
1783 1784 1785 1786 1787 1788 1789 1790 1791
    PERSIST_CPPFLAGS="$CPPFLAGS"
    if test "$enable_delegate_build" != 'no' && test -d "$builddir/freetype/include"; then
        :
    else
        freetype_config=''
        AC_CHECK_PROGS(freetype_config,freetype-config,)dnl
        if test -n "$freetype_config"; then
            freetype_cflags=`$freetype_config --cflags`
            freetype_libs=`$freetype_config --libs`
cristy's avatar
cristy committed
1792
            LIBS="$LIBS $freetype_libs"
cristy's avatar
cristy committed
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803
            CPPFLAGS="$freetype_cflags $CPPFLAGS"
        fi
    fi

dnl First see if there is a library
    if test "$FREETYPE_LIBS" = ''; then
        AC_CHECK_LIB(freetype,FT_Init_FreeType,FREETYPE_LIBS='-lfreetype',,)
        if test "$FREETYPE_LIBS" != ''; then
            passed=`expr $passed + 1`
        else
            failed=`expr $failed + 1`
cristy's avatar
cristy committed
1804
            LIBS="$PERSIST_LIBS"
cristy's avatar
cristy committed
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855
        fi
    fi

dnl Now test for the headers
    AC_CHECK_HEADER([ft2build.h],[FT2BUILD_H='#include <ft2build.h>'],[ft2build=''],[])
    AC_CHECK_HEADER(freetype/freetype.h,[have_freetype_h='yes'],[have_freetype_h='no'],[$FT2BUILD_H])
    if test "$ac_cv_header_ft2build_h" = 'yes' || test "$have_freetype_h" = 'yes'; then
        passed=`expr $passed + 1`
    else
        failed=`expr $failed + 1`
        CPPFLAGS="$PERSIST_CPPFLAGS"
    fi

    AC_MSG_CHECKING([if FreeType package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            FREETYPE_LIBS=''
            AC_MSG_RESULT([no -- some components failed test])
            have_freetype='no (failed tests)'
        else
            LIBS="$FREETYPE_LIBS $LIBS"
            AC_DEFINE(FREETYPE_DELEGATE,1,Define if you have FreeType (TrueType font) library)
            if test "$ac_cv_header_ft2build_h" = 'yes'; then
                AC_DEFINE([HAVE_FT2BUILD_H],[1],[Define to 1 if you have the <ft2build.h> header file.])
            fi
            AC_MSG_RESULT([yes])
            have_freetype='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(FREETYPE_DELEGATE,test "$have_freetype" = 'yes')
AC_SUBST(FREETYPE_LIBS)

dnl ===========================================================================

dnl ===========================================================================

#
# Check for Ghostscript library or framework.
#
# Test for iapi.h & test for gsapi_new_instance in -lgs
# or -framework Ghostscript

AC_ARG_WITH([gslib],
    [AC_HELP_STRING([--without-gslib],
                    [enable Ghostscript library support])],
    [with_gslib=$withval],
    [with_gslib='no'])

cristy's avatar
cristy committed
1856
gslib_framework='no'
cristy's avatar
cristy committed
1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
if test "$with_gslib" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gslib=$with_gslib "
fi

have_gslib='no'
GS_LIBS=''
if test "$with_gslib" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for Ghostscript])
    AC_MSG_RESULT([])
cristy's avatar
cristy committed
1867
    framework=0
cristy's avatar
cristy committed
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883
    failed=0
    passed=0
    AC_CHECK_HEADER(ghostscript/iapi.h,passed=`expr $passed + 1`,
        failed=`expr $failed + 1`,)
    AC_CHECK_HEADER(ghostscript/ierrors.h,passed=`expr $passed + 1`,
        failed=`expr $failed + 1`,)
    AC_CHECK_FRAMEWORK(Ghostscript,gsapi_new_instance,framework=`expr $framework + 1`,
    AC_CHECK_LIB(gs,gsapi_new_instance,passed=`expr $passed + 1`,failed=`expr $failed + 1`,),)
    AC_MSG_CHECKING([if Ghostscript package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_gslib='no (failed tests)'
        else
            if test $framework -gt 0; then
                GS_LIBS='-framework Ghostscript'
cristy's avatar
cristy committed
1884
                gslib_framework='yes'
cristy's avatar
cristy committed
1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
                AC_MSG_RESULT([yes, using framework.])
            else
                AC_MSG_RESULT([yes, using library.])
                GS_LIBS='-lgs'
            fi
            LIBS="$GS_LIBS $LIBS"
            AC_DEFINE(GS_DELEGATE,1,Define if you have Ghostscript library or framework)
            have_gslib='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(GS_DELEGATE, test "$have_gslib" = 'yes')
AC_SUBST(GS_LIBS)

# Set default font search path
AC_ARG_WITH([fontpath],
    [AC_HELP_STRING([--with-fontpath=DIR],
                    [prepend to default font search path])],
    [with_fontpath=$withval],
    [with_fontpath=''])

if test "$with_fontpath" != "yes" && test -z "$with_fontpath"; then
    with_fontpath=''
else
    AC_DEFINE_UNQUOTED(MAGICK_FONT_PATH,"$with_fontpath",Define to prepend to default font search path.)
fi
if test "$with_fontpath=" != ''; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fontpath=$with_fontpath "
fi

# Set Ghostscript font directory
AC_ARG_WITH([gs-font-dir],
    [AC_HELP_STRING([--with-gs-font-dir=DIR],
                    [Ghostscript font directory])],
    [with_gs_font_dir=$withval],
    [with_gs_font_dir='default'])

if test "$with_gs_font_dir" != 'default'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gs-font-dir=$with_gs_font_dir "
fi

dnl ===========================================================================

#
# Check for GVC delegate library.
#
AC_ARG_WITH(gvc,
    [AC_HELP_STRING([--without-gvc],
                    [disable GVC support])],
    [with_gvc=$withval],
    [with_gvc='yes'])

if test "$with_gvc" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gvc=$with_gvc "
fi

GVC_PKG=""
if test "x$with_gvc" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(GVC,[libgvc >= 2.9.0], have_gvc=yes, have_gvc=no)
    AC_MSG_RESULT([])
fi

if test "$have_gvc" = 'yes'; then
    AC_DEFINE(GVC_DELEGATE,1,Define if you have GVC library)
    if test "$with_modules" = 'no'; then
        CPPFLAGS="$GVC_CFLAGS $CPPFLAGS"
    fi
fi

AM_CONDITIONAL(GVC_DELEGATE, test "$have_gvc" = 'yes')
AC_SUBST(GVC_CFLAGS)
AC_SUBST(GVC_LIBS)

dnl ===========================================================================

#
# Check for JBIG delegate library.
#

AC_ARG_WITH([jbig],
    [AC_HELP_STRING([--without-jbig],
                    [disable JBIG support])],
    [with_jbig=$withval],
    [with_jbig='yes'])

have_jbig='no'
JBIG_LIBS=''
if test "$with_jbig" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for JBIG])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(jbig.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(jbig,jbg_dec_init,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if JBIG package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_jbig='no (failed tests)'
        else
            JBIG_LIBS='-ljbig'
            LIBS="$JBIG_LIBS $LIBS"
            AC_DEFINE(JBIG_DELEGATE,1,Define if you have JBIG library)
            AC_MSG_RESULT([yes])
            have_jbig='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(JBIG_DELEGATE, test "$have_jbig" = 'yes')
AC_SUBST(JBIG_LIBS)

dnl ===========================================================================

#
# Check for JPEG delegate library.
#
AC_ARG_WITH([jpeg],
    [AC_HELP_STRING([--without-jpeg],
                    [disable JPEG support])],
    [with_jpeg=$withval],
    [with_jpeg='yes'])

if test "$with_jpeg" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jpeg=$with_jpeg "
fi

have_jpeg='no'
JPEG_LIBS=''
if test "$with_jpeg" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for JPEG])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(jconfig.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_HEADER(jerror.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_HEADER(jmorecfg.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_HEADER(jpeglib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(jpeg,jpeg_read_header,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)

# Test for compatible JPEG library
if test "$ac_cv_jpeg_version_ok" != 'yes'; then
AC_CACHE_CHECK(for JPEG library is version 6b or later, ac_cv_jpeg_version_ok,
[AC_TRY_COMPILE(
#include <stdio.h>
#include <stdlib.h>
#include <jpeglib.h>
,
changequote(<<, >>)dnl
<<
#if JPEG_LIB_VERSION < 62
#error IJG JPEG library must be version 6b or newer!
#endif
return 0;
>>,
changequote([, ])dnl
ac_cv_jpeg_version_ok='yes'; passed=`expr $passed + 1`,
ac_cv_jpeg_version_ok='no'; failed=`expr $failed + 1`)])
fi
    AC_MSG_CHECKING([if JPEG package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_jpeg='no (failed tests)'
        else
            JPEG_LIBS='-ljpeg'
            LIBS="$JPEG_LIBS $LIBS"
            AC_DEFINE(JPEG_DELEGATE,1,Define if you have JPEG library)
            AC_MSG_RESULT([yes])
            have_jpeg='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(JPEG_DELEGATE, test "$have_jpeg" = 'yes')
AC_SUBST(JPEG_LIBS)

dnl ===========================================================================

#
# Check for JPEG Version 2 delegate library.
#
AC_ARG_WITH([jp2],
    [AC_HELP_STRING([--without-jp2],
                    [disable JPEG-2000 support])],
    [with_jp2=$withval],
    [with_jp2='yes'])

if test "$with_jp2" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jp2=$with_jp2 "
fi

have_jp2='no'
JP2_LIBS=''
if test "$with_jp2" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for JPEG Version 2])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(jasper/jasper.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(jasper,jas_stream_fopen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if JPEG version 2 support package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_jp2='no (failed tests)'
        else
            JP2_LIBS='-ljasper'
            LIBS="$JP2_LIBS $LIBS"
            AC_DEFINE(JP2_DELEGATE,1,Define if you have JPEG version 2 "Jasper" library)
            AC_MSG_RESULT([yes])
            have_jp2='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(JP2_DELEGATE, test "$have_jp2" = 'yes')
AC_SUBST(JP2_LIBS)

dnl ===========================================================================

#
# Check for LCMS delegate library.
#
cristy's avatar
cristy committed
2118
# Disable LCMS.
cristy's avatar
cristy committed
2119
AC_ARG_WITH(lcms,
cristy's avatar
cristy committed
2120 2121 2122 2123
        [  --without-lcms          disable lcms (v1.1X) support],
        [with_lcms=$withval],
        [with_lcms='yes'])
if test "$with_lcms" != 'yes' ; then
cristy's avatar
cristy committed
2124 2125 2126
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lcms=$with_lcms "
fi

cristy's avatar
cristy committed
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136
# Disable LCMS2.
AC_ARG_WITH(lcms2,
        [  --without-lcms2         disable lcms (v2.X) support],
        [with_lcms2=$withval],
        [with_lcms2='yes'])
if test "$with_lcms2" != 'yes' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lcms2=$with_lcms2 "
fi

have_lcms2='no'
cristy's avatar
cristy committed
2137
LCMS_LIBS=''
cristy's avatar
cristy committed
2138
if test "$with_lcms2" != 'no'; then
cristy's avatar
cristy committed
2139
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
2140 2141
    AC_MSG_CHECKING([for LCMS v2])
    AC_MSG_RESULT()
cristy's avatar
cristy committed
2142 2143 2144
    failed=0
    passed=0
    have_lcms_header='no'
cristy's avatar
cristy committed
2145 2146

    # Check for <lcms2.h>
cristy's avatar
cristy committed
2147 2148
    AC_CHECK_HEADER(lcms2.h,have_lcms_header='yes',,)
    if test "$have_lcms_header" = 'yes'; then
cristy's avatar
cristy committed
2149 2150 2151 2152 2153 2154 2155 2156
       AC_DEFINE(HAVE_LCMS2_H,1,Define if you have the <lcms2.h> header file.)
       passed=`expr $passed + 1`
    fi

    # Check for <lcms2/lcms2.h)
    if test "$have_lcms_header" != 'yes'; then
      AC_CHECK_HEADER(lcms2/lcms2.h,have_lcms_header='yes',,)
      if test "$have_lcms_header" = 'yes'; then
cristy's avatar
cristy committed
2157
        passed=`expr $passed + 1`
cristy's avatar
cristy committed
2158 2159 2160 2161 2162 2163 2164
        AC_DEFINE(HAVE_LCMS2_LCMS2_H,1,Define if you have the <lcms2/lcms2.h> header file.)
      fi
    fi

    # Failed to find lcms header?
    if test "$have_lcms_header" != 'yes'; then
      failed=`expr $failed + 1`
cristy's avatar
cristy committed
2165
    fi
cristy's avatar
cristy committed
2166 2167 2168

    AC_CHECK_LIB(lcms2,cmsSetLogErrorHandler,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING(if LCMS v2 package is complete)
cristy's avatar
cristy committed
2169
    if test $passed -gt 0; then
cristy's avatar
cristy committed
2170 2171 2172 2173 2174 2175 2176 2177 2178
      if test $failed -gt 0; then
        AC_MSG_RESULT(no -- some components failed test)
        have_lcms2='no (failed tests)'
      else
        LCMS_LIBS='-llcms2'
        LIBS="$LCMS_LIBS $LIBS"
        AC_MSG_RESULT(yes)
        have_lcms2='yes'
      fi
cristy's avatar
cristy committed
2179
    else
cristy's avatar
cristy committed
2180
      AC_MSG_RESULT(no)
cristy's avatar
cristy committed
2181 2182 2183
    fi
fi

cristy's avatar
cristy committed
2184 2185 2186 2187 2188 2189 2190 2191
#
# Check for LCMS v1 (1.11 or later)
#
if test $have_lcms2 = 'yes'; then
  with_lcms='no'
fi

have_lcms='no'
cristy's avatar
cristy committed
2192
if test "$with_lcms" != 'no'; then
cristy's avatar
cristy committed
2193
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
2194 2195
    AC_MSG_CHECKING([for LCMS v1.1X])
    AC_MSG_RESULT()
cristy's avatar
cristy committed
2196 2197 2198
    failed=0
    passed=0
    have_lcms_header='no'
cristy's avatar
cristy committed
2199 2200 2201 2202 2203

    # Check for <lcms.h>
    if test "$have_lcms_header" != 'yes'; then
      AC_CHECK_HEADER(lcms.h,have_lcms_header='yes',,)
      if test "$have_lcms_header" = 'yes'; then
cristy's avatar
cristy committed
2204 2205
        passed=`expr $passed + 1`
        AC_DEFINE(HAVE_LCMS_H,1,Define if you have the <lcms.h> header file.)
cristy's avatar
cristy committed
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215
      fi
    fi

    # Check for <lcms/lcms.h>
    if test "$have_lcms_header" != 'yes'; then
      AC_CHECK_HEADER(lcms/lcms.h,have_lcms_header='yes',,)
      if test "$have_lcms_header" = 'yes'; then
        passed=`expr $passed + 1`
        AC_DEFINE(HAVE_LCMS_LCMS_H,1,Define if you have the <lcms/lcms.h> header file.)
      fi
cristy's avatar
cristy committed
2216
    fi
cristy's avatar
cristy committed
2217 2218 2219 2220 2221 2222 2223 2224

    # Failed to find lcms header?
    if test "$have_lcms_header" != 'yes'; then
      failed=`expr $failed + 1`
    fi

    AC_CHECK_LIB(lcms,cmsSetErrorHandler,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING(if LCMS package is complete)
cristy's avatar
cristy committed
2225
    if test $passed -gt 0; then
cristy's avatar
cristy committed
2226 2227 2228 2229 2230 2231 2232 2233 2234
      if test $failed -gt 0; then
        AC_MSG_RESULT(no -- some components failed test)
        have_lcms='no (failed tests)'
      else
        LCMS_LIBS='-llcms'
        LIBS="$LCMS_LIBS $LIBS"
        AC_MSG_RESULT(yes)
        have_lcms='yes'
      fi
cristy's avatar
cristy committed
2235
    else
cristy's avatar
cristy committed
2236
      AC_MSG_RESULT(no)
cristy's avatar
cristy committed
2237 2238
    fi
fi
cristy's avatar
cristy committed
2239 2240 2241 2242

AM_CONDITIONAL(LCMS_DELEGATE, test "$have_lcms2" = 'yes' -o "$have_lcms" = 'yes')
if test "$have_lcms2" = 'yes' -o "$have_lcms" = 'yes'; then
  AC_DEFINE(LCMS_DELEGATE,1,[Define if you have LCMS (v1.11 or later) library])
cristy's avatar
cristy committed
2243
fi
cristy's avatar
cristy committed
2244 2245
AC_SUBST(LCMS_LIBS)

cristy's avatar
cristy committed
2246

cristy's avatar
cristy committed
2247 2248 2249 2250 2251 2252 2253
dnl ===========================================================================

#
# Check for the LQR (Liquid Rescale) delegate library.
#
AC_ARG_WITH([lqr],
    [AC_HELP_STRING([--without-lqr],
cristy's avatar
cristy committed
2254
                    [disable Liquid Rescale support])],
cristy's avatar
cristy committed
2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434
    [with_lqr=$withval],
    [with_lqr='yes'])

if test "$with_lqr" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lqr=$with_lqr "
fi

have_lqr='no'
LQR_CFLAGS=""
LQR_LIBS=""
LQR_PKG=""
if test "x$with_lqr" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(LQR,[lqr-1 >= 0.1.0], have_lqr=yes, have_lqr=no)
    AC_MSG_RESULT([])
fi

if test "$have_lqr" = 'yes'; then
    AC_DEFINE(LQR_DELEGATE,1,Define if you have LQR library)
    CFLAGS="$LQR_CFLAGS $CFLAGS"
fi

AM_CONDITIONAL(LQR_DELEGATE, test "$have_lqr" = 'yes')
AC_SUBST(LQR_CFLAGS)
AC_SUBST(LQR_LIBS)

dnl ===========================================================================

#
# Check for the OpenEXR delegate library.
#
AC_ARG_WITH([openexr],
    [AC_HELP_STRING([--without-openexr],
                    [disable OpenEXR support])],
    [with_openexr=$withval],
    [with_openexr='yes'])

if test "$with_openexr" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-openexr=$with_openexr "
fi

have_openexr='no'
OPENEXR_CFLAGS=""
OPENEXR_LIBS=""
OPENEXR_PKG=""
if test "x$with_openexr" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(OPENEXR,[OpenEXR >= 1.0.6], have_openexr=yes, have_openexr=no)
    AC_MSG_RESULT([])
fi

if test "$have_openexr" = 'yes'; then
    AC_DEFINE(OPENEXR_DELEGATE,1,Define if you have OPENEXR library)
    if test "$with_modules" = 'no'; then
        CFLAGS="$OPENEXR_CFLAGS $CFLAGS"
    fi
fi

AM_CONDITIONAL(OPENEXR_DELEGATE, test "$have_openexr" = 'yes')
AC_SUBST(OPENEXR_CFLAGS)
AC_SUBST(OPENEXR_LIBS)

dnl ===========================================================================

#
# Check for PNG delegate library.
#
AC_ARG_WITH(png,
    [AC_HELP_STRING([--without-png],
                    [disable PNG support])],
    [with_png=$withval],
    [with_png='yes'])

if test "$with_png" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
fi

have_png='no'
PNG_LIBS=''
if test "$with_png" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for PNG])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(png.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(png,png_get_io_ptr,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if PNG package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_png='no (failed tests)'
        else
            PNG_LIBS='-lpng'
            LIBS="$PNG_LIBS $LIBS"
            AC_DEFINE(PNG_DELEGATE,1,Define if you have PNG library)
            AC_MSG_RESULT([yes])
            have_png='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(PNG_DELEGATE,test "$have_png" = 'yes')
AC_SUBST(PNG_LIBS)

dnl ===========================================================================

#
# Check for RSVG delegate library.
#
AC_ARG_WITH([rsvg],
    [AC_HELP_STRING([--without-rsvg],
                    [disable RSVG support])],
    [with_rsvg=$withval],
    [with_rsvg=$have_x])

if test "$with_rsvg" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-rsvg=$with_rsvg "
fi

have_rsvg='no'
have_cairo='no'
RSVG_CFLAGS=""
RSVG_LIBS=""
RSVG_PKG=""
if test "x$with_rsvg" = "xyes"; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    PKG_CHECK_MODULES(RSVG,[librsvg-2.0 >= 2.9.0], have_rsvg=yes, have_rsvg=no)
    AC_MSG_RESULT([])
    PKG_CHECK_MODULES(CAIRO_SVG, cairo-svg, have_cairo=yes, have_cairo=no)
    AC_MSG_RESULT([])
fi

if test "$have_rsvg" = 'yes'; then
    AC_DEFINE(RSVG_DELEGATE,1,Define if you have RSVG library)
    if test "$with_modules" = 'no'; then
        CPPFLAGS="$RSVG_CFLAGS $CPPFLAGS"
    fi
fi

if test "$have_cairo" = 'yes'; then
    AC_DEFINE(CAIRO_DELEGATE,1,Define if you have CAIRO library)
    if test "$with_modules" = 'no'; then
        CPPFLAGS="$CAIRO_SVG_CFLAGS $CPPFLAGS"
    fi
fi

AM_CONDITIONAL(RSVG_DELEGATE, test "$have_rsvg" = 'yes')
AM_CONDITIONAL(CAIRO_DELEGATE, test "$have_cairo" = 'yes')
AC_SUBST(RSVG_CFLAGS)
AC_SUBST(RSVG_LIBS)

dnl ===========================================================================

#
# Check for TIFF delegate library.
#
AC_ARG_WITH([tiff],
    [AC_HELP_STRING([--without-tiff],
                    [disable TIFF support])],
    [with_tiff=$withval],
    [with_tiff='yes'])

if test "$with_tiff" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-tiff=$with_tiff "
fi

have_tiff='no'
TIFF_LIBS=''
if test "$with_tiff" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for TIFF])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(tiff.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_HEADER(tiffio.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(tiff,TIFFOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(tiff,TIFFClientOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
cristy's avatar
cristy committed
2435
    AC_CHECK_LIB(tiff,TIFFIsBigEndian,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
cristy's avatar
cristy committed
2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484
    AC_CHECK_LIB(tiff,TIFFIsByteSwapped,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(tiff,TIFFReadRGBATile,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(tiff,TIFFReadRGBAStrip,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if TIFF package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_tiff='no (failed tests)'
        else
            TIFF_LIBS='-ltiff'
            LIBS="$TIFF_LIBS $LIBS"
            AC_DEFINE(TIFF_DELEGATE,1,Define if you have TIFF library)
            AC_MSG_RESULT([yes])
            have_tiff='yes'
            AC_CHECK_HEADERS(tiffconf.h)
            AC_CHECK_FUNCS([TIFFIsCODECConfigured TIFFMergeFieldInfo \
              TIFFReadEXIFDirectory TIFFSetErrorHandlerExt TIFFSetTagExtender \
              TIFFSetWarningHandlerExt TIFFSwabArrayOfTriples])
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(TIFF_DELEGATE, test "$have_tiff" = 'yes')
AC_SUBST(TIFF_LIBS)

dnl ===========================================================================

#
# Set Windows font directory.
#
AC_ARG_WITH(windows-font-dir,
    [AC_HELP_STRING([--with-windows-font-dir=DIR],
                    [directory containing MS-Windows fonts])],
                    [with_windows_font_dir=$withval],
                    [with_windows_font_dir=''])
if test "$with_windows_font_dir" != '' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-windows-font-dir=$with_windows_font_dir "
fi

dnl ===========================================================================

#
# Check for WMF delegate library.
#
AC_ARG_WITH([wmf],
    [AC_HELP_STRING([--without-wmf],
                    [disable WMF support])],
    [with_wmf=$withval],
cristy's avatar
cristy committed
2485
    [with_wmf='yes'])
cristy's avatar
cristy committed
2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496

if test "$with_wmf" != 'yes'; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-wmf=$with_wmf "
fi

have_wmf='no'
WMF_LIBS=''
if test "$with_wmf" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for WMF])
    AC_MSG_RESULT([])
cristy's avatar
cristy committed
2497 2498 2499
    failed=0
    passed=0
    AC_CHECK_HEADER(libwmf/eps.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
cristy's avatar
cristy committed
2500
    AC_CHECK_LIB(wmf,wmf_eps_function,passed=`expr $passed + 1`,failed=`expr $failed + 1`,"-lwmflite")
cristy's avatar
cristy committed
2501 2502 2503 2504 2505 2506 2507
    AC_MSG_CHECKING([if WMF package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_wmf='no (failed tests)'
        else
            WMF_LIBS='-lwmf -lwmflite'
cristy's avatar
cristy committed
2508
            LIBS="$WMF_LIBS $LIBS"
cristy's avatar
cristy committed
2509 2510
            AC_DEFINE(WMF_DELEGATE,1,Define if you have WMF library)
            AC_MSG_RESULT([yes])
cristy's avatar
cristy committed
2511 2512 2513 2514 2515 2516
            have_wmf='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
cristy's avatar
cristy committed
2517
AM_CONDITIONAL(WMF_DELEGATE,test "$have_wmf" = 'yes')
cristy's avatar
cristy committed
2518
AC_SUBST(WMF_LIBS)
cristy's avatar
cristy committed
2519 2520 2521

dnl ===========================================================================

cristy's avatar
cristy committed
2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711

dnl ===========================================================================

#
# Check for XML delegate library.
#
AC_ARG_WITH([xml],
    [AC_HELP_STRING([--without-xml],
                    [disable XML support])],
    [with_xml=$withval],
    [with_xml=$have_x])

if test "$with_xml" != 'yes' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-xml=$with_xml "
fi

have_xml='no'
XML_LIBS=''
if test "$with_xml" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for XML])
    AC_MSG_RESULT([])
    PERSIST_LDFLAGS=$LDFLAGS
    PERSIST_CPPFLAGS=$CPPFLAGS
    xml2_config=''
    AC_CHECK_PROGS(xml2_config,xml2-config,)dnl
    if test -n "$xml2_config"; then
        # Debian installs libxml headers under /usr/include/libxml2/libxml with
        # the shared library installed under /usr/lib, whereas the package
        # installs itself under $prefix/libxml and $prefix/lib.
        xml2_prefix=`xml2-config --prefix`
        if test -d "${xml2_prefix}/include/libxml2"; then
            CPPFLAGS="$CPPFLAGS -I${xml2_prefix}/include/libxml2"
        fi
        if test "${xml2_prefix}" != '/usr'; then
            LDFLAGS="$LDFLAGS -L${xml2_prefix}/lib"
        fi
    fi
    failed=0
    passed=0
    AC_CHECK_HEADER(libxml/parser.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
    AC_CHECK_LIB(xml2,xmlParseExternalEntity,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if XML package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_xml='no (failed tests)'
            LDFLAGS="$PERSIST_LDFLAGS"
            CPPFLAGS="$PERSIST_CPPFLAGS"
        else
            XML_LIBS='-lxml2'
            LIBS="$XML_LIBS $LIBS"
            AC_DEFINE(XML_DELEGATE,1,Define if you have XML library)
            AC_MSG_RESULT([yes])
            have_xml='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(XML_DELEGATE,test "$have_xml" = 'yes')
AC_SUBST(XML_LIBS)

dnl ===========================================================================

# Substitute compiler name to build/link PerlMagick
#
AC_SUBST(PERLMAINCC)

#
# Configure install Paths
#

# Subdirectory under lib to place ImageMagick lib files
LIBRARY_RELATIVE_PATH="${PACKAGE_NAME}-${PACKAGE_VERSION}"
AC_DEFINE_UNQUOTED(LIBRARY_RELATIVE_PATH,"$LIBRARY_RELATIVE_PATH",Subdirectory of lib where ImageMagick architecture dependent files are installed)

# Path to ImageMagick bin directory
EXECUTABLE_PATH="${BIN_DIR}"
DEFINE_EXECUTABLE_PATH="${BIN_DIR}/"
case "${build_os}" in
  mingw* )
    DEFINE_EXECUTABLE_PATH=`$WinPathScript "$DEFINE_EXECUTABLE_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(EXECUTABLE_PATH,"$DEFINE_EXECUTABLE_PATH",Directory where executables are installed.)
AC_SUBST(EXECUTABLE_PATH)

# Path to ImageMagick lib
LIBRARY_PATH="${LIB_DIR}/${LIBRARY_RELATIVE_PATH}"
DEFINE_LIBRARY_PATH="${LIB_DIR}/${LIBRARY_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_LIBRARY_PATH=`$WinPathScript "$DEFINE_LIBRARY_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(LIBRARY_PATH,"$DEFINE_LIBRARY_PATH",Directory where architecture-dependent files live.)
AC_SUBST(LIBRARY_PATH)

# Subdirectory under lib to place ImageMagick configuration files
CONFIGURE_RELATIVE_PATH="${LIBRARY_RELATIVE_PATH}/config"
AC_DEFINE_UNQUOTED(CONFIGURE_RELATIVE_PATH,"$CONFIGURE_RELATIVE_PATH",Subdirectory of lib where architecture-dependent configuration files live.)
CONFIGURE_PATH="${LIB_DIR}/${CONFIGURE_RELATIVE_PATH}/"
DEFINE_CONFIGURE_PATH="${LIB_DIR}/${CONFIGURE_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_CONFIGURE_PATH=`$WinPathScript "$DEFINE_CONFIGURE_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(CONFIGURE_PATH,"$DEFINE_CONFIGURE_PATH",Directory where architecture-dependent configuration files live.)
AC_SUBST(CONFIGURE_PATH)

#
# Subdirectory under lib to place ImageMagick coder module files
CODER_RELATIVE_PATH="${LIBRARY_RELATIVE_PATH}/modules-Q${QUANTUM_DEPTH}/coders"
AC_DEFINE_UNQUOTED(CODER_RELATIVE_PATH,"$CODER_RELATIVE_PATH",Subdirectory of lib where coder modules are installed)
CODER_PATH="${LIB_DIR}/${CODER_RELATIVE_PATH}"
DEFINE_CODER_PATH="${LIB_DIR}/${CODER_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_CODER_PATH=`$WinPathScript "$DEFINE_CODER_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(CODER_PATH,"$DEFINE_CODER_PATH",Location of coder modules)
AC_SUBST(CODER_PATH)

#
# Subdirectory under lib to place ImageMagick filter module files
FILTER_RELATIVE_PATH="${LIBRARY_RELATIVE_PATH}/modules-Q${QUANTUM_DEPTH}/filters"
AC_DEFINE_UNQUOTED(FILTER_RELATIVE_PATH,"$FILTER_RELATIVE_PATH",Subdirectory of lib where filter modules are installed)
FILTER_PATH="${LIB_DIR}/${FILTER_RELATIVE_PATH}"
DEFINE_FILTER_PATH="${LIB_DIR}/${FILTER_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_FILTER_PATH=`$WinPathScript "$DEFINE_FILTER_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(FILTER_PATH,"$DEFINE_FILTER_PATH",Location of filter modules)
AC_SUBST(FILTER_PATH)

#
# Path to ImageMagick documentation files
DOCUMENTATION_RELATIVE_PATH="${PACKAGE_NAME}-${PACKAGE_VERSION}"
DOCUMENTATION_PATH="${DATA_DIR}/doc/${DOCUMENTATION_RELATIVE_PATH}"
DEFINE_DOCUMENTATION_PATH="${DATA_DIR}/doc/${DOCUMENTATION_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_DOCUMENTATION_PATH=`$WinPathScript "$DEFINE_DOCUMENTATION_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(DOCUMENTATION_PATH,"$DEFINE_DOCUMENTATION_PATH",Directory where ImageMagick documents live.)
AC_SUBST(DOCUMENTATION_PATH)

#
# Path to ImageMagick share files
SHARE_RELATIVE_PATH="${PACKAGE_NAME}-${PACKAGE_VERSION}"
SHARE_PATH="${DATA_DIR}/${SHARE_RELATIVE_PATH}"
DEFINE_SHARE_PATH="${DATA_DIR}/${SHARE_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_SHARE_PATH=`$WinPathScript "$DEFINE_SHARE_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(SHARE_PATH,"$DEFINE_SHARE_PATH",Directory where architecture-independent files live.)
AC_SUBST(SHARE_PATH)

# Subdirectory under share to place ImageMagick configuration files
SHARE_CONFIGURE_RELATIVE_PATH="${LIBRARY_RELATIVE_PATH}/config"
AC_DEFINE_UNQUOTED(SHARE_CONFIGURE_RELATIVE_PATH,"$SHARE_CONFIGURE_RELATIVE_PATH",Subdirectory of lib where architecture-independent configuration files live.)
SHARE_CONFIGURE_PATH="${DATA_DIR}/${SHARE_CONFIGURE_RELATIVE_PATH}"
DEFINE_SHARE_CONFIGURE_PATH="${DATA_DIR}/${SHARE_CONFIGURE_RELATIVE_PATH}/"
case "${build_os}" in
  mingw* )
    DEFINE_SHARE_CONFIGURE_PATH=`$WinPathScript "$DEFINE_SHARE_CONFIGURE_PATH" 1`
    ;;
esac
AC_DEFINE_UNQUOTED(SHARE_CONFIGURE_PATH,"$DEFINE_SHARE_CONFIGURE_PATH",Directory where architecture-independent configuration files live.)
AC_SUBST(SHARE_CONFIGURE_PATH)

#
# program_transform_name is formed for use in a Makefile, so create a
# modified version for use in a shell script.
configure_transform_name=`echo ${program_transform_name} | sed 's,\\$\\$,$,'`

# Default delegate definitions
AC_MSG_RESULT([-------------------------------------------------------------])
AC_MSG_CHECKING([for ImageMagick delegate programs])
AC_MSG_RESULT([])
AutotraceDecodeDelegateDefault='autotrace'
AVIDecodeDelegateDefault='mplayer'
cristy's avatar
cristy committed
2712
BlenderDecodeDelegateDefault='blender'
cristy's avatar
cristy committed
2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739
BZIPDelegateDefault='bzip2'
BrowseDelegateDefault='xdg-open'
CGMDecodeDelegateDefault='ralcgm'
CatDelegateDefault='cat'
DNGDecodeDelegateDefault='ufraw-batch'
GVCDecodeDelegateDefault='dot'
DVIDecodeDelegateDefault='dvips'
EchoDelegateDefault='echo'
EditorDelegateDefault='xterm'
FIGDecodeDelegateDefault='fig2dev'
ConvertDelegateDefault=`echo convert | sed ${configure_transform_name}`
DisplayDelegateDefault=`echo display | sed ${configure_transform_name}`
MogrifyDelegateDefault=`echo mogrify | sed ${configure_transform_name}`
GnuplotDecodeDelegateDefault='gnuplot'
HDRDecodeDelegateDefault='ra_pfm'
HPGLDecodeDelegateDefault='hp2xx'
HTMLDecodeDelegateDefault='html2ps'
ILBMDecodeDelegateDefault='ilbmtoppm'
ILBMEncodeDelegateDefault='ppmtoilbm'
LPDelegateDefault='lp'
LPRDelegateDefault='lpr'
LZWDecodeDelegateDefault='uncompress'
LZWEncodeDelegateDefault='compress'
LaunchDelegateDefault='gimp'
MANDelegateDefault='groff'
MPEGDecodeDelegateDefault='ffmpeg'
MPEGEncodeDelegateDefault='ffmpeg'
cristy's avatar
cristy committed
2740
MrSIDDecodeDelegateDefault='mrsidgeodecode'
cristy's avatar
cristy committed
2741 2742 2743 2744 2745 2746
MVDelegateDefault='mv'
PCLDelegateDefault='pcl6'
PGPDecodeDelegateDefault='pgpv'
POVDelegateDefault='povray'
if test "$native_win32_build" = 'yes'; then
    PSDelegateDefault='gswin32c'
cristy's avatar
cristy committed
2747
elif test "$gslib_framework" = 'yes'; then
cristy's avatar
cristy committed
2748 2749 2750 2751 2752 2753
    PSDelegateDefault='gsc'
else
    PSDelegateDefault='gs'
fi
RLEEncodeDelegateDefault='rawtorle'
RMDelegateDefault='rm'
cristy's avatar
cristy committed
2754
RSVGDecodeDelegateDefault='rsvg'
cristy's avatar
cristy committed
2755 2756
SCANDecodeDelegateDefault='scanimage'
TXTDelegateDefault='enscript'
cristy's avatar
cristy committed
2757
UniconvertorDelegateDefault='uniconvertor'
cristy's avatar
cristy committed
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793
WMFDecodeDelegateDefault='wmf2eps'
WWWDecodeDelegateDefault='curl'
XPSDelegateDefault='gxps'
ZipDelegateDefault='gzip'

# Search for delegates
AC_PATH_PROG(AutotraceDecodeDelegate, "$AutotraceDecodeDelegateDefault", "$AutotraceDecodeDelegateDefault")
AC_PATH_PROG(AVIDecodeDelegate, "$AVIDecodeDelegateDefault", "$AVIDecodeDelegateDefault")
AC_PATH_PROG(BlenderDecodeDelegate, "$BlenderDecodeDelegateDefault", "$BlenderDecodeDelegateDefault")
AC_PATH_PROG(BZIPDelegate, "$BZIPDelegateDefault", "$BZIPDelegateDefault")
AC_PATH_PROG(BrowseDelegate, "$BrowseDelegateDefault" mozilla firefox netscape, "$BrowseDelegateDefault")
AC_PATH_PROG(CGMDecodeDelegate, "$CGMDecodeDelegateDefault", "$CGMDecodeDelegateDefault")
AC_PATH_PROG(CatDelegate, "$CatDelegateDefault", "$CatDelegateDefault")
AC_PATH_PROG(DNGDecodeDelegate, "$DNGDecodeDelegateDefault", "$DNGDecodeDelegateDefault")
AC_PATH_PROG(GVCDecodeDelegate, "$GVCDecodeDelegateDefault", "$GVCDecodeDelegateDefault")
AC_PATH_PROG(DVIDecodeDelegate, "$DVIDecodeDelegateDefault", "$DVIDecodeDelegateDefault")
AC_PATH_PROG(EchoDelegate, "$EchoDelegateDefault", "$EchoDelegateDefault")
AC_PATH_PROG(EditorDelegate, "$EditorDelegateDefault", "$EditorDelegateDefault")
AC_PATH_PROG(FIGDecodeDelegate, "$FIGDecodeDelegateDefault", "$FIGDecodeDelegateDefault")
AC_PATH_PROG(ConvertDelegate, "$ConvertDelegateDefault", "$ConvertDelegateDefault")
AC_PATH_PROG(DisplayDelegate, "$DisplayDelegateDefault", "$DisplayDelegateDefault")
AC_PATH_PROG(MogrifyDelegate, "$MogrifyDelegateDefault", "$MogrifyDelegateDefault")
AC_PATH_PROG(GnuplotDecodeDelegate, "$GnuplotDecodeDelegateDefault", "$GnuplotDecodeDelegateDefault")
AC_PATH_PROG(HDRDecodeDelegate, "$HDRDecodeDelegateDefault", "$HDRDecodeDelegateDefault")
AC_PATH_PROG(HPGLDecodeDelegate, "$HPGLDecodeDelegateDefault", "$HPGLDecodeDelegateDefault")
AC_PATH_PROG(HTMLDecodeDelegate, "$HTMLDecodeDelegateDefault", "$HTMLDecodeDelegateDefault")
AC_PATH_PROG(ILBMDecodeDelegate, "$ILBMDecodeDelegateDefault", "$ILBMDecodeDelegateDefault")
AC_PATH_PROG(ILBMEncodeDelegate, "$ILBMEncodeDelegateDefault", "$ILBMEncodeDelegateDefault")
AC_PATH_PROG(LPDelegate, "$LPDelegateDefault", no)
AC_PATH_PROG(LPRDelegate, "$LPRDelegateDefault", "$LPRDelegateDefault")
AC_PATH_PROG(LZWDecodeDelegate, "$LZWDecodeDelegateDefault", "$LZWDecodeDelegateDefault")
AC_PATH_PROG(LZWEncodeDelegate, "$LZWEncodeDelegateDefault", "$LZWEncodeDelegateDefault")
AC_PATH_PROG(LaunchDelegate, "$LaunchDelegateDefault", "$LaunchDelegateDefault")
AC_PATH_PROG(MANDelegate, "$MANDelegateDefault", "$MANDelegateDefault")
AC_PATH_PROG(MPEGDecodeDelegate, "$MPEGDecodeDelegateDefault", "$MPEGDecodeDelegateDefault")
AC_PATH_PROG(MPEGEncodeDelegate, "$MPEGEncodeDelegateDefault", "$MPEGEncodeDelegateDefault")
cristy's avatar
cristy committed
2794
AC_PATH_PROG(MrSIDDecodeDelegate, "$MrSIDDecodeDelegateDefault", "$MrSIDDecodeDelegateDefault")
cristy's avatar
cristy committed
2795 2796 2797 2798 2799 2800 2801
AC_PATH_PROG(MVDelegate, "$MVDelegateDefault", "$MVDelegateDefault")
AC_PATH_PROG(PCLDelegate, "$PCLDelegateDefault", "$PCLDelegateDefault")
AC_PATH_PROG(PGPDecodeDelegate, "$PGPDecodeDelegateDefault", "$PGPDecodeDelegateDefault")
AC_PATH_PROG(POVDelegate, "$POVDelegateDefault", "$POVDelegateDefault")
AC_PATH_PROGS(PSDelegate, gsx gsc "$PSDelegateDefault", "$PSDelegateDefault")
AC_PATH_PROG(RLEEncodeDelegate, "$RLEEncodeDelegateDefault", "$RLEEncodeDelegateDefault")
AC_PATH_PROG(RMDelegate, "$RMDelegateDefault", "$RMDelegateDefault")
cristy's avatar
cristy committed
2802
AC_PATH_PROG(RSVGDecodeDelegate, "$RSVGDecodeDelegateDefault", "$RSVGDecodeDelegateDefault")
cristy's avatar
cristy committed
2803 2804
AC_PATH_PROG(SCANDecodeDelegate, "$SCANDecodeDelegateDefault", "$SCANDecodeDelegateDefault")
AC_PATH_PROG(TXTDelegate, "$TXTDelegateDefault", "$TXTDelegateDefault")
cristy's avatar
cristy committed
2805
AC_PATH_PROG(UniconvertorDelegate, "$UniconvertorDelegateDefault", "$UniconvertorDelegateDefault")
cristy's avatar
cristy committed
2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830
AC_PATH_PROG(WMFDecodeDelegate, "$WMFDecodeDelegateDefault", "$WMFDecodeDelegateDefault")
AC_PATH_PROG(WWWDecodeDelegate, "$WWWDecodeDelegateDefault", "$WWWDecodeDelegateDefault")
AC_PATH_PROG(XPSDelegate, "$XPSDelegateDefault", "$XPSDelegateDefault")
AC_PATH_PROG(ZipDelegate, "$ZipDelegateDefault", "$ZipDelegateDefault")

# Prefer lpr to lp; lp needs options tacked on.
if test "$LPRDelegate" != no; then
    PrintDelegate="$LPRDelegate"
else
    PrintDelegate="$LPDelegate -c -s"
fi
AC_SUBST(PrintDelegate)

# Installed ImageMagick utiltity paths
ConvertDelegate="${BIN_DIR}/${ConvertDelegateDefault}"
DisplayDelegate="${BIN_DIR}/${DisplayDelegateDefault}"
MogrifyDelegate="${BIN_DIR}/${MogrifyDelegateDefault}"

# Set delegate booleans
have_ffmpeg='no'; if test "$MPEGDecodeDelegate" != "$MPEGDecodeDelegateDefault" ; then have_ffmpeg='yes'; fi
have_fig2dev='no'    ; if test "$FIGDecodeDelegate" != "$FIGDecodeDelegateDefault" ; then have_fig2dev='yes'; fi
have_gs='no'         ; if test "$PSDelegate" != "$PSDelegateDefault"; then have_gs='yes'; fi
have_hp2xx='no'      ; if test "$HPGLDecodeDelegate" !=  "$HPGLDecodeDelegateDefault" ; then have_hp2xx='yes'; fi
have_ilbmtoppm='no'  ; if test "$ILBMDecodeDelegate" != "$ILBMDecodeDelegateDefault" ; then have_ilbmtoppm='yes'; fi
have_mplayer='no'; if test "$AVIDecodeDelegate" != "$AVIDecodeDelegateDefault" ; then have_mplayer='yes'; fi
cristy's avatar
cristy committed
2831
have_mrsid='no'; if test "$MrSIDDecodeDelegate" != "$MrSIDDecodeDelegateDefault" ; then have_mrsid='yes'; fi
cristy's avatar
cristy committed
2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842
have_pcl='no'        ; if test "$PCLDelegate" != "$PCLDelegateDefault"; then have_pcl='yes'; fi
have_ppmtoilbm='no'  ; if test "$ILBMEncodeDelegate" != "$ILBMEncodeDelegateDefault" ; then have_ppmtoilbm='yes'; fi
have_ra_pfm='no'     ; if test "$HDRDecodeDelegate" != "$HDRDecodeDelegateDefault" ; then have_ra_pfm='yes'; fi
have_ralcgm='no'     ; if test "$CGMDecodeDelegate" != "$CGMDecodeDelegateDefault" ; then have_ralcgm='yes'; fi
have_xps='no'        ; if test "$XPSDelegate" != "$XPSDelegateDefault"; then have_xps='yes'; fi

#
# Test for font directories
#
type_include_files=''

cristy's avatar
cristy committed
2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863
# Dejavu fonts.
AC_MSG_CHECKING(for Dejavu fonts directory)
dejavu_font_dir=''
if test "${with_dejavu_font_dir}" != 'default'; then
  dejavu_font_dir="${with_dejavu_font_dir}/"
else
  for font_dir in "${prefix}/share/dejavu/fonts/" '/usr/share/fonts/dejavu/'; do
    if test -f "${font_dir}DejaVuSerif.ttf"; then
      dejavu_font_dir="${font_dir}"
      break 1
    fi
  done
fi
if test "${dejavu_font_dir}x" != 'x'; then
  type_include_files="${type_include_files} "'<include file="type-dejavu.xml" />'
  AC_MSG_RESULT([$dejavu_font_dir])
else
  AC_MSG_RESULT([not found!]);
fi
AC_SUBST(dejavu_font_dir)

cristy's avatar
cristy committed
2864 2865 2866 2867 2868
# Windows
windows_font_dir=''
if test "$with_windows_font_dir" != "no" && test -n "$with_windows_font_dir"; then
   windows_font_dir="${with_windows_font_dir}/"
fi
cristy's avatar
cristy committed
2869
if test "${windows_font_dir}x" != 'x'; then
cristy's avatar
cristy committed
2870 2871 2872 2873 2874 2875 2876 2877 2878 2879
    if test -f '/usr/X11R6/lib/X11/fonts/truetype/arial.ttf'; then
      windows_font_dir='/usr/X11R6/lib/X11/fonts/truetype/'
    fi
    if test -f '/usr/X11R7/lib/X11/fonts/truetype/arial.ttf'; then
      windows_font_dir='/usr/X11R7/lib/X11/fonts/truetype/'
    fi
    if test -f '/usr/share/fonts/msttcore/arial.ttf'; then
      windows_font_dir='/usr/share/fonts/msttcore/truetype/'
    fi
fi
cristy's avatar
cristy committed
2880
if test "${windows_font_dir}x" != 'x'; then
cristy's avatar
cristy committed
2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962
  type_include_files="$type_include_files "'<include file="type-windows.xml" />'
fi
AC_SUBST(windows_font_dir)

# Ghostscript
AC_MSG_CHECKING(for Ghostscript fonts directory)
ghostscript_font_dir=''
if test "${with_gs_font_dir}" != 'default'; then
  ghostscript_font_dir="${with_gs_font_dir}/"
else
  if test "${native_win32_build}" = 'yes'; then
    # Native Windows Build
    for font_dir in "c:\\Program Files\\gs\\fonts\\" "c:\\Program Files \(x86\)\\gs\\fonts\\" "c:\\gs\\fonts\\"; do
      if test -f "${font_dir}a010013l.pfb"; then
        ghostscript_font_dir="$font_dir"
        break 1
      fi
    done
    if test "${PSDelegate}" != 'gswin32c'; then
      ghostscript_font_dir=`echo "${PSDelegate}" | sed -e 's:/gs/.*:/gs:;s:^/::;s/./&:/;s:/:\\\\:g'`"\\fonts\\"
    fi
  else
    # Linux / Mac OS X / Unix Build
    for font_dir in "${prefix}/share/ghostscript/fonts/" '/usr/share/fonts/default/Type1/' '/usr/share/ghostscript/fonts/' '/usr/share/fonts/ghostscript/' '/usr/share/fonts/type1/gsfonts/' '/opt/local/share/ghostscript/fonts/' '/sw/share/ghostscript/fonts/' '/System/Library/Frameworks/Ghostscript.framework/Resources/fonts/'; do
      if test -f "${font_dir}a010013l.pfb"; then
        ghostscript_font_dir="${font_dir}"
        break 1
      fi
    done
    if test "${ghostscript_font_dir}x" = 'x'; then
      if test "$PSDelegate" != 'gs'; then
        ghostscript_font_dir=`echo "$PSDelegate" | sed -e 's:/bin/gs:/share/ghostscript/fonts:'`"/"
      fi
    fi
  fi
fi
if test "${ghostscript_font_dir}x" != 'x'; then
  type_include_files="${type_include_files} "'<include file="type-ghostscript.xml" />'
  AC_MSG_RESULT([$ghostscript_font_dir])
else
  AC_MSG_RESULT([not found!]);
fi
AC_SUBST(ghostscript_font_dir)
case "${build_os}" in
  mingw* )
    PSDelegate=`$WinPathScript "$PSDelegate" 1`
    ;;
esac

AC_SUBST(type_include_files)

#
# Handle case where user doesn't want frozen paths
#
if test "$with_frozenpaths" != 'yes'; then
  # Re-set delegate definitions to default (no paths)
  AutotraceDecodeDelegate="$AutotraceDecodeDelegateDefault"
  AVIDecodeDelegate="$AVIDecodeDelegateDefault"
  BlenderDecodeDelegate="$BlenderDecodeDelegateDefault"
  BZIPDelegate="$BZIPDelegateDefault"
  BrowseDelegate="$BrowseDelegateDefault"
  CGMDecodeDelegate="$CGMDecodeDelegateDefault"
  CatDelegate="$CatDelegateDefault"
  ConvertDelegate="$ConvertDelegateDefault"
  GVCDecodeDelegate="$GVCDecodeDelegateDefault"
  DVIDecodeDelegate="$DVIDecodeDelegateDefault"
  EchoDelegate="$EchoDelegateDefault"
  EditorDelegate="$EditorDelegateDefault"
  FIGDecodeDelegate="$FIGDecodeDelegateDefault"
  GnuplotDecodeDelegate="$GnuplotDecodeDelegateDefault"
  HPGLDecodeDelegate="$HPGLDecodeDelegateDefault"
  HTMLDecodeDelegate="$HTMLDecodeDelegateDefault"
  ILBMDecodeDelegate="$ILBMDecodeDelegateDefault"
  ILBMEncodeDelegate="$ILBMEncodeDelegateDefault"
  LPDelegate="$LPDelegateDefault"
  LZWDecodeDelegate="$LZWDecodeDelegateDefault"
  LZWEncodeDelegate="$LZWEncodeDelegateDefault"
  LaunchDelegate="$LaunchDelegateDefault"
  MANDelegate="$MANDelegateDefault"
  MPEGDecodeDelegate="$MPEGDecodeDelegateDefault"
  MPEGEncodeDelegate="$MPEGEncodeDelegateDefault"
  MogrifyDelegate="$MogrifyDelegateDefault"
cristy's avatar
cristy committed
2963 2964
  MrSIDDecodeDelegate="$MrSIDDecodeDelegateDefault"
  MVDelegate="$MVDelegateDefault"
cristy's avatar
cristy committed
2965 2966 2967 2968 2969 2970 2971
  PCLDelegate="$PCLDelegateDefault"
  PGPDecodeDelegate="$PGPDecodeDelegateDefault"
  POVDelegate="$POVDelegateDefault"
  PSDelegate="$PSDelegateDefault"
  HDRDecodeDelegate="$HDRDecodeDelegateDefault"
  RLEEncodeDelegate="$RLEEncodeDelegateDefault"
  RMDelegate="$RMDelegateDefault"
cristy's avatar
cristy committed
2972
  RSVGDecodeDelegate="$RSVGDecodeDelegateDefault"
cristy's avatar
cristy committed
2973 2974 2975
  SCANDecodeDelegate="$SCANDecodeDelegateDefault"
  ShowImageDelegate="$ShowImageDelegateDefault"
  TXTDelegate="$TXTDelegateDefault"
cristy's avatar
cristy committed
2976
  UniconvertorDelegate="$UniconvertorDelegateDefault"
cristy's avatar
cristy committed
2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010
  WMFDecodeDelegate="$WMFDecodeDelegateDefault"
  WWWDecodeDelegate="$WWWDecodeDelegateDefault"
  XPSDelegate="$XPSDelegateDefault"
  ZipDelegate="$ZipDelegateDefault"
fi

# Delegate substitutions
AC_SUBST(AutotraceDecodeDelegate)
AC_SUBST(AVIDecodeDelegate)
AC_SUBST(BlenderDecodeDelegate)
AC_SUBST(BZIPDelegate)
AC_SUBST(BrowseDelegate)
AC_SUBST(CGMDecodeDelegate)
AC_SUBST(CatDelegate)
AC_SUBST(ConvertDelegate)
AC_SUBST(GVCDecodeDelegate)
AC_SUBST(DVIDecodeDelegate)
AC_SUBST(EchoDelegate)
AC_SUBST(EditorDelegate)
AC_SUBST(FIGDecodeDelegate)
AC_SUBST(GnuplotDecodeDelegate)
AC_SUBST(HDRDecodeDelegate)
AC_SUBST(HPGLDecodeDelegate)
AC_SUBST(HTMLDecodeDelegate)
AC_SUBST(ILBMDecodeDelegate)
AC_SUBST(ILBMEncodeDelegate)
AC_SUBST(LPDelegate)
AC_SUBST(LZWDecodeDelegate)
AC_SUBST(LZWEncodeDelegate)
AC_SUBST(LaunchDelegate)
AC_SUBST(MANDelegate)
AC_SUBST(MPEGDecodeDelegate)
AC_SUBST(MPEGEncodeDelegate)
AC_SUBST(MogrifyDelegate)
cristy's avatar
cristy committed
3011 3012
AC_SUBST(MrSIDDecodeDelegate)
AC_SUBST(MVDelegate)
cristy's avatar
cristy committed
3013 3014 3015 3016 3017 3018 3019 3020 3021
AC_SUBST(PCLDelegate)
AC_SUBST(PGPDecodeDelegate)
AC_SUBST(POVDelegate)
AC_SUBST(PSDelegate)
AC_SUBST(RLEEncodeDelegate)
AC_SUBST(RMDelegate)
AC_SUBST(SCANDecodeDelegate)
AC_SUBST(ShowImageDelegate)
AC_SUBST(TXTDelegate)
cristy's avatar
cristy committed
3022
AC_SUBST(UniconvertorDelegate)
cristy's avatar
cristy committed
3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273
AC_SUBST(WMFDecodeDelegate)
AC_SUBST(WWWDecodeDelegate)
AC_SUBST(XPSDelegate)
AC_SUBST(ZipDelegate)

#
# RPM support.
#
RPM=''
AC_CHECK_PROGS(TAR,gnutar gtar tar)
AC_CHECK_PROGS(PERL,perl)
AC_CHECK_PROGS(RPM,rpmbuild rpm)
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AC_SUBST(RPM)
AM_CONDITIONAL(RPM_DELEGATE, test "x$RPM" != "x" )

#
# 7ZIP support (http://p7zip.sourceforge.net/)
#
P7ZIP=''
AC_CHECK_PROGS(P7ZIP,[7za])
AC_SUBST(P7ZIP)
AM_CONDITIONAL(P7ZIP_DELEGATE, test "x$P7ZIP" != "x" )

#
# ZIP support (http://www.info-zip.org/Zip.html)
#
ZIP=''
AC_CHECK_PROGS(ZIP,[zip])
AC_SUBST(ZIP)
AM_CONDITIONAL(ZIP_DELEGATE, test "x$ZIP" != "x" )

#
# GhostPCL related configuration.
#
PCLColorDevice=ppmraw
PCLCMYKDevice=bmpsep8
PCLMonoDevice=pbmraw
if test -z "$PCLVersion"; then
    PCLVersion='unknown'
fi
if test $have_pcl = 'yes'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for PCL])
    AC_MSG_RESULT([])
    # PCLColorDevice
    AC_MSG_CHECKING([for pcl color device])
    if $PCLDelegate -dBATCH -sDEVICE=$PCLColorDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        PCLColorDevice=ppmraw
    fi
    AC_MSG_RESULT([$PCLColorDevice])

    # PCLCMYKDevice
    AC_MSG_CHECKING([for pcl CMYK device])
    if $PCLDelegate -dBATCH -sDEVICE=$PCLColorDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        PCLCMYKDevice=$PCLColorDevice
    fi
    AC_MSG_RESULT([$PCLCMYKDevice])

    # PCLMonoDevice
    AC_MSG_CHECKING([for pcl mono device])
    if $PCLDelegate -dBATCH -sDEVICE=$PCLMonoDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        PCLMonoDevice=$PCLColorDevice
    fi
    AC_MSG_RESULT([$PCLMonoDevice])
fi

AC_SUBST(PCLMonoDevice)
AC_SUBST(PCLColorDevice)
AC_SUBST(PCLCMYKDevice)
AC_SUBST(PCLVersion)

#
# GhostXPS related configuration.
#
XPSColorDevice=ppmraw
XPSCMYKDevice=bmpsep8
XPSMonoDevice=pbmraw
if test -z "$XPSVersion"; then
    XPSVersion='unknown'
fi
if test $have_xps = 'yes'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for XPS])
    AC_MSG_RESULT([])
    # XPSColorDevice
    AC_MSG_CHECKING([for xps color device])
    if $XPSDelegate -dBATCH -sDEVICE=$XPSColorDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        XPSColorDevice=ppmraw
    fi
    AC_MSG_RESULT([$XPSColorDevice])

    # XPSCMYKDevice
    AC_MSG_CHECKING([for xps CMYK device])
    if $XPSDelegate -dBATCH -sDEVICE=$XPSColorDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        XPSCMYKDevice=$XPSColorDevice
    fi
    AC_MSG_RESULT([$XPSCMYKDevice])

    # XPSMonoDevice
    AC_MSG_CHECKING([for xps mono device])
    if $XPSDelegate -dBATCH -sDEVICE=$XPSMonoDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        XPSMonoDevice=$XPSColorDevice
    fi
    AC_MSG_RESULT([$XPSMonoDevice])
fi

AC_SUBST(XPSMonoDevice)
AC_SUBST(XPSColorDevice)
AC_SUBST(XPSCMYKDevice)
AC_SUBST(XPSVersion)

#
# Ghostscript related configuration.
#
if test "$have_png" = 'yes'; then
    GSAlphaDevice=pngalpha
else
    GSAlphaDevice=pnmraw
fi
GSColorDevice=pnmraw
GSCMYKDevice=pam
GSMonoDevice=pbmraw
GSPDFDevice=pdfwrite
GSPSDevice=pswrite
GSEPSDevice=epswrite
GSVersion='unknown'
if test $have_gs = 'yes'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for Ghostscript])
    AC_MSG_RESULT([])
    AC_MSG_CHECKING([for Ghostscript version])
    if GSVersion=`$PSDelegate --version`; then
        :
    else
        GSVersion=`$PSDelegate --help | sed -e '1q' | awk '{ print $3 }'`
    fi
    AC_MSG_RESULT([$GSVersion])

    # GSAlphaDevice
    AC_MSG_CHECKING([for gs alpha device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSAlphaDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSAlphaDevice=pnmraw
    fi
    AC_MSG_RESULT([$GSAlphaDevice])

    # GSColorDevice
    AC_MSG_CHECKING([for gs color device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSColorDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSColorDevice=pnmraw
    fi
    AC_MSG_RESULT([$GSColorDevice])

    # GSCMYKDevice
    AC_MSG_CHECKING([for gs CMYK device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSCMYKDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSCMYKDevice=bmpsep8
    fi
    AC_MSG_RESULT([$GSCMYKDevice])

    # GSMonoDevice
    AC_MSG_CHECKING([for gs mono device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSMonoDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSMonoDevice=$GSColorDevice
    fi
    AC_MSG_RESULT([$GSMonoDevice])

    # GSPDFDevice
    AC_MSG_CHECKING([for gs PDF writing device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSPDFDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSPDFDevice=nodevice
    fi
        AC_MSG_RESULT([$GSPDFDevice])

    # GSPSDevice
    AC_MSG_CHECKING([for gs PS writing device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSPSDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSPSDevice=nodevice
    fi
    AC_MSG_RESULT([$GSPSDevice])

    # GSEPSDevice
    AC_MSG_CHECKING([for gs EPS writing device])
    if $PSDelegate -q -dBATCH -sDEVICE=$GSEPSDevice -sOutputFile=/dev/null < /dev/null 2> /dev/null; then
        :
    else
        GSEPSDevice=nodevice
    fi
    AC_MSG_RESULT([$GSEPSDevice])
fi

AC_SUBST(GSAlphaDevice)
AC_SUBST(GSCMYKDevice)
AC_SUBST(GSColorDevice)
AC_SUBST(GSEPSDevice)
AC_SUBST(GSMonoDevice)
AC_SUBST(GSPDFDevice)
AC_SUBST(GSPSDevice)
AC_SUBST(GSVersion)

#
# PerlMagick-related configuration
#

# Look for PERL if PerlMagick requested
# If name/path of desired PERL interpreter is specified, look for that one first
have_perl='no'
if test "$with_perl" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for Perl])
    AC_MSG_RESULT([])
    if test "$with_perl" != 'yes'; then
        AC_CACHE_CHECK(for perl,ac_cv_path_PERL,ac_cv_path_PERL="$with_perl");
        PERL=$ac_cv_path_PERL
        AC_SUBST(PERL)dnl
        have_perl="$ac_cv_path_PERL"
    else
        AC_PATH_PROGS(PERL,perl perl5,)dnl
        if test "$ac_cv_path_PERL"; then
            have_perl="$ac_cv_path_PERL"
        fi
    fi
fi

cristy's avatar
cristy committed
3274 3275 3276 3277 3278 3279
if test "$with_perl" != 'yes' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-perl=$with_perl "
fi

PERL_SUPPORTS_DESTDIR='no'

cristy's avatar
cristy committed
3280 3281 3282 3283 3284 3285 3286 3287 3288 3289
with_perl_static='no'
with_perl_dynamic='no'
if test "$have_perl" != 'no'; then
    if test "$with_perl" != 'no' && test "$libtool_build_shared_libs" = 'no'; then
        with_perl_static='yes'
    fi
    if test "$with_perl" != 'no' && test "$libtool_build_shared_libs" = 'yes'; then
        with_perl_dynamic='yes'
    fi
    # Is PERL's MakeMaker new enough to support DESTDIR?
cristy's avatar
cristy committed
3290
    AX_PROG_PERL_VERSION(5.8.1,[PERL_SUPPORTS_DESTDIR='yes'],[PERL_SUPPORTS_DESTDIR='no'])
cristy's avatar
cristy committed
3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325
fi
AM_CONDITIONAL(WITH_PERL, test "$have_perl" != 'no')
AM_CONDITIONAL(WITH_PERL_STATIC, test $with_perl_static = 'yes')
AM_CONDITIONAL(WITH_PERL_DYNAMIC, test $with_perl_dynamic = 'yes')
AC_SUBST(PERL_SUPPORTS_DESTDIR)

# Determine path to pick up MagickCore library from for use with building PerlMagick
MAGICKCORE_PATH="${LIB_DIR}"
if test $with_perl_static = 'yes'; then
    # Find out where libtool hides its uninstalled libraries (as libtool_objdir)
    libtool_objdir=$objdir

    # Linker search path to library, followed by -lMagickCore
    MAGICKCORE_PATH="${builddir}/magick/${libtool_objdir}"
fi
AC_SUBST(MAGICKCORE_PATH)

# Create a simple string containing format names for all delegate libraries
DELEGATES=''
if test "$have_autotrace"  = 'yes'; then DELEGATES="$DELEGATES autotrace"; fi
if test "$have_bzlib"      = 'yes'; then DELEGATES="$DELEGATES bzlib"; fi
if test "$have_djvu"       = 'yes'; then DELEGATES="$DELEGATES djvu"; fi
if test "$have_dps"        = 'yes'; then DELEGATES="$DELEGATES dps"; fi
if test "$have_fftw"       = 'yes'; then DELEGATES="$DELEGATES fftw"; fi
if test "$have_fpx"        = 'yes'; then DELEGATES="$DELEGATES fpx"; fi
if test "$have_fontconfig" = 'yes'; then DELEGATES="$DELEGATES fontconfig"; fi
if test "$have_freetype"   = 'yes'; then DELEGATES="$DELEGATES freetype"; fi
if test "$have_gslib"      = 'yes'; then DELEGATES="$DELEGATES gs"; fi
if test "$have_gvc"        = 'yes'; then DELEGATES="$DELEGATES gvc"; fi
if test "$have_jbig"       = 'yes'; then DELEGATES="$DELEGATES jbig"; fi
if test "$have_jpeg"       = 'yes'; then
  DELEGATES="$DELEGATES jpeg";
  if test "$have_png"      = 'yes'; then DELEGATES="$DELEGATES jng"; fi
fi
if test "$have_jp2"        = 'yes'; then DELEGATES="$DELEGATES jp2"; fi
cristy's avatar
cristy committed
3326
if test "$have_lcms2"      = 'yes'; then DELEGATES="$DELEGATES lcms2"; fi
cristy's avatar
cristy committed
3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356