configure.ac 129 KB
Newer Older
Cristy's avatar
Cristy committed
1
#  Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
cristy's avatar
cristy committed
2 3 4 5 6
#  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
#
Cristy's avatar
Cristy committed
7
#    https://imagemagick.org/script/license.php
cristy's avatar
cristy committed
8 9 10 11 12 13 14 15
#
#  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
16 17 18 19
#
#  Copying and distribution of this file, with or without modification,
#  are permitted in any medium without royalty provided the copyright
#  notice and this notice are preserved.
cristy's avatar
cristy committed
20

cristy's avatar
cristy committed
21
# Process this file with autoconf to create configure script.
cristy's avatar
cristy committed
22
AC_PREREQ(2.69)
cristy's avatar
cristy committed
23

cristy's avatar
cristy committed
24 25 26
# ==============================================================================
# ImageMagick release.
# ==============================================================================
cristy's avatar
cristy committed
27 28
m4_define([magick_major_version], [7])
m4_define([magick_minor_version], [0])
Cristy's avatar
Cristy committed
29
m4_define([magick_micro_version], [8])
Cristy's avatar
Cristy committed
30
m4_define([magick_patchlevel_version], [42])
cristy's avatar
cristy committed
31
m4_define([magick_version],
cristy's avatar
cristy committed
32
          [magick_major_version.magick_minor_version.magick_micro_version-magick_patchlevel_version])
Cristy's avatar
Cristy committed
33
m4_define([magick_git_revision], esyscmd([sh -c "(gitversion.sh .) | awk '{ print \$1 }' | tr -d '\n'"]))
34
m4_define([magick_tar_name],[ImageMagick])
cristy's avatar
cristy committed
35

cristy's avatar
cristy committed
36 37 38
# ==============================================================================
# Initalize Automake
# ==============================================================================
Cristy's avatar
Cristy committed
39 40 41 42
AC_INIT([ImageMagick],
        [magick_version],
        [https://github.com/ImageMagick/ImageMagick/issues],
        [magick_tar_name],
Cristy's avatar
Cristy committed
43
        [https://imagemagick.org])
cristy's avatar
cristy committed
44
AC_CONFIG_SRCDIR([MagickCore/MagickCore.h])
cristy's avatar
cristy committed
45
AC_CONFIG_AUX_DIR([config])
cristy's avatar
cristy committed
46
AC_REQUIRE_AUX_FILE([tap-driver.sh])
cristy's avatar
cristy committed
47 48
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config/config.h])
cristy's avatar
cristy committed
49
AX_PREFIX_CONFIG_H([MagickCore/magick-baseconfig.h],[MagickCore])
cristy's avatar
cristy committed
50 51
AC_CANONICAL_SYSTEM
AC_CANONICAL_TARGET
Cristy's avatar
Cristy committed
52
AM_INIT_AUTOMAKE([foreign color-tests -Wall -Wno-portability subdir-objects dist-bzip2 dist-lzip dist-xz dist-zip tar-ustar])
Cristy's avatar
Cristy committed
53
AM_SILENT_RULES([yes])
cristy's avatar
cristy committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

#
# 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)

cristy's avatar
cristy committed
71 72 73 74 75 76
AC_ARG_ENABLE([reproducible-build],
    [AC_HELP_STRING([--enable-reproducible-build],
                    [enable reproducible build])],
    [enable_reproducible_build=$enableval],
    [enable_reproducible_build='no'])

cristy's avatar
cristy committed
77 78 79
# Source file containing package/library versioning information.
. ${srcdir}/version.sh

cristy's avatar
cristy committed
80
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}${PACKAGE_VERSION_ADDENDUM}"
cristy's avatar
cristy committed
81

cristy's avatar
cristy committed
82
MAGICK_TARGET_CPU=$host_cpu
cristy's avatar
cristy committed
83
AC_SUBST(MAGICK_TARGET_CPU)
cristy's avatar
cristy committed
84
AC_DEFINE_UNQUOTED(MAGICK_TARGET_CPU,$MAGICK_TARGET_CPU,[Target Host CPU])
cristy's avatar
cristy committed
85

cristy's avatar
cristy committed
86
MAGICK_TARGET_VENDOR=$host_vendor
cristy's avatar
cristy committed
87
AC_SUBST(MAGICK_TARGET_VENDOR)
cristy's avatar
cristy committed
88
AC_DEFINE_UNQUOTED(MAGICK_TARGET_VENDOR,$MAGICK_TARGET_VENDOR,[Target Host Vendor])
cristy's avatar
cristy committed
89

cristy's avatar
cristy committed
90
MAGICK_TARGET_OS=$host_os
cristy's avatar
cristy committed
91
AC_SUBST(MAGICK_TARGET_OS)
cristy's avatar
cristy committed
92
AC_DEFINE_UNQUOTED(MAGICK_TARGET_OS,$MAGICK_TARGET_OS,[Target Host OS])
cristy's avatar
cristy committed
93

cristy's avatar
cristy committed
94 95 96 97 98 99 100

# Substitute versioning
AC_SUBST([MAGICK_MAJOR_VERSION],[magick_major_version])
AC_SUBST([MAGICK_MINOR_VERSION],[magick_minor_version])
AC_SUBST([MAGICK_MICRO_VERSION],[magick_micro_version])
AC_SUBST([MAGICK_PATCHLEVEL_VERSION],[magick_patchlevel_version])
AC_SUBST([MAGICK_VERSION],[magick_version])
101
AC_SUBST([MAGICK_GIT_REVISION],[magick_git_revision])
cristy's avatar
cristy committed
102

cristy's avatar
cristy committed
103 104 105 106
# 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
107 108 109 110
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
111

cristy's avatar
cristy committed
112 113 114 115 116 117 118 119
AC_SUBST(MAGICKPP_LIBRARY_CURRENT)dnl
AC_SUBST(MAGICKPP_LIBRARY_REVISION)dnl
AC_SUBST(MAGICKPP_LIBRARY_AGE)dnl
AC_SUBST([MAGICKPP_LIBRARY_CURRENT_MIN],
         [`expr $MAGICKPP_LIBRARY_CURRENT - $MAGICKPP_LIBRARY_AGE`])
AC_SUBST([MAGICKPP_LIBRARY_VERSION_INFO],
         [$MAGICKPP_LIBRARY_CURRENT:$MAGICKPP_LIBRARY_REVISION:$MAGICKPP_LIBRARY_AGE])

cristy's avatar
cristy committed
120 121
AC_SUBST(PACKAGE_NAME)dnl
AC_SUBST(PACKAGE_VERSION)dnl
cristy's avatar
cristy committed
122
AC_SUBST(PACKAGE_PERL_VERSION)dnl
cristy's avatar
cristy committed
123 124 125 126
AC_SUBST(PACKAGE_RELEASE)dnl
AC_SUBST(PACKAGE_CHANGE_DATE)dnl
AC_SUBST(PACKAGE_LIB_VERSION)dnl
AC_SUBST(PACKAGE_LIB_VERSION_NUMBER)dnl
cristy's avatar
cristy committed
127 128 129 130
AS_IF([test X$enable_reproducible_build = Xyes],
 [PACKAGE_RELEASE_DATE=$PACKAGE_RELEASE_DATE_REPRODUCIBLE],
 [PACKAGE_RELEASE_DATE=$PACKAGE_RELEASE_DATE_RAW],
)
cristy's avatar
cristy committed
131
AC_SUBST(PACKAGE_RELEASE_DATE)dnl
cristy's avatar
cristy committed
132

cristy's avatar
cristy committed
133
AC_SUBST(PACKAGE_VERSION_ADDENDUM)dnl
cristy's avatar
cristy committed
134 135 136 137

# Ensure that make can run correctly
AM_SANITY_CHECK

cristy's avatar
cristy committed
138
# versioning of library
cristy's avatar
cristy committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
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)

