Skip to content
Snippets Groups Projects
configure.ac 5.77 KiB
Newer Older
  • Learn to ignore specific revisions
  • # CAPABILITY TESTING MACROS
    
      [M4_HDF5_LIB],
      [
        cat > nptm_test_hdf5.cpp <<EOF
    
    #include <hdf5.h>
    int main(int argc, char **argv) {
      hid_t file_id = 0;
      herr_t status = H5Iis_valid(file_id);
      return (int)status;
    }
    EOF
    
        $CXX -o nptm_test_hdf5 nptm_test_hdf5.cpp -I$HDF5_INCLUDE -L$HDF5_LIB -lhdf5 > /dev/null 2>>error.log
        export TEST_HDF5_LIB=$?
        rm nptm_test_hdf5.cpp
        if test "x$TEST_HDF5_LIB" = "x0"; then
          rm nptm_test_hdf5
        fi
      ]
    )
    
    m4_define(
      [M4_DETECT_LAPACK],
      [
        LAPACK_ROOT=$MKLROOT
        if test "x$LAPACK_ROOT" != "x"; then
          export LAPACK_INCLUDE=$(MKLROOT)/include
          export LAPACK_LIB=$(MKLROOT)/lib
          export LAPACK_LIBRARY="-Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
        else
          export LAPACK_INCLUDE=/usr/include
          export LAPACK_LIB=/lib/x86_64-linux-gnu
          export LAPACK_LIBRARY="-llapacke64"
        fi
      ]
    
    # END CAPABILITY TESTING MACROS
    
    # autoconf setup initialization
    AC_INIT([np_tmcode], [8.04], [giovanni.lamura@inaf.it])
    
    # Folder structure safety check
    
    AC_CONFIG_SRCDIR([../src/libnptm/TransitionMatrix.cpp])
    
    
    # Auxiliary build folder
    
    AC_CONFIG_AUX_DIR([build_aux])
    
    
    # automake initialization
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    
    # Compiler detection
    AM_PROG_AR
    
    AC_ARG_ENABLE(
    
      [mpi],
      [AS_HELP_STRING([--enable-mpi], [use MPI if available [default=yes]])],
      [
        if test "x$enableval" = "xno"; then
          if test "x$F77" = "xmpif90"; then
            gfortran --version > /dev/null
            if test "x$?" = "x0"; then
              AC_SUBST([F77], [gfortran])
            fi
          fi
          if test "x$F77" = "xmpif90"; then
            f77 --version > /dev/null
            if test "x$?" = "x0"; then
              #export F77=f77
              AC_SUBST([F77], [f77])
            fi
          fi
          if test "x$CXX" = "xmpicxx"; then
            g++ --version > /dev/null
            if test "x$?" = "x0"; then
              #export CXX=g++
              AC_SUBST([CXX], [g++])
            fi
          fi
          if test "x$CXX" = "xmpicxx"; then
            clang --version > /dev/null
            if test "x$?" = "x0"; then
              #export CXX=clang
              AC_SUBST([CXX], [clang])
            fi
          fi
          if test "x$F77" = "x"; then
            gfortran --version > /dev/null
            if test "x$?" = "x0"; then
              #export F77=gfortran
              AC_SUBST([F77], [gfortran])
            fi
          fi
          if test "x$F77" = "x"; then
            f77 --version > /dev/null
            if test "x$?" = "x0"; then
              #export F77=f77
              AC_SUBST([F77], [f77])
            fi
          fi
          if test "x$CXX" = "x"; then
            g++ --version > /dev/null
            if test "x$?" = "x0"; then
              #export CXX=g++
              AC_SUBST([CXX], [g++])
            fi
          fi
          if test "x$CXX" = "x"; then
            clang --version > /dev/null
            if test "x$?" = "x0"; then
              #export CXX=clang
              AC_SUBST([CXX], [clang])
            fi
          fi
        else
          mpicxx --version > /dev/null
          if test "x$?" = "x0"; then
            #export CXX=mpicxx
            #export F77=mpif90
            AC_SUBST([CXX], [mpicxx])
            AC_SUBST([F77], [mpif90])
          else
            AC_MSG_ERROR(["MPI was enabled, but no MPI compiler was found!"])
          fi
        fi
      ],
      [
        if test "x$CXX" = "x"; then
          mpicxx --version > /dev/null
          if test "x$?" = "x0"; then
            #export CXX=mpicxx
            #export F77=mpif90
            AC_SUBST([CXX], [mpicxx])
            AC_SUBST([F77], [mpif90])
          fi
        fi
        if test "x$CXX" = "x"; then
          g++ --version > /dev/null
          if test "x$?" = "x0"; then
            #export CXX=g++
            AC_SUBST([CXX], [g++])
          fi
        fi
        if test "x$CXX" = "x"; then
          clang --version > /dev/null
          if test "x$?" = "x0"; then
            #export CXX=clang
            AC_SUBST([CXX], [clang])
          fi
        fi
      ]
    
    AC_PROG_CXX([$CXX])
    AC_PROG_F77([$F77])
    
    
    # Libtool initialization
    LT_INIT
    
    # Environment setup
    AS_IF(
    
      [test "x$HDF5_INCLUDE" = "x"],
      [AC_SUBST([HDF5_INCLUDE], ["/usr/include/hdf5/serial"])],
      [AC_MSG_NOTICE([HDF5_INCLUDE=$(HDF5_INCLUDE)])]
    
      [test "x$HDF5_LIB" = "x"],
      [AC_SUBST([HDF5_LIB], ["/usr/lib/x86_64-linux-gnu/hdf5/serial"])],
      [AC_MSG_NOTICE([HDF5_LIB=$(HDF5_LIB)])]
    
    
    # Check for required headers
    AC_CHECK_HEADER(
    
      [$HDF5_INCLUDE/hdf5.h],
      ,
      AC_MSG_ERROR(["Could not find HDF5 headers!]),
    )
    
    # Check for required libraries
    M4_HDF5_LIB
    AS_IF(
    
      [test "x$TEST_HDF5_LIB" = "x0"],
      [AC_SUBST([HDF5_LDFLAGS], ["-L${HDF5_LIB} -lhdf5"])],
      [AC_MSG_ERROR(["HDF5 library not found!"])]
    
    # Configure the optional features
    
    M4_DETECT_LAPACK
    AS_IF(
      [test "x$LAPACK_LIBRARY" != "x"],
      [AC_MSG_NOTICE([LAPACK detected])],
      [AC_MSG_NOTICE([No LAPACK found])]
    )
    
    AC_ARG_ENABLE(
      [openmp],
      [AS_HELP_STRING([--enable-openmp], [enable OpneMP multi-threading [default=yes]])],
      [
        if test "x$enableval" != "xno"; then
          AC_SUBST([OMPFLAGS], ["-fopenmp"])
        fi
      ],
      [
        AC_SUBST([OMPFLAGS], ["-fopenmp"])
      ]
    )
    
    AC_ARG_WITH(
      [lapack],
      [AS_HELP_STRING([--with-lapack], [use LAPACK @<:@default=check@:>@])],
      [
        if test "x$withval" = "xno"; then
          AC_SUBST([LAPACK_FLAGS], [""])
          AC_SUBST([LAPACK_LDFLAGS], [""])
        fi
      ],
      [
        if test "x$LAPACK_INCLUDE" != "x"; then
          AC_SUBST([LAPACK_FLAGS], ["-DUSE_LAPACK -DLAPACK_ILP64 -DUSE_ILP64 -I${LAPACK_INCLUDE}"])
          AC_SUBST([LAPACK_LDFLAGS], ["-L${LAPACK_LIB} ${LAPACK_LIBRARY}"])
        fi
      ]
    )
    
    AC_ARG_WITH(
      [magma],
      [AS_HELP_STRING([--with-magma], [use MAGMA @<:@default=check@:>@])],
      [],
      []
    )
    
    AC_ARG_ENABLE(
      [ilp64],
      [AS_HELP_STRING([--enable-ilp64], [use MAGMA @<:@default=check@:>@])],
      [],
      []
    )
    
    FFLAGS="-std=legacy -O3"
    CXXFLAGS="-O3 -ggdb -Wno-format-contains-nul -I$HDF5_INCLUDE $OMPFLAGS $LAPACK_FLAGS"
    SUBDIRS="cluster libnptm sphere testing trapping"
    
    # Send output to Makefiles
    AC_CONFIG_FILES([Makefile])
    
    # Generate the output
    AC_OUTPUT