configure.ac 26.2 KB
Newer Older
1
2
dnl configure.ac --- autoconf script for YAXT
dnl
Thomas Jahns's avatar
Thomas Jahns committed
3
dnl Copyright  (C)  2019  Thomas Jahns <jahns@dkrz.de>
4
5
6
7
8
dnl
dnl Version: 1.0
dnl Keywords: configure configure.ac autotools
dnl Author: Thomas Jahns <jahns@dkrz.de>
dnl Maintainer: Thomas Jahns <jahns@dkrz.de>
9
dnl URL: https://www.dkrz.de/redmine/projects/scales-ppm
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
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are  permitted provided that the following conditions are
dnl met:
dnl
dnl Redistributions of source code must retain the above copyright notice,
dnl this list of conditions and the following disclaimer.
dnl
dnl Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the DKRZ GmbH nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl Commentary:
dnl
dnl
dnl
dnl Code:
dnl
Thomas Jahns's avatar
Thomas Jahns committed
44
45
46
47
dnl ######################################################################
dnl Basic autotools settings.
dnl ######################################################################
AC_PREREQ([2.64])
48
dnl Update the corresponding entry in doc/Doxyfile when changing this
Thomas Jahns's avatar
Thomas Jahns committed
49
AC_INIT([yaxt],[0.8.1],[hanke@dkrz.de],,
50
  [http://www.dkrz.de/redmine/projects/yaxt])
Thomas Jahns's avatar
Thomas Jahns committed
51
AC_CONFIG_SRCDIR([src/xt_idxlist.c])
Thomas Jahns's avatar
Thomas Jahns committed
52
AC_CONFIG_AUX_DIR([config])
Thomas Jahns's avatar
Thomas Jahns committed
53
AC_CONFIG_MACRO_DIR([m4])
54
55
dnl forbid acx macro names from remaining unexpanded
m4_pattern_forbid([^ACX_])
Thomas Jahns's avatar
Thomas Jahns committed
56
AC_CANONICAL_HOST
57
AM_INIT_AUTOMAKE([1.11 foreign subdir-objects parallel-tests])
Thomas Jahns's avatar
Thomas Jahns committed
58
59
AM_MAINTAINER_MODE
dnl ######################################################################
60
61
62
63
64
dnl Diagnose incompatible tool versions
dnl ######################################################################
m4_if(m4_version_compare(AC_AUTOCONF_VERSION,[2.67]),1,
  [m4_if(m4_version_compare(LT_PACKAGE_VERSION,[2.4.2]),[-1],[m4_fatal([autoconf versions 2.68 and newer require using libtool 2.4.2 or newer])])])
dnl ######################################################################
Thomas Jahns's avatar
Thomas Jahns committed
65
66
dnl Checks for programs.
dnl ######################################################################
67
dnl Require an ISO C99 compliant C compiler
Thomas Jahns's avatar
Thomas Jahns committed
68
69
m4_pushdef([_AC_PROG_CC_C89],
  [_AC_PROG_CC_C99(,[AC_MSG_FAILURE([CC=$CC is not an ISO C99 compiler])])])
70
AC_PROG_CC([mpicc mpiicc mpxlc_r mpixlc_r gcc cc])
71
72
m4_popdef([_AC_PROG_CC_C89])

73
74
75
76
AX_PTHREAD([AC_DEFINE([HAVE_PTHREAD],1,[Define if you have POSIX threads libraries and header files.])
   LIBS="$PTHREAD_LIBS $LIBS"
   CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
   CC="$PTHREAD_CC"])
77
ACX_TLS_XLC_RETRY
78
79
m4_pushdef([_AC_F95_FC],[mpifort mpiifort mpxlf_r mpxlf95_r mpxlf_r mpixlf95_r mpif90 mpif77 ]m4_dquote(m4_defn(
  [_AC_F95_FC])))
Thomas Jahns's avatar
Thomas Jahns committed
80
AC_PROG_FC
81
m4_popdef([_AC_F95_FC])
Thomas Jahns's avatar
Thomas Jahns committed
82
83
AC_FC_SRCEXT([f90])
AC_FC_FREEFORM
84
AC_LANG_PUSH([Fortran])
85
ACX_PROG_FC_CHECK_FPP
86
dnl Appending the preprocessor flag to FCFLAGS directly is wrong because
87
88
89
90
91
92
93
94
95
dnl it "must appear immediately before the source-code file name when
dnl compiling" (see the description of AC_FC_PP_SRCEXT in Autoconf manual).
dnl Moreover, the flag should not appear in the linking command because it
dnl might confuse the compiler, which is, for example, the case for Cray
dnl compiler when the preprocessor flag is equal to '-eZ'. Indeed, this looks
dnl more like a bug in the compiler but there might be more such cases.
dnl Meanwhile, the problem with Cray compiler is unexpectedly resolved by using
dnl '-eT' flag instead of '-eZ' (the original intention for switching the flag
dnl was to get rid of intermediate *.i files generated by the compiler).
96
FCFLAGS_f90="$FCFLAGS_f90 $FC_FPP_FLAG"
97
98
AC_PROG_FPP
AC_LANG_POP([Fortran])
99
AC_PROG_MKDIR_P
100
101
102
AX_WITH_PERL([/bin/false], $PATH:$prefix/bin:/usr/bin:/usr/local/bin)
AX_PROG_PERL_VERSION([5.0005],[],
        AC_MSG_ERROR([Perl (version>=5.0005) is required]))
103
AC_CHECK_PROGS([M4],[m4 gm4 gnum4],[false],,)
104
105
AM_PROG_CC_C_O
AC_PROG_FC_C_O
106
# Set up libtool.
107
ACX_USE_LIBTOOL_CONFIGURATION
108
AC_SUBST([lt_cv_nm_interface])
109
110
111
112
113
114
115
116
117
118
119
dnl ######################################################################
dnl Properties of the compiler
dnl ######################################################################
ACX_SL_FC_MOD_SUFFIX(,[AC_MSG_ERROR(dnl
[Fortran module file extension must be known to install F90 modules.])])
AM_CONDITIONAL([FC_MOD_UPPERCASE],
  [test x$ac_fc_mod_uppercase = xyes])
AC_LANG_PUSH([Fortran])
ACX_SL_FC_CHECK_MOD_PATH_FLAG
AC_LANG_POP([Fortran])
ACX_FC_VOLATILE([FCFLAGS="${FCFLAGS} ${FPP_DEFOPT}HAVE_VOLATILE"])
Thomas Jahns's avatar
Thomas Jahns committed
120
AC_FC_DUMMY_MAIN(,[:])
121
AC_FC_WRAPPERS
122
123
ACX_FC_LOGICAL_INTEROP([HAVE_FC_LOGICAL_INTEROP=yes
  FCFLAGS="${FCFLAGS+$FCFLAGS }${FPP_DEFOPT}HAVE_FC_LOGICAL_INTEROP"])
Thomas Jahns's avatar
Thomas Jahns committed
124
125
ACX_FC_LOGICAL_C_BOOL(
  [FCFLAGS="${FCFLAGS+$FCFLAGS }${FPP_DEFOPT}HAVE_FC_LOGICAL_C_BOOL"])
126
127
128
129
130
131
132
133
134
dnl
dnl check if the compiler supports pointer bounds remapping
ACX_FC_POINTER_BOUNDS_REMAP([HAVE_POINTER_REMAP=yes],[HAVE_POINTER_REMAP=no])
AS_IF([test $HAVE_POINTER_REMAP = yes],
  [ACX_FC_POINTER_HUGE_BOUNDS_REMAP(,
     [AC_MSG_NOTICE([Disabling native low-bounds mapping, $FC has a known defective implementation.])
      HAVE_POINTER_REMAP=no])])
AS_IF([test $HAVE_POINTER_REMAP = yes],
  [FCFLAGS="${FCFLAGS+$FCFLAGS }${FPP_DEFOPT}HAVE_FC_PTR_BOUND_REMAP"])
135
136
137
138
139
dnl Do we need helper functions for contiguous arrays?
ACX_FC_HAVE_IS_CONTIGUOUS([HAVE_FC_IS_CONTIGUOUS=yes
  FCFLAGS="${FCFLAGS+$FCFLAGS }${FPP_DEFOPT}HAVE_FC_IS_CONTIGUOUS"
  AC_DEFINE([HAVE_FC_IS_CONTIGUOUS],[1])])
AH_TEMPLATE([HAVE_FC_IS_CONTIGUOUS],
140
141
142
143
144
145
  [Defined to 1 iff Fortran compiler supports IS_CONTIGUOUS query])dnl
ACX_FC_HAVE_C_LOC_OF_SLICE([HAVE_FC_C_LOC_OF_SLICE=yes
  FCFLAGS="${FCFLAGS+$FCFLAGS }${FPP_DEFOPT}HAVE_FC_C_LOC_OF_SLICE"
  AC_DEFINE([HAVE_FC_C_LOC_OF_SLICE],[1])])
AH_TEMPLATE([HAVE_FC_C_LOC_OF_SLICE],
  [Defined to 1 iff Fortran compiler supports C_LOC of an array slice])dnl
Thomas Jahns's avatar
Thomas Jahns committed
146
dnl Check whether char is unsigned by default
147
148
149
150
151
AC_C_CHAR_UNSIGNED
AS_IF([test x$ac_cv_c_char_unsigned = xyes],
  [C_CHAR_IS_UNSIGNED=1],
  [C_CHAR_IS_UNSIGNED=0])
AC_SUBST([C_CHAR_IS_UNSIGNED])
152
153
dnl preprocessor implicit type conversions depends on the size of these, also
dnl the result is used in establishing Xt_long
Thomas Jahns's avatar
Thomas Jahns committed
154
155
156
157
158
159
AC_CHECK_SIZEOF([int])
AC_SUBST([C_SIZEOF_INT],[$ac_cv_sizeof_int])
AC_CHECK_SIZEOF([long])
AC_SUBST([C_SIZEOF_LONG],[$ac_cv_sizeof_long])
AC_CHECK_SIZEOF([long long])
AC_SUBST([C_SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long])
Thomas Jahns's avatar
Thomas Jahns committed
160
AC_CHECK_SIZEOF([unsigned long])
161
AC_CHECK_SIZEOF([__int128])
Thomas Jahns's avatar
Thomas Jahns committed
162
163
164
165
166
167
AC_COMPILE_IFELSE([AC_LANG_SOURCE([__int128_t f(void) {
  __int128_t i = 0, j = i + 1;
  return j >= 0;
}])],
  [AC_CHECK_SIZEOF([__int128_t])],
  [ac_cv_sizeof___int128_t=0])
Thomas Jahns's avatar
Thomas Jahns committed
168
dnl
169
dnl check for various builtins
Thomas Jahns's avatar
Thomas Jahns committed
170
171
172
173
AS_FOR([builtin_macro],[builtin],[__builtin_ctzl __builtin_clzl],
  [AS_VAR_PUSHDEF([builtin_cache],[acx_cv_have_decl_]builtin_macro)
   AC_CACHE_CHECK([whether ]builtin_macro[ is declared],
     [builtin_cache],
174
     [AC_LINK_IFELSE([AC_LANG_PROGRAM(,[  long lbz = builtin_macro][[(56UL)]])],
Thomas Jahns's avatar
Thomas Jahns committed
175
176
177
        [AS_VAR_SET([builtin_cache],[yes])],
        [AS_VAR_SET([builtin_cache],[no])])])
   AS_VAR_IF([builtin_cache],[yes],
178
179
180
     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]),[1])],
     [AC_DEFINE_UNQUOTED([HAVE_DECL_]AS_TR_CPP([builtin_macro]),[0])])
   AS_VAR_POPDEF([builtin_cache])])
