root / ImageMagick / branches / ImageMagick-6.3.9 / configure.ac

Revision 10261, 103.2 kB (checked in by cristy, 5 months ago)
  • Property svn:executable set to *
Line 
1#  Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization
2#  dedicated to making software imaging solutions freely available.
3#
4#  You may not use this file except in compliance with the License.  You may
5#  obtain a copy of the License at
6#
7#    http://www.imagemagick.org/script/license.php
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14
15AC_PREREQ(2.61)
16AC_INIT([ImageMagick],[6.3.9],[http://www.imagemagick.org],[ImageMagick])
17AC_CONFIG_SRCDIR([magick/MagickCore.h])
18AC_CONFIG_AUX_DIR([config])
19AC_CONFIG_MACRO_DIR([m4])
20AC_CONFIG_LIBOBJ_DIR([ltdl])
21AC_CONFIG_HEADERS([config/config.h])
22AX_PREFIX_CONFIG_H([magick/magick-config.h],[MagickCore])
23AC_CONFIG_FILES([\
24    config/configure.xml \
25    config/delegates.xml \
26    config/ImageMagick.rdf \
27    config/MagickCore.dox \
28    config/MagickWand.dox \
29    config/type-ghostscript.xml \
30    config/type-solaris.xml \
31    config/type-windows.xml \
32    config/type.xml \
33    ImageMagick.spec \
34    Magick++/bin/Magick++-config \
35    magick/ImageMagick.pc \
36    Magick++/lib/ImageMagick++.pc \
37    Magick++/lib/Magick++.pc \
38    magick/Magick-config \
39    magick/MagickCore-config \
40    magick/MagickCore.pc \
41    magick.sh \
42    magick/version.h \
43    Makefile \
44    PerlMagick/Magick.pm \
45    PerlMagick/Makefile.PL \
46    utilities/animate.1 \
47    utilities/compare.1 \
48    utilities/composite.1 \
49    utilities/conjure.1 \
50    utilities/convert.1 \
51    utilities/display.1 \
52    utilities/identify.1 \
53    utilities/ImageMagick.1 \
54    utilities/import.1 \
55    utilities/mogrify.1 \
56    utilities/montage.1 \
57    utilities/stream.1 \
58    wand/MagickWand-config \
59    wand/MagickWand.pc \
60    wand/Wand-config \
61    wand/Wand.pc ])
62
63#
64# Save initial user-tunable values
65#
66USER_LIBS=$LIBS
67for var in CC CFLAGS CPPFLAGS CXX CXXCPP LDFLAGS LIBS ; do
68  eval isset=\${$var+set}
69    if test "$isset" = 'set'; then
70        eval val=$`echo $var`
71        DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS}'${var}=${val}' "
72    fi
73done
74AC_SUBST(DISTCHECK_CONFIG_FLAGS)
75
76CONFIGURE_ARGS=`echo "$0 $@" | sed -e 's/  */ /g'`
77AC_SUBST(CONFIGURE_ARGS)
78
79# Source file containing package/library versioning information.
80. ${srcdir}/version.sh
81
82echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}${PACKAGE_VERSION_ADDENDUM}"
83AC_CANONICAL_TARGET([])
84
85# Substitute library versioning
86AC_SUBST(LIBRARY_CURRENT)dnl
87AC_SUBST(LIBRARY_REVISION)dnl
88AC_SUBST(LIBRARY_AGE)dnl
89AC_SUBST(PACKAGE_NAME)dnl
90AC_SUBST(PACKAGE_VERSION)dnl
91AC_SUBST(PACKAGE_LIB_VERSION)dnl
92AC_SUBST(PACKAGE_LIB_VERSION_NUMBER)dnl
93AC_SUBST(PACKAGE_RELEASE_DATE)dnl
94AC_SUBST(PACKAGE_VERSION_ADDENDUM)dnl
95
96# Ensure that make can run correctly
97AM_SANITY_CHECK
98
99AM_INIT_AUTOMAKE([1.10.1 subdir-objects dist-zip dist-bzip2 dist-lzma foreign])
100AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/ChangeLog $(top_srcdir)/version.sh'])
101
102PERLMAINCC=$CC
103
104MAGICK_CFLAGS=''
105MAGICK_CPPFLAGS=$CPPFLAGS_USER
106MAGICK_PCFLAGS=$CPPFLAGS_USER
107MAGICK_LDFLAGS=''
108MAGICK_LIBS=''
109
110#
111# Evaluate shell variable equivalents to Makefile directory variables
112#
113if test "x$prefix" = xNONE; then
114    prefix=$ac_default_prefix
115fi
116# Let make expand exec_prefix.
117if test "x$exec_prefix" = xNONE; then
118    exec_prefix='${prefix}'
119fi
120
121#
122eval "eval PREFIX_DIR=${prefix}"
123AC_SUBST(PREFIX_DIR)
124eval "eval EXEC_PREFIX_DIR=${exec_prefix}"
125AC_SUBST(EXEC_PREFIX_DIR)
126eval "eval BIN_DIR=$bindir"
127AC_SUBST(BIN_DIR)
128eval "eval SBIN_DIR=$sbindir"
129AC_SUBST(SBIN_DIR)
130eval "eval LIBEXEC_DIR=$libexecdir"
131AC_SUBST(LIBEXEC_DIR)
132eval "eval DATA_DIR=$datadir"
133AC_SUBST(DATA_DIR)
134eval "eval SYSCONF_DIR=$sysconfdir"
135AC_SUBST(SYSCONF_DIR)
136eval "eval SHAREDSTATE_DIR=$sharedstatedir"
137AC_SUBST(SHAREDSTATE_DIR)
138eval "eval LOCALSTATE_DIR=$localstatedir"
139AC_SUBST(LOCALSTATE_DIR)
140eval "eval LIB_DIR=$libdir"
141AC_SUBST(LIB_DIR)
142eval "eval INCLUDE_DIR=$includedir"
143AC_SUBST(INCLUDE_DIR)
144eval "eval PERSISTINCLUDE_DIR=$oldincludedir"
145AC_SUBST(PERSISTINCLUDE_DIR)
146eval "eval INFO_DIR=$infodir"
147AC_SUBST(INFO_DIR)
148eval "eval MAN_DIR=$mandir"
149AC_SUBST(MAN_DIR)
150
151# Get full paths to source and build directories
152srcdirfull="`cd $srcdir && pwd`"
153builddir="`pwd`"
154
155WinPathScript="${srcdirfull}/winpath.sh"
156AC_SUBST(WinPathScript)
157
158#
159# Compute variables useful for running uninstalled software.
160#
161MAGICK_CODER_MODULE_PATH="${builddir}/coders"
162MAGICK_CONFIGURE_SRC_PATH="${srcdirfull}/config"
163MAGICK_CONFIGURE_BUILD_PATH="${builddir}/config"
164MAGICK_FILTER_MODULE_PATH="${builddir}/filters"
165DIRSEP=':'
166case "${host_os}" in
167    mingw* )
168        MAGICK_CODER_MODULE_PATH=`$WinPathScript "${MAGICK_CODER_MODULE_PATH}" 0`
169        MAGICK_CONFIGURE_SRC_PATH=`$WinPathScript "${MAGICK_CONFIGURE_SRC_PATH}" 0`
170        MAGICK_CONFIGURE_BUILD_PATH=`$WinPathScript "${MAGICK_CONFIGURE_BUILD_PATH}" 0`
171        MAGICK_FILTER_MODULE_PATH=`$WinPathScript "${MAGICK_FILTER_MODULE_PATH}" 0`
172        DIRSEP=';'
173    ;;
174esac
175AC_SUBST(MAGICK_CODER_MODULE_PATH)
176AC_SUBST(MAGICK_CONFIGURE_SRC_PATH)
177AC_SUBST(MAGICK_CONFIGURE_BUILD_PATH)
178AC_SUBST(MAGICK_FILTER_MODULE_PATH)
179AC_SUBST(DIRSEP)
180
181# Check for programs
182AC_PROG_CC
183AC_PROG_CPP
184AC_PROG_LD
185AC_SUBST(LD)
186AM_PROG_CC_C_O
187AC_PROG_INSTALL
188AC_PROG_MAKE_SET
189AC_PROG_RANLIB
190AC_COMPILE_WARNINGS
191AC_PROG_LN_S
192AM_WITH_DMALLOC
193
194#
195# Enable OS features.
196#
197AC_GNU_SOURCE
198
199#
200# Tests for Windows
201#
202AC_EXEEXT
203AC_OBJEXT
204
205GDI32_LIBS=''
206StaticCplusPlusLibraries='no'
207native_win32_build='no'
208cygwin_build='no'
209case "${host_os}" in
210    cygwin* )
211        StaticCplusPlusLibraries='yes'
212        cygwin_build='yes'
213        GDI32_LIBS='-lgdi32'
214    ;;
215    mingw* )
216        StaticCplusPlusLibraries='yes'
217        native_win32_build='yes'
218        GDI32_LIBS='-lgdi32'
219    ;;
220esac
221if test "${GDI32_LIBS}x" != 'x'; then
222    AC_DEFINE(WINGDI32_DELEGATE,1,Define to use the Windows GDI32 library)
223fi
224AC_SUBST(GDI32_LIBS)
225AM_CONDITIONAL(WINGDI32_DELEGATE, test "${GDI32_LIBS}x" != 'x' )
226AM_CONDITIONAL(WIN32_NATIVE_BUILD, test "${native_win32_build}" = 'yes' )
227AM_CONDITIONAL(CYGWIN_BUILD, test "${cygwin_build}" = 'yes' )
228
229#
230# Compiler flags tweaks
231#
232if test "${GCC}" != "yes"; then
233    case "${host}" in
234        *-*-hpux* )
235            # aCC: HP ANSI C++ B3910B A.03.34
236            CFLAGS="${CFLAGS} -Wp,-H30000"
237            if test -n "${CXXFLAGS}"; then
238                CXXFLAGS='-AA'
239            else
240                CXXFLAGS="${CXXFLAGS} -AA"
241            fi
242        ;;
243        *-dec-osf5.* )
244            # Compaq alphaev68-dec-osf5.1 compiler
245            if test -n "${CXXFLAGS}"; then
246                CXXFLAGS='-std strict_ansi -noimplicit_include'
247            else
248                CXXFLAGS="${CXXFLAGS} -std strict_ansi -noimplicit_include"
249            fi
250  esac
251fi
252
253dnl Platform-specific stuff
254case "$host" in
255*darwin*)
256  dnl OS X universal binary support, requires --disable-dependency-tracking
257  AC_ARG_ENABLE(osx-universal-binary,
258        AC_HELP_STRING([--enable-osx-universal-binary],
259           [build universal binary on OS X [[default=no]]]),
260        [build_osxuniversal="${enableval}"], [build_osxuniversal=no])
261 
262  if test "${build_osxuniversal}" != no ; then
263    if test "$enable_dependency_tracking" != no ; then
264      AC_MSG_ERROR([--enable-osx-universal-binary requires --disable-dependency-tracking.
265Please re-run configure with these options:
266  --disable-dependency-tracking --enable-osx-universal-binary
267        ])
268    fi
269    CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
270    CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
271    LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -arch ppc -arch i386"
272  fi
273 
274esac
275
276# Enable support for threads
277AC_ARG_WITH([threads],
278    [AC_HELP_STRING([--without-threads],
279                    [disable threads support])],
280    [with_threads=$withval],
281    [with_threads='yes'])
282
283have_threads=no
284if test "$with_threads" != 'no'; then
285    ACX_PTHREAD()
286    if test "$acx_pthread_ok" = yes; then
287        have_threads=yes
288        DEF_THREAD="$PTHREAD_CFLAGS"
289        CFLAGS="$CFLAGS $DEF_THREAD"
290        CXXFLAGS="$CXXFLAGS $DEF_THREAD"
291        if test "$CC" != "$PTHREAD_CC"; then
292            AC_MSG_WARN([Replacing compiler $CC with compiler $PTHREAD_CC to support pthreads.])
293            CC="$PTHREAD_CC"
294        fi
295    fi
296fi
297
298# Enable support for OpenMP
299AC_OPENMP([C])
300CFLAGS="$CFLAGS $OPENMP_CFLAGS"
301LDFLAGS="$LDFLAGS $OPENMP_CFLAGS"
302MAGICK_PCFLAGS="$MAGICK_PCFLAGS $OPENMP_CFLAGS"
303
304########
305#
306# Check for large file support
307#
308########
309AC_SYS_LARGEFILE
310AC_FUNC_FSEEKO
311LFS_CPPFLAGS=''
312if test "$enable_largefile" != no; then
313    if test "$ac_cv_sys_file_offset_bits" != 'no'; then
314        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
315    else
316        AC_MSG_CHECKING([for native large file support])
317        AC_RUN_IFELSE([#include <unistd.h>
318          main () {
319          exit(!(sizeof(off_t) == 8));
320        }],
321        [ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
322         AC_MSG_RESULT([yes])],
323        [AC_MSG_RESULT([no])])
324    fi
325    if test "$ac_cv_sys_large_files" != 'no'; then
326        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_LARGE_FILES=1"
327    fi
328    if  test "$ac_cv_sys_largefile_source" != 'no'; then
329        LFS_CPPFLAGS="$LFS_CPPFLAGS -D_LARGEFILE_SOURCE=1"
330    fi
331fi
332AC_SUBST(LFS_CPPFLAGS)
333
334#
335# Configure libtool & libltdl
336#
337# Configure libtool
338AC_LIBTOOL_DLOPEN
339LT_INIT([win32-dll])
340LT_LANG([C++])
341AC_SUBST(LIBTOOL_DEPS)
342
343
344# Configure libltdl
345LT_CONFIG_LTDL_DIR([ltdl])
346LTDL_INIT([convenience nonrecursive])
347# Substitute INCLTDL and LIBLTDL in the Makefiles
348#AC_SUBST(INCLTDL)
349#AC_SUBST(LIBLTDL)
350
351# Check to see if building shared libraries
352libtool_build_shared_libs='no'
353if test "$enable_shared" = 'yes'; then
354    libtool_build_shared_libs='yes'
355fi
356
357# Check to see if building static libraries
358libtool_build_static_libs='no'
359if test "$enable_static" = 'yes'; then
360    libtool_build_static_libs='yes'
361fi
362
363# MinGW and Cygwin can't build C++ DLLs which support exceptions.
364if test "${StaticCplusPlusLibraries}" = 'yes'; then
365    LTCXXLIBOPTS='--static'
366    AC_SUBST(LTCXXLIBOPTS)
367fi
368
369#
370# Enable support for building loadable modules
371#
372AC_ARG_WITH([modules],
373    [AC_HELP_STRING([--with-modules],
374                    [support dynamically loadable modules])],
375    [with_modules=$withval],
376    [with_modules=$libtool_build_shared_libs])
377
378# Only allow building loadable modules if we are building shared libraries
379if test "$with_modules" != 'no' ; then
380    if test "$libtool_build_shared_libs" = 'no'; then
381        AC_MSG_WARN([Modules may only be built if building shared libraries is enabled.])
382        with_modules='no'
383    fi
384fi
385if test "$with_modules" != 'no'; then
386    AC_DEFINE(BUILD_MODULES,1,Define if coders and filters are to be built as modules.)
387fi
388AM_CONDITIONAL(WITH_MODULES, test "$with_modules" != 'no')
389
390# Enable building/use of libltdl if we are building shared libraries regardless
391# of whether modules are built or not.
392with_ltdl='no'
393if test "$libtool_build_shared_libs" != 'no'; then
394    with_ltdl='yes'
395fi
396
397AM_CONDITIONAL(WITH_LTDL, test "$with_ltdl" != 'no')
398if test "$with_ltdl" != 'no'; then
399    AC_DEFINE(LTDL_DELEGATE,1,Define if using libltdl to support dynamically loadable modules)
400
401    # Set DLLDFLAGS
402    if test X"$enable_shared" = Xyes; then
403        DLLDFLAGS=-export-dynamic
404        AC_SUBST(DLLDFLAGS)
405    fi
406fi
407
408# Enable build using delegate libraries built in subdirectories rather than installed
409# delegate libraries (bzlib fpx jp2 jbig jpeg lcms png tiff ttf wmf xml zlib)
410AC_ARG_ENABLE([delegate-build],
411    [AC_HELP_STRING([--enable-delegate-build],
412                    [look for delegate libraries in build directory])],
413    [enable_delegate_build=$enableval],
414    [enable_delegate_build='no'])
415
416AC_ARG_ENABLE([deprecated],
417    [AC_HELP_STRING([--disable-deprecated],
418                    [exclude deprecated methods in MagickCore and MagickWand API's])],
419    [enable_deprecated=$enableval],
420    [enable_deprecated='no'])
421
422if test "$enable_deprecated" = 'yes'; then
423  AC_DEFINE(EXCLUDE_DEPRECATED,1,[exclude deprecated methods in MagickCore API])
424else
425  DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --disable-deprecate "
426fi
427
428# Build a version of ImageMagick which operates uninstalled.
429# Used to build distributions located via MAGICK_HOME / executable path
430AC_ARG_ENABLE([installed],
431    [AC_HELP_STRING([--disable-installed],
432                    [Formally install ImageMagick under PREFIX])],
433    [enable_installed=$enableval],
434    [enable_installed='yes'])
435
436if test "$enable_installed" = 'yes'; then
437    AC_DEFINE(INSTALLED_SUPPORT,1,[ImageMagick is formally installed under prefix])
438else
439    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --disable-installed "
440fi
441
442# Permit enciphering and deciphering image pixels.
443AC_ARG_ENABLE([cipher],
444    [AC_HELP_STRING([--enable-cipher],
445                    [permit enciphering and deciphering image pixels])],
446    [enable_cipher=$enableval],
447    [enable_cipher='no'])
448
449if test "$enable_cipher" = 'yes'; then
450    AC_DEFINE(CIPHER_SUPPORT,1,[permit enciphering and deciphering image pixels])
451fi
452
453# Build an embeddable version of ImageMagick.
454AC_ARG_ENABLE([embeddable],
455    [AC_HELP_STRING([--enable-embeddable],
456                    [enable self-contained, embeddable, zero-configuration ImageMagick])],
457    [enable_embeddable=$enableval],
458    [enable_embeddable='no'])
459
460if test "$enable_embeddable" = 'yes'; then
461    AC_DEFINE(EMBEDDABLE_SUPPORT,1,[Build self-contained, embeddable, zero-configuration ImageMagick (experimental)])
462fi
463
464# Build a high dynamic range version of ImageMagick.
465AC_ARG_ENABLE([hdri],
466    [AC_HELP_STRING([--enable-hdri],
467                    [accurately represent the wide range of intensity levels found in real scenes])],
468    [enable_hdri=$enableval],
469    [enable_hdri='no'])
470
471MAGICK_HDRI=""
472if test "$enable_hdri" = 'yes'; then
473    MAGICK_HDRI="HDRI"
474    AC_DEFINE(HDRI_SUPPORT,1,[accurately represent the wide range of intensity levels  in real scenes])
475fi
476AC_SUBST(MAGICK_HDRI)dnl
477
478# Enable verbose output from libtool (enable libtool's default)
479AC_ARG_ENABLE([libtool-verbose],
480    [AC_HELP_STRING([--enable-libtool-verbose],
481                    [enable verbose libtool output])],
482    [enable_libtool_verbose=$enableval],
483    [enable_libtool_verbose='no'])
484
485if test "$enable_libtool_verbose" = 'no'; then
486    LIBTOOL="$LIBTOOL --silent"
487fi
488
489# Build a version of ImageMagick with assert statements.
490AC_ARG_ENABLE([assert],
491    [AC_HELP_STRING([--disable-assert],
492                    [disable assert() statements in build])],
493    [enable_assert=$enableval],
494    [enable_assert='yes'])
495
496if test "$enable_assert" = 'no'; then
497    AC_DEFINE(NDEBUG,1,[Turn off assert statements])
498fi
499
500# Add configure option --enable-maintainer-mode which enables dependency
501# checking and generation useful to package maintainers.  This is made an
502# option to avoid confusing end users.
503AM_MAINTAINER_MODE
504
505
506# Enable ccmalloc memory debugging support
507AC_ARG_ENABLE([ccmalloc],
508    [AC_HELP_STRING([--enable-ccmalloc],
509                    [enable 'ccmalloc' memory debug support])],
510    [enable_ccmalloc=$enableval],
511    [enable_ccmalloc='no'])
512
513# Enable Electric Fence memory debugging support
514AC_ARG_ENABLE([efence],
515    [AC_HELP_STRING([--enable-efence],
516                    [enable 'efence' memory debug support])],
517    [enable_efence=$enableval],
518    [enable_efence='no'])
519
520# Enable prof-based profiling support
521AC_ARG_ENABLE([prof],
522    [AC_HELP_STRING([--enable-prof],
523                    [enable 'prof' profiling support])],
524    [enable_prof=$enableval],
525    [enable_prof='no'])
526
527# Enable gprof-based profiling support
528AC_ARG_ENABLE([gprof],
529    [AC_HELP_STRING([--enable-gprof],
530                    [enable 'gprof' profiling support])],
531    [enable_gprof=$enableval],
532    [enable_gprof='no'])
533
534# Enable gcov-based profiling support
535AC_ARG_ENABLE([gcov],
536    [AC_HELP_STRING([--enable-gcov],
537                    [enable 'gcov' profiling support])],
538    [enable_gcov=$enableval],
539    [enable_gcov='no'])
540
541enable_profiling='no'
542if test "$enable_prof" = 'yes' || test "$enable_gprof" = 'yes' || test "$enable_gcov" = 'yes'; then
543    enable_profiling='yes'
544    if test "$libtool_build_shared_libs" = 'yes'; then
545        echo "Warning: Can not profile code using shared libraries"
546    fi
547fi
548
549# Magick API method prefix
550AC_ARG_WITH([method-prefix],
551    [AC_HELP_STRING([--with-method-prefix=PREFIX],
552                    [prefix MagickCore API methods])],
553    [with_method_prefix=$enableval],
554    [with_method_prefix=''])
555
556if test "$with_method_prefix" != ''; then
557    AC_DEFINE_UNQUOTED(NAMESPACE_PREFIX,$with_method_prefix,[Magick API method prefix])
558fi
559
560# Number of bits in a Quantum
561AC_ARG_WITH([quantum-depth],
562    [AC_HELP_STRING([--with-quantum-depth=DEPTH],
563                    [number of bits in a pixel quantum (default 16)])],
564    [with_quantum_depth=$withval],
565    [with_quantum_depth=16])
566
567if test "$with_quantum_depth" != '8'; then
568    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-quantum-depth=$with_quantum_depth "
569fi
570
571case "${with_quantum_depth}" in
572    8 )
573    ;;
574    16 )
575    ;;
576    32 )
577    ;;
578    64 )
579    ;;
580    * )
581        AC_MSG_ERROR("Pixel quantum depth must have value of 8, 16, or 32")
582    ;;
583esac
584QUANTUM_DEPTH="$with_quantum_depth"
585AC_DEFINE_UNQUOTED(QUANTUM_DEPTH,$QUANTUM_DEPTH,[Number of bits in a pixel Quantum (8/16/32/64)])
586AC_SUBST(QUANTUM_DEPTH)dnl
587
588# Set pixel cache threshold
589AC_ARG_WITH([cache],
590    [AC_HELP_STRING([--with-cache=THRESHOLD],
591                    [set pixel cache threshhold in MB (default available memory)])],
592    [with_cache=$withval],
593    [with_cache=''])
594
595if test "$with_cache" != ''; then
596    AC_DEFINE_UNQUOTED(PixelCacheThreshold,$with_cache,[Pixel cache threshold in MB (defaults to available memory)])
597    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-cache=$with_cache "
598fi
599
600# Disable/Enable support for full delegate paths
601AC_ARG_WITH([frozenpaths],
602    [AC_HELP_STRING([--with-frozenpaths],
603                    [freeze delegate paths])],
604    [with_frozenpaths=$withval],
605    [with_frozenpaths='no'])
606
607# Enable build/install of Magick++
608AC_ARG_WITH([magick-plus-plus],
609    [AC_HELP_STRING([--without-magick-plus-plus],
610                    [disable build/install of Magick++])],
611    [with_magick_plus_plus=$withval],
612    [with_magick_plus_plus='yes'])
613
614# Disable build/install of PerlMagick.
615AC_ARG_WITH([perl],
616    [AC_HELP_STRING([--with-perl],
617                    [enable build/install of PerlMagick])],
618    [with_perl=$withval],
619    [with_perl=$libtool_build_shared_libs])
620
621# Options to pass when configuring PerlMagick
622AC_ARG_WITH([perl-options],
623    [AC_HELP_STRING([--with-perl-options=OPTIONS],
624                    [options to pass on command-line when generating PerlMagick's build file])])
625
626PERL_MAKE_OPTIONS=$with_perl_options
627AC_SUBST(PERL_MAKE_OPTIONS)
628
629
630# Disable BZLIB (bzip2 library)
631AC_ARG_WITH([bzlib],
632    [AC_HELP_STRING([--without-bzlib],
633                    [disable BZLIB support])],
634    [with_bzlib=$withval],
635    [with_bzlib='yes'])
636
637if test "$with_bzlib" != 'yes'; then
638    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-bzlib=$with_bzlib "
639fi
640
641# Disable Display Postscript.
642AC_ARG_WITH([dps],
643    [AC_HELP_STRING([--without-dps],
644                    [disable Display Postscript support])],
645    [with_dps=$withval],
646    [with_dps='yes'])
647
648if test "$with_dps" != 'yes'; then
649    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-dps=$with_dps "
650fi
651
652# Disable DJVU.
653AC_ARG_WITH([djvu],
654    [AC_HELP_STRING([--with-djvu],
655                    [enable DjVu support])],
656    [with_djvu=$withval],
657    [with_djvu='no'])
658
659if test "$with_djvu" != 'yes'; then
660    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-djvu=$with_djvu "
661fi
662
663# Enable FlashPIX.
664AC_ARG_WITH([fpx],
665    [AC_HELP_STRING([--without-fpx],
666                    [disable FlashPIX support])],
667    [with_fpx=$withval],
668    [with_fpx='yes'])
669
670if test "$with_fpx" != 'yes'; then
671    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fpx=$with_fpx "
672fi
673
674# Enable Ghostscript library support.
675AC_ARG_WITH([gslib],
676    [AC_HELP_STRING([--without-gslib],
677                    [disable Ghostscript library support])],
678    [with_gslib=$withval],
679    [with_gslib='yes'])
680
681if test "$with_gslib" != 'yes'; then
682    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gslib=$with_gslib "
683fi
684
685# Disable JBIG.
686AC_ARG_WITH([jbig],
687    [AC_HELP_STRING([--without-jbig],
688                    [disable JBIG support])],
689    [with_jbig=$withval],
690    [with_jbig='yes'])
691
692if test "$with_jbig" != 'yes'; then
693    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jbig=$with_jbig "
694fi
695
696# Disable JPEG.
697AC_ARG_WITH([jpeg],
698    [AC_HELP_STRING([--without-jpeg],
699                    [disable JPEG support])],
700    [with_jpeg=$withval],
701    [with_jpeg='yes'])
702
703if test "$with_jpeg" != 'yes'; then
704    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jpeg=$with_jpeg "
705fi
706
707# Disable JPEG Version 2.
708AC_ARG_WITH([jp2],
709    [AC_HELP_STRING([--without-jp2],
710                    [disable JPEG-2000 support])],
711    [with_jp2=$withval],
712    [with_jp2='yes'])
713
714if test "$with_jp2" != 'yes'; then
715    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jp2=$with_jp2 "
716fi
717
718# Disable TIFF.
719AC_ARG_WITH([tiff],
720    [AC_HELP_STRING([--without-tiff],
721                    [disable TIFF support])],
722    [with_tiff=$withval],
723    [with_tiff='yes'])
724
725if test "$with_tiff" != 'yes'; then
726    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-tiff=$with_tiff "
727fi
728
729# Enable umem, object-caching memory allocation library.
730AC_ARG_WITH(umem,
731        [  --with-umem             enable umem memory allocation library support],
732        [with_umem=$withval],
733        [with_umem='no'])
734if test "$with_umem" != 'yes' ; then
735    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-umem=$with_umem "
736fi
737
738# Disable WMF.
739AC_ARG_WITH([wmf],
740    [AC_HELP_STRING([--without-wmf],
741                    [disable WMF support])],
742    [with_wmf=$withval],
743    [with_wmf=$with_modules])
744
745if test "$with_wmf" != 'yes'; then
746    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-wmf=$with_wmf "
747fi
748
749# Set default font search path
750AC_ARG_WITH([fontpath],
751    [AC_HELP_STRING([--with-fontpath=DIR],
752                    [prepend to default font search path])],
753    [with_fontpath=$withval],
754    [with_fontpath=''])
755
756if test "$with_fontpath" != "yes" && test -z "$with_fontpath"; then
757    with_fontpath=''
758else
759    AC_DEFINE_UNQUOTED(MAGICK_FONT_PATH,"$with_fontpath",Define to prepend to default font search path.)
760fi
761if test "$with_fontpath=" != ''; then
762    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fontpath=$with_fontpath "   
763fi
764
765# Set Ghostscript font directory
766AC_ARG_WITH([gs-font-dir],
767    [AC_HELP_STRING([--with-gs-font-dir=DIR],
768                    [Ghostscript font directory])],
769    [with_gs_font_dir=$withval],
770    [with_gs_font_dir='default'])
771
772if test "$with_gs_font_dir" != 'default'; then
773    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gs-font-dir=$with_gs_font_dir "
774fi 
775
776# Set Windows font directory
777AC_ARG_WITH([windows-font-dir],
778    [AC_HELP_STRING([--with-windows-font-dir=DIR],
779                    [MS Windows font directory])],
780    [with_windows_font_dir=$withval],
781    [with_windows_font_dir=''])
782
783if test "x$with_windows_font_dir" = "xno"; then
784    with_windows_font_dir=
785fi
786if test "$with_windows_font_dir" != ''; then
787    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-windows-font-dir=$with_windows_font_dir "
788fi
789
790AC_ARG_WITH([zlib],
791    [AC_HELP_STRING([--without-zlib],
792                    [disable ZLIB support])],
793    [with_zlib=$withval],
794    [with_zlib='yes'])
795
796if test "$with_zlib" != 'yes'; then
797    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zlib=$with_zlib "
798fi
799
800#
801# Specify path to shared libstdc++ if not in normal location
802#
803AC_ARG_WITH([libstdc],
804    [AC_HELP_STRING([--with-libstdc=DIR],
805                    [ use libstdc++ in DIR (for GNU C++)])],
806    [with_libstdc=$withval],
807    [with_libstdc=''])
808
809if test "$with_libstdc" != ''; then
810    if test -d "$with_libstdc"; then
811        LIBSTDCLDFLAGS="-L$with_libstdc"
812    fi
813fi
814AC_SUBST(LIBSTDCLDFLAGS)
815
816# Does gcc required -traditional?
817AC_PROG_GCC_TRADITIONAL
818
819########
820#
821# Set defines required to build DLLs and modules using MinGW
822#
823########
824# These options are set for multi-thread DLL module build
825#  libMagickCore:           _DLL _MAGICKMOD_ _MAGICKLIB_
826#  module:              _DLL
827#  executable/Magick++: _DLL _MAGICKMOD_
828MODULE_EXTRA_CPPFLAGS=''
829LIBRARY_EXTRA_CPPFLAGS=''
830if test "${native_win32_build}" = 'yes'; then
831    if test "${libtool_build_shared_libs}" = 'yes'; then
832        CPPFLAGS="$CPPFLAGS -D_DLL"
833        MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_DLL"
834        MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_DLL"
835        LIBRARY_EXTRA_CPPFLAGS="$LIBRARY_EXTRA_CPPFLAGS -D_MAGICKLIB_"
836        if test "$with_modules" = 'yes'; then
837            LIBRARY_EXTRA_CPPFLAGS="$LIBRARY_EXTRA_CPPFLAGS -D_MAGICKMOD_"
838        else
839            MODULE_EXTRA_CPPFLAGS="$MODULE_EXTRA_CPPFLAGS -D_MAGICKLIB_"
840        fi
841    else
842        CPPFLAGS="$CPPFLAGS -D_LIB"
843        MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_LIB"
844        MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_LIB"
845    fi
846    if test "$with_threads" = 'yes'; then
847         CPPFLAGS="$CPPFLAGS -D_MT"
848         MAGICK_CPPFLAGS="$MAGICK_CPPFLAGS -D_MT"
849         MAGICK_PCFLAGS="$MAGICK_PCFLAGS -D_MT"
850    fi
851fi
852AC_SUBST(MODULE_EXTRA_CPPFLAGS)
853AC_SUBST(LIBRARY_EXTRA_CPPFLAGS)
854
855# Check standard headers
856AC_HEADER_STDC
857if ! test x"$ac_cv_header_stdc" = x"yes"; then
858    AC_MSG_WARN([configure has detected that you do not have the ANSI standard C
859    header files.  Compilation cannot proceed.  Please install the ANSI C
860    headers and rerun this script.]);
861fi
862AC_HEADER_DIRENT
863
864# Check additional headers
865AC_CHECK_HEADERS(errno.h fcntl.h inttypes.h limits.h locale.h machine/param.h mach-o/dyld.h stdarg.h string.h strings.h sys/ipc.h sys/resource.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/wait.h unistd.h)
866
867########
868#
869# Checks for typedefs, structures, and compiler characteristics.
870#
871########
872
873AC_HEADER_STDBOOL
874AC_C_VOLATILE
875AC_C_STRINGIZE
876AC_HEADER_STAT
877AC_HEADER_TIME
878AC_STRUCT_TM
879
880########
881#
882# Checks for typedefs, structures, and compiler characteristics.
883#
884########
885
886# If the C compiler does not fully support the ANSI C qualifier const,
887# define const to be empty.
888AC_C_CONST
889
890# If the C compiler supports the keyword inline, do nothing. Otherwise
891# define inline to __inline__ or __inline if it accepts one of those,
892# otherwise define inline to be empty.
893AC_C_INLINE
894
895# If the C compiler supports the keyword restrict, do nothing. Otherwise
896# define restrict to __restrict__ or __restrict if it accepts one of those,
897# otherwise define restrict to be empty.
898AC_C_RESTRICT
899
900# If words are stored with the most significant byte first (like
901# Motorola and SPARC CPUs), define `WORDS_BIGENDIAN'.
902AC_C_BIGENDIAN
903
904# Define mode_t to a suitable type, if standard headers do not define it.
905AC_TYPE_MODE_T
906
907# Define off_t to a suitable type, if standard headers do not define it.
908AC_TYPE_OFF_T
909
910# Define pid_t to a suitable type, if standard headers do not define it.
911AC_TYPE_PID_T
912
913# Define size_t to a suitable type, if standard headers do not define it.
914AC_TYPE_SIZE_T
915
916# Define ssize_t to a suitable type, if standard headers do not define it.
917AC_TYPE_SSIZE_T
918
919# If the C compiler supports a working long double type with more range
920# or precision than the double type, define HAVE_LONG_DOUBLE.
921AC_C_LONG_DOUBLE
922
923# If the C type char is unsigned, define __CHAR_UNSIGNED__, unless the
924# C compiler predefines it.
925AC_C_CHAR_UNSIGNED
926
927# Obtain size of an 'signed short' and define as SIZEOF_SIGNED_SHORT
928AC_CHECK_SIZEOF(signed short)
929
930# Obtain size of an 'unsigned short' and define as SIZEOF_UNSIGNED_SHORT
931AC_CHECK_SIZEOF(unsigned short)
932
933# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT
934AC_CHECK_SIZEOF(signed int)
935
936# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT
937AC_CHECK_SIZEOF(unsigned int)
938
939# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG
940AC_CHECK_SIZEOF(signed long)
941
942# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG
943AC_CHECK_SIZEOF(unsigned long)
944
945# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG.  If
946# 'signed long long' is not supported then the value defined is zero.
947AC_CHECK_SIZEOF(signed long long)
948
949# Obtain size of a 'unsigned long long' and define as
950# SIZEOF_UNSIGNED_LONG_LONG.  If 'unsigned long long' is not
951# supported then the value defined is zero.
952AC_CHECK_SIZEOF(unsigned long long)
953
954# Obtain size of off_t and define as SIZEOF_OFF_T
955AC_CHECK_SIZEOF(off_t)
956
957# Obtain size of size_t and define as SIZEOF_SIZE_T
958AC_CHECK_SIZEOF(size_t)
959
960# Obtain size of an unsigned int pointer and define as SIZEOF_UNSIGNED_INTP
961AC_CHECK_SIZEOF(unsigned int*)
962
963# If `signal.h' declares signal as returning a pointer to a function
964# returning void, define RETSIGTYPE to be void; otherwise, define it
965# to be int.
966AC_TYPE_SIGNAL
967
968#
969# Compute sized types for current CPU and compiler options.
970#
971
972AC_MSG_CHECKING(for signed 8-bit type)
973INT8_T='signed char'
974AC_MSG_RESULT($INT8_T)
975AC_SUBST(INT8_T)
976
977AC_MSG_CHECKING(for unsigned 8-bit type)
978UINT8_T='unsigned char'
979AC_MSG_RESULT($UINT8_T)
980AC_SUBST(UINT8_T)
981
982AC_MSG_CHECKING(for signed 16-bit type)
983INT16_T='signed short'
984AC_MSG_RESULT($INT16_T)
985AC_SUBST(INT16_T)
986
987AC_MSG_CHECKING(for unsigned 16-bit type)
988UINT16_T='unsigned short'
989AC_MSG_RESULT($UINT16_T)
990AC_SUBST(UINT16_T)
991
992AC_MSG_CHECKING(for signed 32-bit type)
993INT32_T='none'
994if test $ac_cv_sizeof_signed_int -eq 4; then
995  INT32_T='signed int'
996elif test $ac_cv_sizeof_signed_long -eq 4; then
997  INT32_T='signed long'
998fi
999AC_MSG_RESULT($INT32_T)
1000AC_SUBST(INT32_T)
1001
1002AC_MSG_CHECKING(for unsigned 32-bit type)
1003UINT32_T='none'
1004if test $ac_cv_sizeof_unsigned_int -eq 4; then
1005  UINT32_T='unsigned int'
1006elif test $ac_cv_sizeof_unsigned_long -eq 4; then
1007  UINT32_T='unsigned long'
1008fi
1009AC_MSG_RESULT($UINT32_T)
1010AC_SUBST(UINT32_T)
1011
1012AC_MSG_CHECKING(for signed 64-bit type)
1013INT64_T='none'
1014if test $ac_cv_sizeof_signed_long -eq 8; then
1015  INT64_T='signed long'
1016elif test $ac_cv_sizeof_signed_long_long -eq 8; then
1017  INT64_T='signed long long'
1018fi
1019AC_MSG_RESULT($INT64_T)
1020AC_SUBST(INT64_T)
1021
1022AC_MSG_CHECKING(for unsigned 64-bit type)
1023UINT64_T='none'
1024if test $ac_cv_sizeof_unsigned_long -eq 8; then
1025  UINT64_T='unsigned long'
1026elif test $ac_cv_sizeof_unsigned_long_long -eq 8; then
1027  UINT64_T='unsigned long long'
1028fi
1029AC_MSG_RESULT($UINT64_T)
1030AC_SUBST(UINT64_T)
1031
1032AC_MSG_CHECKING(for unsigned maximum type)
1033UINTMAX_T='none'
1034if test "$UINT64_T" != 'none'; then
1035  UINTMAX_T=$UINT64_T
1036elif test "$UINT32_T" != 'none'; then
1037  UINTMAX_T=$UINT32_T
1038fi
1039AC_MSG_RESULT($UINTMAX_T)
1040AC_SUBST(UINTMAX_T)
1041
1042AC_MSG_CHECKING(for pointer difference type)
1043UINTPTR_T='none'
1044if test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_unsigned_intp; then
1045  UINTPTR_T='unsigned long'
1046elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_unsigned_intp; then
1047  UINTPTR_T='unsigned long long'
1048fi
1049AC_MSG_RESULT($UINTPTR_T)
1050AC_SUBST(UINTPTR_T)
1051
1052AC_MSG_CHECKING([whether our compiler supports __func__])
1053AC_TRY_COMPILE([],
1054 [{ const char *func = __func__; return(func != 0 ? 0 : 1); }],
1055 AC_MSG_RESULT([yes]),
1056 AC_MSG_RESULT([no])
1057 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
1058 AC_TRY_COMPILE([],
1059   [{ const char *func = __FUNCTION__; return(func != 0 ? 0 : 1); }],
1060   AC_MSG_RESULT([yes])
1061   AC_DEFINE(__func__, __FUNCTION__,
1062     [Define to appropriate substitue if compiler does not have __func__]),
1063   AC_MSG_RESULT([no])
1064   AC_DEFINE(__func__, __FILE__,
1065     [Define to appropriate substitue if compiler does not have __func__])))
1066
1067########
1068#
1069# Check for functions
1070#
1071########
1072MAGICK_FUNC_MMAP_FILEIO
1073AC_FUNC_CLOSEDIR_VOID
1074AC_FUNC_MMAP
1075AC_FUNC_MEMCMP
1076AC_FUNC_SELECT_ARGTYPES
1077AC_FUNC_SETVBUF_REVERSED
1078AC_TYPE_SIGNAL
1079AC_FUNC_STRTOD
1080AC_FUNC_VPRINTF
1081
1082AC_CHECK_FUNCS([_exit atexit clock clock_gettime execvp floor fork ftime ftruncate getcwd getpid getexecname getdtablesize getpagesize gettimeofday lstat memset mkstemp munmap _NSGetExecutablePath pclose _pclose poll popen _popen pow pread pwrite raise rand_r readlink realpath select seekdir setlocale sqrt setvbuf stat strcspn strdup strpbrk strspn strstr strtol symlink sysconf sigemptyset sigaction strerror strlcat strlcpy strcasecmp strncasecmp telldir tempnam times usleep vsprintf vsnprintf waitpid _wfopen])
1083
1084########
1085#       
1086# Check for function prototypes
1087#
1088########
1089
1090AC_CHECK_DECLS([pread, pwrite],[],[],[
1091#include <unistd.h>])
1092
1093AC_CHECK_DECLS([strlcpy],[],[],[
1094#include <strings.h>])
1095
1096AC_CHECK_DECLS([vsnprintf],[],[],[
1097#include <stdio.h>
1098#include <stdarg.h>])
1099
1100########
1101#
1102# C++ Support Tests (For Magick++)
1103#
1104########
1105have_magick_plus_plus='no'
1106if test "$with_magick_plus_plus" = 'yes'; then
1107    OLIBS="$LIBS"
1108    LIBS=''
1109    AC_LANG_PUSH(C++)
1110
1111    # Full set of headers used ...
1112    # algorithm cctype cerrno cmath cstdio cstdlib cstring ctime exception
1113    # functional iomanip iosfwd iostream iterator list string strstream utility
1114    AC_LANG([C++])
1115    AC_PROG_CXX
1116    AC_CXX_HAVE_BOOL
1117    AC_CXX_HAVE_NAMESPACES
1118    AC_CXX_HAVE_STD_NAMESPACE
1119    AC_CXX_HAVE_STD_LIBS
1120    AC_CXX_HAVE_LSTRING
1121    AC_OPENMP([C++])
1122    CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
1123    AC_LANG_POP
1124
1125    AC_MSG_CHECKING([whether C++ compiler is sufficient for Magick++])
1126    if \
1127        test $ac_cv_cxx_have_bool = 'yes' && \
1128        test $ac_cv_cxx_have_lstring = 'yes' && \
1129        test $ac_cv_cxx_have_namespaces = 'yes' && \
1130        test $ac_cv_cxx_have_std_libs = 'yes' && \
1131        test $ac_cv_cxx_have_std_namespace = 'yes'; then
1132        have_magick_plus_plus='yes'
1133    else
1134        have_magick_plus_plus='no (failed tests)'
1135    fi
1136    AC_MSG_RESULT([$have_magick_plus_plus])
1137    LIBS="$OLIBS"
1138fi
1139AM_CONDITIONAL(WITH_MAGICK_PLUS_PLUS, test "$have_magick_plus_plus" = 'yes')
1140
1141# Only check for delegate libraries in subdirectories if requested.
1142if test "$enable_delegate_build" != 'no'; then
1143    # Check for delegate sub-directories and add -I & -L options as required.
1144    # This presumes that delegates are installed as detailed in the ImageMagick
1145    # README. If delegates are installed in a standard location where the
1146    # compiler will automatically find them then these options should not be
1147    # required.
1148
1149    #
1150    # Most delegates have includes in the same directory as the library, but not all ...
1151    #
1152    # Includes
1153    for dir in bzlib fpx jp2 jp2/src/libjasper/include jbig/libjbig jpeg lcms/include magick png tiff/libtiff ttf/include wand wmf/include xml/include zlib; do
1154        if test -d "$builddir/$dir"; then
1155            CPPFLAGS="$CPPFLAGS -I$builddir/$dir"
1156        else
1157            if test -d "$srcdirfull/$dir"; then
1158                CPPFLAGS="$CPPFLAGS -I$srcdirfull/$dir"
1159            fi
1160        fi
1161    done
1162
1163    # Libraries
1164    for dir in bzlib fpx jp2 jp2/src/libjasper jbig/libjbig jpeg lcms/src magick png tiff/libtiff ttf/objs wand wmf/src xml zlib; do
1165    if test -d "$builddir/$dir/.libs"; then
1166        LDFLAGS="$LDFLAGS -L$builddir/$dir/.libs"
1167    else
1168        if test -d "$srcdirfull/$dir/.libs"; then
1169            LDFLAGS="$LDFLAGS -L$srcdirfull/$dir/.libs"
1170        fi
1171    fi
1172    if test -d "$builddir/$dir"; then
1173        LDFLAGS="$LDFLAGS -L$builddir/$dir"
1174    else
1175        if test -d "$srcdirfull/$dir"; then
1176            LDFLAGS="$LDFLAGS -L$srcdirfull/$dir"
1177        fi
1178    fi
1179  done
1180fi
1181
1182# Assume that delegate headers reside under same directory as ImageMagick
1183# installation prefix.
1184MAGICK_CPPFLAGS="-I$INCLUDE_DIR/ImageMagick $MAGICK_CPPFLAGS"
1185
1186#
1187# Find the X11 RGB database
1188#
1189AC_CACHE_CHECK(for X11 configure files,im_cv_x_configure,
1190[# Look for the header file in a standard set of common directories.
1191# Check X11 before X11Rn because it is often a symlink to the current release.
1192    for ac_dir in          \
1193    /lib/usr/lib/X11       \
1194    /usr/X11/lib           \
1195    /usr/X11R4/lib         \
1196    /usr/X11R5/lib         \
1197    /usr/X11R6/lib         \
1198    /usr/X386/lib          \
1199    /usr/XFree86/lib/X11   \
1200    /usr/athena/lib        \
1201    /usr/lib               \
1202    /usr/lib/X11           \
1203    /usr/lib/X11R4         \
1204    /usr/lib/X11R5         \
1205    /usr/lib/X11R6         \
1206    /usr/local/X11/lib     \
1207    /usr/local/X11R4/lib   \
1208    /usr/local/X11R5/lib   \
1209    /usr/local/X11R6/lib   \
1210    /usr/local/lib         \
1211    /usr/local/lib/X11     \
1212    /usr/local/lib/X11R4   \
1213    /usr/local/lib/X11R5   \
1214    /usr/local/lib/X11R6   \
1215    /usr/local/x11r5/lib   \
1216    /usr/lpp/Xamples/lib   \
1217    /usr/openwin/lib       \
1218    /usr/openwin/share/lib \
1219    /usr/unsupported/lib   \
1220    /usr/x386/lib          \
1221    ; do
1222    if test -f "$ac_dir/X11/rgb.txt"; then
1223      im_cv_x_configure="$ac_dir/X11/"
1224      break
1225    elif test -f "$ac_dir/rgb.txt"; then
1226      im_cv_x_configure="$ac_dir/"
1227      break
1228    fi
1229
1230  done])
1231X11_CONFIGURE_PATH="$im_cv_x_configure"
1232if test "$native_win32_build" = 'yes'; then
1233    X11_CONFIGURE_PATH=`$WinPathScript "$X11ConfigurePath=" 1`
1234fi
1235AC_DEFINE_UNQUOTED(X11_CONFIGURE_PATH,"$X11ConfigurePath",Location of X11 configure files)
1236
1237#
1238# Find OpenMP library
1239#
1240GOMP_LIBS=''
1241if test "$enable_openmp" != 'no'; then
1242  AC_CHECK_LIB(gomp,GOMP_parallel_start,GOMP_LIBS="-lgomp",,)
1243  LIBS="$GOMP_LIBS $LIBS"
1244fi
1245AC_SUBST(GOMP_LIBS)
1246
1247#
1248# Find Posix threads library
1249#
1250THREAD_LIBS=''
1251if test "$with_threads" != 'no' && test "$have_threads" = 'yes'; then
1252
1253    if test "x$PTHREAD_LIBS" = "x"; then
1254    case "${host_cpu}-${host_os}" in
1255      *-freebsd*)
1256        MAGICK_CHECK_PTHREAD_LIB(c_r,PTHREAD_LIBS=-lc_r) ;;
1257    esac
1258    fi
1259
1260    for lib in pthread pthreads; do
1261        if test "x$PTHREAD_LIBS" = "x"; then
1262            MAGICK_CHECK_PTHREAD_LIB([$lib],[PTHREAD_LIBS=-l$lib])
1263        fi
1264    done
1265
1266    THREAD_LIBS="$PTHREAD_LIBS"
1267    LIBS="$LIBS $THREAD_LIBS"
1268fi
1269AC_SUBST(THREAD_LIBS)
1270
1271#
1272# Check for umem.
1273#
1274have_umem='no'
1275UMEM_LIBS=''
1276if test "$with_umem" != 'no'; then
1277  AC_MSG_CHECKING(for UMEM support )
1278  AC_MSG_RESULT()
1279  failed=0;
1280  passed=0;
1281  AC_CHECK_HEADER(umem.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
1282  AC_CHECK_LIB(umem,umem_alloc,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1283  AC_CHECK_LIB(umem,umem_free,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1284  AC_MSG_CHECKING(if umem memory allocation library is complete)
1285  if test $passed -gt 0; then
1286    if test $failed -gt 0; then
1287      AC_MSG_RESULT(no -- some components failed test)
1288      have_umem='no (failed tests)'
1289    else
1290      UMEM_LIBS='-lumem'
1291      LIBS="$UMEM_LIBS $LIBS"
1292      AC_DEFINE(HasUMEM,1,Define if you have umem memory allocation library)
1293      AC_MSG_RESULT(yes)
1294      have_umem='yes'
1295    fi
1296  else
1297    AC_MSG_RESULT(no)
1298  fi
1299fi
1300AM_CONDITIONAL(HasUMEM, test "$have_umem" = 'yes')
1301AC_SUBST(UMEM_LIBS)
1302
1303#
1304# Add support for ccmalloc memory debugging library if requested
1305#
1306have_ccmalloc='no'
1307CCMALLOC_LIBS=''
1308if test "$enable_ccmalloc" = 'yes'; then
1309    AC_PATH_PROG(CCMALLOCDelegate,ccmalloc,)
1310    if test -n "$CCMALLOCDelegate"; then
1311        eval `grep PREFIX= $CCMALLOCDelegate | sed -e 's/PREFIX/CCMALLOC_PREFIX/'`
1312        OLIBS="$LIBS"
1313        # Assume that gcc is used with ccmalloc.
1314        LIBS="$LIBS $CCMALLOC_PREFIX/lib/ccmalloc-gcc.o"
1315       AC_CHECK_LIB(ccmalloc,ccmalloc_malloc,CCMALLOC_LIBS="$CCMALLOC_PREFIX/lib/ccmalloc-gcc.o -lccmalloc -ldl",,-ldl)
1316        if test -n "$CCMALLOC_LIBS"; then
1317            LIBS="$OLIBS"
1318            LIBS="$LIBS $CCMALLOC_LIBS"
1319            have_ccmalloc='yes'
1320        else
1321            LIBS="$OLIBS"
1322        fi
1323    fi
1324fi
1325
1326#
1327# Add support for efence memory debugging library if requested
1328#
1329if test "$enable_efence" = 'yes'; then
1330    EFENCE_LIBS='-lefence'
1331    LIBS="$EFENCE_LIBS $LIBS"
1332fi
1333
1334#
1335# Find math library
1336#
1337MATH_LIBS=''
1338AC_CHECK_LIB(m,sqrt,MATH_LIBS="-lm",,)
1339LIBS="$MATH_LIBS $LIBS"
1340AC_SUBST(MATH_LIBS)
1341
1342#
1343# Check for ZLIB
1344#
1345have_zlib='no'
1346ZLIB_LIBS=''
1347dnl PNG requires zlib so enable zlib check if PNG is requested
1348if test "$with_zlib" != 'no' || test "$with_png" != 'no'; then
1349    AC_MSG_RESULT([-------------------------------------------------------------])
1350    AC_MSG_RESULT([Checking for ZLIB support])
1351    AC_MSG_RESULT([-------------------------------------------------------------])
1352    ZLIB_LIBS=''
1353    failed=0;
1354    passed=0;
1355    AC_CHECK_HEADER(zconf.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
1356    AC_CHECK_HEADER(zlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
1357    AC_CHECK_LIB(z,compress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1358    AC_CHECK_LIB(z,uncompress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1359    AC_CHECK_LIB(z,deflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1360    AC_CHECK_LIB(z,inflate,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1361    AC_CHECK_LIB(z,gzseek,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1362    AC_CHECK_LIB(z,gztell,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
1363    AC_MSG_CHECKING([if ZLIB package is complete])
1364    if test $passed -gt 0; then
1365        if test $failed -gt 0; then
1366            AC_MSG_RESULT([no -- some components failed test])
1367            have_zlib='no (failed tests)'
1368        else
1369            ZLIB_LIBS='-lz'
1370            LIBS="$ZLIB_LIBS $LIBS"
1371            AC_DEFINE(ZLIB_DELEGATE,1,Define if you have zlib compression library)