## -*- Autoconf -*- ## Process this file with autoconf to produce a configure script. # Autoconf initialization. ## This puts the cvs ID tag in the output configure script. AC_REVISION($Id: configure.in,v 1.109 2006/02/24 18:58:14 ed Exp $)dnl ## Running autoconf on this file will trigger a warning if ## autoconf is not at least version 2.59. AC_PREREQ(2.59) ## Initialize autoconf with name of project, version, and support ## email address. AC_INIT(netCDF, 3.6.1, support@unidata.ucar.edu) # Tell the user what version of netCDF we are building. AC_MSG_NOTICE([netCDF AC_PACKAGE_VERSION]) ## Autoconf will check for the existance of this file before proceeding. AC_CONFIG_SRCDIR([libsrc/nc.c]) # Find out about the host we're building on. AC_CANONICAL_HOST dnl After some deliberation, Russ decided that -g would be the best dnl default flag for CFLAGS. Recall that ${VAR-exp} expands to $VAR dnl if var is set (even to null), and to exp otherwise. #CFLAGS=${CFLAGS--g} # If F77 is set, and FC isn't, then set FC to whatever F77 was set to. if test "${F77+set}" = set -a "${FC+set}" != set; then FC=$F77 fi # Does the user want configure to keep hands off any compiler or # linker settings? AC_MSG_CHECKING([whether configure should try to set compiler flags]) AC_ARG_ENABLE([flag-setting], [AS_HELP_STRING([--disable-flag-setting], [Turn off configure's attempts to correctly set compiler and linker flags.])]) test "x$enable_flag_setting" = xno || enable_flag_setting=yes # If the user set any flags, then don't try and set any. if test "x${CPPFLAGS+set}" = xset; then enable_flag_setting=no fi if test "x${CFLAGS+set}" = xset; then enable_flag_setting=no fi if test "x${CXXFLAGS+set}" = xset; then enable_flag_setting=no fi if test "x${FFLAGS+set}" = xset; then enable_flag_setting=no fi if test "x${FCFLAGS+set}" = xset; then enable_flag_setting=no fi AC_MSG_RESULT($enable_flag_setting) # Autoconf seems to like FCFLAGS, but netcdf has used FFLAGS. Let's # just grab anything that's in FCFLAGS and continue to use FFLAGS. FFLAGS=${FFLAGS-${FCFLAGS}} # Does the user want to build in 64-bit mode? AC_MSG_CHECKING([whether netCDF is to be built in 64-bit mode]) AC_ARG_ENABLE([64-bit], [AS_HELP_STRING([--enable-64bit], [set flags to build in 64-bit mode(only supported on HPUX, SunOS, IRIX, and AIX)])]) test "x$enable_64bit" = xyes || enable_64bit=no AC_MSG_RESULT($enable_64bit) if test "$enable_flag_setting" = no -a "$enable_64bit" = yes; then AC_MSG_ERROR([incompatible settings - cannot enable-64bit and disable-flag-setting], 1) fi if test "x$enable_64bit" = xyes; then AC_MSG_NOTICE([setting flags to build in 64-bit mode]) AC_MSG_CHECKING(if we can set flags for 64 bit) nc_result=no case "$host_os" in *aix*) CFLAGS="$CFLAGS -q64" FFLAGS="$FFLAGS -q64" F90FLAGS="$F90FLAGS -q64" ARFLAGS="$ARFLAGS -X64 cru" NMFLAGS="$NMFLAGA -X64" nc_result=yes ;; *irix*) CFLAGS="$CFLAGS -64" CXXFLAGS="$CXXFLAGS -64" FCFLAGS="$FCFLAGS -64" FFLAGS="$FFLAGS -64" F90FLAGS="$F90FLAGS -64" nc_result=yes ;; *solaris*) CFLAGS="$CFLAGS -xarch=v9" FFLAGS="$FFLAGS -xarch=v9" FCLAGS="$FCFLAGS -xarch=v9" CXXFLAGS="$CXXFLAGS -xarch=v9" F90FLAGS="$F90FLAGS -xarch=v9" nc_result=yes ;; *hpux*) CFLAGS="$CFLAGS +DD64" FFLAGS="$FFLAGS -w +noppu +DA2.0W" nc_result=yes ;; esac AC_MSG_RESULT([$nc_result]) fi # If the env. variable TEMP_LARGE is set, use it as a place for the # large (i.e. > 2 GiB) files created during the large file testing. AC_MSG_CHECKING([where to put large files]) TEMP_LARGE=${TEMP_LARGE-.} AC_MSG_RESULT($TEMP_LARGE) AC_SUBST(TEMP_LARGE) UD_SRCDIR AC_PROG_CC(pathcc xlc icc cc c89 acc gcc) # If the user has set CXX to null, we skip C++ interface. case "${CXX+set}" in set) case "$CXX" in '') AC_MSG_WARN([[CXX set to NULL, C++ interface will not be built.]]) ;; *) AC_PROG_CXX(${CXX}) ;; esac ;; *) case "$host" in *cygwin*|*osf*|*apple*) AC_PROG_CXX(g++) ;; *) AC_PROG_CXX(pathCC cl KCC CC icpc cxx cc++ xlC aCC c++ g++ egcs gcc) ;; esac ;; esac case "$CXX" in '') ;; *) # On some systems, a discovered compiler nevertheless # won't work (because it's a script to a non-existant # executable, for example); thus, we check the compiler # with a test program. We also test for "iostream" and # the standard C++ library because we need these to # work. AC_MSG_CHECKING(C++ compiler \"$CXX\") AC_LANG_SAVE() AC_LANG_CPLUSPLUS() AC_TRY_RUN( [ #include int main() { std::cout << ""; return 0; } ], [ AC_MSG_RESULT(works) ], [ AC_MSG_WARN($CXX failed on standard C++ test program) CXX= unset ac_cv_prog_CXX ]) AC_LANG_RESTORE() ;; esac # If the user has set FC to null, we skip F77 and F90 interface. # If it's not set at all, try and find a compiler. Then there are a # lot of things to check relating to the fortran compiler, mostly for # flags that are required for some platforms. case "${FC+set}" in set) case "$FC" in '') AC_MSG_WARN([[FC set to NULL, F77 and F90 interfaces will not be built.]]) ;; esac ;; *) AC_PROG_FC(pathf90 xlf fort xlf95 ifort ifc efc pgf95 lf95 g95 f95 gfortran frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77 ) ;; esac # Intel C compiler needs -mp flag. if test "x$enable_flag_setting" = xyes; then AC_MSG_CHECKING([if we're using the Intel C compiler and need -mp option in CFLAGS]) case "$CC" in *icc*) CFLAGS="${CFLAGS} -mp" ;; esac AC_MSG_RESULT($CFLAGS) fi # If FC isn't set, we couldn't find a fortran compiler. case "${FC+set}" in set) case "$FC" in '') AC_MSG_WARN([[No fortran compiler found, F77 and F90 interfaces will not be built.]]) ;; *) if test "x$enable_flag_setting" = xyes; then AC_MSG_CHECKING([if we need special ifort options on Linux]) case "$host_os-$FC" in *linux*-*ifort*) case "$FFLAGS" in *-mp*) ;; *) FFLAGS="${FFLAGS} -mp -recursive" ;; esac ;; esac AC_MSG_RESULT(FFLAGS=$FFLAGS) # on AIX, with xlf90, we need a suffux related option to pass f90 test. AC_MSG_CHECKING([if we need special f90 options with xlf]) case "$FC" in *xlf*) case "${F90+set}" in set);; *) F90=xlf90;; esac case "$F90FLAGS" in *qsuffix*) ;; *) F90FLAGS="-qsuffix=f=f90 ${F90FLAGS}";; esac ;; esac AC_MSG_RESULT(F90LAGS=$F90FLAGS) fi # If it is set, test various things about it. AC_PROG_FC("$FC") if test "x$enable_flag_setting" = xyes; then dnl Add -DpgiFortran to CPPFLAGS if we're using a Portland Group dnl compiler. Add -Df2cFortran if we're using a GNU fortran 77 dnl compiler, and no F90 compiler. In either case, make sure it's dnl not already in CPPFLAGS before we add it, so it dnl doesn't show up twice, and look ugly. AC_MSG_CHECKING(Fortran compilers values) AC_MSG_RESULT(FC=$FC F77=$F77 F90=$F90) AC_MSG_CHECKING(if Fortran-related pre-processor flag needed) case "$FC" in *pgf95*|*pgf90*|*pgf77*|*ifort*) CPPFLAGS="${CPPFLAGS} -DpgiFortran" ;; *lf95*|*lf90*) CPPFLAGS="${CPPFLAGS} -DNAGf90Fortran" ;; *pathf95*|*pathf90*) CPPFLAGS="${CPPFLAGS} -Df2cFortran" ;; *) if test x$ac_cv_fc_compiler_gnu = xyes; then if test x$FC = xg77 -o x$FC = xf77 -o x$FC = xg95 -o x$FC = xgfortran; then CPPFLAGS="${CPPFLAGS} -Df2cFortran" else CPPFLAGS="${CPPFLAGS} -DpgiFortran" fi fi ;; esac AC_MSG_RESULT($CPPFLAGS) # The HP-UX fortran compiler needs a library for the # linker to get getopts. Also needs CPPFLAGS to include # -D_HPUX_SOURCE if c89 compiler is used. case "$host" in *hpux*) dnl AC_MSG_CHECKING([if FLIBS needs extra F77 lib]) dnl case "$FC" in dnl *f77*|*fort77*|*f90*) dnl if test "x$ac_cv_fc_compiler_gnu" != xyes; then dnl FLIBS="${FLIBS} -lU77" dnl fi dnl ;; dnl esac dnl AC_MSG_RESULT($FLIBS) AC_MSG_CHECKING([if -D_HPUX_SOURCE should be in CPPFLAGS]) case "$CC" in *c89*) CPPFLAGS="${CPPFLAGS} -D_HPUX_SOURCE" ;; esac AC_MSG_RESULT($CPPFLAGS) ;; esac fi # Now check for F90 compiler. UD_PROG_F90 ;; esac ;; esac AC_PREFIX_DEFAULT(`(cd ..; pwd)`) AC_CONFIG_HEADER( config.h:ncconfig.in fortran/nfconfig.inc:fortran/nfconfig.in ) dnl UD_CONFIG_HEADER(fortran/nfconfig.inc:fortran/nfconfig.in) dnl AC_DEFINE(_ANSI_C_SOURCE) dnl AC_DEFINE(_POSIX_SOURCE) dnl AC_DEFINE(_XOPEN_SOURCE) UD_PROG_M4 UD_PROG_CC_MAKEDEPEND if test "x$enable_flag_setting" = xyes; then # AC_SYS_LARGEFILES doesn't seem to work on solaris with the c89 # compiler, unless the -Xa flag is used, so take care of that... case "$host_os" in *solaris*) if test "$CC" = c89; then case "${CPPFLAGS}" in *-Xa*) ;; *) CPPFLAGS="$CPPFLAGS -Xa" ;; esac fi ;; esac # AC_SYS_LARGEFILE has problems on AIX when OBJECT_MODE is 64. AC_MSG_CHECKING([if we need to set _LARGE_FILES despite results of previous tests]) if test "$enable_largefile" != no; then case "$host_os" in *aix*) if test "$OBJECT_MODE" = 64; then AC_DEFINE(_LARGE_FILES, [1], [Turned on by netCDF configure.]) fi case "$CFLAGS" in *q64*) AC_DEFINE(_LARGE_FILES, [1], [Turned on by netCDF configure.]) ;; esac ;; *hpux*) AC_DEFINE(_FILE_OFFSET_BITS, [64], [Turned on by netCDF configure.]) ;; esac fi AC_MSG_RESULT(${_LARGE_FILES}) fi AC_SYS_LARGEFILE UD_PROG_AR() UD_PROG_NM() AC_PROG_RANLIB AC_PROG_INSTALL ## This next macro just prints some results for debugging ## support issues. UD_DISPLAY_RESULTS # Calling signal(3) to ignore SIGFPE in the f90(1) environment # on SunOS SunOS 5.9 doesn't work on i386 platform without this # setting compiler flag ftrap on the sun compilers. if test "x$enable_flag_setting" = xyes; then AC_MSG_CHECKING(for SunOS Fortran -ftrap= option) if test "$host_cpu" = i386; then case "$host_os-$FC" in solaris*-*f90|solaris*-*f95) IGNORE_FPE=-ftrap=no%overflow ;; esac fi IGNORE_FPE=${IGNORE_FPE-} AC_MSG_RESULT($IGNORE_FPE) AC_SUBST(IGNORE_FPE) fi UD_FORTRAN_TYPES UD_CHECK_LIB_MATH AC_CHECK_HEADER(stdlib.h, ,AC_DEFINE(NO_STDLIB_H)) AC_CHECK_HEADER(sys/types.h, ,AC_DEFINE(NO_SYS_TYPES_H)) AC_CHECK_FUNC(strerror, ,AC_DEFINE(NO_STRERROR)) AC_CHECK_FUNC(strlcat,AC_DEFINE([HAVE_STRLCAT],1,[Define this if you have strlcat()])) UD_CHECK_FTRUNCATE AC_FUNC_ALLOCA AC_STRUCT_ST_BLKSIZE UD_CHECK_IEEE AC_TYPE_SIZE_T AC_TYPE_OFF_T AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(ptrdiff_t, int) AC_CHECK_TYPE(uchar, unsigned char) AC_C_CHAR_UNSIGNED AC_C_BIGENDIAN AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) UD_CHECK_SIZEOF(off_t) UD_CHECK_SIZEOF(size_t) UD_MAKEWHATIS UD_FTPBINDIR dnl dnl Ensure that the Fortran "header-file" "fortran/nfconfig.inc" doesn't dnl contain any C-style comments. AC_OUTPUT(macros.make, [sed '1d;s%^/\* \(.*\) \*/%\1%' fortran/nfconfig.inc >conftest.tmp mv conftest.tmp fortran/nfconfig.inc] )