Thomas Jahns's avatar
Thomas Jahns committed
181
182
183
184
AH_TEMPLATE([HAVE_DECL___BUILTIN_CTZL],
  [Define to 1 if __builtin_ctzl is available, 0 if not])
AH_TEMPLATE([HAVE_DECL___BUILTIN_CLZL],
  [Define to 1 if __builtin_clzl is available, 0 if not])
185
186
187
188
189
190
191
192
193
194
195
AC_CACHE_CHECK([whether __builtin_clz is declared],
  [acx_cv_have_decl___builtin_clz],
  [AC_LINK_IFELSE([AC_LANG_PROGRAM(,[  int nlz = __builtin_clz(56U)])],
     [AS_VAR_SET([acx_cv_have_decl___builtin_clz],[yes])],
     [AS_VAR_SET([acx_cv_have_decl___builtin_clz],[no])])])
AC_CACHE_CHECK([whether __builtin_clzll is declared],
  [acx_cv_have_decl___builtin_clzll],
  [AC_LINK_IFELSE([AC_LANG_PROGRAM(,[  int nlz = __builtin_clzll(56ULL)])],
     [AS_VAR_SET([acx_cv_have_decl___builtin_clzll],[yes])],
     [AS_VAR_SET([acx_cv_have_decl___builtin_clzll],[no])])])

