forked from NOAA-GFDL/GRTCODE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
117 lines (110 loc) · 3.7 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
AC_PREREQ([2.59])
AC_INIT([grtcode], [0.0], [[email protected]])
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-zip subdir-objects])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AC_C_CONST
AC_PROG_CPP
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_SYS_LARGEFILE
#Check for math library.
AC_CHECK_HEADER([math.h], [], [AC_MSG_ERROR([cannot find math.h])])
AC_CHECK_LIB([m], [pow], [], [AC_MSG_ERROR([cannot link -lm.])])
#Check for netcdf.
AC_CHECK_HEADER([netcdf.h], [], [AC_MSG_ERROR([cannot find netcdf.h])])
AC_CHECK_LIB([netcdf], [nc_open], [], [AC_MSG_ERROR([could not link libnetcdf.])])
#Provide an option to build in single precision.
AC_ARG_ENABLE([single_precision],
[--enable-single-precision Use single precision],
[case "${enableval}" in
yes) single_precision=true ;;
no) single_precision=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-single-precision]) ;;
esac],[single_precision=false])
AM_CONDITIONAL([USE_SINGLE_PRECISION], [test x$single_precision = xtrue])
#Provide an option to build with CUDA.
AC_ARG_VAR([NVCC], [nvcc compiler command])
AC_ARG_VAR([NVCCFLAGS], [nvcc compiler flags])
AC_ARG_VAR([NVCCLDFLAGS], [nvcc linker flags])
AC_ARG_ENABLE([cuda],
[--enable-cuda Enable ability to run on NVIDIA GPUs.],
[case "${enableval}" in
yes) cuda=true ;;
no) cuda=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-cuda]) ;;
esac],[cuda=false])
AM_CONDITIONAL([ENABLE_CUDA], [test x$cuda = xtrue])
if test x$cuda = xtrue
then
AC_PATH_PROG([NVCC], [nvcc], [no])
if test x$NVCC != xno
then
AC_MSG_CHECKING([whether nvcc works])
cat > conftest.cu <<EOF
__global__ void test(void)
{
int tid = blockIdx.x*blockDim.x + threadIdx.x;
return;
}
int main(void)
{
test<<<1, 32, 0, 0>>>();
return 0;
}
EOF
if $NVCC -x cu -w -o conftest.o -c conftest.cu && \
$NVCC -dlink -o conftest-device.o conftest.o && \
$CXX $LDFLAGS -o conftest.x conftest.o conftest-device.o -lcudart && \
./conftest.x
then
AC_MSG_RESULT([yes])
rm -f conftest.cu conftest.x
else
AC_MSG_RESULT([no])
rm -f conftest.cu conftest.x
AC_MSG_ERROR([nvcc could not compile/run executable])
fi
else
AC_MSG_ERROR([could not find nvcc])
fi
fi
#Provide an option to build fortran bindings.
AC_ARG_ENABLE([fortran],
[--enable-fortran Build fortran bindings.],
[case "${enableval}" in
yes) fortran=true ;;
no) fortran=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-fortran]) ;;
esac],[fortran=false])
AM_CONDITIONAL([FORTRAN_BINDINGS], [test x$fortran = xtrue])
AC_PROG_FC
#Provide an option to use DISORT.
AC_ARG_ENABLE([disort],
[--enable-disort Use disort solver.],
[case "${enableval}" in
yes) disort=true ;;
no) disort=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-disort]) ;;
esac],[disort=false])
AM_CONDITIONAL([USE_DISORT], [test x$disort = xtrue])
if test x$disort = xtrue
then
AC_CHECK_HEADER([cdisort.h], [], [AC_MSG_ERROR([cannot find cdisort.h])])
AC_CHECK_LIB([cdisort], [c_disort], [], [AC_MSG_ERROR([could not link libcdisort.])], [-lm])
fi
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile
utilities/Makefile utilities/src/Makefile
gas-optics/Makefile gas-optics/src/Makefile
cloud-optics/Makefile cloud-optics/src/Makefile
shortwave/Makefile shortwave/src/Makefile shortwave/test/Makefile
longwave/Makefile longwave/src/Makefile longwave/test/Makefile
rfmip-irf/Makefile rfmip-irf/src/Makefile rfmip-irf/test/Makefile
circ/Makefile circ/src/Makefile circ/test/Makefile
fortran-bindings/Makefile])
AC_OUTPUT