cristy's avatar
cristy committed
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
MAGICKPP_LIB_VERSION="0x"
if test ${MAGICKPP_LIBRARY_CURRENT} -lt 10 ; then
  MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}0
fi
MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}${MAGICKPP_LIBRARY_CURRENT}
if test ${MAGICKPP_LIBRARY_AGE} -lt 10 ; then
  MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}0
fi
MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}${MAGICKPP_LIBRARY_AGE}
if test ${MAGICKPP_LIBRARY_REVISION} -lt 10 ; then
  MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}0
fi
MAGICKPP_LIB_VERSION=${MAGICKPP_LIB_VERSION}${MAGICKPP_LIBRARY_REVISION}
AC_SUBST(MAGICKPP_LIB_VERSION)

# Definition used to define MagickLibVersionText in version.h
MAGICKPP_LIB_VERSION_TEXT="${PACKAGE_VERSION}"
AC_SUBST(MAGICKPP_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)



cristy's avatar
cristy committed
187 188 189 190 191 192 193 194 195 196
# 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
197
MAGICK_FEATURES=''
cristy's avatar
cristy committed
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

#
# 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)
Cristy's avatar
Cristy committed
223
eval "eval DOC_DIR=$datadir/doc"
cristy's avatar
cristy committed
224
AC_SUBST(DOC_DIR)
cristy's avatar
cristy committed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
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
274 275 276 277 278 279

#
# Enable OS features.
#
AC_USE_SYSTEM_EXTENSIONS

cristy's avatar
cristy committed
280 281 282 283
# ==============================================================================
# Find required base packages
# ==============================================================================
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
cristy's avatar
cristy committed
284
AC_PROG_CC
cristy's avatar
cristy committed
285
AC_PROG_CXX
cristy's avatar
cristy committed
286 287 288 289
AC_PROG_CC_STDC
AC_PROG_CPP
AC_PROG_LD
AC_SUBST(LD)
cristy's avatar
cristy committed
290
AC_PROG_CC_C99
cristy's avatar
cristy committed
291
AM_PROG_CC_C_O
cristy's avatar
cristy committed
292
AX_CFLAGS_WARN_ALL
cristy's avatar
cristy committed
293 294 295
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S
cristy's avatar
cristy committed
296
AC_PROG_SED
cristy's avatar
cristy committed
297
AC_PROG_AWK
cristy's avatar
cristy committed
298
AM_WITH_DMALLOC
cristy's avatar
cristy committed
299
AX_C___ATTRIBUTE__
cristy's avatar
cristy committed
300
AX_GCC_ARCHFLAG([yes])
Cristy's avatar
Cristy committed
301
PKG_PROG_PKG_CONFIG([0.20])
cristy's avatar
cristy committed
302 303
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
cristy's avatar
cristy committed
304

cristy's avatar
cristy committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318
# Test for 64-bit build.
AC_CHECK_SIZEOF([size_t])

AX_COMPILER_VENDOR

if test "x$GCC" = "xyes"; then
  CFLAGS="$CFLAGS -fexceptions"
  touch local.exp
else
  cat > local.exp <<EOF
set CC_FOR_TARGET "$CC"
EOF
fi

cristy's avatar
cristy committed
319
# Check for linker script support
cristy's avatar
cristy committed
320 321
gl_LD_VERSION_SCRIPT

cristy's avatar
cristy committed
322 323 324 325
#
# Enable run-time checking.
#
AC_ARG_ENABLE([bounds-checking],
cristy's avatar
cristy committed
326
    [AC_HELP_STRING([--enable-bounds-checking],
cristy's avatar
cristy committed
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
                    [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

GDI32_LIBS=''
343
WS2_32_LIBS=''
cristy's avatar
cristy committed
344 345 346 347 348 349 350 351 352 353
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'
354
        OLE_LIBS='-loleaut32'
355
        WS2_32_LIBS="-lws2_32"
cristy's avatar
cristy committed
356 357 358 359 360 361
    ;;
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)
362
AC_SUBST(OLE_LIBS)
363
AC_SUBST(WS2_32_LIBS)
cristy's avatar
cristy committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
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
cristy's avatar
cristy committed
418 419
  *darwin* | *-macos10*)
    dnl Disable FORTIFY_SOURCE to fix a bug in LVVM / OpenMP support
cristy's avatar
cristy committed
420
    CFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=0"
cristy's avatar
cristy committed
421 422
    dnl OS X universal binary support, requires --disable-dependency-tracking
    AC_ARG_ENABLE([osx-universal-binary],
cristy's avatar
cristy committed
423 424 425 426
        AC_HELP_STRING([--enable-osx-universal-binary],
           [build universal binary on OS X [[default=no]]]),
        [build_osxuniversal="${enableval}"], [build_osxuniversal=no])

cristy's avatar
cristy committed
427 428 429
    if test "${build_osxuniversal}" != no ; then
      if test "$enable_dependency_tracking" != no ; then
        AC_MSG_ERROR([--enable-osx-universal-binary requires --disable-dependency-tracking.
cristy's avatar
cristy committed
430 431 432
Please re-run configure with these options:
  --disable-dependency-tracking --enable-osx-universal-binary
        ])
cristy's avatar
cristy committed
433 434 435 436
      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"
cristy's avatar
cristy committed
437 438 439 440
  fi
  ;;
esac

cristy's avatar
cristy committed
441 442 443
#
# ARCH specific include directory
#
cristy's avatar
cristy committed
444 445
AC_ARG_WITH([includearch-dir],
    [AC_HELP_STRING([--includearch-dir=DIR],
cristy's avatar
cristy committed
446
                    [ARCH specific include directory])],
cristy's avatar
cristy committed
447 448
                    [includearch_dir=$withval],
                    [includearch_dir=$INCLUDE_DIR])
cristy's avatar
cristy committed
449

cristy's avatar
cristy committed
450
eval "eval INCLUDEARCH_DIR=$includearch_dir"
cristy's avatar
cristy committed
451
AC_SUBST(INCLUDEARCH_DIR)
cristy's avatar
cristy committed
452 453 454 455

#
# ARCH specific configuration directory
#
cristy's avatar
cristy committed
456 457
AC_ARG_WITH([sharearch-dir],
    [AC_HELP_STRING([--sharearch-dir=DIR],
cristy's avatar
cristy committed
458
                    [ARCH specific config directory])],
cristy's avatar
cristy committed
459
                    [sharearch_dir=$withval],
cristy's avatar
cristy committed
460
                    [sharearch_dir="${LIB_DIR}"])
cristy's avatar
cristy committed
461

cristy's avatar
cristy committed
462 463
eval "eval SHAREARCH_DIR=$sharearch_dir"
AC_SUBST(SHAREARCH_DIR)
cristy's avatar
cristy committed
464

cristy's avatar
cristy committed
465
# Path to the pkgconfig folder
cristy's avatar
cristy committed
466 467 468 469 470
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR],
            [Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]),
            [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])

cristy's avatar
cristy committed
471
#
Cristy's avatar
Cristy committed
472
# Enable support for POSIX thread APIs
cristy's avatar
cristy committed
473
#
cristy's avatar
cristy committed
474
AC_ARG_WITH([threads],
Cristy's avatar
Cristy committed
475
    [AC_HELP_STRING([--without-threads], [disable POSIX threads API support])],
cristy's avatar
cristy committed
476 477 478
    [with_threads=$withval],
    [with_threads='yes'])

cristy's avatar
cristy committed
479
THREAD_LIBS=''
cristy's avatar
cristy committed
480 481
have_threads=no
if test "$with_threads" != 'no'; then
cristy's avatar
cristy committed
482
    AX_PTHREAD()
cristy's avatar
cristy committed
483
    if test "$ax_pthread_ok" = yes; then