196
197
198
199
200
201
202
dnl ######################################################################
dnl Test whether cfortran.h works correctly
dnl ######################################################################
ACX_FIND_CFORTRAN_DEF
ACX_XLF_QEXTNAME_ADD_APPENDUS
ACX_CHECK_CFORTRAN

Thomas Jahns's avatar
Thomas Jahns committed
203
204
205
206
207
dnl ######################################################################
dnl Checks for header files.
dnl ######################################################################
dnl
AC_HEADER_STDC
208
209
210

#  ----------------------------------------------------------------------
# Compile with MPI support
211
212
213
214
215
216
217
218
dnl
dnl ######################################################################
dnl Checks for MPI.
dnl ######################################################################
ACX_C_PACKAGE([MPI],[mpi.h],,,
  [AC_MSG_ERROR([Required header mpi.h not found or not compilable.])],
  [MPI_Waitall],[mpi mpich],,,
  [AC_MSG_ERROR([Cannot link C MPI programs.])])
219
220
221
222
223
224
ACX_F90_PACKAGE([MPI],[mpi],,,
  [AC_MSG_ERROR([Required Fortran 90 module not found or incompatible.])],
  [mpi_waitall],[mpi mpi_f90 mpi_f77 mpich],[[-lmpi_f77 -lmpi],[-lmpi]],,
  [AC_MSG_ERROR([Cannot link Fortran 90 MPI programs.])],,
[      INTEGER :: req(1), stat(mpi_status_size, 1), ierror
],[(1, req, stat, ierror)])
225

226
227
228
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $MPI_C_INCLUDE"
TJ_FIND_INTEGRAL_TYPE([MPI_Fint],[MPI_FINT],[@%:@include <mpi.h>])
229
230
231
232
233
234
235
236
ACX_MPI_SEND_CONST_VOID_P_BUF_ARG([CAST_MPI_SEND_BUF="(buf)"
   XT_MPI_SEND_BUF_CONST=const],
  [CAST_MPI_SEND_BUF="((void *)(buf))"
   XT_MPI_SEND_BUF_CONST=])
