Newer
Older
[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],
[
export -p | grep MKL
MKL_DEF=$?
if test "x$MKL_DEF" = "x0"; then
export LAPACKFLAGS="-DUSE_LAPACK -DLAPACK_ILP64 -DUSE_ILP64 -I{MKLROOT}/include"
export LAPACKLDFLAGS="-L${MKLROOT}/lib -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"
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
if test -f /usr/include/lapacke.h; then
export LAPACKFLAGS="-DUSE_LAPACK -DLAPACK_ILP64 -DUSE_ILP64"
export LAPACKLDFLAGS="-llapacke64"
fi
fi
]
)
m4_define(
[M4_DETECT_MAGMA],
[
if test "x$CUDA_LIB" = "x"; then
export -p | grep CUDA
CUDA_DEF=$?
if test "x$CUDA_DEF" = "x0"; then
CUDA_LIB=${CUDA_HOME}/targets/x86_64-linux/lib
else
CUDA_LIB=/usr/local/cuda/targets/x86_64-linux/lib
fi
fi
export -p | grep MAGMA
MAGMA_DEF=$?
if test "x$MAGMA_DEF" = "x0"; then
export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 -I${MAGMA_INCLUDE}"
export MAGMALDFLAGS="-L${CUDA_LIB} -lcudart -L${MAGMA_LIB} -lmagma"
else
if test "x$MAGMA_INCLUDE" != "x"; then
export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64 -I${MAGMA_INCLUDE}"
else
if test -f /usr/include/magma_v2.h; then
export MAGMAFLAGS="-DUSE_MAGMA -DMAGMA_ILP64"
fi
fi
if test "x$MAGMA_LIB" != "x"; then
export MAGMALDFLAGS="-L${CUDA_LIB} -lcudart -L${MAGMA_LIB} -lmagma"
else
if test -f /usr/include/magma_v2.h; then
export MAGMALDFLAGS="-L${CUDA_LIB} -lcudart -lmagma"
fi
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])
AC_CONFIG_AUX_DIR([build_aux])
# automake initialization
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
# Compiler detection
AM_PROG_AR
[AS_HELP_STRING([--enable-mpi], [enable MPI compilation [default=auto]])],
if test "x$enableval" = "xno"; then
if test "x$CXX" = "x"; then
AC_PROG_CXX([g++ clang++])
else
AC_PROG_CXX([$CXX])
fi
AC_MSG_NOTICE([Using $CXX])
AC_SUBST([MPIFLAGS], [""])
elif test "x$enableval" = "xauto"; then
AC_PROG_CXX([mpicxx mpic++ mpiCC])
if test "x$CXX" != "x"; then
AC_SUBST([MPIFLAGS], [-DUSE_MPI])
else
AC_PROG_CXX([g++ clang++])
AC_SUBST([MPIFLAGS], [""])
fi
elif test "x$enableval" = "xyes"; then
AC_PROG_CXX([mpicxx mpic++ mpiCC])
if test "x$CXX" != "x"; then
AC_SUBST([MPIFLAGS], [-DUSE_MPI])
else
AC_MSG_ERROR([MPI was requested, but no MPI compiler detected!])
fi
fi
],
[
if test "x$CXX" = "x"; then
AC_PROG_CXX([mpicxx mpic++ mpiCC])
if test "x$CXX" != "x"; then
AC_SUBST([MPIFLAGS], [-DUSE_MPI])
else
AC_PROG_CXX([g++ clang++])
AC_SUBST([MPIFLAGS], [""])
AC_MSG_NOTICE([Using $CXX])
fi
AC_PROG_CXX([$CXX])
# Check whether the compiler is clang++ (needs additional flags)
CXX_IS_CLANG=$($CXX --version | grep clang)
AS_IF(
[test "x$CXX_IS_CLANG" = "x0"],
[AC_SUBST([CLANGFLAGS], [-stdlib=libstdc++])],
[AC_SUBST([CLANGFLAGS], [""])]
)
# 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!"])]
[test "x$LAPACKLDFLAGS" != "x"],
[AC_MSG_NOTICE([LAPACK detected. Activating by default (use --without-lapack to disable).])],
[AC_MSG_NOTICE([No LAPACK found.])]
)
M4_DETECT_MAGMA
AS_IF(
[test "x$MAGMALDFLAGS" != "x"],
[AC_MSG_NOTICE([MAGMA detected. Activating by default (use --without-magma to disable).])],
[AC_MSG_NOTICE([MAGMA not 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([LAPACKFLAGS], [""])
AC_SUBST([LAPACKLDFLAGS], [""])
else
AC_SUBST([LAPACKFLAGS], [${LAPACKFLAGS}])
AC_SUBST([LAPACKLDFLAGS], [${LAPACKLDFLAGS}])
AC_SUBST([LAPACKFLAGS], [${LAPACKFLAGS}])
AC_SUBST([LAPACKLDFLAGS], [${LAPACKLDFLAGS}])
]
)
AC_ARG_WITH(
[magma],
[AS_HELP_STRING([--with-magma], [use MAGMA @<:@default=check@:>@])],
[
if test "x$withval" = "xno"; then
AC_SUBST([MAGMAFLAGS], [""])
AC_SUBST([MAGMALDFLAGS], [""])
else
AC_SUBST([MAGMAFLAGS], [${MAGMAFLAGS}])
AC_SUBST([MAGMALDFLAGS], [${MAGMALDFLAGS}])
fi
],
[
AC_SUBST([MAGMAFLAGS], [${MAGMAFLAGS}])
AC_SUBST([MAGMALDFLAGS], [${MAGMALDFLAGS}])
]
AC_ARG_ENABLE(
[nvtx],
[AS_HELP_STRING([--enable-nvtx], [use NVTX profiling @<:@default=no@:>@])],
[
if test "x$enableval" = "xyes"; then
AC_SUBST([NVTXFLAGS], ["-DUSE_NVTX"])
fi
],
[
AC_SUBST([NVTXFLAGS], [""])
]
)
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
# Test for additional user configurations
# Test for specific include folders
AC_ARG_WITH(
[include],
[AS_HELP_STRING([--with-include], [additional include folders @<:@default=none@:>@])],
[
if test "x$with_val" != "x"; then
AC_SUBST([USER_INCLUDE], [$with_val])
fi
],
[AC_SUBST([USER_INCLUDE], [""])]
)
# Test for special FORTRAN compiler flags
AC_ARG_WITH(
[fflags],
[AS_HELP_STRING([--with-fflags=flags], [FORTRAN compiler flags @<:@default="-std=legacy -O3"@:>@])],
[
if test "x$with_val" != "x"; then
AC_SUBST([FFLAGS], [$with_val])
fi
],
[
AC_SUBST([FFLAGS], ["-std=legacy -O3"])
]
)
# Test for special linker flags
AC_ARG_WITH(
[ldflags],
[AS_HELP_STRING([--with-ldflags=flags], [custom linker flags @<:@default=none@:>@])],
[
if test "x$with_val" != "x"; then
AC_SUBST([USER_LDFLAGS], [$with_val])
fi
],
[
AC_SUBST([USER_LDFLAGS], [""])
]
)
CXXFLAGS="$CLANGFLAGS -O3 -ggdb $USER_INCLUDE -I$HDF5_INCLUDE $OMPFLAGS $MPIFLAGS $LAPACKFLAGS $MAGMAFLAGS $NVTXFLAGS"
SUBDIRS="cluster libnptm sphere testing trapping"
# Send output to Makefiles
AC_CONFIG_FILES([Makefile])
# Generate the output
AC_OUTPUT