configure.ac 25.1 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(,,
268
269
  [AC_MSG_WARN([$MPI_LAUNCH_failMsg])
   AS_VAR_IF([with_regard_for_quality], [yes],
270
271
272
273
     [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)])])])
AS_VAR_IF([with_regard_for_quality], [yes],
  [ACX_MPI_DEFECTS(,,
     [ACX_MPI_DEFECTS_DOCUMENT
274
275
276
      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],
277
           [xt_mpi_workaround_LIBS=$ac_cv_search_opal_output
278
            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'])],
279
        [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])])])])
280
AC_SUBST([xt_mpi_workaround_LIBS])
281
282
283
284
285
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])
286
287
288
FCFLAGS=$saved_FCFLAGS
CFLAGS=$saved_CFLAGS
LIBS=$saved_LIBS
289

290
291
292
293
# 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
294
295
  [XT_INT=$withval
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[char a[((($XT_INT)-1)<0)];
Thomas Jahns's avatar
Thomas Jahns committed
296
char b[($XT_INT)((-($XT_INT)-0.5)+1.5)]]])],,
297
     [AC_MSG_ERROR([Selected index type not compilable or unsigned])])],
Thomas Jahns's avatar
Thomas Jahns committed
298
  [XT_INT=int])
299
300
301
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,
302
dnl              TYPE_C_PRINTF_FMT, TYPE_C_ABS, TYPE_C_CLZ)
303
304
m4_define([vartype_setq],[$1][_MPIDT=$4
     AC_CHECK_SIZEOF([$2])
305
     $1][_FC_KIND=$3
306
307
308
309
310
     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
311
312
313
314
     $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
315
316
317
318
319

dnl
dnl test if MPI_INTEGER[248] are available
save_FCFLAGS=$FCFLAGS
AC_LANG_PUSH([Fortran])
320
FCFLAGS="$MPI_FC_MOD $FCFLAGS"
Thomas Jahns's avatar
Thomas Jahns committed
321
322
323
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([
324
        USE mpi
Thomas Jahns's avatar
Thomas Jahns committed
325
326
327
328
329
330
331
332
333
334
335
        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])

336
m4_foreach([substtype],[[XT_INT]],
337
338
  [AS_CASE(["$substtype"],
     [int],
339
     [vartype_setq(substtype,[int],[c_int],[MPI_INT],
340
341
                   [INT_MAX],["(-INT_MAX)"],["\"d\""],['(abs((v)))'],
                   [acx_cv_have_decl___builtin_clz])],
342
     [long],
343
     [vartype_setq(substtype,[long],[c_long],[MPI_LONG],
344
345
                   [LONG_MAX],["(-LONG_MAX)"],["\"ld\""],['(labs((v)))'],
                   [acx_cv_have_decl___builtin_clzl])],
346
     [short],
347
348
     [vartype_setq(substtype,[short],[c_short],[MPI_SHORT],
                   [SHRT_MAX],["(-SHRT_MAX)"],["\"hd\""],
349
350
351
352
353
354
355
                   ['((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)])])])],
356
     ["long long"],
357
     [vartype_setq(substtype,[long long],[c_long_long],[MPI_LONG_LONG],
358
359
                   [LLONG_MAX],["(-LLONG_MAX)"],["\"lld\""],['(llabs((v)))'],
                   [acx_cv_have_decl___builtin_clzll])],
360
     [AC_MSG_ERROR([Invalid type selected for substtype])])
361
362
363
364
   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"
365
   eval "FCFLAGS=\"\$FCFLAGS \${FPP_DEFOPT}SIZEOF_[]substtype[]=\$ac_cv_sizeof_]AS_TR_SH([$substtype])[\""
366
367
368
369
   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
370
371
   AC_DEFINE_UNQUOTED([CONF_]substtype[_FMT],[$]substtype[_FMT],
     [printf(3) format string for ]subsstype)
372
373
   AC_DEFINE_UNQUOTED(substtype[_ABS(v)],[$]substtype[_abs],
     [return absolute value of v])
374
375
376
377
378
   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])])
379
380
  ])

381
382
383
384
385
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])
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
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])])
414

Thomas Jahns's avatar
Thomas Jahns committed
415
AC_DEFINE_UNQUOTED([XT_INT],[$XT_INT],[Type to use for enumeration of distributed elements.])
416
417
418
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.])