AC_DEFINE_UNQUOTED([CAST_MPI_SEND_BUF(buf)],[$CAST_MPI_SEND_BUF],
  [Macro to cast arguments to MPI_Send-like functions (if necessary)])
AC_DEFINE_UNQUOTED([XT_MPI_SEND_BUF_CONST],[$XT_MPI_SEND_BUF_CONST],
    [Defined to const, iff buf argument to MPI_Send-like functions can be const])
237
238
239
TJ_FIND_INTEGRAL_TYPE([MPI_Aint],[xt_mpi_aint],[@%:@include <mpi.h>])
xt_mpi_aint_kind=c_[]AS_TR_SH([$xt_mpi_aint])
FCFLAGS="$FCFLAGS ${FPP_DEFOPT}XT_MPI_AINT_KIND=$xt_mpi_aint_kind"
240
241
242
AC_CHECK_SIZEOF([MPI_Datatype],,[@%:@include <mpi.h>])
AS_IF([test $ac_cv_sizeof_MPI_Datatype -eq 0],
  [AC_MSG_FAILURE([Could not detect size of MPI_Datatype!])])
243
244
CFLAGS=$save_CFLAGS
AS_CASE(["$MPI_FINT"],
245
246
247
248
  [int],[XT_MPI_FINT_MAX=INT_MAX XT_MPI_FINT_FC_KIND=c_int],
  [long],[XT_MPI_FINT_MAX=LONG_MAX XT_MPI_FINT_FC_KIND=c_long],
  ["long long"],[XT_MPI_FINT_MAX=LLONG_MAX XT_MPI_FINT_FC_KIND=c_long_long],
  [short],[XT_MPI_FINT_MAX=SHRT_MAX XT_MPI_FINT_FC_KIND=c_short])
249
250
AC_DEFINE_UNQUOTED([XT_MPI_FINT_MAX],[$XT_MPI_FINT_MAX],
  [Maximum value of MPI_Fint.])
251
252
# Match MPI_Fint in reverse to make sure Fortran/C-APIs match
FCFLAGS="$FCFLAGS ${FPP_DEFOPT}XT_MPI_FINT_FC_KIND=$XT_MPI_FINT_FC_KIND"
253
254
255
# the following is needed for source parts from libraries with
# optional MPI dependencies
AC_DEFINE([USE_MPI],[1],[use MPI parallel process environment])
256
257
258
259
saved_CFLAGS=$CFLAGS
saved_FCFLAGS=$FCFLAGS
saved_LIBS=$LIBS
CFLAGS="$CFLAGS $MPI_C_INCLUDE"
260
FCFLAGS="$FCFLAGS $MPI_FC_MOD"
261
LIBS="$LIBS $MPI_C_LIB"
Thomas Jahns's avatar
Thomas Jahns committed
262
263
264
265
266
# check MPI defects
AC_ARG_WITH([regard-for-quality],
  [AS_HELP_STRING([--without-regard-for-quality],
     [ignore results of checks for known defects @<:@default: abort on error@:>@])],
  [],[with_regard_for_quality=yes])
267
ACX_MPIRUN(,[saved_MPI_LAUNCH=$MPI_LAUNCH],
268
269
  [AC_MSG_WARN([$MPI_LAUNCH_failMsg])
   AS_VAR_IF([with_regard_for_quality], [yes],
270
271
272
     [AC_MSG_FAILURE([unable to find a working MPI launch program, which is
required for checks for known MPI defects (see --without-regard-for-quality)])],
     [saved_MPI_LAUNCH=$MPI_LAUNCH ; MPI_LAUNCH=true])])
Thomas Jahns's avatar
Thomas Jahns committed
273
274
275
276
277
278
279
dnl do not remove conftest.err we need to inspect the output
m4_pushdef([_AC_RUN_LOG_LIMIT],
  m4_bpatsubst(m4_dquote(m4_defn([_AC_RUN_LOG_LIMIT])),
    [rm -f conftest.er1 conftest.err],[rm -f conftest.er1]))dnl
m4_pushdef([_AC_LINK_IFELSE],
  m4_bpatsubst(m4_dquote(m4_defn([_AC_LINK_IFELSE])),
    [rm -f core conftest.err],[rm -f core]))dnl
