1dnl                                               -*- Autoconf -*-
2dnl Tag Image File Format (TIFF) Software
3dnl
4dnl Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
5dnl
6dnl Permission to use, copy, modify, distribute, and sell this software and
7dnl its documentation for any purpose is hereby granted without fee, provided
8dnl that (i) the above copyright notices and this permission notice appear in
9dnl all copies of the software and related documentation, and (ii) the names of
10dnl Sam Leffler and Silicon Graphics may not be used in any advertising or
11dnl publicity relating to the software without the specific, prior written
12dnl permission of Sam Leffler and Silicon Graphics.
13dnl
14dnl THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15dnl EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16dnl WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17dnl
18dnl IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19dnl ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20dnl OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21dnl WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22dnl LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23dnl OF THIS SOFTWARE.
24
25dnl Process this file with autoconf to produce a configure script.
26
27AC_PREREQ(2.64)
28AC_INIT([LibTIFF Software],[4.0.3],[tiff@lists.maptools.org],[tiff])
29AC_CONFIG_AUX_DIR(config)
30AC_CONFIG_MACRO_DIR(m4)
31AC_LANG(C)
32
33dnl Compute the canonical host (run-time) system type variable
34AC_CANONICAL_HOST
35
36AM_INIT_AUTOMAKE
37dnl Do not rebuild generated files every time
38AM_MAINTAINER_MODE
39
40dnl Versioning.
41dnl Don't fill the ALPHA_VERSION field, if not applicable.
42LIBTIFF_MAJOR_VERSION=4
43LIBTIFF_MINOR_VERSION=0
44LIBTIFF_MICRO_VERSION=3
45LIBTIFF_ALPHA_VERSION=
46LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION
47dnl This will be used with the 'make release' target
48LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"`
49
50dnl Libtool library revision control info
51dnl See the libtool documentation under the heading "Libtool's versioning
52dnl system" in order to understand the meaning of these fields
53dnl
54dnl current
55dnl      The most recent interface number that this library implements.
56dnl revision
57dnl      The implementation number of the current interface.
58dnl age
59dnl      The difference between the newest and oldest interfaces that
60dnl      this library implements. In other words, the library implements
61dnl      all the interface numbers in the range from number current -
62dnl      age to current.
63dnl
64dnl Here are a set of rules to help you update your library version
65dnl information:
66dnl
67dnl  1. Start with version information of `0:0:0' for each libtool library.
68dnl  2. Update the version information only immediately before a public
69dnl     release of your software. More frequent updates are unnecessary, and
70dnl     only guarantee that the current interface number gets larger faster.
71dnl  3. If the library source code has changed at all since the last update,
72dnl     then increment revision (`c:r:a' becomes `c:r+1:a').
73dnl  4. If any interfaces have been added, removed, or changed since the last
74dnl     update, increment current, and set revision to 0.
75dnl  5. If any interfaces have been added since the last public release, then
76dnl     increment age.
77dnl  6. If any interfaces have been removed since the last public release,
78dnl     then set age to 0.
79LIBTIFF_CURRENT=7
80LIBTIFF_REVISION=0
81LIBTIFF_AGE=2
82LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE
83
84# This is a special hack for OpenBSD and MirOS systems. The dynamic linker
85# in OpenBSD uses some special semantics for shared libraries. Their soname
86# contains only two numbers, major and minor.
87# See http://bugzilla.remotesensing.org/show_bug.cgi?id=838 for details.
88#case "$host_os" in
89#    openbsd* | mirbsd*)
90#	LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION:0
91#	;;
92#    *)
93#	LIBTIFF_VERSION_INFO=$LIBTIFF_MAJOR_VERSION:$LIBTIFF_MINOR_VERSION:$LIBTIFF_MICRO_VERSION
94#	;;
95#esac
96
97AC_SUBST(LIBTIFF_MAJOR_VERSION)
98AC_SUBST(LIBTIFF_MINOR_VERSION)
99AC_SUBST(LIBTIFF_MICRO_VERSION)
100AC_SUBST(LIBTIFF_ALPHA_VERSION)
101AC_SUBST(LIBTIFF_VERSION)
102AC_SUBST(LIBTIFF_VERSION_INFO)
103AC_SUBST(LIBTIFF_RELEASE_DATE)
104
105dnl Checks for programs.
106AC_PROG_CC
107AM_PROG_CC_C_O
108
109dnl We want warnings. As many warnings as possible.
110VL_PROG_CC_WARNINGS()
111
112AC_PROG_INSTALL
113AC_PROG_LN_S
114
115
116# Check if LD supports linker scripts, and define automake conditional
117# HAVE_LD_VERSION_SCRIPT if so.  This functionality is currently
118# constrained to compilers using GNU ld on ELF systems or systems
119# which provide an adequate emulation thereof.
120AC_ARG_ENABLE([ld-version-script],
121  AS_HELP_STRING([--enable-ld-version-script],
122    [enable linker version script (default is disabled)]),
123    [have_ld_version_script=$enableval], [have_ld_version_script=no])
124if test "$have_ld_version_script" != no; then
125  AC_MSG_CHECKING([if LD -Wl,--version-script works])
126  save_LDFLAGS="$LDFLAGS"
127  LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
128  cat > conftest.map <<EOF
129VERS_1 {
130        global: sym;
131};
132
133VERS_2 {
134        global: sym;
135} VERS_1;
136EOF
137  AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
138                 [have_ld_version_script=yes], [have_ld_version_script=no])
139  rm -f conftest.map
140  LDFLAGS="$save_LDFLAGS"
141  AC_MSG_RESULT($have_ld_version_script)
142fi
143AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
144
145
146dnl Tests for Windows
147AC_EXEEXT
148AC_OBJEXT
149
150dnl initialize libtool
151LT_INIT([win32-dll])
152LT_LANG([C++])
153
154# Enable support for silent build rules
155AM_SILENT_RULES
156
157dnl We don't need to add math library to all targets
158case "${host_os}" in
159    cygwin* | mingw32* | beos* | darwin*)
160        ;;
161    *)
162	AC_CHECK_LIB(m,sin,,,)
163        ;;
164esac
165
166tiff_libs_private=
167AC_SUBST(tiff_libs_private)
168
169dnl Checks for header files.
170AC_CHECK_HEADERS([assert.h fcntl.h io.h limits.h malloc.h search.h sys/time.h unistd.h])
171
172dnl Checks for typedefs, structures, and compiler characteristics.
173AC_C_CONST
174AC_C_INLINE
175AC_C_BIGENDIAN
176AC_TYPE_OFF_T
177AC_TYPE_SIZE_T
178AC_HEADER_TIME
179AC_STRUCT_TM
180
181dnl ---------------------------------------------------------------------------
182dnl Compute sized types for current CPU and compiler options
183dnl ---------------------------------------------------------------------------
184
185# Obtain size of an 'signed short' and define as SIZEOF_SIGNED_SHORT
186AC_CHECK_SIZEOF(signed short)
187
188# Obtain size of an 'unsigned short' and define as SIZEOF_UNSIGNED_SHORT
189AC_CHECK_SIZEOF(unsigned short)
190
191# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT
192AC_CHECK_SIZEOF(signed int)
193
194# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT
195AC_CHECK_SIZEOF(unsigned int)
196
197# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG
198AC_CHECK_SIZEOF(signed long)
199
200# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG
201AC_CHECK_SIZEOF(unsigned long)
202
203# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG.
204# If 'long long' is not supported then the value defined is zero.
205AC_CHECK_SIZEOF(signed long long)
206
207# Obtain size of a 'unsigned long long' and define as
208# SIZEOF_UNSIGNED_LONG_LONG.  If 'unsigned long long' is not
209# supported then the value defined is zero.
210AC_CHECK_SIZEOF(unsigned long long)
211
212# Obtain the size of an 'unsigned char *' and define as
213# SIZEOF_UNSIGNED_CHAR_P.  Result is available in
214# ac_cv_sizeof_unsigned_char_p.
215AC_CHECK_SIZEOF(unsigned char *)
216
217AC_MSG_CHECKING(for signed 8-bit type)
218INT8_T='signed char'
219AC_MSG_RESULT($INT8_T)
220AC_DEFINE_UNQUOTED(TIFF_INT8_T,$INT8_T,[Signed 8-bit type])
221
222AC_MSG_CHECKING(for unsigned 8-bit type)
223UINT8_T='unsigned char'
224AC_MSG_RESULT($UINT8_T)
225AC_DEFINE_UNQUOTED(TIFF_UINT8_T,$UINT8_T,[Unsigned 8-bit type])
226
227AC_MSG_CHECKING(for signed 16-bit type)
228INT16_T='signed short'
229AC_MSG_RESULT($INT16_T)
230AC_DEFINE_UNQUOTED(TIFF_INT16_T,$INT16_T,[Signed 16-bit type])
231
232
233AC_MSG_CHECKING(for unsigned 16-bit type)
234UINT16_T='unsigned short'
235AC_MSG_RESULT($UINT16_T)
236AC_DEFINE_UNQUOTED(TIFF_UINT16_T,$UINT16_T,[Unsigned 16-bit type])
237
238AC_MSG_CHECKING(for signed 32-bit type)
239INT32_T='none'
240INT32_FORMAT='none'
241if test $ac_cv_sizeof_signed_int -eq 4
242then
243  INT32_T='signed int'
244  INT32_FORMAT='"%d"'
245elif test $ac_cv_sizeof_signed_long -eq 4
246then
247  INT32_T='signed long'
248  INT32_FORMAT='"%ld"'
249fi
250AC_MSG_RESULT($INT32_T)
251AC_DEFINE_UNQUOTED(TIFF_INT32_T,$INT32_T,[Signed 32-bit type])
252AC_DEFINE_UNQUOTED(TIFF_INT32_FORMAT,$INT32_FORMAT,[Signed 32-bit type formatter])
253
254AC_MSG_CHECKING(for unsigned 32-bit type)
255UINT32_T='none'
256UINT32_FORMAT='none'
257if test $ac_cv_sizeof_unsigned_int -eq 4
258then
259  UINT32_T='unsigned int'
260  UINT32_FORMAT='"%u"'
261elif test $ac_cv_sizeof_unsigned_long -eq 4
262then
263  UINT32_T='unsigned long'
264  UINT32_FORMAT='"%lu"'
265fi
266AC_MSG_RESULT($UINT32_T)
267AC_DEFINE_UNQUOTED(TIFF_UINT32_T,$UINT32_T,[Unsigned 32-bit type])
268AC_DEFINE_UNQUOTED(TIFF_UINT32_FORMAT,$UINT32_FORMAT,[Unsigned 32-bit type formatter])
269
270AC_MSG_CHECKING(for signed 64-bit type)
271INT64_T='none'
272INT64_FORMAT='none'
273if test $ac_cv_sizeof_signed_long -eq 8
274then
275  INT64_T='signed long'
276  INT64_FORMAT='"%ld"'
277elif test $ac_cv_sizeof_signed_long_long -eq 8
278then
279  INT64_T='signed long long'
280  case "${host_os}" in
281    mingw32*)
282      # MinGW32 understands 'long long', but uses printf from WIN32 CRT
283      INT64_FORMAT='"%I64d"'
284      ;;
285    *)
286      INT64_FORMAT='"%lld"'
287      ;;
288  esac
289fi
290
291
292AC_MSG_RESULT($INT64_T)
293AC_DEFINE_UNQUOTED(TIFF_INT64_T,$INT64_T,[Signed 64-bit type])
294AC_DEFINE_UNQUOTED(TIFF_INT64_FORMAT,$INT64_FORMAT,[Signed 64-bit type formatter])
295
296AC_MSG_CHECKING(for unsigned 64-bit type)
297UINT64_T='none'
298UINT64_FORMAT='none'
299if test $ac_cv_sizeof_unsigned_long -eq 8
300then
301  UINT64_T='unsigned long'
302  UINT64_FORMAT='"%lu"'
303elif test $ac_cv_sizeof_unsigned_long_long -eq 8
304then
305  UINT64_T='unsigned long long'
306  case "${host_os}" in
307    mingw32*)
308      # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT
309      UINT64_FORMAT='"%I64u"'
310      ;;
311    *)
312      UINT64_FORMAT='"%llu"'
313      ;;
314  esac
315fi
316AC_MSG_RESULT($UINT64_T)
317AC_DEFINE_UNQUOTED(TIFF_UINT64_T,$UINT64_T,[Unsigned 64-bit type])
318AC_DEFINE_UNQUOTED(TIFF_UINT64_FORMAT,$UINT64_FORMAT,[Unsigned 64-bit type formatter])
319
320# Determine TIFF equivalent of ssize_t
321AC_MSG_CHECKING(for signed size type)
322SSIZE_T='unknown'
323SSIZE_FORMAT='unknown'
324if test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_unsigned_char_p
325then
326  SSIZE_T='signed long'
327  SSIZE_FORMAT='"%ld"'
328elif test $ac_cv_sizeof_signed_long_long -eq $ac_cv_sizeof_unsigned_char_p
329then
330  SSIZE_T='signed long long'
331  SSIZE_FORMAT='"%lld"'
332fi
333AC_MSG_RESULT($SSIZE_T)
334AC_DEFINE_UNQUOTED(TIFF_SSIZE_T,$SSIZE_T,[Signed size type])
335AC_DEFINE_UNQUOTED(TIFF_SSIZE_FORMAT,$SSIZE_FORMAT,[Signed size type formatter])
336
337# Determine the type to use for the difference between two pointers.
338# We will default to the POSIX ptrdiff_t if it is available, but will
339# be prepared for the case when it is not.
340PTRDIFF_T='unknown'
341PTRDIFF_FORMAT='"%ld"'
342AC_CHECK_TYPE(ptrdiff_t,[PTRDIFF_T=ptrdiff_t])
343if test $PTRDIFF_T = unknown
344then
345  PTRDIFF_T=$SSIZE_T
346  PTRDIFF_FORMAT=$SSIZE_FORMAT
347fi
348AC_MSG_CHECKING(for pointer difference type)
349AC_MSG_RESULT($PTRDIFF_T)
350AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_T,$PTRDIFF_T,[Pointer difference type])
351AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_FORMAT,$PTRDIFF_FORMAT,[Pointer difference type formatter])
352
353dnl Some compilers (IBM VisualAge) has these types defined, so check it here:
354AC_CHECK_TYPES([int8, int16, int32],,,
355[
356#if HAVE_INTTYPES_H
357# include <inttypes.h>
358#endif
359])
360
361dnl Checks for library functions.
362AC_CHECK_FUNCS([floor isascii memmove memset mmap pow setmode sqrt strchr strrchr strstr strtol strtoull])
363
364dnl Will use local replacements for unavailable functions
365AC_REPLACE_FUNCS(getopt)
366AC_REPLACE_FUNCS(strcasecmp)
367AC_REPLACE_FUNCS(strtoul)
368AC_REPLACE_FUNCS(strtoull)
369AC_REPLACE_FUNCS(lfind)
370
371dnl ---------------------------------------------------------------------------
372dnl Check the native cpu bit order.
373dnl ---------------------------------------------------------------------------
374AC_MSG_CHECKING([native cpu bit order])
375case "$host_cpu" in
376    i*86*|x86_64*)
377        HOST_FILLORDER=FILLORDER_LSB2MSB
378	AC_MSG_RESULT([lsb2msb])
379	;;
380    *)
381	HOST_FILLORDER=FILLORDER_MSB2LSB
382	AC_MSG_RESULT([msb2lsb])
383        ;;
384esac
385AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
386
387dnl ---------------------------------------------------------------------------
388dnl Configure legacy tifconf.h HOST_BIGENDIAN.
389dnl ---------------------------------------------------------------------------
390if test "$ac_cv_c_bigendian" = yes ; then
391    HOST_BIGENDIAN=1
392else
393    HOST_BIGENDIAN=0
394fi
395AC_DEFINE_UNQUOTED(HOST_BIGENDIAN,$HOST_BIGENDIAN,[Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel)])
396
397dnl ---------------------------------------------------------------------------
398dnl Make the POSIX.2 features available.
399dnl ---------------------------------------------------------------------------
400#_POSIX_C_SOURCE=2
401#AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE, $_POSIX_C_SOURCE, [Define this macro to a positive integer to control which POSIX functionality is made available.])
402
403dnl ---------------------------------------------------------------------------
404dnl Set the floating point format.
405dnl FIXME: write appropriate test.
406dnl ---------------------------------------------------------------------------
407HAVE_IEEEFP=1
408AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine])
409
410dnl ---------------------------------------------------------------------------
411dnl Enable run-time paths to libraries usage.
412dnl ---------------------------------------------------------------------------
413
414AC_ARG_ENABLE(rpath,
415	      AS_HELP_STRING([--enable-rpath],
416			     [Enable runtime linker paths (-R libtool option)]),
417	      [HAVE_RPATH=$enableval], [HAVE_RPATH=no])
418AM_CONDITIONAL(HAVE_RPATH, test "$HAVE_RPATH" = "yes")
419
420dnl ---------------------------------------------------------------------------
421dnl Support large files.
422dnl ---------------------------------------------------------------------------
423
424AC_SYS_LARGEFILE
425
426dnl ---------------------------------------------------------------------------
427dnl Point to path where we should install documentation.
428dnl ---------------------------------------------------------------------------
429
430LIBTIFF_DOCDIR=\${prefix}/share/doc/${PACKAGE}-${LIBTIFF_VERSION}
431
432AC_ARG_WITH(docdir,
433	    AS_HELP_STRING([--with-docdir=DIR],
434			   [directory where documentation should be installed]),,)
435if test "x$with_docdir" != "x" ; then
436  LIBTIFF_DOCDIR=$with_docdir
437fi
438
439AC_SUBST(LIBTIFF_DOCDIR)
440
441dnl ---------------------------------------------------------------------------
442dnl Switch on/off internal codecs.
443dnl ---------------------------------------------------------------------------
444
445AC_ARG_ENABLE(ccitt,
446	      AS_HELP_STRING([--disable-ccitt],
447			     [disable support for CCITT Group 3 & 4 algorithms]),
448	      [HAVE_CCITT=$enableval], [HAVE_CCITT=yes])
449
450if test "$HAVE_CCITT" = "yes" ; then
451  AC_DEFINE(CCITT_SUPPORT,1,[Support CCITT Group 3 & 4 algorithms])
452fi
453
454AC_ARG_ENABLE(packbits,
455	      AS_HELP_STRING([--disable-packbits],
456			     [disable support for Macintosh PackBits algorithm]),
457	      [HAVE_PACKBITS=$enableval], [HAVE_PACKBITS=yes])
458
459if test "$HAVE_PACKBITS" = "yes" ; then
460  AC_DEFINE(PACKBITS_SUPPORT,1,[Support Macintosh PackBits algorithm])
461fi
462
463AC_ARG_ENABLE(lzw,
464	      AS_HELP_STRING([--disable-lzw],
465			     [disable support for LZW algorithm]),
466	      [HAVE_LZW=$enableval], [HAVE_LZW=yes])
467
468if test "$HAVE_LZW" = "yes" ; then
469  AC_DEFINE(LZW_SUPPORT,1,[Support LZW algorithm])
470fi
471
472AC_ARG_ENABLE(thunder,
473	      AS_HELP_STRING([--disable-thunder],
474			     [disable support for ThunderScan 4-bit RLE algorithm]),
475	      [HAVE_THUNDER=$enableval], [HAVE_THUNDER=yes])
476
477if test "$HAVE_THUNDER" = "yes" ; then
478  AC_DEFINE(THUNDER_SUPPORT,1,[Support ThunderScan 4-bit RLE algorithm])
479fi
480
481HAVE_NEXT=yes
482
483AC_ARG_ENABLE(next,
484	      AS_HELP_STRING([--disable-next],
485			     [disable support for NeXT 2-bit RLE algorithm]),
486	      [HAVE_NEXT=$enableval], [HAVE_NEXT=yes])
487
488if test "$HAVE_NEXT" = "yes" ; then
489  AC_DEFINE(NEXT_SUPPORT,1,[Support NeXT 2-bit RLE algorithm])
490fi
491
492AC_ARG_ENABLE(logluv,
493	      AS_HELP_STRING([--disable-logluv],
494			     [disable support for LogLuv high dynamic range encoding]),
495	      [HAVE_LOGLUV=$enableval], [HAVE_LOGLUV=yes])
496
497if test "$HAVE_LOGLUV" = "yes" ; then
498  AC_DEFINE(LOGLUV_SUPPORT,1,[Support LogLuv high dynamic range encoding])
499fi
500
501dnl ---------------------------------------------------------------------------
502dnl Switch on/off support for Microsoft Document Imaging
503dnl ---------------------------------------------------------------------------
504
505AC_ARG_ENABLE(mdi,
506	      AS_HELP_STRING([--disable-mdi],
507			     [disable support for Microsoft Document Imaging]),
508	      [HAVE_MDI=$enableval], [HAVE_MDI=yes])
509
510if test "$HAVE_MDI" = "yes" ; then
511  AC_DEFINE(MDI_SUPPORT,1,[Support Microsoft Document Imaging format])
512fi
513
514dnl ---------------------------------------------------------------------------
515dnl Check for ZLIB.
516dnl ---------------------------------------------------------------------------
517
518HAVE_ZLIB=no
519
520AC_ARG_ENABLE(zlib,
521	      AS_HELP_STRING([--disable-zlib],
522			     [disable Zlib usage (required for Deflate compression, enabled by default)]),,)
523AC_ARG_WITH(zlib-include-dir,
524	    AS_HELP_STRING([--with-zlib-include-dir=DIR],
525			   [location of Zlib headers]),,)
526AC_ARG_WITH(zlib-lib-dir,
527	    AS_HELP_STRING([--with-zlib-lib-dir=DIR],
528			   [location of Zlib library binary]),,)
529
530if test "x$enable_zlib" != "xno" ; then
531
532  if test "x$with_zlib_lib_dir" != "x" ; then
533    LDFLAGS="-L$with_zlib_lib_dir $LDFLAGS"
534  fi
535
536  AC_CHECK_LIB(z, inflateEnd, [zlib_lib=yes], [zlib_lib=no],)
537  if test "$zlib_lib" = "no" -a "x$with_zlib_lib_dir" != "x"; then
538    AC_MSG_ERROR([Zlib library not found at $with_zlib_lib_dir])
539  fi
540
541  if test "x$with_zlib_include_dir" != "x" ; then
542    CPPFLAGS="-I$with_zlib_include_dir $CPPFLAGS"
543  fi
544  AC_CHECK_HEADER(zlib.h, [zlib_h=yes], [zlib_h=no])
545  if test "$zlib_h" = "no" -a "x$with_zlib_include_dir" != "x" ; then
546    AC_MSG_ERROR([Zlib headers not found at $with_zlib_include_dir])
547  fi
548
549  if test "$zlib_lib" = "yes" -a "$zlib_h" = "yes" ; then
550    HAVE_ZLIB=yes
551  fi
552
553fi
554
555if test "$HAVE_ZLIB" = "yes" ; then
556  AC_DEFINE(ZIP_SUPPORT,1,[Support Deflate compression])
557  LIBS="-lz $LIBS"
558  tiff_libs_private="-lz ${tiff_libs_private}"
559
560  if test "$HAVE_RPATH" = "yes" -a "x$with_zlib_lib_dir" != "x" ; then
561    LIBDIR="-R $with_zlib_lib_dir $LIBDIR"
562  fi
563
564fi
565
566dnl ---------------------------------------------------------------------------
567dnl Check for Pixar log-format algorithm.
568dnl ---------------------------------------------------------------------------
569
570AC_ARG_ENABLE(pixarlog,
571	      AS_HELP_STRING([--disable-pixarlog],
572			     [disable support for Pixar log-format algorithm (requires Zlib)]),
573	      [HAVE_PIXARLOG=$enableval], [HAVE_PIXARLOG=yes])
574
575if test "$HAVE_ZLIB" = "yes" -a "$HAVE_PIXARLOG" = "yes" ; then
576  AC_DEFINE(PIXARLOG_SUPPORT, 1,
577	    [Support Pixar log-format algorithm (requires Zlib)])
578else
579  HAVE_PIXARLOG=no
580fi
581
582dnl ---------------------------------------------------------------------------
583dnl Check for JPEG.
584dnl ---------------------------------------------------------------------------
585
586HAVE_JPEG=no
587
588AC_ARG_ENABLE(jpeg,
589	      AS_HELP_STRING([--disable-jpeg],
590			     [disable IJG JPEG library usage (required for JPEG compression, enabled by default)]),,)
591AC_ARG_WITH(jpeg-include-dir,
592	    AS_HELP_STRING([--with-jpeg-include-dir=DIR],
593			   [location of IJG JPEG library headers]),,)
594AC_ARG_WITH(jpeg-lib-dir,
595	    AS_HELP_STRING([--with-jpeg-lib-dir=DIR],
596			   [location of IJG JPEG library binary]),,)
597
598if test "x$enable_jpeg" != "xno" ; then
599
600  if test "x$with_jpeg_lib_dir" != "x" ; then
601    LDFLAGS="-L$with_jpeg_lib_dir $LDFLAGS"
602
603  fi
604
605  AC_CHECK_LIB(jpeg, jpeg_read_scanlines, [jpeg_lib=yes], [jpeg_lib=no],)
606  if test "$jpeg_lib" = "no" -a "x$with_jpeg_lib_dir" != "x" ; then
607    AC_MSG_ERROR([IJG JPEG library not found at $with_jpeg_lib_dir])
608  fi
609
610  if test "x$with_jpeg_include_dir" != "x" ; then
611    CPPFLAGS="-I$with_jpeg_include_dir $CPPFLAGS"
612  fi
613  AC_CHECK_HEADER(jpeglib.h, [jpeg_h=yes], [jpeg_h=no])
614  if test "$jpeg_h" = "no" -a "x$with_jpeg_include_dir" != "x" ; then
615    AC_MSG_ERROR([IJG JPEG library headers not found at $with_jpeg_include_dir])
616  fi
617
618  if test "$jpeg_lib" = "yes" -a "$jpeg_h" = "yes" ; then
619    HAVE_JPEG=yes
620  fi
621
622fi
623
624if test "$HAVE_JPEG" = "yes" ; then
625  AC_DEFINE(JPEG_SUPPORT,1,[Support JPEG compression (requires IJG JPEG library)])
626  LIBS="-ljpeg $LIBS"
627  tiff_libs_private="-ljpeg ${tiff_libs_private}"
628
629  if test "$HAVE_RPATH" = "yes" -a "x$with_jpeg_lib_dir" != "x" ; then
630    LIBDIR="-R $with_jpeg_lib_dir $LIBDIR"
631  fi
632
633fi
634
635dnl ---------------------------------------------------------------------------
636dnl Check for Old JPEG.
637dnl ---------------------------------------------------------------------------
638
639AC_ARG_ENABLE(old-jpeg,
640	      AS_HELP_STRING([--disable-old-jpeg],
641			     [disable support for Old JPEG compresson (read-only, enabled by default)]),
642	      [HAVE_OJPEG=${enableval}], [HAVE_OJPEG=yes])
643
644if test "$HAVE_JPEG" = "yes" -a "$HAVE_OJPEG" = "yes" ; then
645  AC_DEFINE(OJPEG_SUPPORT, 1,
646	    [Support Old JPEG compresson (read-only)])
647else
648  HAVE_OJPEG=no
649fi
650
651dnl ---------------------------------------------------------------------------
652dnl Check for JBIG-KIT.
653dnl ---------------------------------------------------------------------------
654
655HAVE_JBIG=no
656
657AC_ARG_ENABLE(jbig,
658	      AS_HELP_STRING([--disable-jbig],
659			     [disable JBIG-KIT usage (required for ISO JBIG compression, enabled by default)]),,)
660AC_ARG_WITH(jbig-include-dir,
661	    AS_HELP_STRING([--with-jbig-include-dir=DIR],
662			   [location of JBIG-KIT headers]),,)
663AC_ARG_WITH(jbig-lib-dir,
664	    AS_HELP_STRING([--with-jbig-lib-dir=DIR],
665			   [location of JBIG-KIT library binary]),,)
666
667if test "x$enable_jbig" != "xno" ; then
668
669  if test "x$with_jbig_lib_dir" != "x" ; then
670    LDFLAGS="-L$with_jbig_lib_dir $LDFLAGS"
671
672  fi
673
674  AC_CHECK_LIB(jbig, jbg_dec_init, [jbig_lib=yes], [jbig_lib=no],)
675  if test "$jbig_lib" = "no" -a "x$with_jbig_lib_dir" != "x" ; then
676    AC_MSG_ERROR([JBIG-KIT library not found at $with_jbig_lib_dir])
677  fi
678
679  if test "x$with_jbig_include_dir" != "x" ; then
680    CPPFLAGS="-I$with_jbig_include_dir $CPPFLAGS"
681  fi
682  AC_CHECK_HEADER(jbig.h, [jbig_h=yes], [jbig_h=no])
683  if test "$jbig_h" = "no" -a "x$with_jbig_include_dir" != "x" ; then
684    AC_MSG_ERROR([JBIG-KIT library headers not found at $with_jbig_include_dir])
685  fi
686
687  if test "$jbig_lib" = "yes" -a "$jbig_h" = "yes" ; then
688    HAVE_JBIG=yes
689  fi
690
691fi
692
693if test "$HAVE_JBIG" = "yes" ; then
694  AC_DEFINE(JBIG_SUPPORT,1,[Support ISO JBIG compression (requires JBIG-KIT library)])
695  LIBS="-ljbig $LIBS"
696  tiff_libs_private="-ljbig ${tiff_libs_private}"
697
698  if test "$HAVE_RPATH" = "yes" -a "x$with_jbig_lib_dir" != "x" ; then
699    LIBDIR="-R $with_jbig_lib_dir $LIBDIR"
700  fi
701
702  # Older versions of jbigkit lack jbg_newlen
703  AC_CHECK_FUNCS([jbg_newlen])
704
705fi
706
707dnl ---------------------------------------------------------------------------
708dnl Check for liblzma2.
709dnl ---------------------------------------------------------------------------
710
711HAVE_LZMA=no
712
713AC_ARG_ENABLE(lzma,
714	      AS_HELP_STRING([--disable-lzma],
715			     [disable liblzma usage (required for LZMA2 compression, enabled by default)]),,)
716AC_ARG_WITH(lzma-include-dir,
717	    AS_HELP_STRING([--with-lzma-include-dir=DIR],
718			   [location of liblzma headers]),,)
719AC_ARG_WITH(lzma-lib-dir,
720	    AS_HELP_STRING([--with-lzma-lib-dir=DIR],
721			   [location of liblzma library binary]),,)
722
723if test "x$enable_lzma" != "xno" ; then
724
725  if test "x$with_lzma_lib_dir" != "x" ; then
726    LDFLAGS="-L$with_lzma_lib_dir $LDFLAGS"
727  fi
728
729  AC_CHECK_LIB(lzma, lzma_code, [lzma_lib=yes], [lzma_lib=no],)
730  if test "$lzma_lib" = "no" -a "x$with_lzma_lib_dir" != "x"; then
731    AC_MSG_ERROR([lzma library not found at $with_lzma_lib_dir])
732  fi
733
734  if test "x$with_lzma_include_dir" != "x" ; then
735    CPPFLAGS="-I$with_lzma_include_dir $CPPFLAGS"
736  fi
737  AC_CHECK_HEADER(lzma.h, [lzma_h=yes], [lzma_h=no])
738  if test "$lzma_h" = "no" -a "x$with_lzma_include_dir" != "x" ; then
739    AC_MSG_ERROR([Liblzma headers not found at $with_lzma_include_dir])
740  fi
741
742  if test "$lzma_lib" = "yes" -a "$lzma_h" = "yes" ; then
743    HAVE_LZMA=yes
744  fi
745
746fi
747
748if test "$HAVE_LZMA" = "yes" ; then
749  AC_DEFINE(LZMA_SUPPORT,1,[Support LZMA2 compression])
750  LIBS="-llzma $LIBS"
751  tiff_libs_private="-llzma ${tiff_libs_private}"
752
753  if test "$HAVE_RPATH" = "yes" -a "x$with_lzma_lib_dir" != "x" ; then
754    LIBDIR="-R $with_lzma_lib_dir $LIBDIR"
755  fi
756
757fi
758
759dnl ---------------------------------------------------------------------------
760dnl Should 8/12 bit jpeg mode be enabled?
761dnl ---------------------------------------------------------------------------
762
763HAVE_JPEG12=no
764
765AC_ARG_ENABLE(jpeg12,
766	      AS_HELP_STRING([--enable-jpeg12],
767			     [enable libjpeg 8/12bit dual mode]),,)
768AC_ARG_WITH(jpeg12-include-dir,
769	    AS_HELP_STRING([--with-jpeg12-include-dir=DIR],
770			   [location of libjpeg 12bit headers]),,)
771AC_ARG_WITH(jpeg12-lib,
772	    AS_HELP_STRING([--with-jpeg12-lib=LIBRARY],
773			   [path to libjpeg 12bit library]),,)
774
775if test "x$enable_jpeg12" = "xyes" ; then
776
777  if test "x$with_jpeg12_lib" != "x" ; then
778    LIBS="$with_jpeg12_lib $LIBS"
779  fi
780
781  HAVE_JPEG12=yes
782
783  AC_DEFINE(JPEG_DUAL_MODE_8_12,1,[8/12 bit libjpeg dual mode enabled])
784  if test "x$with_jpeg12_include_dir" != "x" ; then
785    AC_DEFINE_UNQUOTED(LIBJPEG_12_PATH,"$with_jpeg12_include_dir/jpeglib.h",[12bit libjpeg primary include file with path])
786  fi
787fi
788
789
790dnl ---------------------------------------------------------------------------
791dnl Check for C++.
792dnl ---------------------------------------------------------------------------
793
794AC_ARG_ENABLE(cxx,
795	      AS_HELP_STRING([--enable-cxx],
796			     [enable C++ stream API building (requires C++ compiler)]),
797	      [HAVE_CXX=$enableval], [HAVE_CXX=yes])
798
799if test "$HAVE_CXX" = "yes" ; then
800  AC_DEFINE(CXX_SUPPORT, 1, [Support C++ stream API (requires C++ compiler)])
801else
802  HAVE_CXX=no
803fi
804
805AM_CONDITIONAL(HAVE_CXX, test "$HAVE_CXX" = "yes")
806
807dnl ---------------------------------------------------------------------------
808dnl Check for OpenGL and GLUT.
809dnl ---------------------------------------------------------------------------
810
811HAVE_OPENGL=no
812
813
814AC_PATH_XTRA
815
816dnl AX_CHECK_GL sets GL_CFLAGS & GL_LIBS.  Also PTHREAD_LIBS,
817dnl PTHREAD_CFLAGS, & PTHREAD_CC as a side-effect
818AX_CHECK_GL
819
820dnl AX_CHECK_GLU sets GLU_CFLAGS & GLU_LIBS
821AX_CHECK_GLU
822
823dnl AX_CHECK_GLUT sets GLUT_CFLAGS & GLUT_LIBS
824AX_CHECK_GLUT
825
826if test "$no_x" != "yes" -a "$no_gl" != "yes" \
827	-a "$no_glu" != "yes" -a "$no_glut" != "yes" ; then
828  HAVE_OPENGL=yes
829fi
830
831AM_CONDITIONAL(HAVE_OPENGL, test "$HAVE_OPENGL" = "yes")
832
833dnl ---------------------------------------------------------------------------
834dnl Check for Win32 IO: make sure we have windows.h but not cygwin
835dnl this must be after the ogl test, since that looks for windows.h and we
836dnl test it
837dnl ---------------------------------------------------------------------------
838
839win32_io_ok=no
840case "${host_os}" in
841    cygwin*)
842        ;;
843    *)
844        if test x"$ac_cv_header_windows_h" = xyes; then
845            win32_io_ok=yes
846	    AC_DEFINE(USE_WIN32_FILEIO,1,[define to use win32 IO system])
847	fi
848        ;;
849esac
850AM_CONDITIONAL([WIN32_IO], [test "$win32_io_ok" = yes])
851
852dnl ---------------------------------------------------------------------------
853dnl Check for X Athena Widgets
854dnl ---------------------------------------------------------------------------
855
856dnl HAVE_XAW=no
857
858dnl ICE_FIND_ATHENA
859
860dnl if test "$no_xaw" != "yes" ; then
861dnl   HAVE_XAW=yes
862dnl fi
863
864dnl AM_CONDITIONAL(HAVE_XAW, test "$HAVE_XAW" = "yes")
865
866dnl ===========================================================================
867dnl ``Orthogonal Features''
868dnl ===========================================================================
869
870dnl ---------------------------------------------------------------------------
871dnl Default handling of strip chopping support.
872dnl ---------------------------------------------------------------------------
873
874AC_ARG_ENABLE(strip-chopping,
875	      AS_HELP_STRING([--disable-strip-chopping],
876			     [disable support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]),
877	      [HAVE_STRIPCHOP=$enableval], [HAVE_STRIPCHOP=yes])
878AC_ARG_WITH(default-strip-size,
879	    AS_HELP_STRING([--with-default-strip-size=SIZE],
880			   [default size of the strip in bytes (when strip chopping enabled) [[default=8192]]]),,)
881
882if test "$HAVE_STRIPCHOP" = "yes" \
883	-a "x$with_default_strip_size" != "xno"; then
884  AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)])
885
886  if test "x$with_default_strip_size" = "x" \
887	  -o "x$with_default_strip_size" = "xyes"; then
888    with_default_strip_size="8192"
889  fi
890
891  AC_DEFINE_UNQUOTED(STRIP_SIZE_DEFAULT,$with_default_strip_size,[Default size of the strip in bytes (when strip chopping enabled)])
892
893fi
894
895dnl ---------------------------------------------------------------------------
896dnl Should we try to defer loading of strip/tile offsets and sizes to
897dnl optimize directory scanning?  These is an experimental feature for
898dnl libtiff 4.0.
899dnl ---------------------------------------------------------------------------
900
901AC_ARG_ENABLE(defer-strile-load,
902	      AS_HELP_STRING([--enable-defer-strile-load],
903			     [enable deferred strip/tile offset/size loading (experimental)]),
904	      [HAVE_DEFER_STRILE_LOAD=$enableval], [HAVE_DEFER_STRILE_LOAD=no])
905
906if test "$HAVE_DEFER_STRILE_LOAD" = "yes" ; then
907  AC_DEFINE(DEFER_STRILE_LOAD,1,[enable deferred strip/tile offset/size loading (experimental)])
908
909fi
910
911dnl ---------------------------------------------------------------------------
912dnl Check for support of CHUNKY_STRIP_READ_SUPPORT, a mechanism to allowing
913dnl reading large strips (usually one strip files) in chunks when using
914dnl TIFFReadScanline().  This is an experimental feature in libtiff 4.0.
915dnl ---------------------------------------------------------------------------
916
917AC_ARG_ENABLE(chunky-strip-read,
918	      AS_HELP_STRING([--enable-chunky-strip-read],
919			     [enable reading large strips in chunks for TIFFReadScanline() (experimental)]),
920	      [HAVE_CHUNKY_STRIP_READ=$enableval], [HAVE_CHUNKY_STRIP_READ=no])
921
922if test "$HAVE_CHUNKY_STRIP_READ" = "yes" ; then
923  AC_DEFINE(CHUNKY_STRIP_READ_SUPPORT,1,[enable partial strip reading for large strips (experimental)])
924
925fi
926
927dnl ---------------------------------------------------------------------------
928dnl Default subifd support.
929dnl ---------------------------------------------------------------------------
930AC_DEFINE(SUBIFD_SUPPORT,1,[Enable SubIFD tag (330) support])
931
932dnl ---------------------------------------------------------------------------
933dnl Default handling of ASSOCALPHA support.
934dnl ---------------------------------------------------------------------------
935
936AC_ARG_ENABLE(extrasample-as-alpha,
937	      AS_HELP_STRING([--disable-extrasample-as-alpha],
938			     [the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly]),
939	      [HAVE_EXTRASAMPLE_AS_ALPHA=$enableval],
940	      [HAVE_EXTRASAMPLE_AS_ALPHA=yes])
941
942if test "$HAVE_EXTRASAMPLE_AS_ALPHA" = "yes" ; then
943  AC_DEFINE(DEFAULT_EXTRASAMPLE_AS_ALPHA, 1,
944	    [Treat extra sample as alpha (default enabled). The RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly.])
945fi
946
947dnl ---------------------------------------------------------------------------
948dnl Default handling of YCbCr subsampling support.
949dnl See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details.
950dnl ---------------------------------------------------------------------------
951
952AC_ARG_ENABLE(check-ycbcr-subsampling,
953	      AS_HELP_STRING([--disable-check-ycbcr-subsampling],
954			     [disable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag]),
955	      [CHECK_JPEG_YCBCR_SUBSAMPLING=$enableval],
956	      [CHECK_JPEG_YCBCR_SUBSAMPLING=yes])
957
958if test "$CHECK_JPEG_YCBCR_SUBSAMPLING" = "yes" ; then
959  AC_DEFINE(CHECK_JPEG_YCBCR_SUBSAMPLING, 1,
960	    [Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled).])
961fi
962
963dnl ---------------------------------------------------------------------------
964
965AC_SUBST(LIBDIR)
966
967AC_CONFIG_HEADERS([libtiff/tif_config.h libtiff/tiffconf.h])
968
969AC_CONFIG_FILES([Makefile \
970		 build/Makefile \
971		 contrib/Makefile \
972		 contrib/addtiffo/Makefile \
973		 contrib/dbs/Makefile \
974		 contrib/dbs/xtiff/Makefile \
975		 contrib/iptcutil/Makefile \
976		 contrib/mfs/Makefile \
977		 contrib/pds/Makefile \
978		 contrib/ras/Makefile \
979		 contrib/stream/Makefile \
980		 contrib/tags/Makefile \
981		 contrib/win_dib/Makefile \
982                 html/Makefile \
983		 html/images/Makefile \
984		 html/man/Makefile \
985                 libtiff-4.pc \
986                 libtiff/Makefile \
987                 man/Makefile \
988		 port/Makefile \
989		 test/Makefile \
990                 tools/Makefile])
991AC_OUTPUT
992
993dnl ---------------------------------------------------------------------------
994dnl Display configuration status
995dnl ---------------------------------------------------------------------------
996
997LOC_MSG()
998LOC_MSG([Libtiff is now configured for ${host}])
999LOC_MSG()
1000LOC_MSG([  Installation directory:             ${prefix}])
1001LOC_MSG([  Documentation directory:            ${LIBTIFF_DOCDIR}])
1002LOC_MSG([  C compiler:                         ${CC} ${CFLAGS}])
1003LOC_MSG([  C++ compiler:                       ${CXX} ${CXXFLAGS}])
1004LOC_MSG([  Enable runtime linker paths:        ${HAVE_RPATH}])
1005LOC_MSG([  Enable linker symbol versioning:    ${have_ld_version_script}])
1006LOC_MSG([  Support Microsoft Document Imaging: ${HAVE_MDI}])
1007LOC_MSG([  Use win32 IO:                       ${win32_io_ok}])
1008LOC_MSG()
1009LOC_MSG([ Support for internal codecs:])
1010LOC_MSG([  CCITT Group 3 & 4 algorithms:       ${HAVE_CCITT}])
1011LOC_MSG([  Macintosh PackBits algorithm:       ${HAVE_PACKBITS}])
1012LOC_MSG([  LZW algorithm:                      ${HAVE_LZW}])
1013LOC_MSG([  ThunderScan 4-bit RLE algorithm:    ${HAVE_THUNDER}])
1014LOC_MSG([  NeXT 2-bit RLE algorithm:           ${HAVE_NEXT}])
1015LOC_MSG([  LogLuv high dynamic range encoding: ${HAVE_LOGLUV}])
1016LOC_MSG()
1017LOC_MSG([ Support for external codecs:])
1018LOC_MSG([  ZLIB support:                       ${HAVE_ZLIB}])
1019LOC_MSG([  Pixar log-format algorithm:         ${HAVE_PIXARLOG}])
1020LOC_MSG([  JPEG support:                       ${HAVE_JPEG}])
1021LOC_MSG([  Old JPEG support:                   ${HAVE_OJPEG}])
1022LOC_MSG([  JPEG 8/12 bit dual mode:            ${HAVE_JPEG12}])
1023LOC_MSG([  ISO JBIG support:                   ${HAVE_JBIG}])
1024LOC_MSG([  LZMA2 support:                      ${HAVE_LZMA}])
1025LOC_MSG()
1026LOC_MSG([  C++ support:                        ${HAVE_CXX}])
1027LOC_MSG()
1028dnl LOC_MSG([  X Athena Widgets support:           ${HAVE_XAW}])
1029LOC_MSG([  OpenGL support:                     ${HAVE_OPENGL}])
1030LOC_MSG()
1031
1032