-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1290 lines (1190 loc) · 54.1 KB
/
configure.ac
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
# $Header$ -*-Shell-script-*-
# Purpose: Template autoconf uses to generate NCO configure script
# Newer convention names this file configure.ac, rather than configure.in
# Copyright (C) 2003--2017 Charlie Zender
# License: GNU General Public License (GPL) Version 3
# See http://www.gnu.org/copyleft/gpl.html for full license text
# Usage:
# autoconf
# cd ~/nco;aclocal;autoheader;automake --foreign;autoconf
# cd ~/nco;make distclean;aclocal;autoheader;automake --foreign;autoconf;configure;make install
# cd ~/nco;autoreconf --force
# cd ~/nco;for fl in NEWS README AUTHORS ChangeLog ; do ln -s doc/${fl} ${fl};done;autoreconf --force
# Distribution:
# scp ~/nco/configure givre.ess.uci.edu:nco
# scp ~/nco/configure gplogin2.ess.uci.edu:nco
# NB: Different GNU toolchain versions produce different (though equivalent)
# configure scripts from the same autotools inputs.
# To keep proliferation of different but equivalent versions of automatically
# generated scripts (e.g., configure, Makefile.in) from cluttering repository,
# please try to generate scripts only from current autotools distributions
# on machines running an up-to-date version of a Debian-flavor of Linux,
# preferably Sid or Ubuntu
# GNU autotools rely on ~/nco/autobld/config.[guess,sub]
# Auto-configuration fails if these routines cannot detect your machine type
# This happens periodically as newer machines are introduced
# Notify the NCO project if configuration fails in either file
# and we will update the config files from the upstream source,
# ftp://ftp.gnu.org/pub/gnu/config/config.[guess,sub]
# Autotools glossary:
# AC_ARG_ENABLE(foo,...) Create configure option --enable-foo
# AC_ARG_VAR Add token TKN to environment variables ingested by configure
# AC_CHECK_DECL Find token TKN defined in header, define ${flg} accordingly
# AC_CHECK_FUNC Find fnc_nm() in libXXX.a, define ${flg} accordingly
# AC_CHECK_HEADER Find XXX.h and define HAVE_XXX_H
# AC_CHECK_LIB Find libXXX.a, prepend -lXXX to LIBS, define HAVE_LIBXXX
# AC_CHECK_PROG Find whether prg_nm is on ${PATH}, define ${flg} accordingly
# AC_DEFINE Define token TKN to value VAL with comment CMNT in config.h
# AC_DEFINE_UNQUOTED Define token TKN to value VAL with comment CMNT in config.h. Use then when TKN or VAL are shell variables.
# AC_EGREP_HEADER Search CPP output of header.h (NB: CPP outputs C-code only), define ${flg} accordingly
# AC_MSG_NOTICE Print MSG to output
# AC_MSG_WARN Print MSG to output
# AC_SUBST fxm
# NCO_CHECK_FUNC Sets HAVE_XXX = 0 _and_ NEED_XXX = 1 when xxx() not found
# Process configure input with autoconf to produce configure script
# (package name,version,bug-report-address,tarball name)
AC_INIT([NCO netCDF Operators],[4.6.7-alpha04],[[email protected]],[nco])
#AC_INIT([NCO netCDF Operators],[m4_esyscmd([git describe --abbrev=7 --dirty --always --tags])],[[email protected]],[nco])
# Print GNU copyright in configure script
AC_COPYRIGHT
# Safety check that correct --srcdir was specified
AC_CONFIG_SRCDIR([src/nco/ncks.c])
# Put helper scripts here to reduce top level clutter
AC_CONFIG_AUX_DIR(autobld)
# Tell system about local m4 macros to keep libtool in sync
AC_CONFIG_MACRO_DIR([m4])
# Get build system parameters, need config.guess and config.sub to use these
# Set $build
AC_CANONICAL_BUILD
# Set $host = GNU canonical "triplet" = GNU_TRP
AC_CANONICAL_HOST
# Set $target
AC_CANONICAL_TARGET
# Get NCO version
if test -r doc/VERSION; then
# NCO_VERSION=`cat doc/VERSION`
NCO_VERSION=`git describe --abbrev=7 --dirty --always --tags`
AC_SUBST(NCO_VERSION)
fi
# Set egrep
AC_PROG_EGREP
# Get hostname and user
if test "${USER}"; then
nco_user=${USER};
elif test "${LOGNAME}"; then
nco_user="${LOGNAME}";
else
nco_user="nobody";
fi
AC_DEFINE_UNQUOTED(USER,${nco_user},User)
if test "${HOSTNAME}"; then
nco_hostname="${HOSTNAME}"
# following line $HOST will not be set (from AC_CANONICAL_HOST - will set $host
elif test "${HOST}"; then
nco_hostname="${HOST}"
else
nco_hostname="nowhere";
fi
AC_DEFINE_UNQUOTED(HOST,${nco_hostname},Hostname)
AC_DEFINE_UNQUOTED(HOSTNAME,${nco_hostname},Hostname alias)
AC_DEFINE_UNQUOTED(GNU_TRP,${build},Autoconf-generated architecture \"triplet\")
# Begin pvmgetarch Compatibility
# Compatibility map between pvmgetarch and GNU triplets
# Maintained as master list of architectures on which NCO is known to work
# Define boolean variables for some architecture-specific clauses in configure.in
case ${host} in
alpha*-dec-osf* ) AC_DEFINE(LINUXALPHA,1,Compatibility pvmgetarch token for OSF on DEC Alpha)
;;
alpha*-*-linux* ) AC_DEFINE(LINUXALPHA,1,Compatibility pvmgetarch token for Linux on DEC Alpha)
;;
# e.g., alphaev5-cray-unicosmk2.0.5.X at NIWA
alpha*-cray-unicos* ) AC_DEFINE(CRAY,1,Compatibility pvmgetarch token for UNICOS on DEC Alpha)
;;
hppa*-hp-hpux* ) AC_DEFINE(HPUX,1,Compatibility pvmgetarch token for HPUX on PA RISC)
;;
i*86-pc-freebsd* ) AC_DEFINE(FREEBSD,1,Compatibility pvmgetarch token for FreeBSD on Intel x86)
;;
i*86-pc-linux* ) AC_DEFINE(LINUX,1,Compatibility pvmgetarch token for Linux on Intel x86) LINUX=1 ;
;;
i*86-pc-cygwin* ) AC_DEFINE(WIN32,1,Compatibility pvmgetarch token for Windows on Intel x86)
;;
mips*-sgi-irix* ) AC_DEFINE(SGIMP64,1,Compatibility pvmgetarch token for IRIX on SGI MIPS)
;;
*-apple-darwin* ) AC_DEFINE(MACOSX,1,Compatibility pvmgetarch token for Apple Mac OSX) MACOSX=1 ;
;;
powerpc-ibm-aix* ) AC_DEFINE(AIX,1,Compatibility pvmgetarch token for AIX on IBM PowerPC)
;;
powerpc-*-linux* ) AC_DEFINE(LINUXPPC,1,Compatibility pvmgetarch token for Linux on PowerPC)
;;
rs6000-ibm-aix* ) AC_DEFINE(AIX,1,Compatibility pvmgetarch token for AIX on IBM RS6000)
;;
sparc64-*-linux* ) AC_DEFINE(LINUXSPARC64,1,Compatibility pvmgetarch token for Linux on Sun Sparc)
;;
sparc-sun-solaris2* ) AC_DEFINE(SUNMP,1,Compatibility pvmgetarch token for Solaris 2.x on Sun Sparc)
;;
sx*-nec-superux* ) AC_DEFINE(NECSX,1,Compatibility pvmgetarch token for SuperUX on NEC SX)
;;
x86_64-unknown-cygwin* ) AC_DEFINE(WIN32,1,Compatibility pvmgetarch token for Windows on Intel-compatible x86_64)
;;
x86_64*-linux* ) AC_DEFINE(LINUXAMD64,1,Compatibility pvmgetarch token for Linux on AMD x86_64)
;;
esac
# 20131120: Workaround for Cygwin64
if test "x${host}" = 'xx86_64-unknown-cygwin'; then
AC_DEFINE(NEED_STRDUP,1,Use NCO strdup on Cygwin)
fi
# End pvmgetarch Compatibility
# Use automake to create Makefiles
AM_INIT_AUTOMAKE
#AM_INIT_AUTOMAKE(nco,"${nco_version}")
# Put preprocessor symbols in config.h
AM_CONFIG_HEADER(config.h)
# Check for build chain
# CC and CXX have preferred lists
# AC_PROG_CC sets GCC to 'yes' when GCC is detected
# AC_PROG_CC sets CFLAGS = -g [-O2 iff GCC]
# 20061120: Require alternative compilers be passed to configure as environment variables
#AC_PROG_CC( xlc_r xlc acc cc pathcc pgcc icc gcc como c89)
#AC_PROG_CXX(xlC_r xlC aCC CC cxx pathCC pgCC icpc g++ c++ como)
# 20150107: Autotools on FC21 complain that next command requires autobld/compile
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_CXXCPP
AC_PROG_CC_STDC
AM_PROG_LEX
AC_PROG_YACC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
# Until fix for libtool error is found
LIBTOOL="${LIBTOOL} --tag=CXX"
#LIBTOOL="${LIBTOOL} --tag=ignore_tag_err"
AM_CONDITIONAL(BUILD_YACC_SOURCE,[test "${YACC}" != "yacc" || test -f "src/nco/ncap_yacc.c"])
# Disable maintainer-only options in generated Makefiles unless flag
# --enable-maintainer-mode is given at configure time
AM_MAINTAINER_MODE
# Check for specific library functions and take corrective action when buggy versions found
AC_FUNC_MEMCMP
AC_FUNC_STAT
AC_FUNC_STRTOD
# Check for library functions, if found then #define HAVE_FUNCTION in config.h
AC_CHECK_FUNCS([canonicalize_file_name floor gethostname getpagesize getrusage memchr memmove memset mkstemp pow readlink realpath regcomp setlocale sqrt strchr strerror strpbrk strrchr strstr strtol])
# Check for header files
AC_HEADER_STDC
AC_CHECK_HEADERS([getopt.h libintl.h limits.h locale.h netinet/in.h stdlib.h string.h strings.h unistd.h])
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS(cstdlib)
AC_LANG_POP([C++])
# Check for typedefs, structures, and compiler characteristics
# Allow wanton use of 'const' despite compiler
AC_C_CONST
# Allow inline, use __inline__ or __inline, or remove inline as appropriate
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_TYPE_UID_T
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_SIZEOF(int*)
AC_CXX_HAVE_VALARRAY
# Arrange for large file support (LFS)
AC_SYS_LARGEFILE
echo "#################################"
echo "# Test for netCDF #"
echo "################################"
#Mac OSX MacPorts packages
# sudo port install netcdf
# installs to /opt/local/include, /opt/local/lib
# Add this path to CPPFLAGS if it exists, otherwise do nothing
AC_CHECK_FILE([/opt/local/include/netcdf.h], [CPPFLAGS="$CPPFLAGS -I/opt/local/include"], [])
AC_CHECK_FILE([/opt/local/lib/libnetcdf.a], [LDFLAGS="$LDFLAGS -L/opt/local/lib -lnetcdf"], [])
# Begin mandatory link test with libnetcdf.a
# Make precious variables for ./configure --help
AC_ARG_VAR(NETCDF_INC,Location of netCDF headers (compile-time))
AC_ARG_VAR(NETCDF_LIB,Location of netCDF library (compile-time))
# User-specified netCDF locations, if any, take precedence
if test "${NETCDF_ROOT}" != ''; then
if test -d "${NETCDF_ROOT}"; then
CPPFLAGS="-I${NETCDF_ROOT}/include ${CPPFLAGS}";
LDFLAGS="-L${NETCDF_ROOT}/lib ${LDFLAGS}";
else
echo "WARNING: NETCDF_ROOT location \"${NETCDF_ROOT}\" does not exist!"
fi
fi # !NETCDF_ROOT
if test "${NETCDF_LIB}"; then
if test -d "${NETCDF_LIB}"; then
LDFLAGS="-L${NETCDF_LIB} ${LDFLAGS} "
else
echo "WARNING: NETCDF_LIB location \"${NETCDF_LIB}\" does not exist!"
fi
fi # !NETCDF_LIB
if test "${NETCDF_INC}"; then
if test -d "${NETCDF_INC}"; then
CPPFLAGS="-I${NETCDF_INC} ${CPPFLAGS} "
else
echo "WARNING: NETCDF_INC location \"${NETCDF_INC}\" does not exist!"
fi
fi # !NETCDF_INC
# NCO no longer supports netCDF2
AC_CHECK_HEADERS([netcdf.h],[],[AC_MSG_FAILURE([cannot find netCDF header])])
AC_DEFINE(NO_NETCDF_2,1,No netCDF version 2.x API)
AC_CHECK_LIB([netcdf],[nc_open],[LIBS="-lnetcdf ${LIBS}"],[AC_MSG_FAILURE([cannot find netCDF library])])
echo "#################################"
echo "# Test for netCDF4 support #"
echo "#################################"
AC_ARG_ENABLE(netcdf4,AS_HELP_STRING([--enable-netcdf4],[Enable netCDF Version 4 features (same as enable-netcdf-4) [[default=yes]]]),enable_netcdf4=${enableval},enable_netcdf4=yes)
# 20100105: make --enable-netcdf-4 synonym for --enable-netcdf4
if test "x${enable_netcdf4}" = 'xno' ; then
AC_ARG_ENABLE(netcdf-4,AS_HELP_STRING([--enable-netcdf-4],[Enable netCDF Version 4 features (same as enable-netcdf4) [[default=yes]]]),enable_netcdf4=${enableval},enable_netcdf4=yes)
fi # !netCDF4
AC_ARG_VAR([NETCDF_ROOT],[Root of netCDF4 installation] (compile-time))
# Test if user set NETCDF_ROOT and it exists
if test "x${enable_netcdf4}" = 'xyes'; then
if test -z "${NETCDF_ROOT}"; then
# 20160901: Branch fails on Fedora Core 23+ (not MacOSX, not Ubuntu) due to mysterious emission of "Using <pathname>/nf-config" text as if warning user about security hole
NETCDF_CONFIG='nc-config'
NETCDF_ROOT="`nc-config --prefix`"
else
NETCDF_CONFIG="${NETCDF_ROOT}/bin/nc-config"
fi
LDFLAGS="`${NETCDF_CONFIG} --libs` ${LDFLAGS}";
CPPFLAGS="`${NETCDF_CONFIG} --cflags` ${CPPFLAGS}";
fi
# ENABLE_NETCDF4 refers to presence of netCDF4-enabled library
# ENABLE_NETCDF4 implies HAVE_NETCDF4_H
# The converse is not true! Some distributions (e.g., Debian stable)
# build _only_ netCDF3 library from netCDF4 source code
AC_CHECK_DECL([NC_CHUNKED],[header_defines_nc_chunked='yes'],[header_defines_nc_chunked='no'],[[#include <netcdf.h>]])
if test "x${header_defines_nc_chunked}" = 'xyes' ; then
AC_DEFINE([HAVE_NETCDF4_H],[1],[Define to 1 if netcdf.h contains netCDF4 definitions])
AC_MSG_NOTICE([netcdf.h contains netCDF4 definitions])
fi
if (test "x${enable_netcdf4}" = 'xyes' && test "x${header_defines_nc_chunked}" = 'xyes') ; then
AC_CHECK_LIB([netcdf],[nc_def_var_chunking],[LIBS="-lnetcdf ${LIBS}"
AC_DEFINE([ENABLE_NETCDF4],[1],[Define to 1 if libnetcdf.a contains netCDF4 functions])
AC_MSG_NOTICE([Good news: Simple program compiles and links to netCDF4 library])
],[
AC_MSG_NOTICE([Bad news: Simple program does not compile and link with netCDF4 library])
])
fi
# Begin OpenMP
AC_ARG_ENABLE(openmp,AS_HELP_STRING([--enable-openmp],[Build NCO with OpenMP [[default=yes]]]),enable_openmp=${enableval},enable_openmp=yes)
# Enable OpenMP unless told not to
if ((test "x${enable_openmp}" != 'xno') && (test "x${enable_netcdf4}" = 'xyes')); then
AC_OPENMP
AC_SUBST(OPENMP_CFLAGS)
AC_DEFINE([ENABLE_OPENMP],[1],[Compile operators with OpenMP support])
AC_MSG_NOTICE([OpenMP support enabled])
CFLAGS="${CFLAGS} ${OPENMP_CFLAGS}"
fi
# End OpenMP
# Begin DAP support
echo "Beginning generic tests for DAP support"
# Store pre-DAP LIBS value to restore from later
nco_LIBS_no_DAP="${LIBS}"
AC_ARG_ENABLE(dap,AS_HELP_STRING([--enable-dap],[Build DAP-enabled NCO with netCDF-provided DAP [[default=yes]]]),enable_dap=${enableval},enable_dap=yes)
# Check for DAP in netCDF library unless told not to
if test "${enable_dap}" != 'no'; then
echo "Testing for DAP-netCDF support (is DAP in libnetcdf.a?)..."
AC_CHECK_LIB([netcdf],[daperror],,enable_dap=no,[-lcurl])
if test "${enable_dap}" = 'no'; then
AC_MSG_WARN([DAP-netCDF support through libnetcdf.a disabled (missing DAP functions)])
fi
if (test "x${enable_dap}" = 'xyes'); then
AC_DEFINE([ENABLE_DAP],[1],[Compile operators with DAP support from libnetcdf])
AC_MSG_NOTICE([DAP support enabled])
LIBS="${LIBS} -lcurl"
# This would activate conditional DAP tests, if there were any
# AM_CONDITIONAL(TEST_DAP,[test "${enable_dap}" = 'yes'])
fi
fi
# End DAP
##################################################
# Check libraries, add to link path if found
# fxm: move some checks to OS-specific blocks
##################################################
#AC_CHECK_LIB([C],[cosf])
AC_CHECK_FUNC(getopt_long,,[nco_need_getopt_long='yes'])
AC_CHECK_LIB([f95],[_g95_ac_array],,,[-lm])
AC_CHECK_LIB([m],[sin])
AC_CHECK_LIB([sunmath],[sinf])
AC_CHECK_LIB([intl],[gettext])
AC_CHECK_LIB([resolv],[res_init])
AC_CHECK_LIB([socket],[main])
AC_CHECK_LIB([thread],[main])
AC_CHECK_LIB([nco],[nco_open],[enable_libnco=yes],,)
AM_CONDITIONAL(NCO_NEED_GETOPT_LONG,test "${nco_need_getopt_long}" = 'yes')
# Architecture-dependent library checks
case ${host} in
hppa*-hp-hpux* | sparc-sun-solaris2* )
AC_CHECK_LIB([nsl],[main]) ;;
esac
# End OS-specific libraries
# NCO_CHECK_FUNC, defined in acinclude.m4, does
# "#define HAVE_XXX 1" and "#undef NEED_XXX" when function xxx() is found and
# "#undef HAVE_XXX" and "#define NEED_XXX 1" when function xxx() is not found
# Purpose: CPP macros like "if(NEED_XXX)" are simpler to read than "if(!HAVE_xxx)"
NCO_CHECK_FUNCS([nc_inq_format])
NCO_CHECK_FUNCS([getopt getopt_long])
NCO_CHECK_FUNCS([atan2])
NCO_CHECK_FUNCS([acosf asinf atanf atan2f cosf expf fabsf fmodf log10f logf powf sinf sqrtf tanf])
NCO_CHECK_FUNCS([erff erfcf gammaf])
NCO_CHECK_FUNCS([acoshf asinhf atanhf coshf sinhf tanhf])
NCO_CHECK_FUNCS([ceilf floorf])
NCO_CHECK_FUNCS([nearbyint rint round trunc])
NCO_CHECK_FUNCS([nearbyintf rintf roundf truncf])
NCO_CHECK_FUNCS([getopt_long])
NCO_CHECK_FUNCS([strdup strcasecmp strsep strcasestr])
echo "##########################################################"
echo "# Sorting out MacOSX build parameters #"
echo "##########################################################"
#echo "DEBUG: enable_libnco = ${enable_libnco} and MACOSX = ${MACOSX}"
if ((test "${enable_libnco}" = 'yes') && (test "${MACOSX}" != 1)); then
echo "Phew, NOT MacOSX, adding -lnco to LIBS"
LIBS="-lnco ${LIBS}"
fi
#echo "DEBUG: After library checks LIBS=$LIBS"
# End Library checks
# Begin ANTLR
echo "#################################"
echo "# Testing for ANTLR support #"
echo "#################################"
AC_ARG_VAR(ANTLR_ROOT,Location of ANTLR version 2.7.x installation (compile-time))
AC_ARG_ENABLE(ncoxx,AS_HELP_STRING([--enable-ncoxx],[Build libnco++ and ncap2 (same as enable-ncap2) [[default=yes]]]),enable_ncoxx=${enableval},[enable_ncoxx=yes])
AC_ARG_ENABLE(ncap2,AS_HELP_STRING([--enable-ncap2],[Build ncap2 and libnco++ (same as enable-ncoxx) [[default=yes]]]),enable_ncoxx=${enableval},[enable_ncoxx=yes])
if test "${C_INC}"; then
# Prepend ${C_INC} to search path if present
# C_INC refers to a directory that is guaranteed to be searched first
# C_INC is useful on AIX platforms that have alternative C-compilers (e.g., gcc) installed in a directory (e.g., /usr/local) searched for other software (e.g., antlr)
# Specifying both C_INC and ANTLR_INC would cause the pre-processor to grab
# C-headers from C_INC and antlr headers from ANTLR_INC
# Using C_INC was required on UCI's old ESMF
CPPFLAGS="-I${C_INC} ${CPPFLAGS}"
fi
AC_LANG_PUSH([C++])
if test "${enable_ncoxx}" != 'no'; then
if test "${ANTLR_ROOT}"; then
if test -z "${ANTLR_BIN}"; then
ANTLR_BIN="${ANTLR_ROOT}/bin"
fi
if test -z "${ANTLR_INC}"; then
ANTLR_INC="${ANTLR_ROOT}/include"
fi
if test -z "${ANTLR_LIB}"; then
ANTLR_LIB="${ANTLR_ROOT}/lib"
fi
fi
if test "${ANTLR_BIN}"; then
# Add ${ANTLR_BIN}, if present, to binary search path
PATH="${PATH}:${ANTLR_BIN}"
fi
if test "${ANTLR_INC}"; then
# Add ${ANTLR_INC}, if present, to include search path
CPPFLAGS="${CPPFLAGS} -I${ANTLR_INC}"
fi
if test "${ANTLR_LIB}"; then
# Add ${ANTLR_LIB}, if present, to library search path
LDFLAGS="${LDFLAGS} -L${ANTLR_LIB}"
fi
fi
# AC_CHECK_PROGS (variable, progs-to-check-for, [value-if-not-found], [path]
# Check for antlr executable installed as runantlr (runantlr ~= java antlr.Tool)
AC_CHECK_PROGS(HAVE_ANTLR,[runantlr antlr],no,${PATH},[])
#echo "DEBUG: HAVE_ANTLR = ${HAVE_ANTLR}"
# Issue message if Antlr library was found
if test "${HAVE_ANTLR}" != 'no' ; then
AC_MSG_NOTICE([antlr library was found])
else
AC_MSG_NOTICE([antlr library was not found, disabling ncap2 build])
fi
if test "x${HAVE_ANTLR}" = 'xyes'; then
# 20070228: Avoid CHECK_LIB on C++ libraries (requires too-complex link-test scripts)
# AC_CHECK_LIB([antlr],[ASTFactory],enable_ncoxx=yes,enable_ncoxx=no,[-lstdc++])
AC_CHECK_HEADER([antlr/CommonToken.hpp],enable_ncoxx=yes,enable_ncoxx=no)
if test "${enable_ncoxx}" = 'yes'; then
echo "INFO: ANTLR development support found---will build nco++ directory and ncap2"
fi
fi
if test "${enable_ncoxx}" != 'yes'; then
echo "INFO: ANTLR support not found. To build ncap2, please install ANTLR and its C++ development package, e.g., 'sudo aptitude install antlr libantlr-dev' or 'sudo yum install antlr antlr-c++-devel'"
fi
AC_LANG_POP([C++])
# end ANTLR
# Begin MPI (deprecated)
AC_ARG_ENABLE(mpi,AS_HELP_STRING([--enable-mpi],[Build NCO for Message Passing Interface (NB: Do not use, this is not yet supported) [[default=no]]]),enable_mpi=${enableval},enable_mpi=no)
AM_CONDITIONAL(ENABLE_MPI,[test "${enable_mpi}" = 'yes'])
# End MPI
# Begin Fortran (obsolete)
# If --enable-fortran define USE_FORTRAN_ARITHMETIC
AC_ARG_ENABLE(fortran,AS_HELP_STRING([--enable-fortran],[Use Fortran arithmetic (deprecated) [[default=no]]]),enable_fortran=${enableval},enable_fortran=no)
if test "${enable_fortran}" = 'yes'; then
AC_DEFINE(USE_FORTRAN_ARITHMETIC,1,Use Fortran arithmetic)
fi
# End Fortran
# Begin i18n
# i18n support (experimental, for future use)
AC_ARG_VAR(I18N_SHARE,Root of internationalization (i18n) locale directories (run-time))
# Add user-specified netCDF locations, if any, else add /usr/local/ locations if they exist
if test "${I18N_SHARE}"; then
if test -d "${I18N_SHARE}"; then
echo "I18N_SHARE directory exists"
else
echo "WARNING: I18N_SHARE location \"${I18N_SHARE}\" does not exist!"
fi
else
if test -d '/usr/share/locale'; then
I18N_SHARE='/usr/share/locale'
fi
fi
AC_ARG_ENABLE(i18n,AS_HELP_STRING([--enable-i18n],[Internationalization (i18n) support (WARNING: Experimental, for future use) [[default=no]]]),enable_i18n=${enableval},enable_i18n=no)
# Check for i18n libraries unless told otherwise
if test "${enable_i18n}" != 'no'; then
# These must all be present for i18n to work. If all present, enable_i18n=yes
AC_CHECK_LIB([intl],[main],nco_have_libintl=yes,)
if test "${enable_i18n}" = 'no'; then
AC_MSG_WARN([i18n support disabled (missing libraries)])
elif test "${enable_i18n}" = 'yes'; then
AC_DEFINE(I18N,1,i18n support requested)
AC_MSG_NOTICE([i18n support enabled (WARNING: Experimental, for future use)])
LIBS="-lmfhdf -li18n ${LIBS}"
fi
fi
# End i18n
# Begin largefile
# If --enable-largefile define ENABLE_LARGEFILE
# fxm: TODO bld45 Obsolete! Replace with test for 64-bit offset support (i.e., netCDF 3.6)
if test "${enable_largefile}" = 'yes'; then
echo "This approach to large file support (LFS) is deprecated; use only if netCDF 3.6 is unavailable..."
AC_DEFINE(ENABLE_LARGEFILE,1,Enable Large File Support (LFS))
fi
# End largefile
# Begin nco_c++
# If --enable-nco_cplusplus, compile NCO C++ interface library
AC_ARG_ENABLE(nco_cplusplus,AS_HELP_STRING([--enable-nco_cplusplus],[Build NCO C++ interface library [[default=yes]]]),enable_nco_cxx=${enableval},enable_nco_cxx=yes)
# End nco_c++
echo "##################################################"
echo "# Testing for ESMF support (only for developers) #"
echo "##################################################"
# Begin ESMF
# Begin mandatory link test with libnetcdf.a
# Make precious variables for ./configure --help
AC_ARG_VAR(ESMF_INC,Location of ESMF headers (compile-time))
AC_ARG_VAR(ESMF_LIB,Location of ESMF library (compile-time))
# NB: Desirable for ESMF flags to precede netCDF flags so configure does not look in ESMF location for netCDF
# Store pre-ESMF LIBS value to restore from later
nco_LIBS_no_ESMF="${LIBS}"
nco_CPPFLAGS_no_ESMF="${CPPFLAGS}"
AC_ARG_ENABLE(esmf,AS_HELP_STRING([--enable-esmf],[Build-in ESMF support for integrated (instead of off-line) regridding. WARNING: Development code = Unsupported (and not necessary for regridding! Dragons lurk here.) [[default=no]]]),enable_esmf=${enableval},enable_esmf=no)
if test "${enable_esmf}" != 'yes'; then
enable_esmf='no'
fi
# Check for ESMF libraries unless told not to
# Linking to ESMF library requires six more libraries to fully resolve on Linux:
# -lesmf -lrt -lgfortran -ldl -lnetcdff -lnetcdf_c++
if test "${enable_esmf}" != 'no'; then
if test "${ESMF_INC}"; then
CPPFLAGS="${CPPFLAGS} -I${ESMF_INC}"
else
ESMF_ROOT='/usr/local'
ESMF_INC="${ESMF_ROOT}/include"
ESMF_INC_ARG="-I${ESMF_INC}/include"
CPPFLAGS="${CPPFLAGS} ${ESMF_INC_ARG}"
fi
if test "${ESMF_LIB}"; then
LIBS="${LIBS} -L${ESMF_LIB}"
else
ESMF_ROOT='/usr/local'
ESMF_LIB="${ESMF_ROOT}/lib"
LIBS="${LIBS} -L${ESMF_LIB}"
fi
# fxm: make non-fatal code path for when cannot find esmf-config
AC_CHECK_LIB([netcdf_c++],[main])
AC_CHECK_LIB([netcdff],[main])
AC_CHECK_LIB([dl],[main])
AC_CHECK_LIB([gfortran],[main])
# librt.a: Real-time library
AC_CHECK_LIB([rt],[main])
# Most elegant formulation:
# AC_CHECK_FUNC([clock_gettime])
# if test $ac_cv_func_clock_gettime = no; then
# AC_CHECK_LIB(rt, clock_gettime,,
# [AC_MSG_ERROR([librt required but not found])])
# fi
AC_CHECK_LIB([esmf],[ESMC_Initialize],,enable_esmf=no)
AC_MSG_NOTICE([These ESMF library and header tests must succeed for ESMF support:])
if test "${ESMF_ROOT}"; then
AC_CHECK_FILE([${ESMF_INC}/ESMC.h],AC_DEFINE([HAVE_ESMF_H],1,[Define to 1 if <ESMC.h> is present]),enable_esmf=no)
else
AC_CHECK_HEADER([ESMC.h],AC_DEFINE([HAVE_ESMF_H],1,[Define to 1 if <ESMC.h> is present]),enable_esmf=no)
fi
if test "${enable_esmf}" = 'no'; then
AC_MSG_WARN([ESMF support disabled (missing/unusable library or header file)])
LIBS="${nco_LIBS_no_ESMF}"
CPPFLAGS="${nco_CPPFLAGS_no_ESMF}"
elif test "${enable_esmf}" = 'yes'; then
AC_DEFINE(ENABLE_ESMF,1,Compile operators with ESMF support)
AC_MSG_NOTICE([ESMF support enabled])
fi
fi
AM_CONDITIONAL(ENABLE_ESMF,[test "${enable_esmf}" = 'yes'])
#echo "DEBUG: After ESMF tests LIBS = ${LIBS}"
# This would activate conditional ESMF tests, if there were any
# AM_CONDITIONAL(TEST_ESMF,[test "${enable_esmf}" = 'yes'])
# End ESMF
echo "########################################"
echo "# Testing for GSL support #"
echo "########################################"
# Begin GSL
# NB: Desirable for GSL flags to follow netCDF flags so configure does not look in GSL location (often /usr) for netCDF
# Store pre-GSL LIBS value to restore from later
nco_LIBS_no_GSL="${LIBS}"
nco_CPPFLAGS_no_GSL="${CPPFLAGS}"
AC_ARG_ENABLE(gsl,AS_HELP_STRING([--enable-gsl],[Build-in GSL support if possible [[default=yes]]]),enable_gsl=${enableval},enable_gsl=yes)
if test "${enable_gsl}" = 'yes'; then
if test "${GSL_ROOT}"; then
GSL_CONFIG="${GSL_ROOT}/bin/gsl-config"
else
GSL_CONFIG='gsl-config'
fi
if which ${GSL_CONFIG} > /dev/null; then
enable_gsl='yes'
else
AC_MSG_NOTICE([WARNING: Did not find 'gsl-config' command in your default path])
enable_gsl='no'
fi
fi
# Check for GSL libraries unless told not to
if test "${enable_gsl}" != 'no'; then
# fxm: make non-fatal code path for when cannot find gsl-config
if test -z "${GSL_ROOT}"; then
GSL_CONFIG='gsl-config'
GSL_ROOT="`gsl-config --prefix`"
else
GSL_CONFIG="${GSL_ROOT}/bin/gsl-config"
fi
if test "${GSL_INC}"; then
CPPFLAGS="${CPPFLAGS} -I${GSL_INC}"
else
GSL_INC="${GSL_ROOT}/include"
GSL_INC_ARG="`${GSL_CONFIG} --cflags`"
CPPFLAGS="${CPPFLAGS} ${GSL_INC_ARG}"
fi
if test "${GSL_LIB}"; then
LIBS="${LIBS} -L${GSL_LIB}"
else
GSL_LIB="${GSL_ROOT}/lib"
LIBS="${LIBS} `${GSL_CONFIG} --libs`"
fi
AC_MSG_NOTICE([These GSL library and header tests must succeed for GSL support:])
# fxm: default action of check_lib adds a superfluous -lgsl to $LIBS
AC_CHECK_LIB([gsl],[gsl_sf_gamma_inc],,enable_gsl=no)
if test "${GSL_ROOT}"; then
AC_CHECK_FILE([${GSL_INC}/gsl/gsl_sf_gamma.h],AC_DEFINE([HAVE_GSL_H],1,[Define to 1 if <gsl/gsl_sf_gamma.h> is present]),enable_gsl=no)
else
AC_CHECK_HEADER([gsl/gsl_sf_gamma.h],AC_DEFINE([HAVE_GSL_H],1,[Define to 1 if <gsl_sf_gamma.h> is present]),enable_gsl=no)
fi
if test "${enable_gsl}" = 'no'; then
AC_MSG_WARN([GSL support disabled (missing/unusable library or header file)])
LIBS="${nco_LIBS_no_GSL}"
CPPFLAGS="${nco_CPPFLAGS_no_GSL}"
elif test "${enable_gsl}" = 'yes'; then
# Assumes GSL version in form 1.[0-9]+ extract minor version only
GSL_VER="`${GSL_CONFIG} --version`"
GSL_MAJOR="`echo "${GSL_VER}" | cut -d '.' -f 1`"
GSL_MINOR="`echo "${GSL_VER}" | cut -d '.' -f 2`"
GSL_VER=`expr $GSL_MAJOR \* 100 + $GSL_MINOR`
if test "x${GSL_VER}" = 'x'; then
# 20100115: Fix for machines like bluefire that lack gsl-config
GSL_VER='104'
GSL_MAJOR='1'
GSL_MINOR='4'
fi
AC_DEFINE(ENABLE_GSL,1,Compile operators with GSL support)
AC_DEFINE_UNQUOTED(NCO_GSL_MINOR_VERSION,${GSL_MINOR},GSL minor version number)
AC_DEFINE_UNQUOTED(NCO_GSL_MAJOR_VERSION,${GSL_MAJOR},GSL major version number)
AC_DEFINE_UNQUOTED(NCO_GSL_VERSION,${GSL_VER},GSL version number)
AC_MSG_NOTICE([GSL support enabled])
fi
fi
AM_CONDITIONAL(ENABLE_GSL,[test "${enable_gsl}" = 'yes'])
#echo "DEBUG: After GSL tests LIBS = ${LIBS}"
# This would activate conditional GSL tests, if there were any
# AM_CONDITIONAL(TEST_GSL,[test "${enable_gsl}" = 'yes'])
# End GSL
# Begin rx
# Check to enable regular expression stuff, allow user to override
AC_ARG_ENABLE(regex,AS_HELP_STRING([--enable-regex],[Allow extended regular expressions [[default=yes]]]),nco_have_regex=${enableval},nco_have_regex=yes)
if test "x${nco_have_regex}" = 'xyes'; then
AC_CHECK_HEADER([regex.h],AC_DEFINE([HAVE_REGEX_H],1,[Define to 1 if <regex.h> is present]),nco_have_regex=no)
AC_CHECK_HEADER([sys/types.h],AC_DEFINE([HAVE_SYS_TYPES_H],1,[Define to 1 if <sys/types.h> is present]),nco_have_regex=no)
AC_CHECK_FUNC([regexec],AC_DEFINE([HAVE_REGEXEC],1,[Define to 1 if 'regexec()' is present]),nco_have_regex=no)
AC_CHECK_FUNC([regcomp],AC_DEFINE([HAVE_REGCOMP],1,[Define to 1 if 'regcomp()' is present]),nco_have_regex=no)
AC_CHECK_FUNC([regfree],AC_DEFINE([HAVE_REGFREE],1,[Define to 1 if 'regfree()' is present]),nco_have_regex=no)
fi
if test "x${nco_have_regex}" = 'xyes'; then
AC_DEFINE(NCO_HAVE_REGEX_FUNCTIONALITY,1,POSIX extended regular expressions available)
fi
# End rx
# - Variable: CPPFLAGS
# Header file search directory (`-IDIR') and any other miscellaneous
# options for the C and C++ preprocessors and compilers. If it is
# not set in the environment when `configure' runs, the default
# value is empty. `configure' uses this variable when compiling or
# preprocessing programs to test for C and C++ features.
echo "########################################"
echo "# Testing for UDUNITS support #"
echo "########################################"
AC_ARG_ENABLE(udunits,AS_HELP_STRING([--enable-udunits],[Build-in UDUnits support if possible [[default=no]]]),enable_udunits=${enableval},enable_udunits=yes)
AC_ARG_ENABLE(udunits2,AS_HELP_STRING([--enable-udunits2],[Build-in UDUnits2 support if possible [[default=yes]]]),enable_udunits2=${enableval},enable_udunits2=yes)
# Are both UDUnits and UDUnits2 requested?
if (test "${enable_udunits}" != 'no' && test "${enable_udunits2}" != 'no'); then
# Override UDUnits request
echo "WARNING: Requested both UDUnits and UDUnits2 support---overriding UDUnits"
echo "Will attempt to build NCO with UDUnits support from libudunits2, not from libudunits"
enable_udunits='no'
fi # End test for UDUnits duplication
# Begin UDUnits2
# Check for UDUnits2 libraries unless told not to
if test "${enable_udunits2}" != 'no'; then
AC_CHECK_LIB([expat],[XML_ParserCreate],,)
if test "${UDUNITS2_PATH}" != ''; then
if test -d "${UDUNITS2_PATH}"; then
# NB: Use ${UDUNITS2_PATH} not ${UDUNITS2_ROOT} because UDUnits software looks for ${UDUNITS2_PATH}
# Add ${UDUNITS2_PATH}/lib to search path if present
nco_udunits2_xml=${UDUNITS2_PATH}/share/udunits/udunits2.xml
LDFLAGS="${LDFLAGS} -L${UDUNITS2_PATH}/lib"
CPPFLAGS="${CPPFLAGS} -I${UDUNITS2_PATH}/include"
else
echo "WARNING: UDUNITS2_PATH location \"${UDUNITS2_PATH}\" does not exist!"
fi
elif test "${NETCDF_INC}"; then
nco_udunits2_xml="${NETCDF_INC}/../share/udunits/udunits2.xml"
fi
if test "${UDUNITS2_PATH}" = ''; then
# NO UDUNITS2_PATH section
# Fedora 1.7 has /usr/include/udunits2/udunits2.h
# 20160418 FC23 has /usr/include/udunits2/udunits2.h
# Add this path to CPPFLAGS if it exists, otherwise do nothing
AC_CHECK_FILE([/usr/include/udunits2/udunits2.h], [CPPFLAGS="$CPPFLAGS -I/usr/include/udunits2"], [])
# 20170113 FC25 has /usr/include/udunits2/udunits2.h
# Ubuntu
# /usr/lib/x86_64-linux-gnu/libudunits2.a
# /usr/lib/i386-linux-gnu/libudunits2.a
# /usr/include/udunits2.h
AC_CHECK_FILE([/usr/include/udunits2.h], [CPPFLAGS="$CPPFLAGS -I/usr/include"], [])
AC_CHECK_FILE([/usr/lib/x86_64-linux-gnu/libudunits2.a], [LDFLAGS="$LDFLAGS -L/usr/lib/x86_64-linux-gnu"], [])
AC_CHECK_FILE([/usr/lib/i386-linux-gnu/libudunits2.a], [LDFLAGS="$LDFLAGS -L/usr/lib/i386-linux-gnu"], [])
# Mac OSX MacPorts packages
# sudo port install libdap
# sudo port install gsl
# sudo port install antlr
# sudo port install udunits2
# sudo port install netcdf
# installs to /opt/local/include/udunits2/udunits2.h
# /opt/local/share/udunits/udunits2.xml
# Add this path to CPPFLAGS if it exists, otherwise do nothing
AC_CHECK_FILE([/opt/local/include/udunits2/udunits2.h], [CPPFLAGS="$CPPFLAGS -I/opt/local/include/udunits2"], [])
#/opt/local/lib/libudunits2.a
AC_CHECK_FILE([/opt/local/lib/libudunits2.a], [LDFLAGS="$LDFLAGS -L/opt/local/lib/"], [])
# 20101011 Debian installs udunits2.xml in /usr/share/xml/udunits/udunits2
# NB: 20100729 udunits2.xml location seems to have changed from
# /usr/local/share/udunits2.xml (in Fedora Core 6) to /usr/local/share/udunits/udunits2.xml
# Not sure of location in more recent Fedora systems...
# Updating patch from Fedora Core 6 nco.spec:
for udunits2_data_file in /usr/share/xml/udunits/udunits2/udunits2.xml /usr/local/share/udunits/udunits2.xml /usr/local/share/udunits2.xml /share/udunits2.xml /usr/share/udunits/udunits2.xml; do
if test -e "$udunits2_data_file" ; then
nco_udunits2_xml="$udunits2_data_file"
fi
done
fi # end NO UDUNITS2_PATH section
# Warn if udunits2.xml is not found, but continue anyway since builder may be savvy enough to add it when building packages (e.g., .debs)
AC_CHECK_FILE([$nco_udunits2_xml],,AC_WARN([file $nco_udunits2_xml was not found but will still attempt to build NCO with UDUnits2 support.]))
# Use DEFINE_UNQUOTED for quoted string so quotes get correctly merged into source file
AC_DEFINE_UNQUOTED([UDUNITS2_PATH],["$nco_udunits2_xml"],[Location of UDUnits2 data file])
AC_MSG_NOTICE([NB: Following tests of UDUnits2 library and header must succeed for UDUnits2 support:])
AC_CHECK_LIB([udunits2],[ut_read_xml],,enable_udunits2=no)
if test "${UDUNITS2_PATH}"; then
AC_CHECK_FILE([${UDUNITS2_PATH}/include/udunits2.h],AC_DEFINE([HAVE_UDUNITS2_H],1,[Define to 1 if <udunits2.h> is present]),enable_udunits2=no)
else
AC_CHECK_HEADER([udunits2.h],AC_DEFINE([HAVE_UDUNITS2_H],1,[Define to 1 if <udunits2.h> is present]),enable_udunits2=no)
fi
if test "${enable_udunits2}" = 'no'; then
AC_MSG_WARN([UDUnits2 support disabled (missing/unusable library or header file)])
elif test "${enable_udunits2}" = 'yes'; then
LIBS="${LIBS} -ludunits2"
AC_DEFINE(ENABLE_UDUNITS,1,Compile operators with UDUnits2 support)
AC_DEFINE(HAVE_UDUNITS2_H,1,[])
AC_MSG_NOTICE([UDUnits2 support enabled])
fi
# When empty, utInit() uses environment variable UDUNITS2_PATH, if any (see nco_lmt.c)
# Thus UDUNITS2_PATH need not be known at compile time
AC_ARG_VAR([UDUNITS2_PATH],Root directory of UDUnits2 (normally contains [bin, include, lib, share] subdirectories))
fi
# This would activate conditional UDUnits2 tests, if there were any
# AM_CONDITIONAL(TEST_UDUNITS2,[test "${enable_udunits2}" = 'yes'])
# End UDUnits2
# Begin Default OS-specific Compiler Arguments
# Perform standard additions to compilers and preprocessor flags before testing anything
# NB: These flags take effect regardless of enable-[debug/optimize]-custom setting
case ${host} in
i*86-*-linux-gnu | x86_64*-linux* )
case ${CC} in
como* ) CFLAGS="${CFLAGS} --c99" ; ;;
# 20150109: fxm Introduce -D_DEFAULT_SOURCE in place of deprecated (as of gcc 4.9.2) -D_BSD_SOURCE -D_POSIX_SOURCE
# 20150525: fxm Remove -no-gcc from icc flags as per ocehugo
# icc* ) CFLAGS="${CFLAGS} -std=c99" ; CPPFLAGS="${CPPFLAGS} -D_BSD_SOURCE -D_POSIX_SOURCE -no-gcc" ; ;;
icc* ) CFLAGS="${CFLAGS} -std=c99" ; CPPFLAGS="${CPPFLAGS} -D_BSD_SOURCE -D_POSIX_SOURCE" ; ;;
pathcc* ) CFLAGS="${CFLAGS} -std=c99" ; ;;
pgcc* ) CFLAGS="${CFLAGS} -c9x" ; CPPFLAGS="${CPPFLAGS} -DPGI_CC" ; ;;
esac
case ${CXX} in
# icpc* ) CXXFLAGS="${CXXFLAGS} -cxxlib-icc" ; ;;
icpc* ) CXXFLAGS="${CXXFLAGS} -cxxlib-gcc" ; ;;
esac
;;
mips*-sgi-irix* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -c99" ; ;;
esac
;;
powerpc-ibm-aix* )
case ${CC} in
gcc* ) CFLAGS="${CFLAGS} -maix64" ; ;;
# -qmaxmem=num Limit memory used by space intensive optimizations to <num> kilobytes
# -qspill=size Size in B of register allocation spill area, mie needs > 1040 B
# -qlanglvl=extc99: Include orthogonal extensions to C99 standard
xlc* ) CFLAGS="${CFLAGS} -O3 -g -qstrict -Q -qsmp=omp -qlanglvl=extc99 -qmaxmem=8192 -qspill=2048 -q64" ; LDFLAGS="${LDFLAGS} -lC" ; ;;
# CPPFLAGS="${CPPFLAGS} -qlanglvl=extended"
esac
case ${CXX} in
# -bh:5 suppresses annoying messages from xlC linker WARNING: Duplicate symbol: ...
xlC* ) LDFLAGS="${LDFLAGS} -bh:5" ; ;;
esac
esac
# End Default OS-specific Compiler Arguments
# Begin custom GCC switches
# Perform elaborate "or" test since autoconf dislikes [ -o ] syntax
GCC_OR_GXX='no'
if (test "x${GCC}" = 'xyes'); then
GCC_OR_GXX='yes'
fi
if (test "x${GXX}" = 'xyes'); then
GCC_OR_GXX='yes'
fi
if test "x${GCC_OR_GXX}" = 'xyes' ; then
# Explain and set common custom GCC flags once, here, and modify later to suit
# since GCC has same base optimization and debugging flags on all architectures
# Compilation flags for numerical routines recommended by GSL 1.3 manual, p. 397
# CFLAGS += -Werror -Wall -W -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -g -O4
# 20070310: Change to no-shadow so ncoLexer.cpp compiles
# 20150115: Deprecate GCC_CMD_ARGS='-std=c99 -pedantic -D_BSD_SOURCE -D_POSIX_SOURCE'
GCC_CMD_ARGS='-std=c99 -pedantic -D_DEFAULT_SOURCE'
GCC_BASE_FLAGS='-Wall -Wuninitialized -Wunused -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -g -O4'
GCC_BASE_FLAGS="${GCC_BASE_FLAGS} ${OPENMP_CFLAGS}"
GCC_CFLAGS="${GCC_BASE_FLAGS} -Wmissing-prototypes"
GCC_CXXFLAGS="${GCC_BASE_FLAGS}"
# Compilation flags recommended by GSL that I like and use:
# -D_BSD_SOURCE: Support 4.3 BSD Unix extensions to ANSI C (prevents nameser.h warnings)
# -D_POSIX_SOURCE: Support POSIX.1 standard additions to ANSI C (prevents fileno warnings)
# -pedantic: Disallow non-ISO constructs (including type long long) (sometimes useful)
# -Werror: Consider warnings as errors
# -W: Extra warnings, including missing return values, comparison of signed with unsigned
# -Wall: Warn about common programming problems
# -Wcast-align: Warn if casting pointer to type of different size
# -Wcast-qual: Warn if const qualifier removed from pointer
# -Wmaybe-uninitialized: Warn on uninitialized variables. GCC has many false negatives, clang is better? Available on GCC 4.8.2+. Not available on GCC 4.6.3-.
# -Wmissing-prototypes: Warn if missing prototypes (C only, not C++)
# -Wpointer-arith: Warn if pointer arithmetic on types without size, e.g., void
# -Wshadow: Warn if local variable has same name as other local variable
# -Wsometimes-uninitialized: LLVM/clang uses this but GCC does not
# -Wuninitialized: Warn on uninitialized variables. GCC has many false negatives, clang is better?
# -Wwrite-strings: Apply const-qualifier to string constants, die if overwritten
# -fno-common: Prevent global variables from being simultaneously defined in different files
# -g: Put debugging symbols in executable
# -pg: Enable profiling, generate gmon.out output files (also needed by linker)
# -O3: clang -O4 DNE, highest clang optimization is -O3
# -O4: Turn on optimization so uninitialized variables are flagged
# Compilation flags recommended by GSL that I do not like and do not use:
# -ansi: Support only strict ANSI C. Equivalent to -std=c89, conflicts with -std=c99
# --no-alias? -fstrict-aliasing
# -Waggregate-return: Warn if functions return aggregates like structures or unions
# -Wconversion: Warn if converting signed to unsigned. Intended for obsolete, non-prototyped code. Triggers fabsf(), sqrtf(), warnings.
# -Wnested-externs: Warn if extern is encountered within function. C only?
# -Wstrict-prototypes: Warn if inconsistent prototypes. C only?
# -Wtraditional: Warn if constructs differ between traditional and ANSI C. C only?
# -Dinline=: inline is not an ANSI keyword, must undefine inline to work with -ansi
# -fshort-enums: Make enums as short as possible, ususally non-int. Do not ever invoke this! This breaks ABI and causes subtle problems
fi
# End custom GCC switches
# Begin enable_debug_custom
# Custom debug: Activate all known, helpful compile-time and run-time debugging checks
AC_ARG_ENABLE(debug-custom,AS_HELP_STRING([--enable-debug-custom],[Activate all known, helpful compile-time and run-time debugging checks such as pedantic warnings, bounds checking (slowest execution). Automatically activates --enable-debug-symbols. [[default=no]]]),enable_debug_custom=${enableval},enable_debug_custom=no)
if test "${enable_debug_custom}" = 'yes'; then
AC_DEFINE(ENABLE_DEBUG_CUSTOM,1,[Custom debugging: Pedantic, bounds checking (slowest execution)])
if (test "x${GCC}" = 'xyes'); then
CC="${CC} ${GCC_CMD_ARGS}"
GCC_CUSTOM_FLAGS='-g -Wall -Wuninitialized -Wunused -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wmissing-prototypes -fno-common'
CFLAGS="${GCC_CUSTOM_FLAGS} ${OPENMP_CFLAGS}"
if (test "x${CXX}" = 'xg++' && test "x${GXX}" = 'xyes'); then
CXXFLAGS="${GCC_CUSTOM_FLAGS}"
fi
fi
# Other switches are compiler-specific
case ${host} in
alpha*-dec-osf* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -check_bounds -check -check_omp" ; ;;
esac
;;
alpha*-cray-unicos* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -h rounddiv -h indef -h bounds -h nofastmd -h nofastmodulus" ; ;;
esac
;;
i*86-pc-linux* | x86_64*-linux* )
case ${CC} in
icc* ) CFLAGS="${CFLAGS} -Wall -wd810,981,1572 -inline_debug_info"
case ${CXX} in
icpc* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pathcc* ) CFLAGS="${CFLAGS}"
case ${CXX} in
pathCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pgcc* ) CFLAGS="${CFLAGS} -Mbounds -Minfo=all"
case ${CXX} in
pgCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
esac
;;
mips*-sgi-irix* )
if test "x${CC}" = xcc; then
CFLAGS="${CFLAGS} -trapuv"
fi
;;
*-apple-darwin* )
;;
powerpc-ibm-aix* )
case ${CC} in
xlc* ) CFLAGS="${CFLAGS} -qflttrap -qidirfirst -qlonglong -qwarn64 -qcheck=all -qhalt=s"
case ${CXX} in
xlC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
esac
;;
rs6000-ibm-aix* )
;;
sparc-sun-solaris2* )
;;
sx*-nec-superux* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -h0 -hstack=nan" ; ;;
esac
;;
esac
# Check for debugging libraries
AC_CHECK_LIB([ccmalloc],[main],,AC_MSG_WARN([Unable to find ccmalloc library]) )
AC_CHECK_LIB([dl],[main],,AC_MSG_WARN([Unable to find dl library]) )
fi
# End enable_debug_custom
# Begin enable_debug_symbols
# If --enable-debug-symbols, add these compiler flags
AC_ARG_ENABLE(debug-symbols,AS_HELP_STRING([--enable-debug-symbols],[Debugging symbols: Produce symbols for debuggers (e.g., dbx, gdb) [[default=no]]]),enable_debug_symbols=${enableval},enable_debug_symbols=no)
# Custom debug automatically invokes debugging symbols
if test "${enable_debug_custom}" = 'yes'; then
enable_debug_symbols='yes';
fi
if test "${enable_debug_symbols}" = 'yes'; then
AC_DEFINE(ENABLE_DEBUG_SYMBOLS,1,Debugging symbols: Produce symbols for debuggers (e.g., dbx, gdb))
# All known architectures use -g to turn on debugging symbols
CFLAGS="${CFLAGS} -g"
fi
# End enable_debug_symbols
# Begin enable_optimize_custom
# Activate all known, helpful switches for fastest possible run-time performance
# These switches are highly compiler and architecture dependent
# Settings should improve performance relative to default ./configure setttings
AC_ARG_ENABLE(optimize-custom,AS_HELP_STRING([--enable-optimize-custom],[Activate all known, helpful switches for fastest possible run-time performance (slowest compilation) [[default=no]]]),enable_optimize_custom=${enableval},enable_optimize_custom=no)
if test "${enable_optimize_custom}" = 'yes'; then
AC_DEFINE(ENABLE_OPTIMIZE_CUSTOM,1,Fastest possible execution (slowest compilation))
#echo "DEBUG: x\$CC=x${CC}, x\$GCC=x${GCC}"
if (test "x${GCC}" = 'xyes'); then