forked from mathstuf/gdal-svn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
4505 lines (3539 loc) · 145 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dnl ***************************************************************************
dnl $Id$
dnl
dnl Project: GDAL
dnl Purpose: Configure source file.
dnl Author: Frank Warmerdam, [email protected]
dnl
dnl ***************************************************************************
dnl Copyright (c) 2000, Frank Warmerdam
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included
dnl in all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl ***************************************************************************
dnl Disable configure caching ... it causes lots of hassles.
define([AC_CACHE_LOAD], )
define([AC_CACHE_SAVE], )
dnl Process this file with autoconf to produce a configure script.
AC_INIT(GDALmake.opt.in)
AC_CONFIG_MACRO_DIR(m4)
AC_CONFIG_HEADERS([port/cpl_config.h:port/cpl_config.h.in])
AH_BOTTOM([#include "cpl_config_extras.h"])
dnl We require autoconf 2.52+ for libtool support on cygwin/mingw hosts
AC_PREREQ(2.52)
dnl Compute the canonical host-system (the system we are building for)
dnl type variable $host
AC_CANONICAL_HOST
dnl Enable as much warnings as possible
AX_CFLAGS_WARN_ALL(C_WFLAGS)
AX_CXXFLAGS_WARN_ALL(CXX_WFLAGS)
AC_SUBST(CXX_WFLAGS,$CXX_WFLAGS)
AC_SUBST(C_WFLAGS,$C_WFLAGS)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
dnl switch between libtool and native build system
AC_ARG_WITH(libtool, [ --without-libtool Don't use libtool to build the library],,)
if test "$with_libtool" = "no"; then
AC_PROG_RANLIB
dnl AC_COMPILER_PIC as expanded by autoconf-2.68 doesn't work for the C++ part with clang++ 3.0 that doesn't like compiling .c programs
dnl so we inline the expanded code and fix it at hand.
dnl AC_COMPILER_PIC
echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} $CFLAGS -fPIC -c conftest.c 2>&1`"; then
CFLAGS="$CFLAGS -fPIC"
fi
echo 'void f(){}' > conftest.cpp
if test -z "`${CXX-g++} $CXXFLAGS -fPIC -c conftest.cpp 2>&1`"; then
CXXFLAGS="$CXXFLAGS -fPIC"
fi
rm -f conftest*
AC_LD_SHARED
else
with_libtool=yes
fi
AC_SUBST(HAVE_LIBTOOL,$with_libtool)
dnl Checks for libraries.
AC_CHECK_LIB(dl,dlopen,,,)
dnl Needed on Solaris.
AC_CHECK_LIB(rt,nanosleep,,,)
dnl We don't need to add math library to all targets
case "${host_os}" in
cygwin* | mingw32* | pw32* | beos* | darwin*)
;;
*)
AC_CHECK_LIB(m,sin,,,)
;;
esac
dnl Checks for header files.
AC_HEADER_STDC
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)
AC_C_BIGENDIAN
dnl Check for 64 bit file API
AC_HAVE_LONG_LONG
AC_UNIX_STDIO_64
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(void*)
dnl Some compilers (IBM VisualAge) has these types defined, so check it here.
dnl These types are used in internal libtiff.
AC_CHECK_TYPES([int8, int16, int32],,,
[
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
])
dnl We need the following lines for libtiff too.
HAVE_IEEEFP=1
AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine])
dnl Check the native cpu bit order (also libtiff stuff).
AC_MSG_CHECKING([native cpu bit order])
case "$host_cpu" in
i*86*|x86_64*)
HOST_FILLORDER=FILLORDER_LSB2MSB
AC_MSG_RESULT([lsb2msb])
;;
*)
HOST_FILLORDER=FILLORDER_MSB2LSB
AC_MSG_RESULT([msb2lsb])
;;
esac
AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)])
dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(snprintf vsnprintf)
AC_CHECK_FUNCS(atoll)
AC_CHECK_FUNCS(strtof)
AC_CHECK_FUNCS(getcwd)
dnl Check for declarations
AC_CHECK_DECLS(strtof)
AC_CHECK_FUNCS(readlink)
AC_CHECK_FUNCS(lstat)
AC_CHECK_FUNCS(posix_spawnp)
AC_CHECK_FUNCS(vfork)
dnl Make sure at least these are checked under C++. Prototypes missing on
dnl some platforms.
AC_LANG_PUSH(C++)
AC_CHECK_FUNC_CUSTOM(gmtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); gmtime_r( &t, <ime );])
AC_CHECK_FUNC_CUSTOM(localtime_r,[#include <time.h>],[time_t t; struct tm ltime; t = time(0); localtime_r( &t, <ime );])
AC_LANG_POP(C++)
AC_CHECK_FUNC(setlocale)
OPT_GDAL_FORMATS=
EXTRA_INCLUDES=
dnl ---------------------------------------------------------------------------
dnl Check for --enable-debug
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([to enable debug build])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable debugging (disabled by default)]),
[HAVE_DEBUG=$enableval], [HAVE_DEBUG=yes])
if test "x$enable_debug" = "xyes" ; then
dnl Try to strip out optimization.
CXXFLAGS=`echo "$CXXFLAGS " | sed "s/-O2 //"`
CFLAGS=`echo "$CFLAGS " | sed "s/-O2 //"`
CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-O //"`
CFLAGS=`echo "$CFLAGS" | sed "s/-O //"`
dnl remove existing -g to avoid duplicates.
CXXFLAGS=`echo "$CXXFLAGS" | sed "s/-g //"`
CFLAGS=`echo "$CFLAGS" | sed "s/-g //"`
dnl add -g and -DDEBUG
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
CFLAGS="$CFLAGS -g -DDEBUG"
AC_MSG_RESULT([yes, modified CFLAGS="$CFLAGS"])
else
AC_MSG_RESULT([no, CFLAGS="$CFLAGS"])
fi
dnl ---------------------------------------------------------------------------
dnl Check if GCC 4.1 atomic builtins are really available
dnl (some GCC versions are broken w.r.t this on some exotic architectures...)
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([whether GCC 4.1 atomic builtins are available])
rm -f atomicbuiltins.c
echo 'int main(int argc, char* argv[]) { int i; __sync_add_and_fetch(&i, 1); __sync_sub_and_fetch(&i, 1); return 0; } ' > atomicbuiltins.c
if test -z "`${CC} atomicbuiltins.c -o atomicbuiltins 2>&1`" ; then
HAVE_GCC_ATOMIC_BUILTINS=yes
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GCC_ATOMIC_BUILTINS,1, [Define to 1 if GCC atomic builtins are available])
else
HAVE_GCC_ATOMIC_BUILTINS=no
AC_MSG_RESULT([no])
fi
rm -f atomicbuiltins.* atomicbuiltins
AC_SUBST(HAVE_GCC_ATOMIC_BUILTINS,$HAVE_GCC_ATOMIC_BUILTINS)
dnl ---------------------------------------------------------------------------
dnl Check SSE availability
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(sse,
[ --with-sse[=ARG] Detect SSE availability for some optimized routines (ARG=yes(default), no)],,)
AC_MSG_CHECKING([whether SSE is available at compile time])
if test "$with_sse" = "yes" -o "$with_sse" = ""; then
rm -f detectsse.cpp
echo '#ifdef __SSE__' > detectsse.cpp
echo '#include <xmmintrin.h>' >> detectsse.cpp
echo 'void foo() { float fEpsilon = 0.0000000000001f; __m128 xmm_small = _mm_load1_ps(&fEpsilon); } int main() { return 0; }' >> detectsse.cpp
echo '#else' >> detectsse.cpp
echo 'some_error' >> detectsse.cpp
echo '#endif' >> detectsse.cpp
if test -z "`${CXX} ${CXXFLAGS} -o detectsse detectsse.cpp 2>&1`" ; then
AC_MSG_RESULT([yes])
SSEFLAGS=""
HAVE_SSE_AT_COMPILE_TIME=yes
else
if test -z "`${CXX} ${CXXFLAGS} -msse -o detectsse detectsse.cpp 2>&1`" ; then
AC_MSG_RESULT([yes])
SSEFLAGS="-msse"
HAVE_SSE_AT_COMPILE_TIME=yes
else
AC_MSG_RESULT([no])
if test "$with_sse" = "yes"; then
AC_MSG_ERROR([--with-sse was requested, but SSE is not available])
fi
fi
fi
dnl On Solaris, the presence of SSE instructions is flagged in the binary
dnl and prevent it to run on non SSE hardware even if the instructions are
dnl not executed. So if the user did not explicitely requires SSE, test that
dnl we can run SSE binaries
if test "$HAVE_SSE_AT_COMPILE_TIME" = "yes"; then
case $host_os in
solaris*)
AC_MSG_CHECKING([whether SSE is available and needed at runtime])
if ./detectsse; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
if test "$with_sse" = "yes"; then
echo "Caution: the generated binaries will not run on this system."
else
echo "Disabling SSE as it is not explicitely required"
HAVE_SSE_AT_COMPILE_TIME=""
SSEFLAGS=""
fi
fi
;;
esac
fi
rm -f detectsse*
else
AC_MSG_RESULT([no])
fi
AC_SUBST(SSEFLAGS,$SSEFLAGS)
AC_SUBST(HAVE_SSE_AT_COMPILE_TIME,$HAVE_SSE_AT_COMPILE_TIME)
dnl ---------------------------------------------------------------------------
dnl Check AVX availability
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(avx,
[ --with-avx[=ARG] Detect AVX availability for some optimized routines (ARG=yes(default), no)],,)
AC_MSG_CHECKING([whether AVX is available at compile time])
if test "$with_avx" = "yes" -o "$with_avx" = ""; then
rm -f detectavx.cpp
echo '#ifdef __AVX__' > detectavx.cpp
echo '#include <immintrin.h>' >> detectavx.cpp
echo 'void foo() { unsigned int nXCRLow, nXCRHigh; __asm__ ("xgetbv" : "=a" (nXCRLow), "=d" (nXCRHigh) : "c" (0)); float fEpsilon = 0.0000000000001f; __m256 ymm_small = _mm256_set_ps(fEpsilon,fEpsilon,fEpsilon,fEpsilon,fEpsilon,fEpsilon,fEpsilon,fEpsilon); } int main() { return 0; }' >> detectavx.cpp
echo '#else' >> detectavx.cpp
echo 'some_error' >> detectavx.cpp
echo '#endif' >> detectavx.cpp
if test -z "`${CXX} ${CXXFLAGS} -o detectavx detectavx.cpp 2>&1`" ; then
AC_MSG_RESULT([yes])
AVXFLAGS=""
HAVE_AVX_AT_COMPILE_TIME=yes
else
if test -z "`${CXX} ${CXXFLAGS} -mavx -o detectavx detectavx.cpp 2>&1`" ; then
AC_MSG_RESULT([yes])
AVXFLAGS="-mavx"
HAVE_AVX_AT_COMPILE_TIME=yes
else
AC_MSG_RESULT([no])
if test "$with_avx" = "yes"; then
AC_MSG_ERROR([--with-avx was requested, but AVX is not available])
fi
fi
fi
dnl On Solaris, the presence of AVX instructions is flagged in the binary
dnl and prevent it to run on non AVX hardware even if the instructions are
dnl not executed. So if the user did not explicitely requires AVX, test that
dnl we can run AVX binaries
if test "$HAVE_AVX_AT_COMPILE_TIME" = "yes"; then
case $host_os in
solaris*)
AC_MSG_CHECKING([whether AVX is available and needed at runtime])
if ./detectavx; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
if test "$with_avx" = "yes"; then
echo "Caution: the generated binaries will not run on this system."
else
echo "Disabling AVX as it is not explicitely required"
AVXFLAGS=""
HAVE_AVX_AT_COMPILE_TIME=""
fi
fi
;;
esac
fi
rm -f detectavx*
else
AC_MSG_RESULT([no])
fi
AC_SUBST(AVXFLAGS,$AVXFLAGS)
AC_SUBST(HAVE_AVX_AT_COMPILE_TIME,$HAVE_AVX_AT_COMPILE_TIME)
dnl ---------------------------------------------------------------------------
dnl Check if we need -lws2_32
dnl ---------------------------------------------------------------------------
echo "#include <winsock2.h>" > test_ws2_32.c
echo "#include <ws2tcpip.h>" >> test_ws2_32.c
echo "void foo() {}" >> test_ws2_32.c
if test -z "`${CC} -c test_ws2_32.c 2>&1`" ; then
LIBS="$LIBS -lws2_32"
fi
rm -f test_ws2_32*
dnl ---------------------------------------------------------------------------
dnl Check if we have getaddrinfo
dnl ---------------------------------------------------------------------------
echo "#include <sys/types.h>" > test_getaddrinfo.c
echo "#include <sys/socket.h>" >> test_getaddrinfo.c
echo "#include <netdb.h>" >> test_getaddrinfo.c
echo "void test() { getaddrinfo(0,0,0,0); }" >> test_getaddrinfo.c
HAVE_GETADDRINFO=NO
if test -z "`${CC} -c test_getaddrinfo.c 2>&1`" ; then
AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO,1, [Define to 1 if you have the `getaddrinfo' function.])
fi
rm -f test_getaddrinfo*
dnl ---------------------------------------------------------------------------
dnl Check if user requests hidding internal symbols
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(hide_internal_symbols,[ --with-hide-internal-symbols[=ARG] Try to hide internal symbols (ARG=yes/no)],,)
HAVE_HIDE_INTERNAL_SYMBOLS=no
if test "$with_hide_internal_symbols" = "yes"; then
AC_MSG_CHECKING([whether we should hide internal symbols])
rm -f hiddensymbols.c
echo 'int visible() { return 0; } __attribute__ ((visibility("default")))' >> hiddensymbols.c
echo 'int hidden() { return 0; }' >> hiddensymbols.c
if test -z "`${CC} -fvisibility=hidden -c hiddensymbols.c 2>&1`" ; then
HAVE_HIDE_INTERNAL_SYMBOLS=yes
else
HAVE_HIDE_INTERNAL_SYMBOLS=no
fi
if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes"; then
AC_MSG_RESULT([yes])
CFLAGS="$CFLAGS -fvisibility=hidden"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
else
AC_MSG_RESULT([no])
fi
rm -f hiddensymbols.*
else
AC_MSG_CHECKING([whether we should hide internal symbols])
AC_MSG_RESULT([no])
fi
if test "$HAVE_HIDE_INTERNAL_SYMBOLS" = "yes" ; then
AC_DEFINE_UNQUOTED(USE_GCC_VISIBILITY_FLAG,1, [Define to 1 if you want to use the -fvisibility GCC flag])
fi
AC_SUBST(HAVE_HIDE_INTERNAL_SYMBOLS,$HAVE_HIDE_INTERNAL_SYMBOLS)
dnl ---------------------------------------------------------------------------
dnl Check if user requests renaming internal libtiff symbols
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(rename_internal_libtiff_symbols,[ --with-rename-internal-libtiff-symbols[=ARG] Prefix internal libtiff symbols with gdal_ (ARG=yes/no)],,)
if test "$with_rename_internal_libtiff_symbols" = ""; then
with_rename_internal_libtiff_symbols=no
fi
AC_SUBST(RENAME_INTERNAL_LIBTIFF_SYMBOLS,$with_rename_internal_libtiff_symbols)
dnl ---------------------------------------------------------------------------
dnl Check if user requests renaming internal libgeotiff symbols
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(rename_internal_libgeotiff_symbols,[ --with-rename-internal-libgeotiff-symbols[=ARG] Prefix internal libgeotiff symbols with gdal_ (ARG=yes/no)],,)
if test "$with_rename_internal_libgeotiff_symbols" = ""; then
with_rename_internal_libgeotiff_symbols=no
fi
AC_SUBST(RENAME_INTERNAL_LIBGEOTIFF_SYMBOLS,$with_rename_internal_libgeotiff_symbols)
dnl ---------------------------------------------------------------------------
dnl Check if user requests /usr/local to be included.
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([for local include/lib path])
AC_ARG_WITH(local,[ --with-local[=dir] Include /usr/local or other local tree for INCLUDE/LIBS],,)
if test "$with_local" != "no" -a "$with_local" != "" ; then
if test "$with_local" = "yes" ; then
ADD_PREFIX=/usr/local
else
ADD_PREFIX=$with_local
fi
AC_MSG_RESULT(adding $ADD_PREFIX)
LIBS="$LIBS -L$ADD_PREFIX/lib"
CPPFLAGS="$CPPFLAGS -I$ADD_PREFIX/include"
else
AC_MSG_RESULT([none])
fi
dnl ---------------------------------------------------------------------
dnl ENABLE THREADS ONLY IF REQUESTED.
dnl ---------------------------------------------------------------------
THREAD_LIB=""
THREAD_FLAG=""
PTHREAD_ENABLED="no"
AC_ARG_WITH(threads,
[ --with-threads[=ARG] Include thread safe support (ARG=yes(default), no or linkopt)],,)
if test "$with_threads" = "yes" -o "$with_threads" = "" ; then
AC_CHECK_LIB(pthread,pthread_create,THREAD_FLAG=CPL_MULTIPROC_PTHREAD,,,)
if test -n "$THREAD_FLAG" ; then
THREAD_LIB="-lpthread"
else
# For Android, pthread_create is in Bionic libc
unset ac_cv_lib_pthread_pthread_create
AC_CHECK_LIB(c,pthread_create,THREAD_FLAG=CPL_MULTIPROC_PTHREAD,,,)
fi
AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE])
AC_TRY_COMPILE(
[
#define _GNU_SOURCE
#include <pthread.h>
], [
return (PTHREAD_MUTEX_RECURSIVE);
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_PTHREAD_MUTEX_RECURSIVE, 1,
[Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE' constant.])
], [
AC_MSG_RESULT([no])
])
AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
AC_TRY_COMPILE(
[
#define _GNU_SOURCE
#include <pthread.h>
], [
return PTHREAD_MUTEX_ADAPTIVE_NP;
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP, 1,
[Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
], [
AC_MSG_RESULT([no])
])
AC_MSG_CHECKING([for pthread_spinlock_t])
AC_TRY_COMPILE(
[
#define _GNU_SOURCE
#include <pthread.h>
], [
pthread_spinlock_t spin;
return 1;
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SPINLOCK, 1,
[Define to 1 if you have the `pthread_spinlock_t' type.])
], [
AC_MSG_RESULT([no])
])
elif test "$with_threads" != "no" ; then
THREAD_FLAG=CPL_MULTIPROC_PTHREAD
THREAD_LIB="$with_threads"
AC_CHECKING(whether we should include thread/mutex support...)
AC_MSG_RESULT([ using threads with link options "$THREAD_LIB".])
else
AC_CHECKING(whether we should include thread/mutex support...)
AC_MSG_RESULT([ thread safe support disabled.])
fi
if test "$THREAD_FLAG" = "CPL_MULTIPROC_PTHREAD" ; then
AC_DEFINE_UNQUOTED(CPL_MULTIPROC_PTHREAD,1, [Define if you want to use pthreads based multiprocessing support])
PTHREAD_ENABLED="yes"
fi
LIBS="$THREAD_LIB $LIBS"
dnl ---------------------------------------------------------------------------
dnl Check if mremap() with 5 args is available
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([for 5 args mremap()])
AC_TRY_COMPILE(
[
#define _GNU_SOURCE
#include <sys/mman.h>
], [
return (mremap(0,0,0,0,0));
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_5ARGS_MREMAP, 1,
[Define to 1 if you have the 5 args `mremap' function.])
], [
AC_MSG_RESULT([no])
])
dnl ---------------------------------------------------------------------------
dnl Check if _SC_PHYS_PAGES is available
dnl ---------------------------------------------------------------------------
AC_MSG_CHECKING([for _SC_PHYS_PAGES])
AC_TRY_COMPILE(
[
#include <unistd.h>
], [
return (sysconf(_SC_PHYS_PAGES));
],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_SC_PHYS_PAGES, 1,
[Define to 1 if you have the _SC_PHYS_PAGES' constant.])
], [
AC_MSG_RESULT([no])
])
dnl ---------------------------------------------------------------------------
dnl Check if libz is available.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(libz,[ --with-libz[=ARG] Include libz support (ARG=internal or libz directory)],,)
if test "$with_libz" = "external" -o "$with_libz" = "" -o "$with_libz" = "yes" ; then
AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,)
if test "$LIBZ_SETTING" = "external" ; then
AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,)
if test "$LIBZ_SETTING" = "external" ; then
AC_MSG_RESULT([using pre-installed libz])
else
AC_MSG_RESULT([using internal libz code as inflateCopy is missing])
fi
else
AC_MSG_RESULT([using internal libz code as deflateInit_ is missing])
fi
elif test "$with_libz" != "no" -a "$with_libz" != "internal" ; then
LIBS="-L$with_libz -L$with_libz/lib $LIBS"
AC_CHECK_LIB(z,deflateInit_,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
if test "$LIBZ_SETTING" = "external" ; then
AC_CHECK_LIB(z,inflateCopy,LIBZ_SETTING=external,LIBZ_SETTING=internal,-L$with_libz -L$with_libz/lib -lz)
if test "$LIBZ_SETTING" = "external" ; then
AC_MSG_RESULT([using libz library from $with_libz])
else
AC_MSG_RESULT([using internal libz code as inflateCopy from $with_libz is missing])
fi
else
AC_MSG_RESULT([using internal libz code as deflateInit_ from $with_libz is missing])
fi
fi
if test "$LIBZ_SETTING" = "external" ; then
LIBS="-lz $LIBS"
if test "$with_libz" != "" -a "$with_libz" != "yes" -a "$with_libz" != "external" ; then
EXTRA_INCLUDES="-I$with_libz -I$with_libz/include $EXTRA_INCLUDES"
fi
elif test "$with_libz" = "no" ; then
LIBZ_SETTING=no
AC_MSG_RESULT([not using libz at all.])
else
LIBZ_SETTING=internal
OPT_GDAL_FORMATS="zlib $OPT_GDAL_FORMATS"
AC_MSG_RESULT([using internal libz code.])
fi
AC_SUBST(LIBZ_SETTING,$LIBZ_SETTING)
dnl ---------------------------------------------------------------------------
dnl Check for iconv/libiconv.
dnl A rationale for this macro is described in "GNU `gettext' utilities"
dnl manual at
dnl http://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html
dnl ---------------------------------------------------------------------------
AM_ICONV
dnl Extra test needed for GCC 4.5 on Solaris 11, where there is
dnl a different behaviour if the tests are compiled with gcc or g++.
dnl So we introduce a ICONV_CPP_CONST that must be used instead of
dnl ICONV_CONST when used from .cpp files.
if test "$am_func_iconv" = "yes"; then
rm -f testiconv.*
echo '#include <iconv.h>' > testiconv.cpp
echo 'int main(int argc, char** argv) { iconv_t cd = 0; return iconv (cd, (const char **) 0, 0, 0, 0); } ' >> testiconv.cpp
if test -z "`${CXX} ${CPPFLAGS} testiconv.cpp -c 2>&1`" ; then
AC_MSG_RESULT([using ICONV_CPP_CONST="const"])
ICONV_CPP_CONST="const"
else
AC_MSG_RESULT([using ICONV_CPP_CONST=""])
ICONV_CPP_CONST=""
fi
rm -f testiconv.*
AC_DEFINE_UNQUOTED(ICONV_CPP_CONST,$ICONV_CPP_CONST, [For.cpp files, define as const if the declaration of iconv() needs const.])
fi
dnl ---------------------------------------------------------------------------
dnl Check if liblzma is available.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(liblzma,[ --with-liblzma[=ARG] Include liblzma support (ARG=yes/no)],,)
if test "$with_liblzma" = "yes" ; then
AC_CHECK_LIB(lzma,lzma_code,LIBLZMA_SETTING=yes,LIBLZMA_SETTING=no,)
if test "$LIBLZMA_SETTING" = "yes" ; then
LIBS="-llzma $LIBS"
fi
else
LIBLZMA_SETTING=no
fi
AC_SUBST(LIBLZMA_SETTING,$LIBLZMA_SETTING)
dnl ---------------------------------------------------------------------------
dnl Select an PostgreSQL Library to use, or disable driver.
dnl ---------------------------------------------------------------------------
PG_CONFIG=no
AC_ARG_WITH(pg,
AS_HELP_STRING([--with-pg[=ARG]],
[Include PostgreSQL GDAL/OGR Support (ARG=path to pg_config)]),,)
if test "x$with_pg" = "xyes" -o "x$with_pg" = "x" ; then
AC_PATH_PROG(PG_CONFIG, pg_config, no)
else
PG_CONFIG=$with_pg
fi
AC_MSG_CHECKING([for PostgreSQL])
if test "x$PG_CONFIG" = "xno" ; then
HAVE_PG=no
PG_LIB=
PG_INC=
AC_MSG_RESULT([no])
else
if test -d ${PG_CONFIG} ; then
AC_MSG_RESULT([no])
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.])
fi
if test \! -x ${PG_CONFIG} ; then
AC_MSG_RESULT([no])
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.])
fi
AC_MSG_RESULT([yes])
AC_CHECK_LIB(pq,PQconnectdb,HAVE_PG=yes,HAVE_PG=no,-L`$PG_CONFIG --libdir`)
if test "${HAVE_PG}" = "yes" ; then
LIBS=-L`$PG_CONFIG --libdir`" -lpq $LIBS"
PG_INC=-I`$PG_CONFIG --includedir`" -I"`$PG_CONFIG --includedir-server`
PG_EXTRA_DEC=""
saved_LIBS="$LIBS"
AC_CHECK_LIB(pq,PQputCopyData,,DEFINE_PG_PRE74=-DPG_PRE74,)
LIBS="$saved_LIBS"
if test "$DEFINE_PG_PRE74" != "" ; then
echo "The PostgreSQL client version is before 7.4. You will not be able to use binary cursors."
fi
saved_LIBS="$LIBS"
AC_CHECK_LIB(pq,PQescapeStringConn,DEFINE_PG_HAS_PQESCAPESTRINGCONN=-DPG_HAS_PQESCAPESTRINGCONN,,)
LIBS="$saved_LIBS"
if test "$DEFINE_PG_HAS_PQESCAPESTRINGCONN" = "" ; then
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."
fi
PG_INC="${PG_INC} ${DEFINE_PG_PRE74} ${DEFINE_PG_HAS_PQESCAPESTRINGCONN}"
fi
fi
AC_SUBST(HAVE_PG,$HAVE_PG)
AC_SUBST(PG_INC,$PG_INC)
AC_SUBST(PG_LIB,$PG_LIB)
dnl ---------------------------------------------------------------------------
dnl Check if we should build with GRASS support.
dnl ---------------------------------------------------------------------------
GRASS_SETTING=no
GRASS_INCLUDE=
HAVE_GRASS=no
export GRASS_INCLUDE GRASS_SETTING
AC_ARG_WITH(grass,[ --with-grass[=ARG] Include GRASS support (GRASS 5.7+, ARG=GRASS install tree dir)],,)
AC_ARG_WITH(libgrass,[ --with-libgrass[=ARG] Include GRASS support based on libgrass (GRASS 5.0+)],,)
# default use of grass libraries off since we can't easily auto-find them.
if test "$with_grass" = "" ; then
with_grass=no
fi
# Check for GRASS 5.7.0 or later library use.
# TODO: separate libs for rasters and vectors
if test "$with_grass" != "yes" -a "$with_grass" != "no" ; then
AC_CHECK_LIB(grass_gis,G_is_initialized,GRASS_SETTING=grass70+,GRASS_SETTING=no,-L$with_grass/lib -lgrass_datetime)
if test "$GRASS_SETTING" = "no" ; then
AC_CHECK_LIB(grass_gis,G_asprintf,GRASS_SETTING=grass57+,GRASS_SETTING=no,-L$with_grass/lib -lgrass_datetime)
fi
if test "$GRASS_SETTING" != "no" ; then
if test "$GRASS_SETTING" = "grass70+" ; then
G_RASTLIBS="-lgrass_raster -lgrass_imagery"
G_VECTLIBS="-lgrass_vector -lgrass_dig2 -lgrass_dgl -lgrass_rtree -lgrass_linkm -lgrass_dbmiclient -lgrass_dbmibase"
LIBS="-L$with_grass/lib $G_VECTLIBS $G_RASTLIBS -lgrass_gproj -lgrass_gmath -lgrass_gis -lgrass_datetime $LIBS"
else
G_RASTLIBS="-lgrass_I"
G_VECTLIBS="-lgrass_vect -lgrass_dig2 -lgrass_dgl -lgrass_rtree -lgrass_linkm -lgrass_dbmiclient -lgrass_dbmibase"
LIBS="-L$with_grass/lib $G_VECTLIBS $G_RASTLIBS -lgrass_gproj -lgrass_vask -lgrass_gmath -lgrass_gis -lgrass_datetime $LIBS"
fi
GRASS_INCLUDE="-I$with_grass/include"
GRASS_GISBASE="$with_grass"
HAVE_GRASS=yes
else
AC_MSG_ERROR([--with-grass=$with_grass requested, but libraries not found!])
fi
# Check if libgrass is disabled.
elif test "$with_libgrass" = "no" ; then
echo "GRASS support disabled."
elif test "$with_libgrass" = "yes" -o "$with_libgrass" = "" ; then
AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,)
if test "$GRASS_SETTING" = "libgrass" ; then
LIBS="-lgrass5 $LIBS"
fi
else
AC_CHECK_LIB(grass5,G_gisinit_2,GRASS_SETTING=libgrass,GRASS_SETTING=no,-L$with_libgrass/lib)
if test "$GRASS_SETTING" = "libgrass" ; then
LIBS="-L$with_libgrass -L$with_libgrass/lib -lgrass5 $LIBS"
GRASS_INCLUDE="-I$with_libgrass -I$with_libgrass/include $EXTRA_INCLUDES"
else
AC_MSG_ERROR([--with-libgrass=$with_grass requested, but libgrass5 not found!])
fi
fi
AC_SUBST(GRASS_SETTING,$GRASS_SETTING)
AC_SUBST(GRASS_INCLUDE,$GRASS_INCLUDE)
AC_SUBST(GRASS_GISBASE,$GRASS_GISBASE)
AC_SUBST(HAVE_GRASS)
if test "$GRASS_SETTING" != "no" ; then
OPT_GDAL_FORMATS="grass $OPT_GDAL_FORMATS"
fi
dnl ---------------------------------------------------------------------------
dnl Check if cfitsio library is available.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(cfitsio,[ --with-cfitsio[=ARG] Include FITS support (ARG=no or libcfitsio path)],,)
if test "$with_cfitsio" = "no" ; then
FITS_SETTING=no
echo "FITS support disabled."
elif test "$with_cfitsio" = "yes" -o "$with_cfitsio" = "" ; then
AC_CHECK_LIB(cfitsio,ffopen,FITS_SETTING=external,FITS_SETTING=no,)
if test "$FITS_SETTING" = "external" ; then
LIBS="-lcfitsio $LIBS"
echo "using pre-installed libcfitsio."
else
echo "libcfitsio not found - FITS support disabled"
fi
dnl Fedora has cfitsio headers in /usr/include/cfitsio
if test "$FITS_SETTING" = "external" -a -d /usr/include/cfitsio ; then
EXTRA_INCLUDES="-I/usr/include/cfitsio $EXTRA_INCLUDES"
fi
else
FITS_SETTING=external
LIBS="-L$with_cfitsio -L$with_cfitsio/lib -lcfitsio $LIBS"
EXTRA_INCLUDES="-I$with_cfitsio -I$with_cfitsio/include $EXTRA_INCLUDES"
echo "using libcfitsio from $with_cfitsio."
fi
AC_SUBST(FITS_SETTING,$FITS_SETTING)
if test "$FITS_SETTING" != "no" ; then
OPT_GDAL_FORMATS="fits $OPT_GDAL_FORMATS"
fi
dnl ---------------------------------------------------------------------------
dnl Check if PCRaster (libcsf) library is available.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH(pcraster,[ --with-pcraster[=ARG] Include PCRaster (libcsf) support (ARG=internal, no or path)],,)
if test "$with_pcraster" = "no" ; then
PCRASTER_SETTING=no
echo "PCRaster support disabled."
elif test "$with_pcraster" = "yes" -o "$with_pcraster" = "" ; then
AC_CHECK_LIB(csf,Mopen,PCRASTER_SETTING=external,PCRASTER_SETTING=internal,$LIBS)
AC_CHECK_HEADERS(csf.h)
if test "$PCRASTER_SETTING" = "external" -a "$ac_cv_header_csf_h" = "no" ; then
PCRASTER_SETTING=internal
fi
if test "$PCRASTER_SETTING" = "external" ; then
LIBS="-lcsf $LIBS"
echo "using pre-installed libcsf."
else
echo "using internal csf code."
fi
elif test "$with_pcraster" = "internal" ; then
PCRASTER_SETTING=internal
echo "using internal csf code."
else
PCRASTER_SETTING=external
LIBS="-L$with_pcraster/lib -lcsf $LIBS"
EXTRA_INCLUDES="-I$with_pcraster/include $EXTRA_INCLUDES"
echo "using libcsf from $with_pcraster."
fi
AC_SUBST(PCRASTER_SETTING,$PCRASTER_SETTING)
if test "$PCRASTER_SETTING" != "no" ; then
OPT_GDAL_FORMATS="pcraster $OPT_GDAL_FORMATS"
fi
dnl ---------------------------------------------------------------------------
dnl Select a PNG Library to use, or disable driver.
dnl ---------------------------------------------------------------------------
AC_ARG_WITH([png], [ --with-png[=ARG] Include PNG support (ARG=internal, no or path)],,)
AC_MSG_CHECKING([for libpng])
if test "$with_png" = "no" ; then
PNG_SETTING=no
echo "png support disabled."
elif test "$with_png" = "yes" -o "$with_png" = "" ; then
AC_CHECK_LIB([png], [png_set_IHDR], [PNG_SETTING=external], [PNG_SETTING=internal], [$LIBS])
AC_CHECK_HEADERS([png.h])
if test "$PNG_SETTING" = "external" -a "$ac_cv_header_png_h" = "no" ; then
PNG_SETTING=internal
fi
if test "$PNG_SETTING" = "external" ; then
LIBS="-lpng $LIBS"
echo "using pre-installed libpng."
else
echo "using internal png code."
fi
elif test "$with_png" = "internal" ; then
PNG_SETTING=internal
echo "using internal png code."
else
PNG_SETTING=external
LIBS="-L$with_png -L$with_png/lib -lpng $LIBS"
EXTRA_INCLUDES="-I$with_png -I$with_png/include $EXTRA_INCLUDES"
echo "using libpng from $with_png."
fi
AC_SUBST([PNG_SETTING], [$PNG_SETTING])
if test "$PNG_SETTING" != "no" ; then
OPT_GDAL_FORMATS="png $OPT_GDAL_FORMATS"
fi
dnl ---------------------------------------------------------------------------