cristy's avatar
cristy committed
484 485 486 487
        have_threads=yes
        DEF_THREAD="$PTHREAD_CFLAGS"
        CFLAGS="$CFLAGS $DEF_THREAD"
        CXXFLAGS="$CXXFLAGS $DEF_THREAD"
Cristy's avatar
Cristy committed
488
        THREAD_LIBS="$PTHREAD_LIBS"
cristy's avatar
cristy committed
489 490 491 492
        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
493
        AC_DEFINE(THREAD_SUPPORT,1,[Define if you have POSIX threads libraries and header files.])
cristy's avatar
cristy committed
494 495
    fi
fi
cristy's avatar
cristy committed
496 497
LIBS="$LIBS $THREAD_LIBS"
AC_SUBST(THREAD_LIBS)
cristy's avatar
cristy committed
498 499 500 501 502 503 504 505 506

# 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
507 508 509 510 511
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
512

cristy's avatar
cristy committed
513
# Enable support for OpenCL
cristy's avatar
cristy committed
514
AX_OPENCL([C])
cristy's avatar
cristy committed
515
CFLAGS="$CL_CFLAGS $CFLAGS"
cristy's avatar
cristy committed
516
CPPFLAGS="$CL_CFLAGS $CPPFLAGS"
cristy's avatar
cristy committed
517
LIBS="$CL_LIBS $LIBS"
cristy's avatar
cristy committed
518
AC_SUBST(CL_CFLAGS)
cristy's avatar
cristy committed
519
if test "$enable_opencl" != no; then
cristy's avatar
cristy committed
520
  if test "X$ax_cv_check_cl_libcl" != Xno; then :
cristy's avatar
cristy committed
521 522
    MAGICK_FEATURES="OpenCL $MAGICK_FEATURES"
  fi
cristy's avatar
cristy committed
523
fi
cristy's avatar
cristy committed
524

cristy's avatar
cristy committed
525 526 527 528 529 530 531 532 533
########
#
# Check for large file support
#
########
AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
LFS_CPPFLAGS=''
if test "$enable_largefile" != no; then
cristy's avatar
cristy committed
534 535 536 537 538
    case $ac_cv_sys_file_offset_bits in
    no)
        # nothing to do here as the host supports LFS fine
        ;;
    unknown)
cristy's avatar
cristy committed
539
        AC_MSG_CHECKING([for native large file support])
cristy's avatar
cristy committed
540
        AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>
cristy's avatar
cristy committed
541 542
          main () {
          exit(!(sizeof(off_t) == 8));
cristy's avatar
cristy committed
543
        }])],
cristy's avatar
cristy committed
544
        [ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
cristy's avatar
cristy committed
545 546
         AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])])
cristy's avatar
cristy committed
547 548 549 550 551
        ;;
    *)
        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
        ;;
    esac
cristy's avatar
cristy committed
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
    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
AC_LIBTOOL_DLOPEN
LT_INIT([win32-dll])
LT_LANG([C++])
AC_SUBST(LIBTOOL_DEPS)

# 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
579
AM_CONDITIONAL(WITH_SHARED_LIBS, test "${libtool_build_shared_libs}" = 'yes')
cristy's avatar
cristy committed
580 581 582
#
# Enable support for building loadable modules
#
cristy's avatar
cristy committed
583
build_modules='no'
cristy's avatar
cristy committed
584 585 586 587
AC_ARG_WITH([modules],
    [AC_HELP_STRING([--with-modules],
                    [enable building dynamically loadable modules])],
    [with_modules=$withval],
cristy's avatar
cristy committed
588
    [with_modules='no'])
cristy's avatar
cristy committed
589 590 591 592 593

# 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.])
cristy's avatar
cristy committed
594 595 596 597
    build_modules='no'
  else
    build_modules='yes'
  fi
cristy's avatar
cristy committed
598
fi
cristy's avatar
cristy committed
599
if test "$build_modules" != 'no' ; then
cristy's avatar
cristy committed
600
    AC_DEFINE(BUILD_MODULES,1,Define if coders and filters are to be built as modules.)
cristy's avatar
cristy committed
601
    MAGICK_FEATURES="$MAGICK_FEATURES Modules"
cristy's avatar
cristy committed
602
fi
cristy's avatar
cristy committed
603
AM_CONDITIONAL(WITH_MODULES, test "$build_modules" != 'no')
cristy's avatar
cristy committed
604 605

# Enable build using delegate libraries built in subdirectories rather than installed
cristy's avatar
cristy committed
606
# delegate libraries (bzlib fftw fpx gslib jp2 jbig jpeg lcms lzma png tiff ttf wmf xml zlib)
cristy's avatar
cristy committed
607 608 609 610 611 612 613 614
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],
cristy's avatar
cristy committed
615
                    [exclude deprecated methods in MagickCore and MagickWand APIs])],
cristy's avatar
cristy committed
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
    [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])
cristy's avatar
cristy committed
648
    MAGICK_FEATURES="Cipher $MAGICK_FEATURES"
cristy's avatar
cristy committed
649 650
fi

cristy's avatar
cristy committed
651 652 653
# Build a zero-configuration version of ImageMagick.
AC_ARG_ENABLE([zero-configuration],
    [AC_HELP_STRING([--enable-zero-configuration],
cristy's avatar
cristy committed
654
                    [enable self-contained, embeddable, zero-configuration ImageMagick])],
cristy's avatar
cristy committed
655 656
    [enable_zero_configuration=$enableval],
    [enable_zero_configuration='no'])
cristy's avatar
cristy committed
657

cristy's avatar
cristy committed
658 659
if test "$enable_zero_configuration" = 'yes'; then
    AC_DEFINE(ZERO_CONFIGURATION_SUPPORT,1,[Build self-contained, embeddable, zero-configuration ImageMagick])
cristy's avatar
cristy committed
660
    MAGICK_FEATURES="Zero-configuration $MAGICK_FEATURES"
cristy's avatar
cristy committed
661 662 663 664
fi

# Build a high dynamic range version of ImageMagick.
AC_ARG_ENABLE([hdri],
cristy's avatar
cristy committed
665
    [AC_HELP_STRING([--enable-hdri],
cristy's avatar
cristy committed
666 667
                    [accurately represent the wide range of intensity levels found in real scenes])],
    [enable_hdri=$enableval],
cristy's avatar
cristy committed
668
    [enable_hdri='yes'])
cristy's avatar
cristy committed
669 670 671 672

MAGICK_HDRI=""
if test "$enable_hdri" = 'yes'; then
    MAGICK_HDRI="HDRI"
cristy's avatar
cristy committed
673
    magick_hdri_enable='1';
cristy's avatar
cristy committed
674
    MAGICK_FEATURES="HDRI $MAGICK_FEATURES"
cristy's avatar
cristy committed
675 676
else
    magick_hdri_enable='0'
cristy's avatar
cristy committed
677
fi
cristy's avatar
cristy committed
678
AC_DEFINE_UNQUOTED(HDRI_ENABLE_OBSOLETE_IN_H,$magick_hdri_enable,[Whether hdri is enabled or not])
cristy's avatar
cristy committed
679
AC_SUBST(MAGICK_HDRI)dnl
cristy's avatar
cristy committed
680 681
MAGICK_PCFLAGS="$MAGICK_PCFLAGS -DMAGICKCORE_HDRI_ENABLE=$magick_hdri_enable"
CFLAGS="$CFLAGS -DMAGICKCORE_HDRI_ENABLE=$magick_hdri_enable"
cristy's avatar
cristy committed
682
CPPFLAGS="$CPPFLAGS -DMAGICKCORE_HDRI_ENABLE=$magick_hdri_enable"
cristy's avatar
cristy committed
683