280
281
282
283
284
285
286
ACX_MPI_DEFECTS(,,
  [ACX_MPI_DEFECTS_DOCUMENT
   AS_CASE(["$acx_subtestname"],[openmpi_datatype],
     [AC_MSG_WARN([known OpenMPI 2.0.3-4.0.1 problem detected attempting interpositioning work-around!])
      ACX_OMPI_DT_WORKAROUND(,[openmpi_datatype.c],
        [xt_mpi_workaround_LIBS=$ac_cv_search_opal_output
         extrasub="${extrasub+$extrasub$as_nl}/^\# skip internal symbols for stubs created by xlf/i \\\\${as_nl}\# ignore opal symbols overriden by us\\\\${as_nl}/"'^\${exp_sym_prefix}opal_datatype_\\\\(commit\\\\|add\\\\)/b'])],
Thomas Jahns's avatar
Thomas Jahns committed
287
288
289
290
291
292
293
     [incorrect_mpi_abort_exitcode],
     [AC_MSG_WARN([Your installation drops the exit code of MPI_Abort!
Consider getting a better MPI/batch scheduler.])
      AS_IF([grep -v -i 'mpi_abort(@<:@^,()@:>@*, 2)' conftest.err >/dev/null],
        [AC_MSG_NOTICE([Implementing fragile work-around for tests!])
         AC_DEFINE([XT_NEED_MPI_ABORT_WORK_AROUND],[1],
           [To pass the value for MPI_Abort to the surrounding execution environment, a hack is needed.])])],
294
295
296
297
298
299
300
301
     [AS_VAR_IF([with_regard_for_quality],[yes],
        [AC_MSG_FAILURE([test for known defect $acx_subtestname failed,
re-configure with --without-regard-for-quality in case you must use the
given MPI implementation, but some tests might fail])],
        [AC_MSG_NOTICE([ignoring failed test for known defect $acx_subtestname,
because configure option --without-regard-for-quality is active])])])])
m4_popdef([_AC_RUN_LOG_LIMIT])m4_popdef([_AC_LINK_IFELSE])dnl
rm -f conftest.err
302
AC_SUBST([xt_mpi_workaround_LIBS])
303
304
305
306
307
AM_CONDITIONAL([OMPI_DT_WORKAROUND],
  [test x${acx_opal_datatype_add_workaround+set} = xset])
AS_IF([test x${acx_opal_datatype_add_workaround+set} = xset],
  [acx_opal_datatype_add_workaround=`perl -e "use Cwd abs_path; print abs_path('$acx_opal_datatype_add_workaround')"`])
AC_SUBST([acx_opal_datatype_add_workaround])
308
MPI_LAUNCH=$saved_MPI_LAUNCH
309
310
311
FCFLAGS=$saved_FCFLAGS
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS
312

313
314
315
316
# enable user to select an alternative enumeration type in case
# 2^31 elements isn't enough or too much
AC_ARG_WITH([idxtype],
  AS_HELP_STRING([--with-idxtype],[select type to use for global index values @<:@default=int@:>@]),
Thomas Jahns's avatar
Thomas Jahns committed
317
318
  [XT_INT=$withval
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[char a[((($XT_INT)-1)<0)];
Thomas Jahns's avatar
Thomas Jahns committed
319
char b[($XT_INT)((-($XT_INT)-0.5)+1.5)]]])],,
320
     [AC_MSG_ERROR([Selected index type not compilable or unsigned])])],
Thomas Jahns's avatar
Thomas Jahns committed
321
  [XT_INT=int])
322
323
324
dnl expand setting of variables to describe variable type
dnl vartype_setq(TYPE_NAME, TYPE_C_TYPE, FC_KIND, TYPE_MPI_DT,
dnl              TYPE_VAL_MAX, TYPE_VAL_MIN,
325
dnl              TYPE_C_PRINTF_FMT, TYPE_C_ABS, TYPE_C_CLZ)
326
327
m4_define([vartype_setq],[$1][_MPIDT=$4
     AC_CHECK_SIZEOF([$2])
328
     $1][_FC_KIND=$3
329
330
331
332
333
     ACX_FORTRAN_TYPE_KIND([integer],[$3],[$2],
       [      use iso_c_binding],,$1[_FC_KIND=$acx_fortran_kind_subst])
     $1][_MAX=$5
     $1][_MIN=$6
     $1][_FMT=$7
334
335
336
337
     $1][_abs=$8
     AS_IF([test x"$][$9" = xyes],
       [m4_if([$2], [short], [$1][_clz="(m4_substr($9,17)((unsigned short)v))"],
          [$1][_clz="(m4_substr($9,17)(v))"])])])dnl
Thomas Jahns's avatar
Thomas Jahns committed
338
339
340
341
342

dnl
dnl test if MPI_INTEGER[248] are available
save_FCFLAGS=$FCFLAGS
AC_LANG_PUSH([Fortran])
343
FCFLAGS="$MPI_FC_MOD $FCFLAGS"
Thomas Jahns's avatar
Thomas Jahns committed
344
345
346
for mpi_int2test in MPI_INTEGER2 MPI_INTEGER4 MPI_INTEGER8; do
  AC_MSG_CHECKING([if Fortran MPI bindings define $mpi_int2test])
  AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
347
        USE mpi
Thomas Jahns's avatar
Thomas Jahns committed
348
349
350
351
352
353
354
355
356
357
358
        IMPLICIT NONE
        INTEGER :: i
        i = $mpi_int2test
]),[AC_MSG_RESULT([yes])
  eval HAVE_FC_$mpi_int2test=1],
    [AC_MSG_RESULT([no])
     ASX_VAR_UNSET([HAVE_FC_$mpi_int2test])])
done
FCFLAGS=$save_FCFLAGS
AC_LANG_POP([Fortran])

