root/tags/gdal_1_3_2/configure.in

Revision 9673, 59.0 kB (checked in by fwarmerdam, 3 years ago)

updated for libdap 1.6.2 (include dir now libdap)

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