-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
202 lines (181 loc) · 6.09 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
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([datapoll], [0.0.1], [ipe_devteam@noaa.gov])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE
# Checks for programs.
AC_PROG_SED
# Set ddefault language
AC_LANG_PUSH([Fortran])
# Looks for required libraries
ext_libs=""
# - ESMF
AX_LIB_ESMF
AS_IF([test "$with_esmf" = no],
[AC_MSG_ERROR([Unable to find required ESMF library])],
[ext_libs="${ext_libs} ESMF"])
# Looks for Fortran compiler
# Assume we are cross compiling by default to prevent issues on WCOSS-Cray
save_cross_compiling=${cross_compiling}
cross_compiling=yes
# Silence resulting warning
save_ac_tool_warned=${ac_tool_warned}
ac_tool_warned=yes
AC_PROG_FC([${FC} ${ESMF_FC} mpiifort mpifort mpif90 mpixlf90_r mpxlf90_r])
# Restore original cross compilation settings
cross_compiling=${save_cross_compiling}
ac_tool_warned=${save_ac_tool_warned}
# Checks if Fortran compiler supports MPI
AC_MSG_CHECKING([whether MPI is supported])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[dnl
use mpi
integer, parameter :: comm = MPI_COMM_WORLD
])],
[AC_DEFINE([HAVE_MPI], [1])
AC_MSG_RESULT(yes)],
[dnl No MPI found. Disable compiler.
FC=
AC_MSG_RESULT(no)
AC_MSG_ERROR([Cannot find a suitable MPI Fortran compiler.])]
)
AC_FC_PP_SRCEXT([F90])
AX_COMPILER_VENDOR
# Add configure options
# - debug
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[enable debug mode (default: no).])],
[enable_debug=${enableval}], [enable_debug=no])
# Checks for debug/optimization options
AS_IF([test "x$enable_debug" = xyes],[
AC_MSG_CHECKING([compiler for debug options])
save_FCFLAGS=${FCFLAGS}
FCFLAGS=`echo $FCFLAGS | $SED -e 's/-O@<:@0-9s@:>@*//g'`
FCFLAGS=`echo $FCFLAGS | $SED -e 's/-g@<:@0-9@:>@*//g'`
debug_opts=
AS_CASE(["$ax_cv_fc_compiler_vendor"],
[gnu|clang], [debug_opts="-Wall -Wno-unused -Wno-unused-dummy-argument -fbacktrace"],
[ibm], [debug_opts="-qcheck -qfullpath"],
[intel], [debug_opts="-traceback -check pointer,stack,uninit"],
[portland], [debug_opts="-traceback"],
[] dnl no debug options available for other platforms
)
AS_IF([test "x$ac_cv_prog_fc_g" = xyes], [debug_opts="-g ${debug_opts}"], [])
FCFLAGS="-O0 ${debug_opts} ${FCFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[],
[FCFLAGS=${save_FCFLAGS}
debug_opts="unknown. Please add debug flags to FCFLAGS"]
)
AC_MSG_RESULT([${debug_opts}])
], [dnl default optimization settings, if none present
AC_MSG_CHECKING([compiler for optimization options])
fcflags_noopt=
perf_opts=
for fc_flag in $FCFLAGS
do
AS_CASE([$fc_flag],
[-O@<:@0-9s@:>@*|-Ofast], [perf_opts=$fc_flag], dnl find optimization settings
[fcflags_noopt="$fcflags_noopt $fc_flag"]
)
done
AS_IF([test "x$perf_opts" = x], [dnl add default optimization settings
AS_CASE(["$ax_cv_fc_compiler_vendor"],
[gnu|clang], [dnl
perf_opts="-O2"
AS_IF([test "x$enable_safe_fp" != xno],
[perf_opts="${perf_opts} -fno-unsafe-math-optimizations"],[])],
[ibm], [perf_opts="-O2"],
[intel], [dnl
perf_opts="-O2"
AS_IF([test "x$enable_safe_fp" != xno],
[perf_opts="${perf_opts} -fp-model source -ftz -align array64byte -xCORE-AVX2 -qno-opt-dynamic-align"],[])],
[portland], [dnl
perf_opts="-O2"
AS_IF([test "x$enable_safe_fp" != xno],
[perf_opts="${perf_opts} -Kieee"],[])],
[] dnl no debug options available for other platforms
)], [])
AS_IF([test "x$perf_opts" = x], [dnl optization flags unknown
perf_opts=unknown],
[dnl test optimization flags
save_FCFLAGS=${fcflags_noopt}
FCFLAGS="${fcflags_noopt} ${perf_opts}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[],
[FCFLAGS=${save_FCFLAGS}
perf_opts=unknown]
)
]
)
AC_MSG_RESULT([$perf_opts])
]
)
# Checks for compiler characteristics
AC_FC_MODULE_EXTENSION
AC_FC_MODULE_FLAG
# Adds library include paths
fc_inc=
for incpath in ${ESMF_FCFLAGS}
do
incpath=`echo "${incpath}" | $SED -e's/^-@<:@A-Z,a-z@:>@*\//\//g'`
fc_inc="${fc_inc}${FC_MODINC}${incpath} "
done
AC_MSG_CHECKING([whether include flags work])
FCFLAGS="${fc_inc}${FCFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])],
[dnl ESMF-derived include flags may be corrupted. Abort.
AC_MSG_RESULT([no])
AC_MSG_FAILURE([unrecognized include flags])]
)
# Checks whether libraries are compatible with Fortran compiler
for lib in ${ext_libs}
do
AC_MSG_CHECKING([whether ${lib} works])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[dnl
use ${lib}
])],
[AC_MSG_RESULT(yes)],
[dnl ESMF is incompatible with selected Fortran compiler or not found. Abort.
AC_MSG_RESULT(no)
AC_MSG_FAILURE([${lib} library incompatible or not found])]
)
done
AC_LANG_POP
# Set linker flags
DATAPOLL_DEP_LINK_OBJS="${libdir}/libdatapoll.a"
DATAPOLL_DEP_SHRD_PATH="`echo ${LDFLAGS} | $SED -e's/-L//g'`"
DATAPOLL_DEP_SHRD_LIBS="`echo ${LIBS} | $SED -e's/-l//g'`"
AC_SUBST([DATAPOLL_DEP_LINK_OBJS])
AC_SUBST([DATAPOLL_DEP_SHRD_PATH])
AC_SUBST([DATAPOLL_DEP_SHRD_LIBS])
# Checks for auxiliary build tools
AC_PROG_INSTALL
AC_PROG_RANLIB
AM_PROG_AR
# Output Makefiles
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
AS_ECHO("")
AS_ECHO("${PACKAGE_NAME} version ${PACKAGE_VERSION} successfully configured.")
AS_ECHO("")
AS_ECHO("Compiler settings:")
AS_ECHO(" FC = ${FC}")
AS_ECHO(" F77 = ${F77}")
AS_ECHO(" FCFLAGS = ${FCFLAGS}")
AS_ECHO(" FFLAGS = ${FCFLAGS}")
AS_ECHO(" LDFLAGS = ${LDFLAGS}")
AS_ECHO(" LIBS = ${LIBS}")
AS_ECHO("")
AS_ECHO("Libraries required:")
AS_ECHO("* ESMF")
AS_ECHO(" Version: ${ESMF_VERSION}")
AS_ECHO(" FC : ${ESMF_FC}")
AS_ECHO(" FCFLAGS: ${ESMF_FCFLAGS}")
AS_ECHO(" Settings imported from ESMF Makefile fragment: ${ESMFMKFILE}")
AS_ECHO("")
AS_ECHO("Type 'make' to build.")