359
m4_foreach([substtype],[[XT_INT]],
360
361
  [AS_CASE(["$substtype"],
     [int],
362
     [vartype_setq(substtype,[int],[c_int],[MPI_INT],
363
364
                   [INT_MAX],["(-INT_MAX)"],["\"d\""],['(abs((v)))'],
                   [acx_cv_have_decl___builtin_clz])],
365
     [long],
366
     [vartype_setq(substtype,[long],[c_long],[MPI_LONG],
367
368
                   [LONG_MAX],["(-LONG_MAX)"],["\"ld\""],['(labs((v)))'],
                   [acx_cv_have_decl___builtin_clzl])],
369
     [short],
370
371
     [vartype_setq(substtype,[short],[c_short],[MPI_SHORT],
                   [SHRT_MAX],["(-SHRT_MAX)"],["\"hd\""],
372
373
374
375
376
377
378
                   ['((short)abs((v)))'],
                   [acx_cv_have_decl___builtin_clz])
      AS_IF([test x"$acx_cv_have_decl___builtin_clz" = xyes \
             && test $ac_cv_sizeof_int != $ac_cv_sizeof_short],
        [AS_IF([expr $ac_cv_sizeof_int = $ac_cv_sizeof_short \* 2 >/dev/null],
           substtype[_clz="($]substtype[_clz - (int)(CHAR_BIT * sizeof (short)))"],
           [AC_MSG_ERROR([Unexpected size relationship of int ($ac_cv_sizeof_int) and short ($ac_cv_sizeof_short)])])])],
379
     ["long long"],
380
     [vartype_setq(substtype,[long long],[c_long_long],[MPI_LONG_LONG],
381
382
                   [LLONG_MAX],["(-LLONG_MAX)"],["\"lld\""],['(llabs((v)))'],
                   [acx_cv_have_decl___builtin_clzll])],
383
     [AC_MSG_ERROR([Invalid type selected for substtype])])
384
385
386
387
   AS_IF([eval eval test x\\\"\\\${HAVE_FC_MPI_INTEGER[]\$ac_cv_sizeof_]AS_TR_SH([$substtype])[+set}\\\" = xset],
     [eval substtype[]_FC_MPIDT=\"MPI_INTEGER[]\$ac_cv_sizeof_]AS_TR_SH([$substtype])[\"],
     substtype[_FC_MPIDT=MPI_DATATYPE_NULL])
   FCFLAGS="$FCFLAGS ${FPP_DEFOPT}substtype[]_FC_KIND=$substtype[]_FC_KIND ${FPP_DEFOPT}substtype[]_FC_MPIDT=$substtype[]_FC_MPIDT"
388
   eval "FCFLAGS=\"\$FCFLAGS \${FPP_DEFOPT}SIZEOF_[]substtype[]=\$ac_cv_sizeof_]AS_TR_SH([$substtype])[\""
389
390
391
392
   AC_DEFINE_UNQUOTED([CONF_]substtype[_MAX],[$]substtype[_MAX],
     [Maximal value for ]substtype)
   AC_DEFINE_UNQUOTED([CONF_]substtype[_MIN],[$]substtype[_MIN],
     [Minimal value for ]substtype)
Thomas Jahns's avatar
Thomas Jahns committed
393
394
   AC_DEFINE_UNQUOTED([CONF_]substtype[_FMT],[$]substtype[_FMT],
     [printf(3) format string for ]subsstype)
395
396
   AC_DEFINE_UNQUOTED(substtype[_ABS(v)],[$]substtype[_abs],
     [return absolute value of v])
397
398
399
400
401
   AC_DEFINE_UNQUOTED([SIZEOF_]substtype,[SIZEOF_]AS_TR_CPP([$substtype]),
     [The size of `]substtype[', as computed by sizeof.])
   AS_IF([test -n "$]substtype[_clz"],
     [AC_DEFINE_UNQUOTED(substtype[_CLZ(v)],[$]substtype[_clz],
       [return number of leading zero-bits in v])])
402
403
  ])

404
405
406
407
408
AS_CASE([$XT_INT],
  [int],[XT_UINT_MPIDT=MPI_UNSIGNED],
  [short],[XT_UINT_MPIDT=MPI_UNSIGNED_SHORT],
  [long],[XT_UINT_MPIDT=MPI_UNSIGNED_LONG],
  ["long long"],[XT_UINT_MPIDT=MPI_UNSIGNED_LONG_LONG])
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
dnl find type to quickly do double width integer arithmetic on Xt_int,
dnl if available, because results of AC_COMPUTE_INT are limited to the range
dnl of long, sizeof must be used as a proxy for value range
AC_CACHE_CHECK([type to use for long multiplication of Xt_int],
  [acx_cv_XT_LONG],
  [eval acx_sizeof_xt_int=\"\$ac_cv_sizeof_[]AS_TR_SH($XT_INT)\"
   acx_cv_XT_LONG='(unavailable)'
   AS_FOR([itype_macro],[itype],[int long "long long" __int128 __int128_t],
     [eval acx_itype_sizeof=\"\$ac_cv_sizeof_[]AS_TR_SH([itype_macro])\"
      AS_IF([expr "$acx_sizeof_xt_int" \* 2 = "$acx_itype_sizeof" >/dev/null],
        [acx_cv_XT_LONG="itype_macro" ; break])])])
AS_IF([test x"$acx_cv_XT_LONG" != 'x(unavailable)'],
  [AC_DEFINE_UNQUOTED([XT_LONG],[$acx_cv_XT_LONG],[Type to use for fast long multiplication of Xt_int])
   AS_IF([test x"$acx_cv_XT_LONG" != x__int128_t],
     [acx_XT_ULONG="unsigned $acx_cv_XT_LONG"],
     [acx_XT_ULONG="__uint128_t"])
   AC_DEFINE_UNQUOTED([XT_ULONG],[$acx_XT_ULONG],[Type to use for fast long multiplication of Xt_int])],
  [AC_CACHE_CHECK([short type to use for manual long multiplication of Xt_int],
    [acx_cv_XT_SHORT],
    [acx_cv_XT_SHORT='(unavailable)'
     AS_FOR([itype_macro],[itype],[char int long],
       [AS_IF([test itype_macro = char],
          [acx_itype_sizeof=1],
          [eval acx_itype_sizeof=\"\$ac_cv_sizeof_[]AS_TR_SH([itype_macro])\"])
        AS_IF([expr "$acx_sizeof_xt_int" = "$acx_itype_sizeof" \* 2 >/dev/null],
          [acx_cv_XT_SHORT="itype_macro" ; break])])])])
AS_IF([test x"$acx_cv_XT_SHORT" != 'x(unavailable)'],
  [AC_DEFINE_UNQUOTED([XT_SHORT],[$acx_cv_XT_SHORT],[Type to use for manual long multiplication and division of Xt_int])])
437

Thomas Jahns's avatar
Thomas Jahns committed
438
AC_DEFINE_UNQUOTED([XT_INT],[$XT_INT],[Type to use for enumeration of distributed elements.])
439
440
441
AC_DEFINE_UNQUOTED([XT_INT_MPIDT],[$XT_INT_MPIDT],[MPI Datatype for type for enumeration of distributed elements.])
AC_DEFINE_UNQUOTED([XT_UINT_MPIDT],[$XT_UINT_MPIDT],[MPI Datatype for type for counts of distributed elements.])

442
443
444
445
446
447
448
449
450
451
452
AC_ARG_WITH([on-demand-check-programs],
  [AS_HELP_STRING([--with-on-demand-check-programs],
     [only build test programs when calling make check (default: build during make all)])],
  [AS_CASE([$withval],
     [yes|no],,
     [n],[with_on_demand_check_programs=no],
     [y],[with_on_demand_check_programs=yes],
     [AC_MSG_FAILURE([unexpected value for --with-on-demand-check-programs: $withval])])],
  [with_on_demand_check_programs=no])
AM_CONDITIONAL([with_on_demand_check_programs],
  [test x$with_on_demand_check_programs = xyes])
453

454
455
456
457
458
459
460
461
462
463
464
465
AC_ARG_WITH([example-programs],
  [AS_HELP_STRING([--without-example-programs],
     [only build example programs when calling make examples in examples directory (default: build during make all)])],
  [AS_CASE([$withval],
     [yes|no],,
     [n],[with_example_programs=no],
     [y],[with_example_programs=yes],
     [AC_MSG_FAILURE([unexpected value for --with-example-programs: '$withval'])])],
  [with_example_programs=yes])
AM_CONDITIONAL([with_example_programs],
  [test x$with_example_programs = xyes])

466
467
468
469
470
471
472
473
474
475
476
477
AC_ARG_WITH([perf-programs],
  [AS_HELP_STRING([--without-perf-programs],
     [only build performance test programs when calling make perf in perf directory (default: build during make all)])],
  [AS_CASE([$withval],
     [yes|no],,
     [n],[with_perf_programs=no],
     [y],[with_perf_programs=yes],
     [AC_MSG_FAILURE([unexpected value for --with-perf-programs: '$withval'])])],
  [with_perf_programs=yes])
AM_CONDITIONAL([with_perf_programs],
  [test x$with_perf_programs = xyes])

478
479
480
481
482
483
484
485
486
AC_ARG_VAR([BUILD_CFLAGS],
  [append to CFLAGS during build but not in configure phase])
AC_CONFIG_COMMANDS_PRE([CFLAGS="$CFLAGS${BUILD_CFLAGS+ $BUILD_CFLAGS}"])
AC_ARG_VAR([BUILD_FCFLAGS],
  [append to FCFLAGS during build but not in configure phase])
AC_CONFIG_COMMANDS_PRE([FCFLAGS="$FCFLAGS${BUILD_FCFLAGS+ $BUILD_FCFLAGS}"])
AC_ARG_VAR([BUILD_LDFLAGS],
  [append to LDFLAGS during build but not in configure phase])
AC_CONFIG_COMMANDS_PRE([LDFLAGS="$LDFLAGS${BUILD_LDFLAGS+ $BUILD_LDFLAGS}"])
487
488
489
AC_ARG_VAR([BUILD_LIBS],
  [prepend to LIBS during build but not in configure phase])
AC_CONFIG_COMMANDS_PRE([LIBS="${BUILD_LIBS+$BUILD_LIBS }$LIBS"])
490
491
AC_ARG_VAR([BUILD_CC],
  [replace CC with expansion of $BUILD_CC during build but not in configure phase])
Thomas Jahns's avatar
Thomas Jahns committed
492
AC_CONFIG_COMMANDS_PRE([CC=${BUILD_CC-$CC}])
493
494
AC_ARG_VAR([BUILD_FC],
  [replace FC with expansion of $BUILD_FC during build but not in configure phase])
Thomas Jahns's avatar
Thomas Jahns committed
495
AC_CONFIG_COMMANDS_PRE([FC=${BUILD_FC-$FC}])
496

Thomas Jahns's avatar
Thomas Jahns committed
497
498
AC_CONFIG_HEADER([include/config.h])

499
500
AC_CONFIG_FILES([						\
	perf/perf_idxsection_get_positions_of_indices_run	\
501
	perf/perf_sparse_array_gather_run			\
Moritz Hanke's avatar
Moritz Hanke committed
502
	tests/test_exchanger_parallel_run			\
503
	tests/test_redist_p2p_parallel_run			\
504
505
	tests/test_redist_collection_parallel_run		\
	tests/test_redist_collection_static_parallel_run	\
Moritz Hanke's avatar
Moritz Hanke committed
506
	tests/test_redist_repeat_parallel_run			\
507
	tests/test_xmap_all2all_parallel_run			\
508
	tests/test_xmap_all2all_intercomm_parallel_run		\
509
	tests/test_xmap_dist_dir_parallel_run			\
510
	tests/test_xmap_dist_dir_intercomm_parallel_run		\
511
	tests/test_xmap_intersection_parallel_run		\
512
        tests/test_initialized_finalized_run			\
Moritz Hanke's avatar
Moritz Hanke committed
513
	tests/test_idxempty_run					\
514
515
	tests/test_idxvec_run					\
	tests/test_idxlist_collection_run			\
Moritz Hanke's avatar
Moritz Hanke committed
516
	tests/test_idxmod_run					\
517
518
	tests/test_idxsection_run				\
	tests/test_idxstripes_run				\
519
520
	tests/test_redist_single_array_base_run			\
	tests/test_redist_single_array_base_parallel_run	\
521
522
	tests/test_redist_collection_run			\
	tests/test_redist_collection_static_run			\
Moritz Hanke's avatar
Moritz Hanke committed
523
	tests/test_redist_repeat_run				\
524
	tests/test_redist_p2p_run				\
Moritz Hanke's avatar
Moritz Hanke committed
525
	tests/test_request_parallel_run				\
526
	tests/test_exported_symbols				\
527
528
	tests/test_xmap_dist_dir_run				\
	tests/test_xmap_all2all_run				\
529
	tests/test_xmap_all2all_fail_run			\
530
531
	tests/test_handles_run					\
	tests/test_ut_run					\
Moritz Hanke's avatar
Moritz Hanke committed
532
533
534
535
        tests/test_perf_run					\
        tests/test_perf_stripes_run				\
        tests/test_sort_run					\
        tests/test_uid_run					\
536
        tests/test_misc_run					\
Moritz Hanke's avatar
Moritz Hanke committed
537
        tests/test_yaxt_run					\
538
	tests/test_mpi_generate_datatype_run			\
539
	tests/test_mpi_smartdedup_run				\
Anna Fuchs's avatar
Anna Fuchs committed
540
	examples/rrobin_run					\
541
	examples/row2col_run					\
542
	examples/tr_gp2fs_run					\
543
	examples/unstruct_halo_exchange_run			\
544
	util/serialrun],[chmod a+x "$ac_file"])
545
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile examples/Makefile \
546
  inst_headers/Makefile inst_headers/f90/Makefile \
547
  src/pkgconfig/yaxt.pc src/pkgconfig/yaxt_c.pc perf/Makefile])
548
549
550
551
552
# edit out the am--include-marker that's required for automake 1.16
# and later on older automake versions
AS_VERSION_COMPARE([$am__api_version],[1.16],[extrasub="${extrasub+$extrasub$as_nl}s/\# am--include-marker\$//"
])

553
554
555
556
557
558
559
dnl Create dummy Fortran dependency files for Automake version 1.16 or later,
dnl which don't do so automatically anymore, older versions
dnl created the files by the time this command is executed. Having
dnl created the dummy Fortran dependency files, we enforce their
dnl regeneration at the build time by updating the timestamps of the
dnl corresponding Makefiles, which the Fortran dependency file have as
dnl prerequisites.
560
561
AC_CONFIG_COMMANDS([force_dep_regeneration],[$MKDIR_P "tests/${DEPDIR}" "src/${DEPDIR}"
touch "tests/${DEPDIR}/FC.deps" "src/${DEPDIR}/FC.deps"
562
563
564
sleep 1
touch tests/Makefile src/Makefile],
[DEPDIR="${DEPDIR}"])
565
566

AC_OUTPUT
567
568
569
570
dnl
dnl Local Variables:
dnl mode: autoconf
dnl coding: utf-8
571
dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
572
573
dnl license-default: "bsd"
dnl End: