-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
432 lines (368 loc) · 10.4 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# configure.ac (2018-08-27)
# KMR only needs compilers for MPI, usually "mpicc" and "mpif90", but
# it needs to select other ones in some environments like Fujitsu and
# Cray. Thus, it does not run "AC_REQUIRE(AC_PROG_CC)" with normal
# CC, but runs it only after finding MPICC. "m4_define"/"m4_undefine"
# are used for this purpose to place test code after finding MPICC.
# So, at first, it fails to test on compiling with "mpi.h" because
# MPICC is not yet found. On K and FX10, C/CXX/FC FLAGS are
# explicitly set to skip adding "-g", because Fujitsu compilers
# generate slow code with "-g".
AC_INIT([KMR], [1], [], [], [https://github.com/RIKEN-RCCS/kmr])
AC_PREREQ([2.69])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([config.make])
# Update these variables for a new version of KMR. "version" is the
# version and "release_date" is its release date.
version="1.10"
release_date="20201116"
# It sets {target_os}, which is used to add rt library for
# clock_gettime() in Linux.
AC_CANONICAL_TARGET
# Settings for Fujitsu platforms.
if test -d /opt/FJSVtclang -o -d /opt/FJSVfxlang; then
echo "*** This configure does not support K, FX10, FX100 any more. ***"
echo "*** Please fix config.make by hand, sorry. ***"
echo "*** CFLAGS=-Kfast,preex -Xg -std=gnu99 ***"
echo "*** CXXFLAGS=-Kfast,preex -Xg ***"
echo "*** LIBS=-L/opt/FJSVpxtof/sparc64fx/lib64 -ltofutop -ltofucom ***"
fi
! test -d /opt/FJSVtclang -o -d /opt/FJSVfxlang -o \
-d /opt/FJSVxtclanga; fujitsuplatform=$?
# Record of Fujitsu software version.
AC_SUBST(KMRFJSV) #[K/FX10 software version]
if test "1" -eq "$fujitsuplatform"; then
test -z "$host_alias" && host_alias=arm-unknown-linux
test "$cross_compiling"!="yes" && cross_compiling=maybe
test -z "$CC" && CC=fccpx
test -z "$CXX" && CXX=FCCpx
test -z "$F77" && F77=frtpx
test -z "$F90" && F90=frtpx
test -z "$LD" && LD=ldpx
if command -v mpifccpx >/dev/null 2>&1; then
fjsv=`command -v mpifccpx`
KMRFJSV="Env_base=$Env_base;`dirname $fjsv`"
fi
fi
# Settings for Cray platforms.
! command -v cc | grep 'craype' >/dev/null 2>&1; crayplatform=$?
# Disable "enable_embed" (embedding of the kmrwatch0 binary) for Cray
# compilers, because they generate a too large binary by static
# linking it with MPI.
if test "1" -eq "$crayplatform"; then
test -z "$MPICC" && MPICC=cc
test -z "$MPICXX" && MPICXX=CC
test -z "$MPIFC" && MPIFC=ftn
test -z "$LD" && LD=cc
CC="cc" sh config.ccvendor.sh >conftest.out 2>&1
CC_VENDOR=`cat conftest.out`
case "$CC_VENDOR" in
cray)
test -z "$enable_embed" && enable_embed="no"
;;
esac
fi
AC_ARG_ENABLE(debug,
[ --enable-debug turn on debugging [default=no]],, enable_debug=no)
AC_ARG_ENABLE(assert,
[ --enable-assert turn on assert [default=yes]],, enable_assert=yes)
AC_ARG_ENABLE(fortran,
[ --enable-fortran turn on fortran binding [default=yes]],, enable_fortran=yes)
AC_ARG_ENABLE(openmp,
[ --enable-openmp turn on openmp [default=yes]],, enable_openmp=yes)
AC_ARG_ENABLE(tofu,
[ --enable-tofu turn on tofu support [default=yes]],, enable_tofu=yes)
AC_ARG_ENABLE(embed,
[ --enable-embed turn on embedding helper commands [default=yes]],, enable_embed=yes)
AC_ARG_WITH(netcdf,
[ --with-netcdf=PATH tell prefix to netcdf libs (not effective)], [], [])
AC_ARG_WITH(hdf5,
[ --with-hdf5=PATH tell prefix to hdf5 libs (not effective)], [], [])
# Set CFLAGS early to suppress setting "-O2".
if test "$enable_debug" = "yes"; then
CFLAGS="-DDEBUG -g $CFLAGS"
CXXFLAGS="-DDEBUG -g $CXXFLAGS"
FCFLAGS="-DDEBUG -g $FCFLAGS"
fi
# Set CFLAGS to suppress setting "-g" on K and FX10.
if test "1" -eq "$fujitsuplatform"; then
test -z "$CFLAGS" && CFLAGS=""
test -z "$CXXFLAGS" && CXXFLAGS=""
test -z "$FCFLAGS" && FCFLAGS=""
fi
AC_SUBST(OPENMP_CFLAGS) #[C openmp flags]
AC_SUBST(OPENMP_CXXFLAGS) #[C++ openmp flags]
AC_SUBST(OPENMP_FFLAGS) #[F openmp flags]
# Check compiler vendors for C, C++, F90.
# Delay checking gcc after mpicc is set, by m4_define/undefine.
m4_define([m4_provide(AC_PROG_CC)], [])
AC_LANG(C)
AX_MPI()
CC=$MPICC
m4_undefine([m4_provide(AC_PROG_CC)])
AX_MPI()
if test "$enable_openmp" != "no"; then
AX_OPENMP([OPENMP_CFLAGS=$ax_cv_c_openmp])
fi
AC_MSG_CHECKING([for compiler vendor of mpicc])
CC="$MPICC" sh config.ccvendor.sh >conftest.out 2>&1
CC_VENDOR=`cat conftest.out`
AC_MSG_RESULT([$CC_VENDOR])
m4_define([m4_provide(AC_PROG_CXX)], [])
AC_LANG(C++)
AX_MPI()
CXX=$MPICXX
m4_undefine([m4_provide(AC_PROG_CXX)])
AX_MPI()
if test "$enable_openmp" != "no"; then
AX_OPENMP([OPENMP_CXXFLAGS=$ax_cv_cxx_openmp])
fi
AC_MSG_CHECKING([for compiler vendor of mpic++])
CC="$MPICXX" sh config.ccvendor.sh >conftest.out 2>&1
CXX_VENDOR=`cat conftest.out`
AC_MSG_RESULT([$CXX_VENDOR])
m4_define([m4_provide(AC_PROG_FC)], [])
AC_LANG(Fortran)
AX_MPI()
FC=$MPIFC
m4_undefine([m4_provide(AC_PROG_FC)])
AX_MPI()
if test "$enable_openmp" != "no"; then
AX_OPENMP([OPENMP_FFLAGS=$ax_cv_fc_openmp])
fi
AC_MSG_CHECKING([for compiler vendor of mpif90])
CC="$MPIFC" sh config.ccvendor.sh >conftest.out 2>&1
FC_VENDOR=`cat conftest.out`
AC_MSG_RESULT([$FC_VENDOR])
# Set compiler flags for vendors.
AC_SUBST(SO_CCFLAGS) #[C pic flags]
AC_SUBST(SO_LDFLAGS) #[build shared library flags]
AC_SUBST(WARN_CC) #[C warning flags]
AC_SUBST(WARN_CXX) #[C++ warning flags]
AC_SUBST(WARN_FC) #[F warning flags]
AC_SUBST(STD_CC) #[C standard flags]
AC_SUBST(STD_CXX) #[C++ standard flags]
AC_SUBST(STD_FC) #[F standard flags]
AC_ARG_VAR(LIBS) #[libraries]
case "$CC_VENDOR" in
unknown)
;;
gcc|clang|pathscale)
CFLAGS="-m64 $CFLAGS"
STD_CC="-std=gnu99"
WARN_CC=${WARN_CC-"-Wall -Wextra -pedantic -Wno-long-long -Wno-unused-parameter -Wmissing-prototypes -Wno-format-truncation -Wshadow -Wconversion"}
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
intel)
CFLAGS="-m64 $CFLAGS"
STD_CC="-std=gnu99"
WARN_CC=${WARN_CC-"-Wall -w5 -Wremarks -Wcheck -Wmissing-prototypes -Wshadow"}
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
pgi)
CFLAGS="-m64 $CFLAGS"
STD_CC="-c9x"
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
cray)
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
solarisstudio)
CFLAGS="-m64 -mt $CFLAGS"
STD_CC="-xc99"
SO_CCFLAGS="-KPIC"
SO_LDFLAGS="-shared"
;;
fujitsu)
CFLAGS="-Kfast,preex -std=gnu99 $CFLAGS"
SO_CCFLAGS="-KPIC"
SO_LDFLAGS="-shared"
;;
ibmxlc)
CFLAGS="-q64 $CFLAGS"
STD_CC="-qlanglvl=stdc99"
WARN_CC=${WARN_CC-"-qinfo=gen"}
#???
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
necsx)
CFLAGS="-Cvopt $CFLAGS"
STD_CC="-Kc99"
WARN_CC=${WARN_CC-"-w all -pvctl nomsg"}
#???
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
digital|*)
#???
SO_CCFLAGS="-fPIC"
SO_LDFLAGS="-shared"
;;
esac
case "$CXX_VENDOR" in
unknown)
;;
gcc|clang|pathscale)
CXXFLAGS="-m64 $CXXFLAGS"
STD_CXX="-std=c++98"
WARN_CXX=${WARN_CXX-"-Wall -Wextra -pedantic -Wno-long-long -Wno-unused-parameter -Wshadow -Wconversion"}
;;
intel)
CXXFLAGS="-m64 $CXXFLAGS"
STD_CXX="-std=c++98"
WARN_CXX=${WARN_CXX-"-Wall -w5 -Wremarks -Wcheck -Wmissing-prototypes -Wshadow"}
;;
pgi)
CXXFLAGS="-m64 $CXXFLAGS"
;;
cray)
;;
solarisstudio)
CXXFLAGS="-m64 -mt $CXXFLAGS"
;;
fujitsu)
CXXFLAGS="-Kfast,preex $CXXFLAGS"
;;
ibmxlc)
CXXFLAGS="-q64 $CXXFLAGS"
WARN_CXX=${WARN_CXX-"-qinfo=gen"}
;;
necsx)
CXXFLAGS="-Cvopt $CXXFLAGS"
WARN_CXX=${WARN_CXX-"-w all -pvctl nomsg"}
;;
digital|*)
;;
esac
case "$FC_VENDOR" in
unknown)
enable_fortran=no
;;
gcc|clang|pathscale)
FCFLAGS="-m64 $FCFLAGS"
WARN_FC=${WARN_FC-"-Wall -Wextra -pedantic -Wno-unused-parameter -Wno-unused-dummy-argument -Wshadow"}
;;
intel)
FCFLAGS="-m64 $FCFLAGS"
WARN_FC=${WARN_FC-"-warn all"}
;;
pgi)
FCFLAGS="-m64 $FCFLAGS"
;;
cray)
;;
solarisstudio)
FCFLAGS="-m64 -mt $FCFLAGS"
;;
fujitsu)
FCFLAGS="-Kfast,preex $FCFLAGS"
;;
ibmxlc)
FCFLAGS="-q64 $FCFLAGS"
WARN_FC=${WARN_FC-"-qinfo=gen"}
;;
necsx)
FCFLAGS="-Cvopt $FCFLAGS"
WARN_FC=${WARN_FC-"-w all -pvctl nomsg"}
;;
digital|*)
;;
esac
# Mark Fujitsu FX platforms.
if test "1" -eq "$fujitsuplatform"; then
CFLAGS="-DKMRFJFX $CFLAGS"
CXXFLAGS="-DKMRFJFX $CXXFLAGS"
fi
rm -f conftest.out
# Add rt library for clock_gettime() in Linux and Intel-CC.
#
#case ${target_os} in
#linux*)
# LIBS="${LIBS} -lrt"
# ;;
#esac
# Mark if assertion is enabled.
if test "$enable_assert" != "yes"; then
CFLAGS="-DNDEBUG $CFLAGS"
CXXFLAGS="-DNDEBUG $CXXFLAGS"
fi
# Check if Fortran support is needed.
# KMRTARGET is a target of makefile.
AC_SUBST(KMRTARGET)
if test "$enable_fortran" = "yes"; then
KMRTARGET=kmr_f
else
KMRTARGET=kmr_c
fi
# Check if TOFU support files are available.
if test "$enable_tofu" = "yes" -a "1" -eq "$fujitsuplatform" -a -f "src/tofu.h"; then
CFLAGS="-DKMRTOFU $CFLAGS"
fi
# Check if LD is GNU (for program embedding).
#
#AC_ARG_VAR(LD, [Linker command (gnu-ld)])
#AC_MSG_CHECKING([whether ld is gnu])
#if test "$LD" = ""; then LD=ld; fi
#case `"$LD" -v 2>&1 </dev/null` in
#*GNU* | *'with BFD'*)
# gnu_ld=yes
# ;;
#*)
# gnu_ld=no
# ;;
#esac
#AC_MSG_RESULT([$gnu_ld])
# KMRWATCH is a target of makefile.
AC_SUBST(KMRWATCH)
if test "$enable_embed" = "yes"; then
CFLAGS="-DKMRBINEMBED $CFLAGS"
KMRWATCH=kmrwatch0.bin.o
else
KMRWATCH=""
fi
# Set the shared object name as target OS.
AC_SUBST(KMRSOTARGET)
AC_SUBST(KMRSONAME)
case "$target_os" in
darwin*)
KMRSOTARGET="kmr_c.dylib"
KMRSONAME='libkmr.$(KMRVER).dylib'
;;
*)
KMRSOTARGET="kmr_c.so"
KMRSONAME='libkmr.so.$(KMRVER)'
;;
esac
#AC_ARG_VAR(LDEMULATION, [BDF binary target (used as ld -m option)])
#AC_SUBST(KMRLDBDF)
#if test "$LDEMULATION" != ""; then
# KMRLDBDF="-m $LDEMULATION"
#else
# KMRLDBDF=""
#fi
# Check NETCDF/HDF5 support.
if test "$with_netcdf" != ""; then
CFLAGS="-DKMRNETCDF $CFLAGS"
LIBS="$LIBS -L$with_netcdf -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -lm"
fi
if test "$with_hdf5" != ""; then
CFLAGS="-DKMRHDF5 $CFLAGS"
LIBS="$LIBS -L$with_hdf5 -lhdf5_hl -lhdf5 -lsz -lz -lm"
fi
# Add -ldl on Linux.
case "$target_os" in
linux*)
LIBS="${LIBS} -ldl"
;;
esac
# Let KMRLIBDIR show in config.h.
test "x$prefix" = xNONE && prefix=$ac_default_prefix
AC_DEFINE_UNQUOTED(KMRLIBDIR, ["$prefix"])
AC_SUBST(KMRVER, $version)
AC_SUBST(KMRVERDATE, $release_date)
AC_OUTPUT