root/trunk/gdal/configure.in

Revision 15775, 70.6 kB (checked in by ilucena, 2 days ago)

add georaster

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 dnl ***************************************************************************
2 dnl $Id$
3 dnl
4 dnl Project:  GDAL
5 dnl Purpose:  Configure source file.
6 dnl Author:   Frank Warmerdam, warmerdam@pobox.com
7 dnl
8 dnl ***************************************************************************
9 dnl Copyright (c) 2000, Frank Warmerdam
10 dnl
11 dnl Permission is hereby granted, free of charge, to any person obtaining a
12 dnl copy of this software and associated documentation files (the "Software"),
13 dnl to deal in the Software without restriction, including without limitation
14 dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 dnl and/or sell copies of the Software, and to permit persons to whom the
16 dnl Software is furnished to do so, subject to the following conditions:
17 dnl
18 dnl The above copyright notice and this permission notice shall be included
19 dnl in all copies or substantial portions of the Software.
20 dnl
21 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 dnl DEALINGS IN THE SOFTWARE.
28 dnl ***************************************************************************
29
30 dnl Disable configure caching ... it causes lots of hassles.
31 define([AC_CACHE_LOAD], )
32 define([AC_CACHE_SAVE], )
33
34 dnl Process this file with autoconf to produce a configure script.
35 AC_INIT(GDALmake.opt.in)
36 AC_CONFIG_MACRO_DIR(m4)
37 AC_CONFIG_HEADER(port/cpl_config.h)
38
39 dnl We require autoconf 2.52+ for libtool support on cygwin/mingw hosts
40 AC_PREREQ(2.52)
41
42 dnl Compute the canonical target-system type variable $target
43 AC_CANONICAL_TARGET
44
45 dnl Enable as much warnings as possible
46 AX_CFLAGS_WARN_ALL(C_WFLAGS)
47 AX_CXXFLAGS_WARN_ALL(CXX_WFLAGS)
48 AC_SUBST(CXX_WFLAGS,$CXX_WFLAGS)
49 AC_SUBST(C_WFLAGS,$C_WFLAGS)
50
51 dnl Checks for programs.
52 AC_PROG_CC
53 AC_PROG_CXX
54 AC_LIBTOOL_WIN32_DLL
55 AC_PROG_LIBTOOL
56
57 dnl switch between libtool and native build system
58 AC_ARG_WITH(libtool, [  --without-libtool     Don't use libtool to build the library],,)
59
60 if test "$with_libtool" = "no"; then
61 AC_PROG_RANLIB
62 AC_COMPILER_PIC
63 AC_LD_SHARED
64 else
65 with_libtool=yes
66 fi
67 AC_SUBST(HAVE_LIBTOOL,$with_libtool)
68
69 dnl Checks for libraries.
70 AC_CHECK_LIB(dl,dlopen,,,)
71
72 dnl Needed on Solaris.
73 AC_CHECK_LIB(rt,nanosleep,,,)
74
75 dnl We don't need to add math library to all targets
76 case "${host_os}" in
77     cygwin* | mingw32* | pw32* | beos* | darwin*)
78         ;;
79     *)
80         AC_CHECK_LIB(m,sin,,,)
81         ;;
82 esac
83
84 dnl Checks for header files.
85 AC_HEADER_STDC
86 AC_CHECK_HEADERS(assert.h fcntl.h unistd.h dbmalloc.h dlfcn.h stdint.h limits.h locale.h values.h float.h errno.h direct.h)
87
88 AC_C_BIGENDIAN
89
90 dnl Check for 64 bit file API
91 AC_HAVE_LONG_LONG
92 AC_UNIX_STDIO_64
93
94 AC_CHECK_SIZEOF(int)
95 AC_CHECK_SIZEOF(long)
96 AC_CHECK_SIZEOF(unsigned long)
97 AC_CHECK_SIZEOF(void*)
98 dnl Some compilers (IBM VisualAge) has these types defined, so check it here.
99 dnl These types are used in internal libtiff.
100 AC_CHECK_TYPES([int8, int16, int32],,,
101 [
102 #if HAVE_INTTYPES_H
103 # include <inttypes.h>
104 #endif
105 ])
106
107 dnl We need the following lines for libtiff too.
108 HAVE_IEEEFP=1
109 AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine])
110
111 dnl Check the native cpu bit order (also libtiff stuff).
112 AC_MSG_CHECKING([native cpu bit order])
113 case "$target_cpu" in
114     i*86*)
115         HOST_FILLORDER=FILLORDER_LSB2MSB
116         AC_MSG_RESULT([lsb2msb])
117         ;;
118     *)
119         HOST_FILLORDER=FILLORDER_MSB2LSB
120         AC_MSG_RESULT([msb2lsb])
121         ;;
122 esac
123 AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
124
125 dnl Checks for library functions.
126 AC_FUNC_VPRINTF
127 AC_CHECK_FUNCS(snprintf vsnprintf)
128 AC_CHECK_FUNCS(atoll)
129 AC_CHECK_FUNCS(strtof)
130 AC_CHECK_FUNCS(getcwd)
131
132 dnl Check for declarations
133 AC_CHECK_DECLS(strtof)
134
135 dnl Make sure at least these are checked under C++.  Prototypes missing on
136 dnl some platforms.
137
138 AC_LANG_PUSH(C++)
139 AC_CHECK_FUNC_CUSTOM(gmtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); gmtime_r( &t, &ltime );])
140 AC_CHECK_FUNC_CUSTOM(localtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); localtime_r( &t, &ltime );])
141 AC_LANG_POP(C++)
142
143 AC_CHECK_FUNC(setlocale)
144
145 OPT_GDAL_FORMATS=
146 EXTRA_INCLUDES=
147
148 dnl ---------------------------------------------------------------------------
149 dnl Check for --enable-debug
150 dnl ---------------------------------------------------------------------------
151
152 AC_MSG_CHECKING([to enable debug build])
153
154 AC_ARG_ENABLE(debug,
155               AS_HELP_STRING([--enable-debug],
156                              [enable debugging (disabled by default)]),
157               [HAVE_DEBUG=$enableval], [HAVE_DEBUG=yes])
158
159 if test "x$enable_debug" = "xyes" ; then
160
161   dnl Try to strip out optimization.
162
163   CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-O2 //"`
164   CFLAGS=`echo "$CFLAGS " | sed "s/-O2 //"`
165   CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-O //"`
166   CFLAGS=`echo "$CFLAGS" | sed "s/-O //"`
167
168   dnl remove existing -g to avoid duplicates.
169
170   CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-g //"`
171   CFLAGS=`echo "$CFLAGS" | sed "s/-g //"`
172
173   dnl add -g and -DDEBUG
174
175   CXXFLAGS="$CXXFLAGS -g -DDEBUG"
176   CFLAGS="$CFLAGS -g -DDEBUG"
177
178   AC_MSG_RESULT([yes, modified CFLAGS="$CFLAGS"])
179 else
180   AC_MSG_RESULT([no, CFLAGS="$CFLAGS"])
181 fi
182
183 dnl ---------------------------------------------------------------------------
184 dnl Check if user requests hidding internal symbols
185 dnl ---------------------------------------------------------------------------
186
187 AC_ARG_WITH(with_hide_internal_symbols,[  --with-hide-internal-symbols[=ARG] Try to hide internal symbols (ARG=yes/no)],,)
188
189 HAVE_HIDE_INTERNAL_SYMBOLS=no
190
191 if test "$with_hide_internal_symbols" = "yes"; then
192
193     AC_MSG_CHECKING([whether we should hide internal symbols])
194
195     rm -f hiddensymbols.c
196     echo 'int visible() { return 0; } __attribute__ ((visibility("default")))' >> hiddensymbols.c
197     echo 'int hidden() { return 0; }' >> hiddensymbols.c
198     if test -z "`${CC} -fvisibility=hidden -c hiddensymbols.c 2>&1`" ; then
199       HAVE_HIDE_INTERNAL_SYMBOLS=yes
200     else
201       HAVE_HIDE_INTERNAL_SYMBOLS=no
202     fi
203     if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes"; then
204         AC_MSG_RESULT([yes])
205         CFLAGS="$CFLAGS -fvisibility=hidden"
206         CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
207     else
208         AC_MSG_RESULT([no])
209     fi
210     rm -f hiddensymbols.*
211 else
212   AC_MSG_CHECKING([whether we should hide internal symbols])
213   AC_MSG_RESULT([no])
214 fi
215
216 if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes" ; then
217   AC_DEFINE_UNQUOTED(USE_GCC_VISIBILITY_FLAG,1, [Define to 1 if you want to use the -fvisibility GCC flag])
218 fi
219
220 AC_SUBST(HAVE_HIDE_INTERNAL_SYMBOLS,$HAVE_HIDE_INTERNAL_SYMBOLS)
221
222 dnl ---------------------------------------------------------------------------
223 dnl Check if user requests /usr/local to be included.
224 dnl ---------------------------------------------------------------------------
225
226 AC_MSG_CHECKING([for local include/lib path])
227
228 AC_ARG_WITH(local,[  --with-local[=dir]      Include /usr/local or other local tree for INCLUDE/LIBS],,)
229
230 if test "$with_local" != "no" -a "$with_local" != "" ; then
231  
232   if test "$with_local" = "yes" ; then
233     ADD_PREFIX=/usr/local
234   else
235     ADD_PREFIX=$with_local
236   fi
237
238   AC_MSG_RESULT(adding $ADD_PREFIX)
239
240   LIBS="$LIBS -L$ADD_PREFIX/lib"
241   CPPFLAGS="$CPPFLAGS -I$ADD_PREFIX/include"
242 else
243   AC_MSG_RESULT([none])
244 fi
245
246 dnl ---------------------------------------------------------------------
247 dnl ENABLE THREADS ONLY IF REQUESTED.
248 dnl ---------------------------------------------------------------------
249
250 THREAD_LIB=""
251 THREAD_FLAG=""
252 PTHREAD_ENABLED="no"
253
254 AC_ARG_WITH(threads,
255 [  --with-threads[=linkopt]Include thread safe support],,)
256
257 if test "$with_threads" = "yes" ; then
258
259   AC_CHECK_LIB(pthread,pthread_create,THREAD_FLAG=CPL_MULTIPROC_PTHREAD,,,)
260
261   if test -n "$THREAD_FLAG" ; then
262       THREAD_LIB="-lpthread"
263   fi
264   PTHREAD_ENABLED="yes"
265
266 elif test -n "$with_threads" -a "$with_threads" != "no" ; then
267
268   THREAD_FLAG=CPL_MULTIPROC_PTHREAD
269   THREAD_LIB="$with_threads" 
270
271   AC_CHECKING(whether we should include thread/mutex support...)
272   AC_MSG_RESULT([        using threads with link options "$THREAD_LIB".])
273
274   PTHREAD_ENABLED="yes"
275
276 else
277   AC_CHECKING(whether we should include thread/mutex support...)
278   AC_MSG_RESULT([        thread safe support disabled.])
279 fi
280
281 if test "$THREAD_FLAG" = "CPL_MULTIPROC_PTHREAD" ; then
282   AC_DEFINE_UNQUOTED(CPL_MULTIPROC_PTHREAD,1, [Define if you want to use pthreads based multiprocessing support])
283 fi
284
285 LIBS="$THREAD_LIB $LIBS"
286
287 dnl ---------------------------------------------------------------------------
288 dnl Check if libz is available.
289 dnl ---------------------------------------------------------------------------
290
291 AC_ARG_WITH(libz,[  --with-libz[=ARG]       Include libz support (ARG=internal or libz directory)],,)
292
293 if test "$with_libz" = "external" -o "$with_libz" = "" -o "$with_libz" = "yes" ; then
294
295   AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,)
296
297   if test "$LIBZ_SETTING" = "external" ; then
298     AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,)
299     if test "$LIBZ_SETTING" = "external" ; then
300         AC_MSG_RESULT([using pre-installed libz])
301     else
302         AC_MSG_RESULT([using internal libz code as inflateCopy is missing])
303     fi
304   else
305     AC_MSG_RESULT([using internal libz code as deflateInit_ is missing])
306   fi
307
308 elif test "$with_libz" != "no" -a "$with_libz" != "internal" ; then
309
310   LIBS="-L$with_libz -L$with_libz/lib $LIBS"
311
312   AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
313   if test "$LIBZ_SETTING" = "external" ; then
314     AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
315      if test "$LIBZ_SETTING" = "external" ; then
316         AC_MSG_RESULT([using libz library from $with_libz])
317     else
318         AC_MSG_RESULT([using internal libz code as inflateCopy from $with_libz is missing])
319     fi
320   else
321     AC_MSG_RESULT([using internal libz code as deflateInit_ from $with_libz is missing])
322   fi
323
324 fi
325
326 if test "$LIBZ_SETTING" = "external" ; then
327   LIBS="-lz $LIBS"
328 elif test "$with_libz" = "no" ; then
329   LIBZ_SETTING=no
330   AC_MSG_RESULT([not using libz at all.])
331 else
332   LIBZ_SETTING=internal
333   OPT_GDAL_FORMATS="zlib $OPT_GDAL_FORMATS"
334   AC_MSG_RESULT([using internal libz code.])
335 fi
336
337 AC_SUBST(LIBZ_SETTING,$LIBZ_SETTING)
338
339 dnl ---------------------------------------------------------------------------
340 dnl Select an PostgreSQL Library to use, or disable driver.
341 dnl ---------------------------------------------------------------------------
342
343 PG_CONFIG=no
344
345 AC_ARG_WITH(pg,
346             AS_HELP_STRING([--with-pg[=ARG]],
347                [Include PostgreSQL OGR Support (ARG=path to pg_config)]),,)
348
349 if test "x$with_pg" = "xyes" -o "x$with_pg" = "x" ; then
350   AC_PATH_PROG(PG_CONFIG, pg_config, no)
351 else
352   PG_CONFIG=$with_pg
353 fi
354
355 AC_MSG_CHECKING([for PostgreSQL])
356
357 if test "x$PG_CONFIG" = "xno" ; then
358
359   HAVE_PG=no
360   PG_LIB=
361   PG_INC=
362
363   AC_MSG_RESULT([no])
364
365 else
366   if test -d ${PG_CONFIG} ; then
367       AC_MSG_RESULT([no])
368       AC_MSG_ERROR([--with-pg argument is a directory.  It should be the path to the pg_config script, often somewhere like /usr/local/pgsql/bin/pg_config.])
369   fi
370
371   if test \! -x ${PG_CONFIG} ; then
372       AC_MSG_RESULT([no])
373       AC_MSG_ERROR([--with-pg argument is a not an executable file.  It should be the path to the pg_config script, often somewhere like /usr/local/pgsql/bin/pg_config.])
374   fi
375
376   AC_MSG_RESULT([yes])
377
378   ax_save_LIBS="${LIBS}"
379   LIBS=-L`$PG_CONFIG --libdir`" -lpq"
380   AC_CHECK_LIB(pq,PQconnectdb,HAVE_PG=yes,HAVE_PG=no,)
381   LIBS="${ax_save_LIBS}"
382  
383   if test "${HAVE_PG}" = "yes" ; then
384     LIBS=-L`$PG_CONFIG --libdir`" -lpq $LIBS"
385     PG_INC=-I`$PG_CONFIG --includedir`" -I"`$PG_CONFIG --includedir-server`
386
387     PG_EXTRA_DEC=""
388     AC_CHECK_LIB(pq,PQputCopyData,,DEFINE_PG_PRE74=-DPG_PRE74,)
389     if test "$DEFINE_PG_PRE74" != "" ; then
390       echo "The PostgreSQL client version is before 7.4. You will not be able to use binary cursors."
391     fi
392
393     AC_CHECK_LIB(pq,PQescapeStringConn,DEFINE_PG_HAS_PQESCAPESTRINGCONN=-DPG_HAS_PQESCAPESTRINGCONN,,)
394     if test "$DEFINE_PG_HAS_PQESCAPESTRINGCONN" = "" ; then
395       echo "falling back to using PQescapeString. You should upgrade at least to security releases 8.1.4, 8.0.8, 7.4.13, 7.3.15."
396     fi
397
398     PG_INC="${PG_INC} ${DEFINE_PG_PRE74} ${DEFINE_PG_HAS_PQESCAPESTRINGCONN}"
399   fi
400
401 fi
402
403 AC_SUBST(HAVE_PG,$HAVE_PG)
404 AC_SUBST(PG_INC,$PG_INC)
405 AC_SUBST(PG_LIB,$PG_LIB)
406
407 dnl ---------------------------------------------------------------------------
408 dnl Check if we should build with GRASS support.
409 dnl ---------------------------------------------------------------------------
410
411 GRASS_SETTING=no
412 GRASS_INCLUDE=
413 HAVE_GRASS=no
414 export GRASS_INCLUDE GRASS_SETTING
415
416 AC_ARG_WITH(grass,[  --with-grass[=ARG]      Include GRASS support (GRASS 5.7+, ARG=GRASS install tree dir)],,)
417
418 AC_ARG_WITH(libgrass,[  --with-libgrass[=ARG]   Include GRASS support based on libgrass (GRASS 5.0+)],,)
419
420 # default use of grass libraries off since we can't easily auto-find them.
421 if test "$with_grass" = "" ; then
422   with_grass=no
423 fi
424
425 # Check for GRASS 5.7.0 or later library use.
426 # TODO: separate libs for rasters and vectors
427 if test "$with_grass" != "yes" -a "$with_grass" != "no" ; then
428
429   AC_CHECK_LIB(grass_gis,G_asprintf,GRASS_SETTING=grass57+,GRASS_SETTING=no,-L$with_grass/lib -lgrass_datetime)
430    
431   if test "$GRASS_SETTING" = "grass57+" ; then   
432     G_RASTLIBS="-lgrass_I"
433     G_VECTLIBS="-lgrass_vect -lgrass_dig2 -lgrass_dgl -lgrass_rtree -lgrass_linkm -lgrass_dbmiclient -lgrass_dbmibase"
434     LIBS="-L$with_grass/lib $G_VECTLIBS $G_RASTLIBS -lgrass_gproj -lgrass_vask -lgrass_gmath -lgrass_gis -lgrass_datetime $LIBS"
435     GRASS_INCLUDE="-I$with_grass/include"
436     GRASS_GISBASE="$with_grass"
437     HAVE_GRASS=yes
438   else
439     AC_MSG_ERROR([--with-grass=$with_grass requested, but libraries not found!])
440   fi
441
442 # Check if libgrass is disabled.
443 elif test "$with_libgrass" = "no" ; then
444
445   echo "GRASS support disabled."
446
447 elif test "$with_libgrass" = "yes" -o "$with_libgrass" = "" ; then
448
449   AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,)
450
451   if test "$GRASS_SETTING" = "libgrass" ; then   
452     LIBS="-lgrass5 $LIBS"
453   fi
454
455 else
456
457   AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,-L$with_libgrass/lib)
458
459   if test "$GRASS_SETTING" = "libgrass" ; then   
460     LIBS="-L$with_libgrass -L$with_libgrass/lib -lgrass5 $LIBS"
461     GRASS_INCLUDE="-I$with_libgrass -I$with_libgrass/include $EXTRA_INCLUDES"
462   else
463     AC_MSG_ERROR([--with-libgrass=$with_grass requested, but libgrass5 not found!])
464   fi
465 fi
466
467 AC_SUBST(GRASS_SETTING,$GRASS_SETTING)
468 AC_SUBST(GRASS_INCLUDE,$GRASS_INCLUDE)
469 AC_SUBST(GRASS_GISBASE,$GRASS_GISBASE)
470 AC_SUBST(HAVE_GRASS)
471
472 if test "$GRASS_SETTING" != "no" ; then
473   OPT_GDAL_FORMATS="grass $OPT_GDAL_FORMATS"
474 fi
475
476 dnl ---------------------------------------------------------------------------
477 dnl Check if cfitsio library is available.
478 dnl ---------------------------------------------------------------------------
479
480 AC_ARG_WITH(cfitsio,[  --with-cfitsio[=ARG]    Include FITS support (ARG=no or libcfitsio path)],,)
481
482 if test "$with_cfitsio" = "no" ; then
483
484   FITS_SETTING=no
485
486   echo "FITS support disabled."
487
488 elif test "$with_cfitsio" = "yes" -o "$with_cfitsio" = "" ; then
489
490   AC_CHECK_LIB(cfitsio,ffopen,FITS_SETTING=external,FITS_SETTING=no,)
491
492   if test "$FITS_SETTING" = "external" ; then   
493     LIBS="-lcfitsio $LIBS"
494     echo "using pre-installed libcfitsio."
495   else
496     echo "libcfitsio not found - FITS support disabled"
497   fi
498
499 else
500
501   FITS_SETTING=external
502   LIBS="-L$with_cfitsio -L$with_cfitsio/lib -lcfitsio $LIBS"
503   EXTRA_INCLUDES="-I$with_cfitsio -I$with_cfitsio/include $EXTRA_INCLUDES"
504
505   echo "using libcfitsio from $with_cfitsio."
506 fi
507
508 AC_SUBST(FITS_SETTING,$FITS_SETTING)
509
510 if test "$FITS_SETTING" != "no" ; then
511   OPT_GDAL_FORMATS="fits $OPT_GDAL_FORMATS"
512 fi
513
514 dnl ---------------------------------------------------------------------------
515 dnl Check if PCRaster (libcsf) library is available.
516 dnl ---------------------------------------------------------------------------
517
518 AC_ARG_WITH(pcraster,[  --with-pcraster[=ARG]   Include PCRaster (libcsf) support (ARG=internal, no or path)],,)
519
520 if test "$with_pcraster" = "no" ; then
521
522   PCRASTER_SETTING=no
523
524   echo "PCRaster support disabled."
525
526 elif test "$with_pcraster" = "yes" -o "$with_pcraster" = "" ; then
527
528   AC_CHECK_LIB(csf,Mopen,PCRASTER_SETTING=external,PCRASTER_SETTING=internal,$LIBS)
529   AC_CHECK_HEADERS(csf.h)
530
531   if test "$PCRASTER_SETTING" = "external" -a "$ac_cv_header_csf_h" = "no" ; then
532     PCRASTER_SETTING=internal
533   fi
534
535   if test "$PCRASTER_SETTING" = "external" ; then
536     LIBS="-lcsf $LIBS"
537     echo "using pre-installed libcsf."
538   else
539     echo "using internal csf code."
540   fi
541
542 elif test "$with_pcraster" = "internal" ; then
543
544   PCRASTER_SETTING=internal
545
546   echo "using internal csf code."
547
548 else
549
550   PCRASTER_SETTING=external
551   LIBS="-L$with_pcraster/lib -lcsf $LIBS"
552   EXTRA_INCLUDES="-I$with_pcraster/include $EXTRA_INCLUDES"
553
554   echo "using libcsf from $with_pcraster."
555
556 fi
557
558 AC_SUBST(PCRASTER_SETTING,$PCRASTER_SETTING)
559
560 if test "$PCRASTER_SETTING" != "no" ; then
561   OPT_GDAL_FORMATS="pcraster $OPT_GDAL_FORMATS"
562 fi
563
564 dnl ---------------------------------------------------------------------------
565 dnl Check if netcdf library is available.
566 dnl ---------------------------------------------------------------------------
567
568 AC_ARG_WITH([netcdf],[  --with-netcdf[=ARG]     Include netCDF support (ARG=no or netCDF tree prefix)],,)
569
570 if test "$with_netcdf" = "no" ; then
571
572   NETCDF_SETTING=no
573
574   echo "netCDF support disabled."
575
576 elif test "$with_netcdf" = "yes" -o "$with_netcdf" = "" ; then
577
578   AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no],)
579
580   if test "$NETCDF_SETTING" = "yes" ; then   
581     LIBS="-lnetcdf $LIBS"
582     echo "using pre-installed libnetcdf."
583   else
584     echo "libnetcdf not found - netCDF support disabled"
585   fi
586
587 else
588
589   NETCDF_SETTING=yes
590   LIBS="-L$with_netcdf -L$with_netcdf/lib -lnetcdf $LIBS"
591   EXTRA_INCLUDES="-I$with_netcdf -I$with_netcdf/include $EXTRA_INCLUDES"
592
593   echo "using libnetcdf from $with_netcdf."
594 fi
595
596 AC_SUBST([NETCDF_SETTING], [$NETCDF_SETTING])
597
598 if test "$NETCDF_SETTING" != "no" ; then
599   OPT_GDAL_FORMATS="netcdf $OPT_GDAL_FORMATS"
600 fi
601
602 dnl ---------------------------------------------------------------------------
603 dnl Select a PNG Library to use, or disable driver.
604 dnl ---------------------------------------------------------------------------
605
606 AC_ARG_WITH([png], [  --with-png[=ARG]        Include PNG support (ARG=internal, no or path)],,)
607
608 if test "$with_png" = "no" ; then
609
610   PNG_SETTING=no
611
612   echo "png support disabled."
613
614 elif test "$with_png" = "yes" -o "$with_png" = "" ; then
615
616   AC_CHECK_LIB([png], [png_set_IHDR], [PNG_SETTING=external], [PNG_SETTING=internal], [$LIBS])
617   AC_CHECK_HEADERS([png.h])
618
619   if test "$PNG_SETTING" = "external" -a "$ac_cv_header_png_h" = "no" ; then   
620     PNG_SETTING=internal
621   fi
622   if test "$PNG_SETTING" = "external" ; then   
623     LIBS="-lpng $LIBS"
624     echo "using pre-installed libpng."
625   else
626     echo "using internal png code."
627   fi
628
629 elif test "$with_png" = "internal" ; then
630
631   PNG_SETTING=internal
632
633   echo "using internal png code."
634
635 else
636
637   PNG_SETTING=external
638   LIBS="-L$with_png -L$with_png/lib -lpng $LIBS"
639   EXTRA_INCLUDES="-I$with_png -I$with_png/include $EXTRA_INCLUDES"
640
641   echo "using libpng from $with_png."
642
643 fi
644
645 AC_SUBST([PNG_SETTING], [$PNG_SETTING])
646
647 if test "$PNG_SETTING" != "no" ; then
648   OPT_GDAL_FORMATS="png $OPT_GDAL_FORMATS"
649 fi
650
651 dnl ---------------------------------------------------------------------------
652 dnl Select a libtiff library to use.
653 dnl ---------------------------------------------------------------------------
654
655 AC_ARG_WITH(libtiff,[  --with-libtiff=ARG    Libtiff library to use (ARG=internal, yes or path)],,)
656
657 if test "$with_libtiff" = "yes" -o "$with_libtiff" = "" ; then
658
659   dnl We now effectively require libtiff 3.6.0.
660   AC_CHECK_LIB(tiff,TIFFGetTagListCount,TIFF_SETTING=external,TIFF_SETTING=internal,)
661
662   dnl Cygwin takes a somewhat restrictive view of what should be exported
663   dnl from the dll, so don't use the external library if missing semi-private
664   dnl functions.
665   if test "$TIFF_SETTING" = "external" ; then
666     AC_CHECK_LIB(tiff,_TIFFsetDoubleArray,TIFF_SETTING=external,TIFF_SETTING=internal,)
667     dnl Check for the BigTIFF enabled library (libtiff >= 4.0)
668     AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,)
669   else
670     HAVE_BIGTIFF=yes
671   fi
672
673   if test "$TIFF_SETTING" = "external" ; then   
674     LIBS="-ltiff $LIBS"
675     echo "using pre-installed libtiff."
676   else
677     echo "using internal TIFF code."
678   fi
679
680 elif test "$with_libtiff" = "internal" ; then
681
682   TIFF_SETTING=internal
683   HAVE_BIGTIFF=yes
684
685   echo "using internal TIFF code."
686
687 else
688
689   TIFF_SETTING=external
690   if test -r $with_libtiff/tiff.h ; then
691     LIBS="-L$with_libtiff -ltiff $LIBS"
692     EXTRA_INCLUDES="-I$with_libtiff $EXTRA_INCLUDES"
693   else
694     LIBS="-L$with_libtiff/lib -ltiff $LIBS"
695     EXTRA_INCLUDES="-I$with_libtiff/include $EXTRA_INCLUDES"
696   fi
697
698   echo "using libtiff from $with_libtiff."
699
700   dnl Check for the BigTIFF enabled library (libtiff >= 4.0)
701   AC_CHECK_LIB(tiff,TIFFScanlineSize64,HAVE_BIGTIFF=yes,HAVE_BIGTIFF=no,)
702
703 fi
704
705 if test "${HAVE_BIGTIFF}" = "yes" ; then
706   TIFF_OPTS="-DBIGTIFF_SUPPORT"
707
708   echo "BigTIFF support enabled."
709 fi
710
711 AC_SUBST(TIFF_SETTING,${TIFF_SETTING})
712 AC_SUBST(TIFF_OPTS,${TIFF_OPTS})
713
714 dnl ---------------------------------------------------------------------------
715 dnl Select a libgeotiff library to use.
716 dnl ---------------------------------------------------------------------------
717
718 GEOTIFF_INCLUDE=
719 AC_ARG_WITH(geotiff,[  --with-geotiff=ARG    Libgeotiff library to use (ARG=internal, yes or path)],,)
720
721 if test "$with_geotiff" = "yes" -o "$with_geotiff" = "" ; then
722
723   if test "$TIFF_SETTING" = "internal" ; then
724     GEOTIFF_SETTING=internal
725   else
726     dnl We now require libgeotiff 1.2.1 (for XTIFFClientOpen).
727     AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,GEOTIFF_SETTING=internal)
728
729   fi
730
731   if test "$GEOTIFF_SETTING" = "external" ; then   
732
733     dnl Now search for headers
734     if test -r /usr/include/geotiff.h ; then
735       GEOTIFF_INCLUDE=
736     elif test -r /usr/include/geotiff/geotiff.h ; then
737       GEOTIFF_INCLUDE="-I/usr/include/geotiff"
738     fi
739
740     LIBS="-lgeotiff $LIBS"
741     echo "using pre-installed libgeotiff."
742
743   else
744
745     echo "using internal GeoTIFF code."
746
747   fi
748
749 elif test "$with_geotiff" = "internal" ; then
750
751   GEOTIFF_SETTING=internal
752
753   echo "using internal GeoTIFF code."
754
755 else
756
757   GEOTIFF_SETTING=external
758
759   dnl We now require libgeotiff 1.2.1 (for XTIFFClientOpen).
760   dnl first check if $with_geotiff/lib has the library:
761   AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,GEOTIFF_SETTING=not_found,-L$with_geotiff/lib)
762
763   if test $GEOTIFF_SETTING = "external" ; then
764     LIBS="-L$with_geotiff/lib -lgeotiff $LIBS"
765     if test  -d $with_geotiff/include ; then
766       EXTRA_INCLUDES="-I$with_geotiff/include $EXTRA_INCLUDES"
767     fi
768   else
769     dnl check if $with_geotiff itself contains the header and library (e.g. as an uninstalled build directory would)
770     AC_CHECK_LIB(geotiff,XTIFFClientOpen,GEOTIFF_SETTING=external,AC_MSG_ERROR([We require at least GeoTIFF 1.2.1. Consider using the one supplied with GDAL]),-L$with_geotiff)
771     if test $GEOTIFF_SETTING = "external" ; then
772       LIBS="-L$with_geotiff -lgeotiff $LIBS"
773       EXTRA_INCLUDES="-I$with_geotiff $EXTRA_INCLUDES"
774     fi
775   fi
776
777   echo "using libgeotiff from $with_geotiff."
778 fi
779
780 AC_SUBST(GEOTIFF_SETTING,$GEOTIFF_SETTING)
781 AC_SUBST(GEOTIFF_INCLUDE,$GEOTIFF_INCLUDE)
782
783 dnl ---------------------------------------------------------------------------
784 dnl Select a JPEG Library to use, or disable driver.
785 dnl ---------------------------------------------------------------------------
786
787 AC_ARG_WITH(jpeg,[  --with-jpeg[=ARG]       Include JPEG support (ARG=internal, no or path)],,)
788
789 if test "$with_jpeg" = "no" ; then
790
791   JPEG_SETTING=no
792
793   echo "jpeg support disabled."
794
795 elif test "$with_jpeg" = "yes" -o "$with_jpeg" = "" ; then
796
797   AC_CHECK_LIB(jpeg,jpeg_read_scanlines,JPEG_SETTING=external,JPEG_SETTING=internal,)
798   AC_CHECK_HEADERS(jpeglib.h)
799
800   if test "$JPEG_SETTING" = "external" -a "$ac_cv_header_jpeglib_h" = "no" ; then
801     JPEG_SETTING=internal
802   fi
803
804   if test "$JPEG_SETTING" = "external" -a "$TIFF_SETTING" = "internal" ; then
805     AC_MSG_CHECKING([for width_in_blocks in jpeglib.h])
806
807     rm -f conftest.c
808     echo '#include <stdio.h>' >> conftest.c
809     echo '#include "jpeglib.h"' >> conftest.c
810     echo 'int main() { jpeg_component_info *comptr=0; int i; i = comptr->width_in_blocks; }' >> conftest.c
811     if test -z "`${CC} -o conftest conftest.c 2>&1`" ; then
812       AC_MSG_RESULT([yes])
813     else
814       AC_MSG_RESULT([no])
815       JPEG_SETTING=internal
816     fi
817     rm -f conftest*
818   fi
819
820   if test "$JPEG_SETTING" = "external" ; then   
821     LIBS="-ljpeg $LIBS"
822     echo "using pre-installed libjpeg."
823   else
824     echo "using internal jpeg code."
825   fi
826
827 elif test "$with_jpeg" = "internal" ; then
828
829   JPEG_SETTING=internal
830
831   echo "using internal jpeg code."
832
833 else
834
835   JPEG_SETTING=external
836   LIBS="-L$with_jpeg -L$with_jpeg/lib -ljpeg $LIBS"
837   EXTRA_INCLUDES="-I$with_jpeg -I$with_jpeg/include $EXTRA_INCLUDES"
838
839   echo "using libjpeg from $with_jpeg."
840
841 fi
842
843 AC_SUBST(JPEG_SETTING,$JPEG_SETTING)
844
845 if test "$JPEG_SETTING" != "no" ; then
846   OPT_GDAL_FORMATS="jpeg $OPT_GDAL_FORMATS"
847 fi
848
849 dnl ---------------------------------------------------------------------------
850 dnl Select a GIF Library to use, or disable driver.
851 dnl ---------------------------------------------------------------------------
852
853 AC_ARG_WITH(gif,[  --with-gif[=ARG]        Include GIF support (ARG=internal, no or path)],,)
854
855 if test "$with_gif" = "no" ; then
856
857   GIF_SETTING=no
858
859   echo "gif support disabled."
860
861 elif test "$with_gif" = "yes" -o "$with_gif" = "" ; then
862
863   AC_CHECK_LIB(gif,DGifOpenFileName,GIF_SETTING=external,GIF_SETTING=internal,)
864
865   if test "$GIF_SETTING" = "external" ; then   
866     LIBS="-lgif $LIBS"
867     echo "using pre-installed libgif."
868   else
869     echo "using internal gif code."
870   fi
871
872 elif test "$with_gif" = "internal" ; then
873
874   GIF_SETTING=internal
875
876   echo "using internal gif code."
877
878 else
879
880   GIF_SETTING=external
881   LIBS="-L$with_gif -L$with_gif/lib -lgif $LIBS"
882   EXTRA_INCLUDES="-I$with_gif -I$with_gif/include $EXTRA_INCLUDES"
883
884   echo "using libgif from $with_gif."
885
886 fi
887
888 AC_SUBST(GIF_SETTING,$GIF_SETTING)
889
890 if test "$GIF_SETTING" != "no" ; then
891   OPT_GDAL_FORMATS="gif $OPT_GDAL_FORMATS"
892 fi
893
894 dnl ---------------------------------------------------------------------------
895 dnl Select an OGDI Library to use, or disable driver.
896 dnl ---------------------------------------------------------------------------
897
898 OGDI_INCLUDE=
899 export OGDI_INCLUDE
900
901 AC_ARG_WITH(ogdi,[  --with-ogdi[=ARG]       Include OGDI support (ARG=path)],,)
902
903 if test "$with_ogdi" = "no" ; then
904
905   HAVE_OGDI=no
906
907   echo "ogdi support disabled."
908
909 elif test "$with_ogdi" = "yes" -o "$with_ogdi" = "" ; then
910
911   AC_CHECK_LIB(ogdi31,cln_GetLayerCapabilities,HAVE_OGDI=yes,HAVE_OGDI=no,)
912
913   if test "$HAVE_OGDI" = "yes" ; then   
914     LIBS="-logdi31 $LIBS"
915   fi
916
917 else
918
919   HAVE_OGDI=yes
920   LIBS="-L$with_ogdi -L$with_ogdi/lib -logdi31 $LIBS"
921   OGDI_INCLUDE="-I$with_ogdi -I$with_ogdi/include"
922
923   echo "using libogdi31 from $with_ogdi."
924
925 fi
926
927 AC_SUBST(HAVE_OGDI,$HAVE_OGDI)
928 AC_SUBST(OGDI_INCLUDE,$OGDI_INCLUDE)
929
930 if test "$HAVE_OGDI" != "no" ; then
931   OPT_GDAL_FORMATS="ogdi $OPT_GDAL_FORMATS"
932 fi
933
934 dnl ---------------------------------------------------------------------------
935 dnl Select FME_HOME or disable FME support.
936 dnl ---------------------------------------------------------------------------
937
938 X_FME_HOME=
939 export X_FME_HOME
940
941 AC_ARG_WITH(fme,[  --with-fme[=ARG]        Include FMEObjects support (ARG=FME_HOME path)],,)
942
943 AC_MSG_CHECKING([for FMEObjects])
944
945 if test "$with_fme" = "no" ; then
946
947   AC_MSG_RESULT([disabled by user])
948
949 elif test "$with_fme" = "yes" ; then
950
951   if test "$FME_HOME" = "" ; then
952     AC_MSG_ERROR([no, FME_HOME not defined!])
953   elif test -f $FME_HOME/fmeobjects/cpp/isession.h ; then
954     AC_MSG_RESULT([yes])
955     X_FME_HOME=$FME_HOME
956   else
957     AC_MSG_ERROR([FME_HOME defined, but $FME_HOME/fmeobjects/cpp/issesion.h not found.])
958   fi
959    
960 elif test "$with_fme" = "" ; then
961
962   if test "$FME_HOME" = "" ; then
963     AC_MSG_RESULT([no])
964   elif test -f $FME_HOME/fmeobjects/cpp/isession.h ; then
965     AC_MSG_RESULT([yes])
966     X_FME_HOME=$FME_HOME
967   else
968     AC_MSG_RESULT([no, FME_HOME defined, but $FME_HOME/fmeobjects/cpp/issesion.h not found.])
969   fi
970    
971 else
972
973   if test -f $with_fme/fmeobjects/cpp/isession.h ; then
974     AC_MSG_RESULT([yes])
975     X_FME_HOME=$with_fme
976   else
977     AC_MSG_ERROR([$with_fme/fmeobjects/cpp/issesion.h not found!])
978   fi
979  
980 fi
981
982 AC_SUBST(X_FME_HOME,$X_FME_HOME)
983
984 dnl ---------------------------------------------------------------------------
985 dnl Select an HDF4 Library to use, or disable driver.
986 dnl
987 dnl We assume the user will have libjpeg and libz from other sources when
988 dnl linking against static HDF4 libraries.
989 dnl ---------------------------------------------------------------------------
990
991 HDF4_INCLUDE=""
992
993 AC_ARG_WITH(hdf4,[  --with-hdf4[=ARG]       Include HDF4 support (ARG=path)],,)
994
995 if test x"$with_hdf4" = x"no" ; then
996
997   HAVE_HDF4=no
998
999   echo "hdf4 support disabled."
1000
1001 else
1002
1003   if test x"$with_hdf4" = x"yes" -o x"$with_hdf4" = x"" ; then
1004     HDF_LIB_DIR=""
1005   else
1006     if test -d $with_hdf4/lib ; then
1007       HDF_LIB_DIR="$with_hdf4/lib"
1008     else
1009       HDF_LIB_DIR="$with_hdf4"
1010     fi
1011   fi
1012
1013   ORIG_LIBS="$LIBS"
1014   if test "$HDF_LIB_DIR" != "" ; then
1015     LIBS="-L$HDF_LIB_DIR $LIBS"
1016   fi
1017
1018   AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf",HDF_LIB_NAME=missing,-ldf)
1019   if test "$HDF_LIB_NAME" = "missing" ; then
1020     unset ac_cv_lib_mfhdf_SDreaddata
1021     AC_CHECK_LIB(hdf4,SDreaddata,HDF_LIB_NAME=-lhdf4,HDF_LIB_NAME=missing,)
1022   fi
1023
1024 dnl Check again, with -ldf, -ljpeg and -lz this time.
1025   if test "$HDF_LIB_NAME" = "missing" ; then
1026     unset ac_cv_lib_mfhdf_SDreaddata
1027     AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf",HDF_LIB_NAME=missing,-ldf -ljpeg -lz)
1028   fi
1029
1030 dnl Not found... again, with -lsz.
1031   if test "$HDF_LIB_NAME" = "missing" ; then
1032     unset ac_cv_lib_mfhdf_SDreaddata
1033     AC_CHECK_LIB(mfhdf,SDreaddata,HDF_LIB_NAME="-lmfhdf -ldf -lsz",HDF_LIB_NAME=missing,-ldf -lsz -ljpeg -lz)
1034   fi
1035
1036   if test "$HDF_LIB_NAME" != "missing" ; then
1037
1038     if test "$HDF_LIB_DIR" != "" ; then
1039       LIBS="-L$HDF_LIB_DIR $HDF_LIB_NAME $ORIG_LIBS"
1040     else
1041       LIBS="$HDF_LIB_NAME $ORIG_LIBS"
1042     fi
1043
1044   dnl Now search for headers
1045     if test "$with_hdf4" = "yes" -o "$with_hdf4" = "" -a -r /usr/include/hdf/hdf.h ; then
1046       HDF4_INCLUDE="-I/usr/include/hdf"
1047     elif test -r "$with_hdf4/hdf/hdf.h" ; then
1048       HDF4_INCLUDE="-I$with_hdf4/hdf"
1049     elif test -r "$with_hdf4/include/hdf/hdf.h" ; then
1050       HDF4_INCLUDE="-I$with_hdf4/include/hdf"
1051     elif test -r "$with_hdf4/include/hdf.h" ; then
1052       HDF4_INCLUDE="-I$with_hdf4/include"
1053     elif test -r "$with_hdf4/hdf.h" ; then
1054       HDF4_INCLUDE="-I$with_hdf4"
1055     fi
1056
1057     HAVE_HDF4=yes
1058
1059   else
1060
1061     if test x"$with_hdf4" != x"" ; then
1062       AC_MSG_ERROR([HDF4 support requested with arg "$with_hdf4", but neither hdf4 nor mfhdf lib found])
1063     else
1064       LIBS="$ORIG_LIBS"
1065       HAVE_HDF4=no
1066     fi
1067
1068   fi
1069
1070 fi
1071
1072 AC_SUBST(HAVE_HDF4,$HAVE_HDF4)
1073 AC_SUBST(HDF4_INCLUDE,$HDF4_INCLUDE)
1074
1075 if test "$HAVE_HDF4" != "no" ; then
1076   OPT_GDAL_FORMATS="hdf4 $OPT_GDAL_FORMATS"
1077 fi
1078
1079
1080 dnl ---------------------------------------------------------------------------
1081 dnl Select an HDF5 Library to use, or disable driver.
1082 dnl
1083 dnl ---------------------------------------------------------------------------
1084
1085 HDF5_INCLUDE=""
1086
1087 AC_ARG_WITH(hdf5,[  --with-hdf5[=ARG]       Include HDF5 support (ARG=path)],,)
1088
1089 if test "$with_hdf5" = "no" ; then
1090
1091   HAVE_HDF5=no
1092
1093   echo "hdf5 support disabled."
1094
1095 elif test "$with_hdf5" = "yes" -o "$with_hdf5" = "" ; then
1096
1097   AC_CHECK_LIB(hdf5,H5Fopen,HAVE_HDF5=yes,HAVE_HDF5=no,)
1098
1099   if test "$HAVE_HDF5" = "yes" ; then   
1100     LIBS="-lhdf5 $LIBS"
1101   fi
1102
1103 dnl Some Linux distros install hdf include files here.
1104   if test "$HAVE_HDF5" = "yes" -a -r /usr/include/hdf5.h ; then
1105     HDF5_INCLUDE="-I/usr/include"
1106   fi
1107
1108 else
1109
1110   if test -d $with_hdf5/lib ; then
1111     HDF5_LIB_DIR=$with_hdf5/lib
1112   else
1113     HDF5_LIB_DIR=$with_hdf5
1114   fi
1115
1116   ORIG_LIBS="$LIBS"
1117   LIBS="-L$HDF5_LIB_DIR $LIBS -lhdf5"
1118
1119   AC_CHECK_LIB(hdf5,H5Fopen,HDF5_LIB_NAME="-lhdf5 ",HDF5_LIB_NAME=missing,-lhdf5)
1120
1121   if test "$HDF5_LIB_NAME" = "missing" ; then
1122     AC_MSG_ERROR([HDF5 support requested with arg $with_hdf5, but no hdf5 lib found])
1123   fi
1124
1125   LIBS="-L$HDF5_LIB_DIR $HDF5_LIB_NAME $ORIG_LIBS"
1126
1127   if test -r "$with_hdf5/hdf5/hdf5.h" ; then
1128     HDF5_INCLUDE="-I$with_hdf5/hdf5"
1129   elif test -r "$with_hdf5/include/hdf5/hdf5.h" ; then
1130     HDF5_INCLUDE="-I$with_hdf5/include/hdf5"
1131   elif test -r "$with_hdf5/include/hdf5.h" ; then
1132     HDF5_INCLUDE="-I$with_hdf5/include"
1133   elif test -r "$with_hdf5/hdf.h" ; then
1134     HDF5_INCLUDE="-I$with_hdf5"
1135   fi
1136
1137   HAVE_HDF5=yes
1138 fi
1139
1140 AC_SUBST(HAVE_HDF5,$HAVE_HDF5)
1141 AC_SUBST(HDF5_INCLUDE,$HDF5_INCLUDE)
1142
1143 if test "$HAVE_HDF5" != "no" ; then
1144   OPT_GDAL_FORMATS="hdf5 $OPT_GDAL_FORMATS"
1145 fi
1146
1147 dnl ---------------------------------------------------------------------------
1148 dnl Select a JasPer Library to use, or disable driver.
1149 dnl ---------------------------------------------------------------------------
1150
1151 AC_ARG_WITH(jasper,[  --with-jasper[=ARG]     Include JPEG-2000 support via JasPer library (ARG=path)],,)
1152
1153 if test "$with_jasper" = "no" ; then
1154
1155   HAVE_JASPER=no
1156
1157   AC_MSG_NOTICE([JasPer (JPEG2000) support disabled.])
1158
1159 elif test "$with_jasper" = "yes" -o "$with_jasper" = "" ; then
1160
1161   AC_CHECK_LIB(jasper,jpc_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)
1162   AC_CHECK_LIB(jasper,jp2_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)
1163   AC_CHECK_LIB(jasper,pgx_decode,HAVE_JASPER=yes,HAVE_JASPER=no,)
1164
1165   if test "$HAVE_JASPER" = "yes" ; then   
1166     LIBS="-ljasper $LIBS"
1167   fi
1168 else
1169
1170   HAVE_JASPER=yes
1171   LIBS="-L$with_jasper -L$with_jasper/lib -ljasper $LIBS"
1172   EXTRA_INCLUDES="-I$with_jasper -I$with_jasper/include $EXTRA_INCLUDES"
1173
1174   AC_MSG_NOTICE([using JasPer library from $with_jasper.])
1175 fi
1176
1177 if test "$HAVE_JASPER" != "no" ; then
1178   OPT_GDAL_FORMATS="jpeg2000 $OPT_GDAL_FORMATS"
1179  
1180   dnl Test whether we have UUID JasPer hack
1181
1182   AC_CHECK_LIB(jasper,jp2_encode_uuid,HAVE_JASPER_UUID=yes,HAVE_JASPER_UUID=no,)
1183
1184   if test "$HAVE_JASPER_UUID" = "yes" ; then
1185     AC_MSG_NOTICE([hacked JasPer version found (JasPer UUID), GeoJP2 enabled.])
1186     JASPER_FLAGS=-DHAVE_JASPER_UUID
1187   else
1188     AC_MSG_NOTICE([hacked JasPer version not found, GeoJP2 disabled.])
1189   fi
1190 fi
1191
1192 AC_SUBST([HAVE_JASPER],$HAVE_JASPER)
1193 AC_SUBST([JASPER_FLAGS],$JASPER_FLAGS)
1194
1195 dnl ---------------------------------------------------------------------------
1196 dnl Select a ECW Library to use, or disable driver.
1197 dnl ---------------------------------------------------------------------------
1198
1199 AC_ARG_WITH(ecw,[  --with-ecw[=ARG]        Include ECW support (ARG=ECW SDK Path, yes or no)],,)
1200
1201 if test ! -z "`uname | grep Darwin`" ; then
1202   CARBON_FRAMEWORK="-framework Carbon"
1203 else
1204   CARBON_FRAMEWORK=
1205 fi
1206
1207 if test "$with_ecw" = "no" ; then
1208
1209   ECW_SETTING=no
1210
1211   echo "ECW support disabled."
1212
1213 elif test "$with_ecw" = "yes" -o "$with_ecw" = "" ; then
1214
1215   AC_CHECK_LIB(NCSEcw,NCScbmOpenFileView,ECW_SETTING=yes,ECW_SETTING=no,-lNCSCnet -lNCSUtil)
1216
1217   if test "$ECW_SETTING" = "yes" ; then   
1218     LIBS="-lNCSEcw -lNCSCnet -lNCSUtil $LIBS"
1219   fi
1220
1221   if test "$ECW_SETTING" = "no" ; then
1222     AC_CHECK_LIB(ecwj2,NCScbmOpenFileView,ECW_SETTING=yes,ECW_SETTING=no,$CARBON_FRAMEWORK)
1223     if test "$ECW_SETTING" = "yes" ; then   
1224       LIBS="-lecwj2 $CARBON_FRAMEWORK $LIBS"
1225     fi
1226   fi
1227
1228 else
1229
1230   AC_MSG_CHECKING([for libNCSEcw.so or libecwj2])
1231   ECW_SETTING=yes
1232   if test -r $with_ecw/lib/libNCSCnet.so -o -r $with_ecw/lib/libNCSCnet.dylib ; then
1233     LIBS="-L$with_ecw/lib -lNCSEcw -lNCSCnet -lNCSUtil $LIBS"
1234     AC_MSG_RESULT([found in $with_ecw/lib.])
1235   elif test -r $with_ecw/lib/libNCSCNet.so -o -r $with_ecw/lib/libNCSCNet.dylib ; then
1236     LIBS="-L$with_ecw/lib -lNCSEcw -lNCSCNet -lNCSUtil $LIBS"
1237     AC_MSG_RESULT([found in $with_ecw/lib.])
1238   elif test -r $with_ecw/bin/libNCSEcw.so -o -r $with_ecw/bin/libNCSEcw.dylib ; then
1239     LIBS="-L$with_ecw/bin -lNCSEcw -lNCSEcw -lNCSCnet $LIBS"
1240     AC_MSG_RESULT([found in $with_ecw/bin.])
1241   elif test -r $with_ecw/lib/libecwj2.dylib ; then
1242     LIBS="-L$with_ecw/lib -lecwj2 $CARBON_FRAMEWORK $LIBS"
1243     AC_MSG_RESULT([found libecwj2 in $with_ecw/lib.])
1244   else
1245     AC_MSG_ERROR([not found in $with_ecw/lib or $with_ecw/bin.])
1246   fi
1247
1248   AC_MSG_CHECKING([for NCSECWClient.h in $with_ecw/include])
1249   if test -r $with_ecw/include/NCSECWClient.h ; then 
1250     AC_MSG_RESULT([found.])
1251     EXTRA_INCLUDES="-I$with_ecw/include $EXTRA_INCLUDES"
1252   else
1253     AC_MSG_ERROR([not found.])
1254   fi
1255 fi
1256
1257 AC_SUBST(ECW_SETTING,$ECW_SETTING)
1258
1259 if test "$ECW_SETTING" != "no" ; then
1260   OPT_GDAL_FORMATS="ecw $OPT_GDAL_FORMATS"
1261 fi
1262
1263 dnl ---------------------------------------------------------------------------
1264 dnl Select Kakadu library or disable driver.
1265 dnl ---------------------------------------------------------------------------
1266
1267 AC_MSG_CHECKING([for Kakadu JPEG2000 support])
1268
1269 AC_ARG_WITH(kakadu,[  --with-kakadu[=ARG]     Include Kakadu/JPEG2000 support],,)
1270
1271 if test "$with_kakadu" = "no" -o "$with_kakadu" = "" ; then
1272   KAKDIR=
1273   AC_MSG_RESULT([not requested.])
1274   HAVE_KAKADU=no
1275 elif test "$with_kakadu" = "yes" ; then
1276   AC_MSG_ERROR([
1277 For JPEG2000 support using Kakadu you need provide the path to the Kakadu
1278 build directory.  Note that Kakadu is *not* free software.])
1279 else
1280   KAKDIR=$with_kakadu
1281   OPT_GDAL_FORMATS="jp2kak $OPT_GDAL_FORMATS"
1282   LIBS="$LIBS -L$with_kakadu/lib -lkdu"
1283   AC_MSG_RESULT([requested.])
1284   HAVE_KAKADU=yes
1285 fi
1286
1287 AC_SUBST(KAKDIR,$KAKDIR)
1288
1289 dnl ---------------------------------------------------------------------------
1290 dnl Select MrSID library or disable driver.
1291 dnl ---------------------------------------------------------------------------
1292 MRSID_FLAGS=
1293 HAVE_MRSID=no
1294
1295 AC_ARG_WITH(mrsid,[  --with-mrsid[=ARG]      Include MrSID support