684 685 686 687 688 689 690 691 692 693 694 695
# Enable pipes (|) in filenames.
AC_ARG_ENABLE([pipes],
    [AC_HELP_STRING([--enable-pipes],
                    [enable pipes (|) in filenames])],
    [enable_pipes=$enableval],
    [enable_pipes='no'])

if test "$enable_pipes" = 'yes'; then
    AC_DEFINE(PIPES_SUPPORT,1,[enable pipes (|) in filenames])
    MAGICK_FEATURES="Pipes $MAGICK_FEATURES"
fi

cristy's avatar
cristy committed
696 697 698 699 700 701 702 703 704 705 706
# 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

cristy's avatar
cristy committed
707
# Don't emit "rebuild rules" for configure, Makefile.ins, etc.
cristy's avatar
cristy committed
708 709
AM_MAINTAINER_MODE

cristy's avatar
cristy committed
710 711 712 713 714 715 716
# Enable hugepages support
AC_ARG_ENABLE([hugepages],
    [AC_HELP_STRING([--enable-hugepages],
                    [enable 'huge pages' support])],
    [enable_hugepages=$enableval],
    [enable_hugepages='no'])

cristy's avatar
cristy committed
717 718 719 720 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
# 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])],
cristy's avatar
cristy committed
764 765
    [with_method_prefix=$withval],
    [with_method_prefix='no'])
cristy's avatar
cristy committed
766

cristy's avatar
cristy committed
767
if test "$with_method_prefix" != 'no'; then
cristy's avatar
cristy committed
768
    AC_DEFINE_UNQUOTED(NAMESPACE_PREFIX,$with_method_prefix,[Magick API method prefix])
769
    AC_DEFINE_UNQUOTED(NAMESPACE_PREFIX_TAG,["$with_method_prefix"],[Magick API method prefix tag])
cristy's avatar
cristy committed
770
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-method-prefix "
cristy's avatar
cristy committed
771 772
fi

cristy's avatar
cristy committed
773 774
# Enable legacy support (default no)
AC_ARG_ENABLE(legacy-support,
775
              [  --enable-legacy-support install legacy command-line utilities (default disabled)],
cristy's avatar
cristy committed
776 777 778 779
              [with_legacy_support=$enableval],
              [with_legacy_support='no'])
AM_CONDITIONAL(LEGACY_SUPPORT, test "$with_legacy_support" != 'no')

780 781 782 783 784 785
# Enable building command line utilities (default yes)
AC_ARG_WITH(utilities,
            [  --with-utilities enable building command-line utilities (default yes)],
            [with_utilities=$withval], [with_utilities='yes'])
AM_CONDITIONAL(WITH_UTILITIES, test "$with_utilities" = 'yes')

cristy's avatar
cristy committed
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
# 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
802
    * ) AC_MSG_ERROR("Pixel quantum depth must have value of 8, 16, 32, or 64") ;;
cristy's avatar
cristy committed
803 804
esac
QUANTUM_DEPTH="$with_quantum_depth"
cristy's avatar
cristy committed
805
AC_DEFINE_UNQUOTED(QUANTUM_DEPTH_OBSOLETE_IN_H,$QUANTUM_DEPTH,[Number of bits in a pixel Quantum (8/16/32/64)])
cristy's avatar
cristy committed
806
AC_SUBST(QUANTUM_DEPTH)dnl
cristy's avatar
cristy committed
807
MAGICK_PCFLAGS="$MAGICK_PCFLAGS -DMAGICKCORE_QUANTUM_DEPTH=$QUANTUM_DEPTH"
cristy's avatar
cristy committed
808
CFLAGS="$CFLAGS -DMAGICKCORE_QUANTUM_DEPTH=$QUANTUM_DEPTH"
cristy's avatar
cristy committed
809
CPPFLAGS="$CPPFLAGS -DMAGICKCORE_QUANTUM_DEPTH=$QUANTUM_DEPTH"
cristy's avatar
cristy committed
810

cristy's avatar
cristy committed
811
# define a lib suffix for abi purpose
cristy's avatar
cristy committed
812
MAGICK_ABI_SUFFIX="Q${QUANTUM_DEPTH}"
cristy's avatar
cristy committed
813
if test "$enable_hdri" = 'yes'; then
cristy's avatar
cristy committed
814
  MAGICK_ABI_SUFFIX="Q${QUANTUM_DEPTH}${MAGICK_HDRI}"
cristy's avatar
cristy committed
815
fi
cristy's avatar
cristy committed
816
AC_SUBST(MAGICK_ABI_SUFFIX)
cristy's avatar
cristy committed
817

cristy's avatar
cristy committed
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
# 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'])

cristy's avatar
cristy committed
844 845 846 847 848 849 850
# Encode the this name into the shared library.
AC_ARG_WITH([package-release-name],
    [AC_HELP_STRING([--with-package-release-name=NAME],
                    [encode this name into the shared library])],
[MAGICK_LT_RELEASE_OPTS="-release $withval"])
AC_SUBST(MAGICK_LT_RELEASE_OPTS)

cristy's avatar
cristy committed
851 852 853 854 855
# 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
856
    [with_perl='no'])
cristy's avatar
cristy committed
857 858 859 860

# Options to pass when configuring PerlMagick
AC_ARG_WITH([perl-options],
    [AC_HELP_STRING([--with-perl-options=OPTIONS],
cristy's avatar
cristy committed
861
                    [options to pass on command-line when generating PerlMagick build file])],
cristy's avatar
cristy committed
862
PERL_MAKE_OPTIONS=$withval)
cristy's avatar
cristy committed
863 864
AC_SUBST(PERL_MAKE_OPTIONS)

cristy's avatar
cristy committed
865 866 867 868 869 870 871 872 873
# Enable jemalloc, object-caching memory allocation library.
AC_ARG_WITH(jemalloc,
        [  --with-jemalloc         enable jemalloc memory allocation library support],
        [with_jemalloc=$withval],
        [with_jemalloc='no'])
if test "$with_jemalloc" != 'yes' ; then
    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jemalloc=$with_jemalloc "
fi

cristy's avatar
cristy committed
874 875 876 877 878 879 880 881 882 883 884 885 886 887 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
# 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_"
cristy's avatar
cristy committed
919
        if test "$build_modules" = 'yes'; then
cristy's avatar
cristy committed
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
            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
945
AC_HEADER_ASSERT
cristy's avatar
cristy committed
946 947 948
AC_HEADER_DIRENT

# Check additional headers
Cristy's avatar
Cristy committed
949
AC_CHECK_HEADERS(arm/limits.h arpa/inet.h complex.h errno.h fcntl.h limits.h linux/unistd.h locale.h machine/param.h mach-o/dyld.h netinet/in.h OS.h process.h sun_prefetch.h stdarg.h sys/ipc.h sys/mman.h sys/resource.h sys/sendfile.h sys/socket.h sys/syslimits.h sys/time.h sys/timeb.h sys/times.h sys/wait.h utime.h wchar.h xlocale.h)
cristy's avatar
cristy committed
950 951 952 953 954 955 956 957 958 959 960 961 962

########
#
# 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
963
AC_STRUCT_TIMEZONE
cristy's avatar
cristy committed
964 965
AC_SYS_INTERPRETER

cristy's avatar
cristy committed
966 967 968 969 970
#
# Checks for language qualifiers and semantics.
#
AC_C_CHAR_UNSIGNED
AC_C_CONST
cristy's avatar
cristy committed
971 972
AC_C_INLINE
AC_C_RESTRICT
cristy's avatar
cristy committed
973
AC_C_VOLATILE
cristy's avatar
cristy committed
974 975 976 977 978

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