419
420
421
422
423
424
425
426
427
428
429
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])
430

431
432
433
434
435
436
437
438
439
440
441
442
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])

443
444
445
446
447
448
449
450
451
452
453
454
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])

455
456
457
458
459
460
461
462
463
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}"])
464
465
466
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"])
467
468
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
469
AC_CONFIG_COMMANDS_PRE([CC=${BUILD_CC-$CC}])
470
471
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
472
AC_CONFIG_COMMANDS_PRE([FC=${BUILD_FC-$FC}])
473

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

476
477
AC_CONFIG_FILES([						\
	perf/perf_idxsection_get_positions_of_indices_run	\
478
	perf/perf_sparse_array_gather_run			\
Moritz Hanke's avatar
Moritz Hanke committed
479
	tests/test_exchanger_parallel_run			\
480
	tests/test_redist_p2p_parallel_run			\
481
482
	tests/test_redist_collection_parallel_run		\
	tests/test_redist_collection_static_parallel_run	\
Moritz Hanke's avatar
Moritz Hanke committed
483
	tests/test_redist_repeat_parallel_run			\
484
	tests/test_xmap_all2all_parallel_run			\
485
	tests/test_xmap_all2all_intercomm_parallel_run		\
486
	tests/test_xmap_dist_dir_parallel_run			\
487
	tests/test_xmap_dist_dir_intercomm_parallel_run		\
488
	tests/test_xmap_intersection_parallel_run		\
489
        tests/test_initialized_finalized_run			\
Moritz Hanke's avatar
Moritz Hanke committed
490
	tests/test_idxempty_run					\
491
492
	tests/test_idxvec_run					\
	tests/test_idxlist_collection_run			\
Moritz Hanke's avatar
Moritz Hanke committed
493
	tests/test_idxmod_run					\
494
495
	tests/test_idxsection_run				\
	tests/test_idxstripes_run				\
496
497
	tests/test_redist_single_array_base_run			\
	tests/test_redist_single_array_base_parallel_run	\
498
499
	tests/test_redist_collection_run			\
	tests/test_redist_collection_static_run			\
Moritz Hanke's avatar
Moritz Hanke committed
500
	tests/test_redist_repeat_run				\
501
	tests/test_redist_p2p_run				\
Moritz Hanke's avatar
Moritz Hanke committed
502
	tests/test_request_parallel_run				\
503
	tests/test_exported_symbols				\
504
505
	tests/test_xmap_dist_dir_run				\
	tests/test_xmap_all2all_run				\
506
	tests/test_xmap_all2all_fail_run			\
507
508
	tests/test_handles_run					\
	tests/test_ut_run					\
Moritz Hanke's avatar
Moritz Hanke committed
509
510
511
512
        tests/test_perf_run					\
        tests/test_perf_stripes_run				\
        tests/test_sort_run					\
        tests/test_uid_run					\
513
        tests/test_misc_run					\
Moritz Hanke's avatar
Moritz Hanke committed
514
        tests/test_yaxt_run					\
515
	tests/test_mpi_generate_datatype_run			\
516
	tests/test_mpi_smartdedup_run				\
Anna Fuchs's avatar
Anna Fuchs committed
517
	examples/rrobin_run					\
518
	examples/row2col_run					\
519
	examples/tr_gp2fs_run					\
520
	examples/unstruct_halo_exchange_run			\
521
	util/serialrun],[chmod a+x "$ac_file"])
522
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile examples/Makefile \
523
  inst_headers/Makefile inst_headers/f90/Makefile \
524
  src/pkgconfig/yaxt.pc src/pkgconfig/yaxt_c.pc perf/Makefile])
525
526
527
528
529
# 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\$//"
])

530
531
532
533
534
535
536
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.
537
538
AC_CONFIG_COMMANDS([force_dep_regeneration],[$MKDIR_P "tests/${DEPDIR}" "src/${DEPDIR}"
touch "tests/${DEPDIR}/FC.deps" "src/${DEPDIR}/FC.deps"
539
540
541
sleep 1
touch tests/Makefile src/Makefile],
[DEPDIR="${DEPDIR}"])
542
543

AC_OUTPUT
544
545
546
547
dnl
dnl Local Variables:
dnl mode: autoconf
dnl coding: utf-8
548
dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
549
550
dnl license-default: "bsd"
dnl End: