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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
|
# $Header: /cvsroot/nco/nco/configure.in,v 1.351 2012/02/14 00:38:48 zender Exp $ -*-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--2012 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
# 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_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.0.9],[help@nco.sf.net],[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`
# AC_DEFINE_UNQUOTED(VERSION,${nco_version},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\")
# 20090421 Added for autoreconf to complete after Ubuntu Jaunty upgrade to autoconf 2.6.3
#AC_DEFINE([AS_TR_CPP], [csz_fxm], [Description])
# 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*-linux* ) AC_DEFINE(LINUXAMD64,1,Compatibility pvmgetarch token for Linux on AMD x86_64)
;;
esac
# 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)
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 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
# 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)
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=no)
# 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=no)
fi # !netCDF4
AC_ARG_VAR([NETCDF4_ROOT],[Root of netCDF4 installation] (compile-time))
# Test if user set NETCDF4_ROOT and it exists
if test "x${enable_netcdf4}" = 'xyes'; then
if test -z "${NETCDF_ROOT}"; then
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
echo "DEBUG: After netCDF4 section LDFLAGS = ${LDFLAGS}"
# 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
echo "DEBUG: After netCDF4 section header_defines_nc_chunked = ${header_defines_nc_chunked}"
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 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-netcdf,AS_HELP_STRING([--enable-dap-netcdf],[Build DAP-enabled NCO with netCDF-provided DAP [[default=yes]]]),enable_dap_netcdf=${enableval},enable_dap_netcdf=yes)
# Begin DAP-netCDF
# Check for DAP-netCDF libraries unless told not to
if test "${enable_dap_netcdf}" != 'no'; then
echo "Testing for DAP-netCDF support (is DAP in libnetcdf.a?)..."
AC_CHECK_LIB([netcdf],[nc__opendap],,enable_dap_netcdf=no,[-lcurl])
if test "${enable_dap_netcdf}" = 'no'; then
AC_MSG_WARN([DAP-netCDF support through libnetcdf.a disabled (missing DAP functions)])
fi
fi
# End DAP-netCDF
# Begin DAP (all flavors)
enable_dap='no'
if (test "x${enable_dap_netcdf}" = 'xyes'); then
AC_DEFINE([ENABLE_DAP_NETCDF],[1],[DAP support is from libnetcdf])
enable_dap='yes'
AC_DEFINE([ENABLE_DAP],[1],[Compile operators with DAP support])
AC_MSG_NOTICE([DAP support enabled])
LIBS="${LIBS} -lcurl"
# This would activate conditional GSL tests, if there were any
# AM_CONDITIONAL(TEST_DAP,[test "${enable_dap}" = 'yes'])
fi
# End DAP (all flavors)
##################################################
# 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([nearbyintf rintf roundf truncf])
NCO_CHECK_FUNCS([getopt_long])
NCO_CHECK_FUNCS([strdup strcasecmp])
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 is required on UCI's 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
# Check for antlr executable installed as runantlr (runantlr ~= java antlr.Tool)
AC_CHECK_PROGS(HAVE_ANTLR,[runantlr antlr],[],[],${PATH})
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
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 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 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_VER=`echo "${GSL_VER}" | sed -e 's/^1\.//'`
if test "x${GSL_VER}" = 'x'; then
# 20100115: Fix for machines like bluefire that lack gsl-config
GSL_VER='4'
fi
AC_DEFINE(ENABLE_GSL,1,Compile operators with GSL support)
AC_DEFINE_UNQUOTED(NCO_GSL_MINOR_VERSION,${GSL_VER},GSL minor 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
echo "########################################"
echo "# Testing for UDUNITS support #"
echo "########################################"
# Begin UDUnits support
echo "Beginning generic tests for UDUnits"
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?
echo "DEBUG: enable_udunits = ${enable_udunits} and enable_udunits2 = ${enable_udunits2}"
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
# 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"
# nco_udunits2_xml=${UDUNITS2_PATH}/src/lib/udunits2.xml
elif test "${NETCDF_INC}"; then
nco_udunits2_xml="${NETCDF_INC}/../share/udunits/udunits2.xml"
else
# 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 ; do
if test -e "$udunits2_data_file" ; then
nco_udunits2_xml="$udunits2_data_file"
fi
done
fi
# 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_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],Location of UDUnits2 database 'udunits2.xml' (run-time))
AC_ARG_VAR([UDUNITS2_PATH],Root directory of UDUnits2 (normally contains [bin, include, lib, share] subdirectories))
fi
echo "DEBUG: After UDUnits2 tests LIBS = ${LIBS}"
# 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" ; ;;
icc* ) CFLAGS="${CFLAGS} -std=c99" ; CPPFLAGS="${CPPFLAGS} -D_BSD_SOURCE -D_POSIX_SOURCE -no-gcc" ; ;;
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
GCC_CMD_ARGS='-std=c99 -pedantic -D_BSD_SOURCE -D_POSIX_SOURCE'
GCC_BASE_FLAGS='-Wall -Wunused -W -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -fno-common -g -O4'
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
# -Wmissing-prototypes: Warn if missing prototypes (C only, not C++)
# -Wshadow: Warn if local variable has same name as other local variable
# -Wpointer-arith: Warn if pointer arithmetic on types without size, e.g., void
# -Wcast-qual: Warn if const qualifier removed from pointer
# -Wcast-align: Warn if casting pointer to type of different size
# -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
# -O4: Turn on optimization so unitialized 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}"
# fxm: What to do with default -g -O2 flags? Be redundant for now...
CFLAGS="${CFLAGS} ${GCC_CFLAGS}"
if (test "x${CXX}" = 'xg++' && test "x${GXX}" = 'xyes'); then
CXXFLAGS="${GCC_CXXFLAGS}"
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
# fxm: TODO #303 go through GCC manual and add more speedy flags
# Until then, GCC has interesting property that --enable-optimize-custom flags equal --enable-optimize-debug flags!
CC="${CC} ${GCC_CMD_ARGS}"
CFLAGS="${CFLAGS} ${GCC_CFLAGS}"
if (test "x${GXX}" = 'xyes'); then
CXXFLAGS="${GCC_CXXFLAGS}"
fi
fi
case ${host} in
alpha*-dec-osf* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -O2 -ansi-alias" ; ;;
esac
;;
alpha*-cray-unicos* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -h rounddiv -h nofastmd -h nofastmodulus" ; ;;
esac
;;
i*86-pc-linux* )
case ${CC} in
icc* ) CFLAGS="${CFLAGS} -O3 -axW -mcpu=pentium4"
case ${CXX} in
icpc* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pathcc* ) CFLAGS="${CFLAGS} -O3 -mmmx -msse -msse2 -m3dnow -pipe -fexpensive-optimizations"
case ${CXX} in
pathCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pgcc* ) CFLAGS="${CFLAGS} -fast -fastsse -Minfo=all"
case ${CXX} in
pgCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
esac
;;
mips*-sgi-irix* )
if test "x${CC}" = xcc; then
CFLAGS="${CFLAGS} -O2"
fi
;;
powerpc-ibm-aix* )
case ${CC} in
# -qstrict: Ensure that -O3 optimizations do not alter program semantics
# -Q : Inline all appropriate subprograms
xlc* ) CFLAGS="${CFLAGS} -O3 -qstrict -Q"
case ${CXX} in
xlC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
esac
;;
rs6000-ibm-aix* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -O" ; ;;
esac
;;
sparc-sun-solaris2* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -O2" ; ;;
esac
;;
sx*-nec-superux* )
case ${CC} in
cc* ) CFLAGS="${CFLAGS} -h2 -hmath vector -hxint" ; ;;
esac
;;
x86_64*-linux* )
case ${CC} in
icc* ) CFLAGS="${CFLAGS} -O3 -axW -mcpu=pentium4"
case ${CXX} in
icpc* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pathcc* ) CFLAGS="${CFLAGS} -O3 -march=opteron -mmmx -msse -msse2 -m3dnow -pipe -fexpensive-optimizations"
case ${CXX} in
pathCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
pgcc* ) CFLAGS="${CFLAGS} -tp=k8-64 -fast -fastsse -Minfo=all"
case ${CXX} in
pgCC* ) CXXFLAGS="${CXXFLAGS} ${CFLAGS}"
esac
;;
esac
;;
esac
fi
# End enable_optimize_custom
######################################################
# Previous Location of PVM_ARCH stuff
######################################################
# Begin netCDF test data
AC_PATH_PROG(PATH_TO_NCGEN,ncgen,,)
if test "${PATH_TO_NCGEN}"; then
AC_MSG_NOTICE(Creating sample netCDF data files for self-tests)
${PATH_TO_NCGEN} -b -o data/in.nc data/in.cdl
AC_SUBST(PATH_TO_NCGEN)
for fl in 85.nc 86.nc 87.nc 88.nc 89.nc h0001.nc h0002.nc h0003.nc; do
if test -f data/${fl}; then
printf ""
else
${LN_S} in.nc data/${fl};
fi
done
if test -f src/nco_c++/in.nc; then
printf ""
else
${LN_S} ../../data/in.nc src/nco_c++/in.nc
fi
else
echo "ERROR: Unable to find 'ncgen' (part of the netCDF distribution)"
echo "Hence unable to create netCDF data files for testing"
echo "Do this manually in data/ subdirectory before running \"make check\""
fi
# End netCDF test data
# Tell GNU C compiler to use C99 standard (older gcc versions default to C89)
# fxm: only do this for gcc, not g++
if test $ac_compiler_gnu = 'yes'; then
CFLAGS="${CFLAGS} -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE"
case ${host} in
# MacOSX does not understand shared libraries
*-apple-darwin* ) CFLAGS=`echo "${CFLAGS}" | sed -e 's/-D_POSIX_SOURCE//'` ; CFLAGS="-fno-common ${CFLAGS}" ; enable_shared='no' ;;
# Solaris has problems with time.h
sparc-sun-solaris2* ) CFLAGS=`echo "${CFLAGS}" | sed -e 's/-D_POSIX_SOURCE//'` ; ;;
esac
fi
# Drop C99 switches when compiling NCO with C++ compiler, e.g., CC=g++
case ${CC} in
g\+\+* | icpc* ) CC=`echo "${CC}" | sed -e 's/ -std=c99//'` ; CC=`echo "${CC}" | sed -e 's/ -pedantic//'` ; CFLAGS=`echo "${CFLAGS}" | sed -e 's/ -std=c99//'` ; CFLAGS=`echo "${CFLAGS}" | sed -e 's/ -Wmissing-prototypes//'` ; ;;
xlC* ) CC=`echo "${CC}" | sed -e 's/ -qlanglvl=extc99//'` ; CFLAGS=`echo "${CFLAGS}" | sed -e 's/ -qlanglvl=extc99//'` ; CFLAGS="${CFLAGS} -qlonglong" ; ;;
esac
# Drop C99 switches accidentally incorporated into CXXFLAGS
# (for when laziness led me to copy CXXFLAGS from CFLAGS)
case ${CXX} in
g\+\+* | icpc* | pathCC* ) CXX=`echo "${CXX}" | sed -e 's/ -std=c99//'` ; CXXFLAGS=`echo "${CXXFLAGS}" | sed -e 's/ -std=c99//'` ; ;;
pgCC* ) CXX=`echo "${CXX}" | sed -e 's/ -c9x//'` ; CXXFLAGS=`echo "${CXXFLAGS}" | sed -e 's/ -c9x//'` ; ;;
esac
# xlC must use math.h from /usr/vacpp/include or else atan2() will be missing
case ${CXX} in
xlC* ) CPPFLAGS="-I/usr/vacpp/include ${CPPFLAGS}" ; ;;
esac
echo "###############################"
echo "# Require Shared Libs? #"
echo "###############################"
# If --enable-shared define ENABLE_SHARED
echo "DEBUG: enable_shared: ${enable_shared} "
if (test "${enable_shared}" = 'yes'); then
AC_DEFINE(ENABLE_SHARED,1,Enable shared libraries)
fi
# End Shared
# Begin Static
# If --enable-static define ENABLE_STATIC
if test "${enable_static}" = 'yes'; then
AC_DEFINE(ENABLE_STATIC,1,Enable static libraries)
fi
# End Static
# Begin config
AC_CONFIG_FILES([Makefile data/Makefile src/Makefile src/nco/Makefile man/Makefile doc/Makefile])
if test "${ac_cv_cxx_have_valarray}" = 'yes' \
&& test "${enable_nco_cxx}" = 'yes' ; then
AC_CONFIG_FILES(src/nco_c++/Makefile)
NCO_CXX="nco_c++"
else
NCO_CXX=
fi
AC_SUBST(NCO_CXX)
#echo "DEBUG: enable_ncoxx: ${enable_ncoxx} "
if test "${enable_ncoxx}" = 'yes' ; then
AC_CONFIG_FILES(src/nco++/Makefile)
NCOXX="nco++"
else
NCOXX=""
fi
echo "DEBUG: enable_ncoxx: ${enable_ncoxx} and NCOXX = ${NCOXX}"
AC_SUBST(NCOXX)
# End config
# Prefix Flex output symbols with NCO string to avoid namespace conflict with flex-generated symbols from other programs/libraries
NCO_YY_PFX='nco_yy'
LEX_OUTPUT_ROOT="lex.${NCO_YY_PFX}"
LFLAGS="-P${NCO_YY_PFX}"
AC_SUBST(LEX_OUTPUT_ROOT)
AC_SUBST(LFLAGS)
# Every autoconf script finishes by calling AC_OUTPUT to generate and run config.status
AC_OUTPUT
# Echo build parameters for debugging
echo ""
echo "Configuration Parameters:"
echo "AR_FLAGS............. ${AR_FLAGS}"
echo "CC................... ${CC}"
echo "CFLAGS............... ${CFLAGS}"
echo "CPP.................. ${CPP}"
echo "CPPFLAGS............. ${CPPFLAGS}"
echo "CXX.................. ${CXX}"
echo "CXXFLAGS............. ${CXXFLAGS}"
echo "ENABLE_DAP_NETCDF.... ${enable_dap_netcdf}"
echo "ENABLE_DAP........... ${enable_dap}"
echo "ENABLE_GSL........... ${enable_gsl}"
echo "ENABLE_NETCDF4....... ${enable_netcdf4}"
echo "ENABLE_UDUNITS....... ${enable_udunits}"
echo "ENABLE_UDUNITS2...... ${enable_udunits2}"
echo "GSL_ROOT............. ${GSL_ROOT}"
echo "HAVE_NETCDF4_H....... ${header_defines_nc_chunked}"
echo "HOST................. ${HOST}"
echo "host................. ${host}"
echo "HOSTNAME............. ${HOSTNAME}"
echo "LDFLAGS.............. ${LDFLAGS}"
echo "LIBS................. ${LIBS}"
echo "NETCDF4_ROOT......... ${NETCDF4_ROOT}"
# Inform users of the very useful configure.eg
echo "*******************************************************************"
echo "Configuration complete. You are now ready to run 'make'."
echo "Ensure 'make' points to GNU Make (AT&T Make chokes on GNU syntax)."
echo "If the build fails, please examine the file 'configure.eg'"
echo "in the top-level NCO directory. It contains examples known to"
echo "build NCO for various platforms and compilers."
echo "*******************************************************************"
|