cristy's avatar
cristy committed
979 980 981 982 983 984 985 986 987 988 989
# Define to a suitable type, if standard headers do not define it.
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INTMAX_T
AC_TYPE_INTPTR_T
AC_TYPE_LONG_DOUBLE
AC_TYPE_LONG_DOUBLE_WIDER
AC_TYPE_LONG_LONG_INT
AC_TYPE_MBSTATE_T
cristy's avatar
cristy committed
990 991 992 993 994
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
cristy's avatar
cristy committed
995 996 997 998 999 1000 1001 1002
AC_TYPE_UID_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINTPTR_T
AC_TYPE_UNSIGNED_LONG_LONG_INT
cristy's avatar
cristy committed
1003

cristy's avatar
cristy committed
1004
AC_CHECK_TYPES([locale_t], [], [], [[#include <xlocale.h>]])
cristy's avatar
cristy committed
1005

cristy's avatar
cristy committed
1006 1007 1008 1009 1010 1011
# Float_t and double_t are intended to be the the most efficient type.
AC_CHECK_TYPES([float_t], [], [], [[#include <math.h>]])
AC_CHECK_TYPES([double_t], [], [], [[#include <math.h>]])
AC_CHECK_SIZEOF([float_t], [], [[#include <math.h>]])
AC_CHECK_SIZEOF([double_t], [], [[#include <math.h>]])

cristy's avatar
cristy committed
1012 1013 1014
# Get size of float, double and long double for comparaison.
AC_CHECK_SIZEOF([float])
AC_CHECK_SIZEOF([double])
cristy's avatar
cristy committed
1015
AC_CHECK_SIZEOF([long double])
cristy's avatar
cristy committed
1016

cristy's avatar
cristy committed
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
# 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)

cristy's avatar
cristy committed
1044 1045 1046 1047 1048 1049 1050 1051 1052
# 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)

# Obtain size of ssize_t and define as SIZEOF_SSIZE_T
AC_CHECK_SIZEOF(ssize_t)

cristy's avatar
cristy committed
1053 1054 1055 1056 1057 1058 1059 1060 1061
# 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'
cristy's avatar
cristy committed
1062
AC_MSG_RESULT($INT8_T)
cristy's avatar
cristy committed
1063 1064 1065 1066
AC_SUBST(INT8_T)

AC_MSG_CHECKING(for unsigned 8-bit type)
UINT8_T='unsigned char'
cristy's avatar
cristy committed
1067
AC_MSG_RESULT($UINT8_T)
cristy's avatar
cristy committed
1068 1069 1070 1071
AC_SUBST(UINT8_T)

AC_MSG_CHECKING(for signed 16-bit type)
INT16_T='signed short'
cristy's avatar
cristy committed
1072
AC_MSG_RESULT($INT16_T)
cristy's avatar
cristy committed
1073 1074 1075 1076
AC_SUBST(INT16_T)

AC_MSG_CHECKING(for unsigned 16-bit type)
UINT16_T='unsigned short'
cristy's avatar
cristy committed
1077
AC_MSG_RESULT($UINT16_T)
cristy's avatar
cristy committed
1078 1079 1080 1081
AC_SUBST(UINT16_T)

AC_MSG_CHECKING(for signed 32-bit type)
INT32_T='none'
cristy's avatar
cristy committed
1082
INT32_F='none'
cristy's avatar
cristy committed
1083 1084
if test $ac_cv_sizeof_signed_int -eq 4; then
  INT32_T='signed int'
cristy's avatar
cristy committed
1085
  INT32_F='""'
cristy's avatar
cristy committed
1086 1087
elif test $ac_cv_sizeof_signed_long -eq 4; then
  INT32_T='signed long'
cristy's avatar
cristy committed
1088
  INT32_F='"l"'
cristy's avatar
cristy committed
1089
fi
cristy's avatar
cristy committed
1090
AC_MSG_RESULT($INT32_T)
cristy's avatar
cristy committed
1091
AC_SUBST(INT32_T)
cristy's avatar
cristy committed
1092
AC_SUBST(INT32_F)
cristy's avatar
cristy committed
1093 1094 1095

AC_MSG_CHECKING(for unsigned 32-bit type)
UINT32_T='none'
cristy's avatar
cristy committed
1096
UINT32_F='none'
cristy's avatar
cristy committed
1097 1098
if test $ac_cv_sizeof_unsigned_int -eq 4; then
  UINT32_T='unsigned int'
cristy's avatar
cristy committed
1099
  UINT32_F='""'
cristy's avatar
cristy committed
1100 1101
elif test $ac_cv_sizeof_unsigned_long -eq 4; then
  UINT32_T='unsigned long'
cristy's avatar
cristy committed
1102
  UINT32_F='"l"'
cristy's avatar
cristy committed
1103
fi
cristy's avatar
cristy committed
1104
AC_MSG_RESULT($UINT32_T)
cristy's avatar
cristy committed
1105
AC_SUBST(UINT32_T)
cristy's avatar
cristy committed
1106
AC_SUBST(UINT32_F)
cristy's avatar
cristy committed
1107 1108 1109

AC_MSG_CHECKING(for signed 64-bit type)
INT64_T='none'
cristy's avatar
cristy committed
1110
INT64_F='none'
cristy's avatar
cristy committed
1111 1112
if test $ac_cv_sizeof_signed_long -eq 8; then
  INT64_T='signed long'
cristy's avatar
cristy committed
1113
  INT64_F='"l"'
cristy's avatar
cristy committed
1114 1115
elif test $ac_cv_sizeof_signed_long_long -eq 8; then
  INT64_T='signed long long'
cristy's avatar
cristy committed
1116
  INT64_F='"ll"'
cristy's avatar
cristy committed
1117
fi
cristy's avatar
cristy committed
1118
case "${host_os}" in
cristy's avatar
cristy committed
1119 1120 1121 1122
  mingw* )
    INT64_F='"I64"'
    ;;
esac
cristy's avatar
cristy committed
1123
AC_MSG_RESULT($INT64_T)
cristy's avatar
cristy committed
1124
AC_SUBST(INT64_T)
cristy's avatar
cristy committed
1125
AC_SUBST(INT64_F)
cristy's avatar
cristy committed
1126 1127 1128

AC_MSG_CHECKING(for unsigned 64-bit type)
UINT64_T='none'
cristy's avatar
cristy committed
1129
UINT64_F='none'
cristy's avatar
cristy committed
1130 1131
if test $ac_cv_sizeof_unsigned_long -eq 8; then
  UINT64_T='unsigned long'
cristy's avatar
cristy committed
1132
  UINT64_F='"l"'
cristy's avatar
cristy committed
1133 1134
elif test $ac_cv_sizeof_unsigned_long_long -eq 8; then
  UINT64_T='unsigned long long'
cristy's avatar
cristy committed
1135
  UINT64_F='"ll"'
cristy's avatar
cristy committed
1136
fi
cristy's avatar
cristy committed
1137
case "${host_os}" in
cristy's avatar
cristy committed
1138 1139 1140 1141
  mingw* )
    UINT64_F='"I64"'
    ;;
esac
cristy's avatar
cristy committed
1142
AC_MSG_RESULT($UINT64_T)
cristy's avatar
cristy committed
1143
AC_SUBST(UINT64_T)
cristy's avatar
cristy committed
1144
AC_SUBST(UINT64_F)
cristy's avatar
cristy committed
1145 1146 1147

AC_MSG_CHECKING(for unsigned maximum type)
UINTMAX_T='none'
cristy's avatar
cristy committed
1148
UINTMAX_F='none'
cristy's avatar
cristy committed
1149 1150
if test "$UINT64_T" != 'none'; then
  UINTMAX_T=$UINT64_T
cristy's avatar
cristy committed
1151
  UINTMAX_F=$UINT64_F
cristy's avatar
cristy committed
1152 1153
elif test "$UINT32_T" != 'none'; then
  UINTMAX_T=$UINT32_T
cristy's avatar
cristy committed
1154
  UINTMAX_F=$UINT32_F
cristy's avatar
cristy committed
1155
fi
cristy's avatar
cristy committed
1156
AC_MSG_RESULT($UINTMAX_T)
cristy's avatar
cristy committed
1157
AC_SUBST(UINTMAX_T)
cristy's avatar
cristy committed
1158
AC_SUBST(UINTMAX_F)
cristy's avatar
cristy committed
1159 1160 1161

AC_MSG_CHECKING(for pointer difference type)
UINTPTR_T='none'
cristy's avatar
cristy committed
1162
UINTPTR_F='none'
cristy's avatar
cristy committed
1163 1164
if test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_unsigned_intp; then
  UINTPTR_T='unsigned long'
cristy's avatar
cristy committed
1165
  UINTPTR_F='"l"'
cristy's avatar
cristy committed
1166 1167
elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_unsigned_intp; then
  UINTPTR_T='unsigned long long'
cristy's avatar
cristy committed
1168
  UINTPTR_F='"ll"'
cristy's avatar
cristy committed
1169
fi
cristy's avatar
cristy committed
1170
AC_MSG_RESULT($UINTPTR_T)
cristy's avatar
cristy committed
1171
AC_SUBST(UINTPTR_T)
cristy's avatar
cristy committed
1172
AC_SUBST(UINTPTR_F)
cristy's avatar
cristy committed
1173 1174 1175 1176

AC_MSG_CHECKING([whether our compiler supports __func__])
AC_TRY_COMPILE([],
 [{ const char *func = __func__; return(func != 0 ? 0 : 1); }],
cristy's avatar
cristy committed
1177 1178
 AC_MSG_RESULT([yes]),
 AC_MSG_RESULT([no])
cristy's avatar
cristy committed
1179 1180 1181
 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
 AC_TRY_COMPILE([],
   [{ const char *func = __FUNCTION__; return(func != 0 ? 0 : 1); }],
cristy's avatar
cristy committed
1182
   AC_MSG_RESULT([yes])
cristy's avatar
cristy committed
1183 1184
   AC_DEFINE(__func__, __FUNCTION__,
     [Define to appropriate substitue if compiler does not have __func__]),
cristy's avatar
cristy committed
1185
   AC_MSG_RESULT([no])
cristy's avatar
cristy committed
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
   AC_DEFINE(__func__, __FILE__,
     [Define to appropriate substitue if compiler does not have __func__])))

########
#
# Check for functions
#
########
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
cristy's avatar
cristy committed
1202
AC_FUNC_STRERROR_R
cristy's avatar
cristy committed
1203 1204
AC_FUNC_VPRINTF

cristy's avatar
cristy committed
1205 1206 1207 1208 1209 1210 1211 1212
#
# 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
1213 1214 1215 1216
#
# Find socket library
#
AC_SEARCH_LIBS(gethostbyname, resolv nsl)
cristy's avatar
cristy committed
1217 1218 1219
AC_SEARCH_LIBS(socket, socket,
[
  AC_DEFINE([HAVE_SOCKET],[1],[Define to 1 if you have socket support.])
cristy's avatar
cristy committed
1220
  MAGICK_FEATURES="DPC $MAGICK_FEATURES"
cristy's avatar
cristy committed
1221
])
cristy's avatar
cristy committed
1222

Cristy's avatar
Cristy committed
1223
AC_CHECK_FUNCS([acosh _aligned_malloc asinh atanh atoll atexit cabs carg cimag creal clock clock_getres clock_gettime ctime_r directio erf _exit execvp fchmod floor fork ftime ftruncate getc_unlocked getcwd getpid getexecname getdtablesize getpagesize getrlimit getrusage gettimeofday gmtime_r isnan j0 j1 lltostr localtime_r lstat memmove memset mkstemp munmap nanosleep newlocale _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 realpath select seekdir sendfile setlocale socket sqrt setvbuf stat strchr strrchr strcspn strdup strpbrk strspn strstr strtod strtod_l strtol strtoul symlink sysconf sigemptyset sigaction spawnvp strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times ulltostr uselocale usleep utime vfprintf vfprintf_l vsprintf vsnprintf vsnprintf_l waitpid _wfopen _wstat])
cristy's avatar
cristy committed
1224 1225 1226 1227 1228 1229 1230 1231

#
# 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])
cristy's avatar
cristy committed
1232
  AC_COMPILE_IFELSE([
cristy's avatar
cristy committed
1233 1234
    AC_LANG_PROGRAM(
      [[#include <time.h>]],
cristy's avatar
cristy committed
1235
       [[clockid_t clockType = CLOCK_REALTIME;]])],
cristy's avatar
cristy committed
1236
      [
cristy's avatar
cristy committed
1237
        AC_MSG_RESULT(yes)
1238
        AC_DEFINE([HAVE_CLOCK_REALTIME],[1],
cristy's avatar
cristy committed
1239 1240
          [Define to 1 if clock_gettime supports CLOCK_REALTIME.])
      ],
cristy's avatar
cristy committed
1241
      AC_MSG_RESULT(no)
cristy's avatar
cristy committed
1242 1243 1244 1245 1246 1247
    )
  ],
  [
    AC_CHECK_FUNCS([gettimeofday ftime], [break])
  ]
)
cristy's avatar
cristy committed
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

########
#
# 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
1281 1282 1283
    AX_CXX_BOOL
    AX_CXX_NAMESPACES
    AX_CXX_NAMESPACE_STD
cristy's avatar
cristy committed
1284 1285 1286 1287 1288 1289
    AC_CXX_HAVE_STD_LIBS
    AC_OPENMP([C++])
    AC_LANG_POP

    AC_MSG_CHECKING([whether C++ compiler is sufficient for Magick++])
    if \
cristy's avatar
cristy committed
1290 1291
        test $ax_cv_cxx_bool = 'yes' && \
        test $ax_cv_cxx_namespaces = 'yes' && \
cristy's avatar
cristy committed
1292
        test $ac_cv_cxx_have_std_libs = 'yes' && \
cristy's avatar
cristy committed
1293
        test $ax_cv_cxx_have_std_namespace = 'yes'; then
cristy's avatar
cristy committed
1294 1295 1296 1297
        have_magick_plus_plus='yes'
    else
        have_magick_plus_plus='no (failed tests)'
    fi
cristy's avatar
cristy committed
1298
    AC_MSG_RESULT([$have_magick_plus_plus])
cristy's avatar
cristy committed
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
    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
1315
    for dir in bzlib fftw fpx gslib/src jp2 jbig/libjbig jpeg lcms/include lzma magick openjp2/include png tiff/libtiff ttf/include wand webp/src wmf/include xml/include zlib; do
cristy's avatar
cristy committed
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325
        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
1326
    for dir in bzlib fftw fpx gslib/src jbig/libjbig jpeg lcms/src lzma magick openjp2 png tiff/libtiff ttf/objs wand webp wmf/src xml zlib; do
cristy's avatar
cristy committed
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345
    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.
cristy's avatar
cristy committed
1346
MAGICK_CPPFLAGS="-I$INCLUDE_DIR/${PACKAGE_NAME}-$MAGICK_MAJOR_VERSION $MAGICK_CPPFLAGS"
cristy's avatar
cristy committed
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

#
# 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
cristy's avatar
cristy committed
1402
AC_DEFINE_UNQUOTED(X11_CONFIGURE_PATH,"$X11ConfigurePath",[Location of X11 configure files])
cristy's avatar
cristy committed
1403 1404 1405 1406 1407 1408 1409

#
# Find OpenMP library
#
GOMP_LIBS=''
if test "$enable_openmp" != 'no'; then
  if test "${GCC}" = "yes"; then
cristy's avatar
cristy committed
1410 1411 1412 1413 1414 1415
    # Open64 (passes for GCC but uses different OpenMP implementation)
    if test "x$GOMP_LIBS" = x ; then
      if $CC --version 2>&1 | grep Open64 > /dev/null ; then
        AC_CHECK_LIB(openmp,omp_get_num_procs,GOMP_LIBS="-lopenmp",,)
      fi
    fi
Cristy's avatar
Cristy committed
1416 1417 1418 1419 1420 1421
    # Clang (passes for GCC but uses different OpenMP implementation)
    if test "x$LIB_OMP" = x ; then
      if $CC --version 2>&1 | grep clang > /dev/null ; then
        AC_CHECK_LIB(omp,GOMP_parallel_start,LIB_OMP="-lomp",,)
      fi
    fi
cristy's avatar
cristy committed
1422 1423 1424 1425
    # GCC
    if test "x$GOMP_LIBS" = x ; then
      AC_CHECK_LIB(gomp,GOMP_parallel_start,GOMP_LIBS="-lgomp",,)
    fi
cristy's avatar
cristy committed
1426
  else
cristy's avatar
cristy committed
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
    # Sun CC
    if test "x$GOMP_LIBS" = x ; then
      AC_CHECK_LIB(mtsk,sunw_mp_register_warn,GOMP_LIBS="-lmtsk",,)
    fi
    # AIX xlc
    if test "x$GOMP_LIBS" = x ; then
    AC_CHECK_LIB(xlsmp,_xlsmpFlush,GOMP_LIBS="-lxlsmp",,)
    fi
    # SGI IRIX 6.5 MIPSpro C/C++
    if test "x$GOMP_LIBS" = x ; then
    AC_CHECK_LIB(mp,mp_destroy,GOMP_LIBS="-lmp",,)
    fi
cristy's avatar
cristy committed
1439 1440 1441 1442 1443
  fi
  LIBS="$GOMP_LIBS $LIBS"
fi
AC_SUBST(GOMP_LIBS)

cristy's avatar
cristy committed
1444
#
cristy's avatar
cristy committed
1445
# Check for jemalloc.
cristy's avatar
cristy committed
1446
#
cristy's avatar
cristy committed
1447 1448 1449 1450 1451 1452 1453
have_jemalloc='no'
JEMALLOC_LIBS=''
if test "$with_jemalloc" != 'no'; then
  AC_MSG_CHECKING(for JEMALLOC support )
  AC_MSG_RESULT()
  failed=0
  passed=0
cristy's avatar
cristy committed
1454 1455
  AC_CHECK_HEADER([jemalloc/jemalloc.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
  AC_CHECK_LIB(jemalloc,[malloc_stats_print],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
cristy's avatar
cristy committed
1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473
  AC_MSG_CHECKING(if jemalloc 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_jemalloc='no (failed tests)'
    else
      JEMALLOC_LIBS='-ljemalloc'
      LIBS="$JEMALLOC_LIBS $LIBS"
      AC_DEFINE(HasJEMALLOC,1,Define if you have jemalloc memory allocation library)
      AC_MSG_RESULT(yes)
      have_jemalloc='yes'
    fi
  else
    AC_MSG_RESULT(no)
  fi
fi
AM_CONDITIONAL(HasJEMALLOC, test "$have_jemalloc" = 'yes')
AC_SUBST(JEMALLOC_LIBS)
cristy's avatar
cristy committed
1474 1475 1476 1477 1478 1479 1480 1481

#
# Check for umem.
#
have_umem='no'
UMEM_LIBS=''
if test "$with_umem" != 'no'; then
  AC_MSG_CHECKING(for UMEM support )
cristy's avatar
cristy committed
1482
  AC_MSG_RESULT()
cristy's avatar
cristy committed
1483 1484 1485 1486 1487 1488 1489 1490
  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
cristy's avatar
cristy committed
1491
      AC_MSG_RESULT(no -- some components failed test)
cristy's avatar
cristy committed
1492 1493 1494 1495 1496
      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)
cristy's avatar
cristy committed
1497
      AC_MSG_RESULT(yes)
cristy's avatar
cristy committed
1498 1499 1500
      have_umem='yes'
    fi
  else
cristy's avatar
cristy committed
1501
    AC_MSG_RESULT(no)
cristy's avatar
cristy committed
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
  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

cristy's avatar
cristy committed
1530 1531 1532 1533 1534 1535 1536
#
# Add support for 'huge pages' if requested
#
AS_IF([test "x$enable_hugepages" != "xno"],[
  AC_DEFINE(HAVE_HUGEPAGES, 1, [Compile with hugepage support])
])

cristy's avatar
cristy committed
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
#
# 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=''
cristy's avatar
cristy committed
1564
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
1565
    AC_MSG_CHECKING([for BZLIB])
cristy's avatar
cristy committed
1566
    AC_MSG_RESULT([])
cristy's avatar
cristy committed
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582
    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
cristy's avatar
cristy committed
1583
        AC_MSG_RESULT(no -- some components failed test)
cristy's avatar
cristy committed
1584 1585 1586 1587 1588
        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)
cristy's avatar
cristy committed
1589
        AC_MSG_RESULT(yes)
cristy's avatar
cristy committed
1590 1591 1592
        have_bzlib='yes'
      fi
    else
cristy's avatar
cristy committed
1593
      AC_MSG_RESULT(no)
cristy's avatar
cristy committed
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607
    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
cristy's avatar
cristy committed
1608
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
1609
    AC_MSG_CHECKING([for X11])
cristy's avatar
cristy committed
1610
    AC_MSG_RESULT([])
cristy's avatar
cristy committed
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 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
    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'
cristy's avatar
cristy committed
1666 1667 1668 1669 1670 1671 1672
ZLIB_CFLAGS=""
ZLIB_LIBS=""
ZLIB_PKG=""
if test "x$with_zlib" = "xyes"; then
  AC_MSG_RESULT([-------------------------------------------------------------])
  PKG_CHECK_MODULES(ZLIB,[zlib >= 1.0.0], have_zlib=yes, have_zlib=no)
  AC_MSG_RESULT([])
cristy's avatar
cristy committed
1673
fi
cristy's avatar
cristy committed
1674 1675 1676 1677

if test "$have_zlib" = 'yes'; then
  AC_DEFINE(ZLIB_DELEGATE,1,Define if you have ZLIB library)
  CFLAGS="$ZLIB_CFLAGS $CFLAGS"
1678
  LIBS="$ZLIB_LIBS $LIBS"
cristy's avatar
cristy committed
1679 1680
fi

cristy's avatar
cristy committed
1681
AM_CONDITIONAL(ZLIB_DELEGATE, test "$have_zlib" = 'yes')
cristy's avatar
cristy committed
1682
AC_SUBST(ZLIB_CFLAGS)
cristy's avatar
cristy committed
1683 1684
AC_SUBST(ZLIB_LIBS)

cristy's avatar
cristy committed
1685 1686
dnl ===========================================================================

Cristy's avatar
Cristy committed
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
#
# Check for ZSTD
#
AC_ARG_WITH([zstd],
    [AC_HELP_STRING([--without-zstd],
                    [disable ZSTD support])],
    [with_zstd=$withval],
    [with_zstd='yes'])

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

have_zstd='no'
ZSTD_CFLAGS=""
ZSTD_LIBS=""
ZSTD_PKG=""
if test "x$with_zstd" = "xyes"; then
  AC_MSG_RESULT([-------------------------------------------------------------])
  PKG_CHECK_MODULES(LIBZSTD,[libzstd >= 1.0.0], have_zstd=yes, have_zstd=no)
  AC_MSG_RESULT([])
fi

if test "$have_zstd" = 'yes'; then
  AC_DEFINE(ZSTD_DELEGATE,1,Define if you have ZSTD library)
  CFLAGS="$ZSTD_CFLAGS $CFLAGS"
  LIBS="$ZSTD_LIBS $LIBS"
fi

AM_CONDITIONAL(ZSTD_DELEGATE, test "$have_zstd" = 'yes')
AC_SUBST(ZSTD_CFLAGS)
AC_SUBST(ZSTD_LIBS)

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

cristy's avatar
cristy committed
1722 1723 1724 1725
# whether modules are built or not.
with_ltdl='yes'
have_ltdl='no'
LTDL_LIBS=''
Cristy's avatar
Cristy committed
1726
if test "$build_modules" != 'no' || test "X$ax_cv_check_cl_libcl" != Xno; then
cristy's avatar
cristy committed
1727
  AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
1728
  AC_MSG_CHECKING([for libltdl])
cristy's avatar
cristy committed
1729
  AC_MSG_RESULT([])
cristy's avatar
cristy committed
1730 1731
  failed=0
  passed=0
cristy's avatar
cristy committed
1732 1733 1734
  AC_CHECK_HEADER([ltdl.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
  AC_CHECK_LIB([ltdl],[lt_dlinit],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],)
  AC_MSG_CHECKING([if libltdl package is complete])
cristy's avatar
cristy committed
1735 1736
  if test $passed -gt 0 ; then
    if test $failed -gt 0 ; then
cristy's avatar
cristy committed
1737
      AC_MSG_RESULT([no -- some components failed test])
cristy's avatar
cristy committed
1738 1739 1740 1741
      have_ltdl='no (failed tests)'
    else
      LTDL_LIBS='-lltdl'
      LIBS="$LTDL_LIBS $LIBS"
Cristy's avatar
Cristy committed
1742
      AC_DEFINE(LTDL_DELEGATE,1,[Define if using libltdl to support dynamically loadable modules and OpenCL])
1743
      AC_DEFINE_UNQUOTED([LTDL_MODULE_EXT],["${shrext_cmds}"],[Native module suffix])
cristy's avatar
cristy committed
1744
      AC_MSG_RESULT([yes])
cristy's avatar
cristy committed
1745 1746 1747
      have_ltdl='yes'
    fi
  else
cristy's avatar
cristy committed
1748 1749 1750
    AC_MSG_RESULT([no])
  fi
  if test "$have_ltdl" != 'yes' ; then
Cristy's avatar
Cristy committed
1751
    AC_MSG_FAILURE([libltdl is required for modules and OpenCL builds],[1])
cristy's avatar
cristy committed
1752 1753 1754 1755
  fi
fi
AM_CONDITIONAL(WITH_LTDL, test "$have_ltdl" != 'no')

cristy's avatar
cristy committed
1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767
#
# 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 ===========================================================================

cristy's avatar
cristy committed
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782
#
# Set Apple font directory.
#
AC_ARG_WITH([apple-font-dir],
    [AC_HELP_STRING([--with-apple-font-dir=DIR],
                    [Apple font directory])],
    [with_apple_font_dir=$withval],
    [with_apple_font_dir='default'])

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

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

cristy's avatar
cristy committed
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800
#
# 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
cristy's avatar
cristy committed
1801 1802 1803
  AC_MSG_RESULT([-------------------------------------------------------------])
  PKG_CHECK_MODULES(AUTOTRACE,[autotrace >= 0.31.1], have_autotrace=yes, have_autotrace=no)
  AC_MSG_RESULT([])
cristy's avatar
cristy committed
1804 1805 1806
fi

if test "$have_autotrace" = 'yes'; then
cristy's avatar
cristy committed
1807 1808
  AC_DEFINE(AUTOTRACE_DELEGATE,1,Define if you have AUTOTRACE library)
  CFLAGS="$AUTOTRACE_CFLAGS $CFLAGS"
cristy's avatar
cristy committed
1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832
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
cristy's avatar
cristy committed
1833
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed
1834
    AC_MSG_CHECKING([for DPS])
cristy's avatar
cristy committed
1835
    AC_MSG_RESULT([])
cristy's avatar
cristy committed
1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865
    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
cristy's avatar
cristy committed
1866
            AC_MSG_RESULT([no -- some components failed test])
cristy's avatar
cristy committed
1867 1868 1869 1870 1871 1872
            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)
cristy's avatar
cristy committed
1873
            AC_MSG_RESULT([yes])
cristy's avatar
cristy committed
1874 1875 1876
            have_dps='yes'
        fi
    else
cristy's avatar
cristy committed
1877
        AC_MSG_RESULT([no])
cristy's avatar
cristy committed
1878 1879 1880 1881 1882 1883 1884 1885
        CPPFLAGS=$PERSIST_CPPFLAGS
    fi
fi
AM_CONDITIONAL(DPS_DELEGATE, test "$have_dps" = 'yes')
AC_SUBST(DPS_LIBS)

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

cristy's avatar
cristy committed
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900
#
# 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
1901 1902 1903
#
# Check for FFTW delegate library.
#
cristy's avatar
cristy committed
1904
AC_ARG_WITH([fftw],
cristy's avatar
cristy committed
1905 1906 1907 1908 1909 1910 1911 1912 1913
    [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

cristy's avatar
cristy committed
1914
have_fftw='no'
cristy's avatar
cristy committed
1915 1916 1917 1918 1919 1920 1921
FFTW_CFLAGS=""
FFTW_LIBS=""
FFTW_PKG=""
if test "x$with_fftw" = "xyes"; then
  AC_MSG_RESULT([-------------------------------------------------------------])
  PKG_CHECK_MODULES(fftw3,[fftw3 >= 3.0.0], have_fftw=yes, have_fftw=no)
  AC_MSG_RESULT([])
cristy's avatar
cristy committed
1922
fi
cristy's avatar
cristy committed
1923 1924 1925

if test "$have_fftw" = 'yes'; then
  AC_DEFINE(FFTW_DELEGATE,1,Define if you have FFTW library)
cristy's avatar
cristy committed
1926 1927
  FFTW_CFLAGS="$fftw3_CFLAGS"
  FFTW_LIBS="$fftw3_LIBS"
cristy's avatar
cristy committed
1928 1929 1930
  CFLAGS="$fftw3_CFLAGS $CFLAGS"
fi

cristy's avatar
cristy committed
1931
AM_CONDITIONAL(FFTW_DELEGATE, test "$have_fftw" = 'yes')
cristy's avatar
cristy committed
1932
AC_SUBST(FFTW_CFLAGS)
cristy's avatar
cristy committed
1933 1934 1935 1936
AC_SUBST(FFTW_LIBS)

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

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
#
# Check for FLIF delegate library.
#
AC_ARG_WITH(flif,
    [AC_HELP_STRING([--without-flif],
                    [disable FLIF support])],
    [with_flif=$withval],
    [with_flif='yes'])

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

have_flif='no'
FLIF_LIBS=''
if test "$with_flif" != 'no'; then
    AC_MSG_RESULT([-------------------------------------------------------------])
    AC_MSG_CHECKING([for FLIF])
    AC_MSG_RESULT([])
    failed=0
    passed=0
    AC_CHECK_HEADER(flif.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_CHECK_LIB(flif,flif_create_decoder,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
    AC_MSG_CHECKING([if FLIF package is complete])
    if test $passed -gt 0; then
        if test $failed -gt 0; then
            AC_MSG_RESULT([no -- some components failed test])
            have_flif='no (failed tests)'
        else
            FLIF_LIBS='-lflif'
            LIBS="$FLIF_LIBS $LIBS"
            AC_DEFINE(FLIF_DELEGATE,1,Define if you have FLIF library)
            AC_MSG_RESULT([yes])
            have_flif='yes'
        fi
    else
        AC_MSG_RESULT([no])
    fi
fi
AM_CONDITIONAL(FLIF_DELEGATE,test "$have_flif" = 'yes')
AC_SUBST(FLIF_LIBS)

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

cristy's avatar
cristy committed
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996
#
# 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
cristy's avatar
cristy committed
1997
    AC_MSG_RESULT([-------------------------------------------------------------])
cristy's avatar
cristy committed