dnl Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
dnl HYPRE Project Developers. See the top-level COPYRIGHT file for details.
dnl
dnl SPDX-License-Identifier: (Apache-2.0 OR MIT)

dnl *********************************************************************
dnl * File Name: configure.in
dnl *
dnl * This file is read when autoconf is run and the configure script is
dnl * generated.
dnl * Configure.in is structured as follows:
dnl * initialization information
dnl * determine the current architecture
dnl * set user specified compilers and any other user specified options
dnl *
dnl * For the given the architecture, an optimal compiler is
dnl * found (if not specified by the user). If the architecture is
dnl * unknown or none of the preferred compilers are available then
dnl * default compilers are found.
dnl *
dnl * For each chosen compiler, the appropriate flags are set for
dnl * optimization, debugging, MPI and pthreading (as required) and the
dnl * C preprocessor is checked.
dnl *
dnl * Finally, library flags are added and AC_SUBST is used to export
dnl * all necessary macro values.
dnl *********************************************************************

dnl *********************************************************************
dnl * NOTES:
dnl *
dnl * Several macros first check whether the compiler works, including:
dnl * AC_CHECK_LIB, AC_CHECK_FUNC, AC_CHECK_FUNCS,
dnl * AC_PROG_CC, AC_PROG_CPP, AC_PROG_CXX, AC_PROG_CXXCPP,
dnl * AC_PROG_FC, AC_FC_WRAPPERS,
dnl * AC_HYPRE_CHECK_MPI, AC_HYPRE_FIND_G2C,
dnl * AC_HYPRE_FIND_BLAS, AC_HYPRE_FIND_LAPACK
dnl *
dnl * The following macros require a Fortran compiler and are protected
dnl * below by checking the hypre_using_fortran variable:
dnl * AC_PROG_FC, AC_FC_WRAPPERS,
dnl * AC_HYPRE_FIND_BLAS, AC_HYPRE_FIND_LAPACK
dnl *********************************************************************

dnl *********************************************************************
dnl * Initialization Information
dnl * Set package information so it only has to be modified in one place
dnl *********************************************************************

m4_define([M4_HYPRE_NAME],    [hypre])
m4_define([M4_HYPRE_VERSION], [2.26.0])
m4_define([M4_HYPRE_NUMBER],  [22600])
m4_define([M4_HYPRE_DATE],    [2022/10/14])
m4_define([M4_HYPRE_TIME],    [00:00:00])
m4_define([M4_HYPRE_BUGS],    [https://github.com/hypre-space/hypre/issues])
m4_define([M4_HYPRE_SRCDIR],  [`pwd`])

m4_include([config/hypre_blas_macros.m4])
m4_include([config/hypre_lapack_macros.m4])
m4_include([config/hypre_macros_misc.m4])

AC_PREREQ(2.59)
AC_REVISION($Id$)
AC_INIT(M4_HYPRE_NAME, M4_HYPRE_VERSION)
AC_CONFIG_HEADERS([HYPRE_config.h:config/HYPRE_config.h.in])
AC_COPYRIGHT([Copyright (c) 1998 Lawrence Livermore National Security, LLC and other
HYPRE Project Developers. See the top-level COPYRIGHT file for details.])

AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR([HYPRE.h])
dnl m4_pattern_allow([AC_HYPRE_[A-Z_]+])

dnl * Change default prefix from /usr/local to ./hypre
dnl * Note that $ expansion of shell variables doesn't work with this AC macro.
AC_PREFIX_DEFAULT([M4_HYPRE_SRCDIR/hypre])

dnl *********************************************************************
dnl * Initialize some variables
dnl *
dnl * For some reason, this type of variable initialization doesn't work
dnl * if done before AC_INIT above.  To keep the release info at the top
dnl * of the file, 'm4_define' is used to define m4 macros first.
dnl *********************************************************************
HYPRE_NAME="M4_HYPRE_NAME"
HYPRE_VERSION="M4_HYPRE_VERSION"
HYPRE_NUMBER=M4_HYPRE_NUMBER
HYPRE_DATE="M4_HYPRE_DATE"
HYPRE_TIME="M4_HYPRE_TIME"
HYPRE_BUGS="M4_HYPRE_BUGS"
HYPRE_SRCDIR="M4_HYPRE_SRCDIR"

AC_DEFINE_UNQUOTED(HYPRE_RELEASE_NAME,    ["$HYPRE_NAME"],    [Release name])
AC_DEFINE_UNQUOTED(HYPRE_RELEASE_VERSION, ["$HYPRE_VERSION"], [Release version])
AC_DEFINE_UNQUOTED(HYPRE_RELEASE_NUMBER,  [$HYPRE_NUMBER],    [Release number])
AC_DEFINE_UNQUOTED(HYPRE_RELEASE_DATE,    ["$HYPRE_DATE"],    [Date of release])
AC_DEFINE_UNQUOTED(HYPRE_RELEASE_TIME,    ["$HYPRE_TIME"],    [Time of release])
AC_DEFINE_UNQUOTED(HYPRE_RELEASE_BUGS,    ["$HYPRE_BUGS"],    [Bug reports])

AC_SUBST(HYPRE_NAME)
AC_SUBST(HYPRE_VERSION)
AC_SUBST(HYPRE_NUMBER)
AC_SUBST(HYPRE_DATE)
AC_SUBST(HYPRE_TIME)
AC_SUBST(HYPRE_BUGS)

AC_SUBST(HYPRE_SRCDIR)

AS_IF([test -d "$HYPRE_SRCDIR/../.git"],
  [
  develop_string=$(git -C $HYPRE_SRCDIR describe --match 'v*' --long --abbrev=9)
  develop_lastag=$(git -C $HYPRE_SRCDIR describe --match 'v*' --abbrev=0)
  develop_number=$(git -C $HYPRE_SRCDIR rev-list --count $develop_lastag..HEAD)
  develop_branch=$(git -C $HYPRE_SRCDIR rev-parse --abbrev-ref HEAD)
  AS_IF([test -n "$develop_string"],
    [
    AC_DEFINE_UNQUOTED(HYPRE_DEVELOP_STRING, ["$develop_string"], [Develop branch string])
    AC_DEFINE_UNQUOTED(HYPRE_DEVELOP_NUMBER, [$develop_number],   [Develop branch commit number])
    AS_IF([test "x$develop_branch" = "xmaster"],
      [AC_DEFINE_UNQUOTED(HYPRE_DEVELOP_BRANCH, ["$develop_branch"], [Main development branch?])],
      [AC_MSG_NOTICE([NOTE: On branch $develop_branch, not the main development branch])]
    )
    ],
    [AC_MSG_NOTICE([NOTE: Could not describe development branch])]
  )
  ],
  [AC_MSG_NOTICE([NOTE: Could not find .git directory])]
)

dnl *********************************************************************
dnl * Clear variables defined by AC_INIT to avoid name conflicts with
dnl * other packages.
dnl *********************************************************************
PACKAGE_DATE=
PACKAGE_TIME=
PACKAGE_DATETIME=
PACKAGE_NAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_TARNAME=
PACKAGE_BUGREPORT=

dnl *********************************************************************
dnl * Initialize hypre variables
dnl *********************************************************************
hypre_user_chose_mpi=no
hypre_user_chose_blas=no
hypre_user_chose_lapack=no
hypre_user_chose_raja=no
hypre_using_raja=no
hypre_user_chose_kokkos=no
hypre_using_kokkos=no

hypre_using_c=yes
hypre_using_cxx=yes

hypre_using_mpi=yes

hypre_using_distributed_ls=yes

hypre_using_superlu=no
hypre_using_dsuperlu=no

hypre_using_fei=no
hypre_using_mli=no

hypre_using_openmp=no
hypre_using_device_openmp=no
hypre_using_insure=no
hypre_using_cuda=no
hypre_using_gpu=no
hypre_using_um=no
hypre_gpu_mpi=no
hypre_using_gpu_profiling=no
hypre_using_cuda_streams=no
hypre_using_cusparse=yes
hypre_using_cublas=yes
hypre_using_curand=yes
hypre_using_cusolver=no
hypre_using_device_pool=no
hypre_using_device_malloc_async=no
hypre_using_umpire=no
hypre_using_umpire_host=no
hypre_using_umpire_device=no
hypre_using_umpire_um=no
hypre_using_umpire_pinned=no

hypre_using_caliper=no
hypre_user_gave_caliper_lib=no
hypre_user_gave_caliper_inc=no

hypre_found_cuda=no

hypre_using_node_aware_mpi=no
hypre_using_memory_tracker=no

hypre_test_using_host=no

hypre_cxxstd=11

dnl *********************************************************************
dnl * Initialize hypre-HIP variables
dnl *********************************************************************
hypre_using_hip=no
hypre_using_rocsparse=no
hypre_using_rocblas=no
hypre_using_rocrand=no

hypre_found_hip=no


dnl *********************************************************************
dnl * Initialize hypre-SYCL variables
dnl *********************************************************************
hypre_using_sycl=no
hypre_using_onemklsparse=no
hypre_using_onemklblas=no
hypre_using_onemklrand=no

hypre_found_mkl=no

dnl *********************************************************************
dnl * Initialize flag-check variables
dnl *********************************************************************
hypre_blas_lib_old_style=no
hypre_blas_lib_dir_old_style=no
hypre_lapack_lib_old_style=no
hypre_lapack_lib_dir_old_style=no

dnl *********************************************************************
dnl * Determine BUILD, HOST, and TARGET types
dnl *********************************************************************
if test "x$build_alias" = "x"
then
   AC_CANONICAL_BUILD
fi

if test "x$host_alias" = "x"
then
   AC_CANONICAL_HOST
fi

if test "x$target_alias" = "x"
then
   target_alias=$host_alias
fi

dnl *********************************************************************
dnl * Define optional features
dnl *********************************************************************
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
               [Set compiler flags for debugging.]),
[case "${enableval}" in
    yes) hypre_using_debug=yes ;;
    no)  hypre_using_debug=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-debug]) ;;
 esac],
[hypre_using_debug=no]
)

AC_ARG_ENABLE(shared,
AS_HELP_STRING([--enable-shared],
               [Build shared libraries (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_shared=yes ;;
    no)  hypre_using_shared=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-shared]) ;;
 esac],
[hypre_using_shared=no]
)

AC_ARG_ENABLE(mixedint,
AS_HELP_STRING([--enable-mixedint],
               [Use long long int for HYPRE_BigInt and int for HYPRE_Int (default is int for both). Note: This option disables Euclid, ParaSails, pilut and CGC coarsening.]),
[case "${enableval}" in
    yes) hypre_using_fei=no
         hypre_using_mixedint=yes
         hypre_using_distributed_ls=no ;;
    no)  hypre_using_mixedint=no
         hypre_using_distributed_ls=yes ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-mixedint]) ;;
 esac],
[hypre_using_mixedint=no]
)
if test "$hypre_using_mixedint" = "yes"
then
   AC_DEFINE(HYPRE_MIXEDINT, 1, [Define to 1 if using long long int for HYPRE_BigInt])
fi

AC_ARG_ENABLE(bigint,
AS_HELP_STRING([--enable-bigint],
               [Use long long int for HYPRE_Int (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_fei=no
         hypre_using_bigint=yes ;;
    no)  hypre_using_bigint=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-bigint]) ;;
 esac],
[hypre_using_bigint=no]
)
if test "$hypre_using_bigint" = "yes"
then
   AC_DEFINE(HYPRE_BIGINT, 1, [Define to 1 if using long long int for HYPRE_Int and HYPRE_BigInt])
fi

AC_ARG_ENABLE(single,
AS_HELP_STRING([--enable-single],
               [Use single precision values (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_fei=no
         hypre_using_single=yes ;;
    no)  hypre_using_single=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-single]) ;;
 esac],
[hypre_using_single=no]
)
if test "$hypre_using_single" = "yes"
then
   AC_DEFINE(HYPRE_SINGLE, 1, [Define to 1 if using single precision values for HYPRE_Real])
fi

AC_ARG_ENABLE(longdouble,
AS_HELP_STRING([--enable-longdouble],
               [Use long double precision values (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_fei=no
         hypre_using_longdouble=yes ;;
    no)  hypre_using_longdouble=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-longdouble]) ;;
 esac],
[hypre_using_longdouble=no]
)
if test "$hypre_using_longdouble" = "yes"
then
   AC_DEFINE(HYPRE_LONG_DOUBLE, 1, [Define to 1 if using quad precision values for HYPRE_Real])
fi

AC_ARG_ENABLE(complex,
AS_HELP_STRING([--enable-complex],
               [Use complex values (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_fei=no
         hypre_using_complex=yes ;;
    no)  hypre_using_complex=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-complex]) ;;
 esac],
[hypre_using_complex=no]
)
if test "$hypre_using_complex" = "yes"
then
   AC_DEFINE(HYPRE_COMPLEX, 1, [Define to 1 if using complex values])
fi

AC_ARG_ENABLE(maxdim,
AS_HELP_STRING([--enable-maxdim=MAXDIM],
               [Change max dimension size to MAXDIM (default is 3).
                Currently must be at least 3.]),
[hypre_maxdim=${enableval}],
[hypre_maxdim=3]
)
AC_DEFINE_UNQUOTED(HYPRE_MAXDIM, [$hypre_maxdim], [Define to be the max dimension size (must be at least 3)])

AC_ARG_ENABLE(persistent,
AS_HELP_STRING([--enable-persistent],
               [Uses persistent communication (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_persistent=yes ;;
    no)  hypre_using_persistent=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-persistent]) ;;
 esac],
[hypre_using_persistent=no]
)
if test "$hypre_using_persistent" = "yes"
then
   AC_DEFINE(HYPRE_USING_PERSISTENT_COMM, 1, [Define to 1 if using persistent communication])
fi

AC_ARG_ENABLE(hopscotch,
AS_HELP_STRING([--enable-hopscotch],
               [Uses hopscotch hashing if configured with OpenMP and
                atomic capability available(default is NO).]),
[case "${enableval}" in
    yes) hypre_using_hopscotch=yes ;;
    no)  hypre_using_hopscotch=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-hopscotch]) ;;
 esac],
[hypre_using_hopscotch=no]
)
if test "$hypre_using_hopscotch" = "yes"
then
   AC_DEFINE(HYPRE_HOPSCOTCH, 1, [Define to 1 if hopscotch hashing])
fi

AC_ARG_ENABLE(fortran,
AS_HELP_STRING([--enable-fortran],
               [Require a working Fortran compiler (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_fortran=yes ;;
    no)  hypre_using_fortran=no ;;
    *)   hypre_using_fortran=yes ;;
 esac],
[hypre_using_fortran=yes]
)

AC_ARG_ENABLE(unified-memory,
AS_HELP_STRING([--enable-unified-memory],
               [Use unified memory for allocating the memory (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_um=yes ;;
    no)  hypre_using_um=no ;;
    *)   hypre_using_um=no ;;
 esac],
[hypre_using_um=no]
)

AC_ARG_ENABLE(cuda-streams,
AS_HELP_STRING([--enable-cuda-streams],
               [Use CUDA streams (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_cuda_streams=yes ;;
    no)  hypre_using_cuda_streams=no ;;
    *)   hypre_using_cuda_streams=yes ;;
 esac],
[hypre_using_cuda_streams=yes]
)

AC_ARG_ENABLE(cusparse,
AS_HELP_STRING([--enable-cusparse],
               [Use cuSPARSE (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_cusparse=yes ;;
    no)  hypre_using_cusparse=no ;;
    *)   hypre_using_cusparse=yes ;;
 esac],
[hypre_using_cusparse=yes]
)

AC_ARG_ENABLE(cusolver,
AS_HELP_STRING([--enable-cusolver],
               [Use cuSOLVER (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_cusolver=yes ;;
    no)  hypre_using_cusolver=no ;;
    *)   hypre_using_cusolver=yes ;;
 esac],
[hypre_using_cusolver=no]
)

AC_ARG_ENABLE(device-memory-pool,
AS_HELP_STRING([--enable-device-memory-pool],
               [Use device pooling allocator (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_device_pool=yes ;;
    no)  hypre_using_device_pool=no ;;
    *)   hypre_using_device_pool=no ;;
 esac],
[hypre_using_device_pool=no]
)

AC_ARG_ENABLE(device-malloc-async,
AS_HELP_STRING([--enable-device-malloc-async],
               [Use device async malloc (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_device_malloc_async=yes ;;
    no)  hypre_using_device_malloc_async=no ;;
    *)   hypre_using_device_malloc_async=no ;;
 esac],
[hypre_using_device_malloc_async=no]
)

AC_ARG_ENABLE(cublas,
AS_HELP_STRING([--enable-cublas],
               [Use cuBLAS (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_cublas=yes ;;
    no)  hypre_using_cublas=no ;;
    *)   hypre_using_cublas=yes ;;
 esac],
[hypre_using_cublas=yes]
)

AC_ARG_ENABLE(curand,
AS_HELP_STRING([--enable-curand],
               [Use cuRAND (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_curand=yes ;;
    no)  hypre_using_curand=no ;;
    *)   hypre_using_curand=yes ;;
 esac],
[hypre_using_curand=yes]
)



AC_ARG_ENABLE(rocsparse,
AS_HELP_STRING([--enable-rocsparse],
               [Use rocSPARSE (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_rocsparse=yes ;;
    no)  hypre_using_rocsparse=no ;;
    *)   hypre_using_rocsparse=yes ;;
 esac],
[hypre_using_rocsparse=yes]
)

AC_ARG_ENABLE(rocblas,
AS_HELP_STRING([--enable-rocblas],
               [Use rocBLAS (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_rocblas=yes ;;
    no)  hypre_using_rocblas=no ;;
    *)   hypre_using_rocblas=no ;;
 esac],
[hypre_using_rocblas=no]
)

AC_ARG_ENABLE(rocrand,
AS_HELP_STRING([--enable-rocrand],
               [Use rocRAND (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_rocrand=yes ;;
    no)  hypre_using_rocrand=no ;;
    *)   hypre_using_rocrand=yes ;;
 esac],
[hypre_using_rocrand=yes]
)

AC_ARG_ENABLE(gpu-profiling,
AS_HELP_STRING([--enable-gpu-profiling],
               [Use NVTX on CUDA, rocTX on HIP (default is NO).]),
[case "${enableval}" in
    yes) hypre_using_gpu_profiling=yes ;;
    no)  hypre_using_gpu_profiling=no ;;
    *)   hypre_using_gpu_profiling=no ;;
 esac],
[hypre_using_gpu_profiling=no]
)

AC_ARG_ENABLE(gpu-aware-mpi,
AS_HELP_STRING([--enable-gpu-aware-mpi],
               [Use GPU memory aware MPI]),
[case "${enableval}" in
    yes) hypre_gpu_mpi=yes ;;
    no)  hypre_gpu_mpi=no ;;
    *)   AC_MSG_ERROR([Bad value ${enableval} for --enable-gpu-aware-mpi]) ;;
 esac],
[hypre_gpu_mpi=no]
)

AC_ARG_ENABLE(onemklsparse,
AS_HELP_STRING([--enable-onemklsparse],
               [Use oneMKL sparse (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_onemklsparse=yes ;;
    no)  hypre_using_onemklsparse=no ;;
    *)   hypre_using_onemklsparse=yes ;;
 esac],
[hypre_using_onemklsparse=yes]
)

AC_ARG_ENABLE(onemklblas,
AS_HELP_STRING([--enable-onemklblas],
               [Use oneMKL blas (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_onemklblas=yes ;;
    no)  hypre_using_onemklblas=no ;;
    *)   hypre_using_onemklblas=yes ;;
 esac],
[hypre_using_onemklblas=yes]
)

AC_ARG_ENABLE(onemklrand,
AS_HELP_STRING([--enable-onemklrand],
               [Use oneMKL rand (default is YES).]),
[case "${enableval}" in
    yes) hypre_using_onemklrand=yes ;;
    no)  hypre_using_onemklrand=no ;;
    *)   hypre_using_onemklrand=yes ;;
 esac],
[hypre_using_onemklrand=yes]
)

dnl * The AC_DEFINE is below, after hypre_using_mpi is completely set
dnl * Need to change to a new approach that always defines variable to some value

dnl *********************************************************************
dnl * Determine if user provided LD flags
dnl *********************************************************************
if test "x$LDFLAGS" = "x"
then
   hypre_user_chose_ldflags=no
else
   hypre_user_chose_ldflags=yes
fi

dnl *********************************************************************
dnl * Determine if user provided C compiler or flags
dnl *********************************************************************
if test "x$CC" = "x"
then
   hypre_user_chose_ccompilers=no
else
   hypre_user_chose_ccompilers=yes
fi

if test "x$CFLAGS" = "x"
then
   hypre_user_chose_cflags=no
else
   hypre_user_chose_cflags=yes
fi

dnl *********************************************************************
dnl * Determine if user provided CXX compiler or flags
dnl *********************************************************************
if test "x$CXX" = "x"
then
   hypre_user_chose_cxxcompilers=no
else
   hypre_user_chose_cxxcompilers=yes
fi

if test "x$CXXFLAGS" = "x"
then
   hypre_user_chose_cxxflags=no
else
   hypre_user_chose_cxxflags=yes
fi

dnl *********************************************************************
dnl * Determine if user provided CUDA compiler or flags
dnl *********************************************************************
AC_ARG_VAR([CUDA_HOME], [CUDA home directory])
AC_ARG_VAR([HYPRE_CUDA_SM], [CUDA architecture])
AC_ARG_VAR([CUCC], [CUDA compiler command])
AC_ARG_VAR([CUFLAGS], [CUDA compiler flags])

if test "x$CUCC" = "x"
then
   hypre_user_chose_cudacompilers=no
else
   hypre_user_chose_cudacompilers=yes
fi

if test "x$CUFLAGS" = "x"
then
   hypre_user_chose_cuflags=no
else
   hypre_user_chose_cuflags=yes
fi

dnl *********************************************************************
dnl * Determine if user provided fortran compiler or flags
dnl *********************************************************************
if test "x$F77" != "x" && test "x$FC" = "x"
then
   FC="$F77"
fi

if test "x$FC" = "x"
then
   hypre_user_chose_fcompilers=no
else
   hypre_user_chose_fcompilers=yes
fi

if test "x$F77FLAGS" != "x"
then
   FCFLAGS="$F77FLAGS $FCFLAGS"
fi

if test "x$FFLAGS" = "x" || test "x$FCFLAGS" = "x"
then
   hypre_user_chose_fflags=no
else
   hypre_user_chose_fflags=yes
fi

dnl *********************************************************************
dnl * Set default AR value if not defined by the user
dnl *********************************************************************
if test "x$AR" = "x"
then
   AR="ar -rcu"
fi

AC_ARG_WITH(cxxstandard,
AS_HELP_STRING([--with-cxxstandard=val],
               [User specifies c++ starndard in val.]),
[hypre_cxxstd=$withval]
)

dnl *********************************************************************
dnl * If the user has specified a c, c++, or fortran compiler on the
dnl * command line, that compiler will be used.  No checks are done
dnl * to assure this compiler is present or working.  Additionally,
dnl * if the user indicated any MPI include, library, or directory
dnl * to use with the chosen compiler those options are identified
dnl * and the appropriate macros are assigned values.
dnl *********************************************************************

AC_ARG_WITH(LD,
AS_HELP_STRING([--with-LD=ARG],
               [Set linker to ARG.  The environment variable 'LD'
                will be overridden.]),
[LD=$withval]
)

AC_ARG_WITH(LDFLAGS,
AS_HELP_STRING([--with-LDFLAGS=ARG],
               [User can manually set linker flags. The 'LDFLAGS'
                environment variable will be overridden.]),
[LDFLAGS=$withval]
)

AC_ARG_WITH(extra-CFLAGS,
AS_HELP_STRING([--with-extra-CFLAGS=ARG],
               [Define extra C compile flag, where ARG is a space-separated
                list (enclosed in quotes) of directories.]),
[EXTRA_CFLAGS=$withval]
)

AC_ARG_WITH(extra-CXXFLAGS,
AS_HELP_STRING([--with-extra-CXXFLAGS=ARG],
               [Define extra C++ compile flag, where ARG is a space-separated
                list (enclosed in quotes) of directories.]),
[EXTRA_CXXFLAGS=$withval]
)

AC_ARG_WITH(extra-CUFLAGS,
AS_HELP_STRING([--with-extra-CUFLAGS=ARG],
               [Define extra CUDA compile flag, where ARG is a space-separated
                list (enclosed in quotes) of directories.]),
[EXTRA_CUFLAGS=$withval]
)

AC_ARG_WITH(extra-BUILDFLAGS,
AS_HELP_STRING([--with-extra-BUILDFLAGS=ARG],
               [Define extra library build flag, where ARG is a space-separated
                list (enclosed in quotes) of directories.]),
[EXTRA_BUILDFLAGS=$withval]
)

AC_ARG_WITH(extra-incpath,
AS_HELP_STRING([--with-extra-incpath=PATH],
               [Define extra include path, where PATH is a space-separated
                list (enclosed in quotes) of directories.]),
[CCFLAGS="${CCFLAGS} -I`echo ${withval}|sed 's/ /\ -I/g'`"]
)

AC_ARG_WITH(extra-ldpath,
AS_HELP_STRING([--with-extra-ldpath=PATH],
               [Define extra ld path, where PATH is a space-separated
                list (enclosed in quotes) of directories.]),
[LDFLAGS="-L`echo ${withval}|sed 's/ /\ -L/g'` ${LDFLAGS}"]
)

AC_ARG_WITH(insure,
AS_HELP_STRING([--with-insure=FLAGS],
               [FLAGS are options to pass to insure. Nothing is done
                to verify that insure is available]),
[case "${withval}" in
    yes) hypre_using_insure=yes
         hypre_using_debug=yes
         hypre_insure_flags="" ;;
    no)  ;;
     *)  hypre_using_insure=yes
         hypre_using_debug=yes
         hypre_insure_flags="$withval" ;;
 esac]
)

AC_ARG_WITH(strict-checking,
AS_HELP_STRING([--with-strict-checking],
               [Compiles without MPI ('--without-MPI') and tries to
                find a compiler option that warns of as many non-ISO
                features as possible.]),
[case "${withval}" in
 yes)
 hypre_user_chose_ccompilers=yes
 hypre_user_chose_cflags=yes
 hypre_user_chose_cxxcompilers=yes
 hypre_user_chose_cxxflags=yes
 hypre_user_chose_fcompilers=yes
 hypre_user_chose_fflags=yes
 hypre_using_debug=yes
 hypre_using_mpi=no

 AC_CHECK_PROGS(CC, [gcc g++ icc icpc pgcc pgCC xlc xlC kcc KCC], [""])
 if test "x$CC" = "x"
 then
    hypre_using_c=no
    CFLAGS=""
 elif test "x$GCC" = "xyes" || test "x$CC" = "xgcc"; then
    FFLAGS="-g -Wall"
    CFLAGS="-g -Wall -std=gnu99 -pedantic"
    CXXFLAGS="-g -Wall -Wshadow -fno-implicit-templates"
    CXXFLAGS="$CXXFLAGS -Woverloaded-virtual -ansi -pedantic"
 elif test "x$CC" = "xicc"; then
    FFLAGS="-g -Wall"
    CFLAGS="-g -Xc -Wall -x c"
    CXXFLAGS="-g -Xc -Wall -x c++"
 elif test "x$CC" = "xpgcc"; then
    FFLAGS="-g -Wall"
    CFLAGS="-g -Xa -Minform,inform"
    CXXFLAGS="-g -A --display_error_number -Minform,inform"
 elif test "x$CC" = "xxlc"; then
    FFLAGS="-g -Wall"
    CFLAGS="-g -qinfo=dcl:eff:pro:rea:ret:use"
    CXXFLAGS="-g  -qinfo=dcl:eff:obs:pro:rea:ret:use"
 elif test "x$CC" = "xKCC" || test "x$CC" = "xkcc"; then
    FFLAGS="-g -Wall"
    CFLAGS="-g --c --strict --lint --display_error_number"
    CFLAGS="$CFLAGS --diag_suppress 45,236,450,826"
    CFLAGS="$CFLAGS,1018,1021,1022,1023,1024,1030,1041"
    CXXFLAGS="-g --strict --lint --display_error_number"
    CXXFLAGS="$CXXFLAGS --diag_suppress 381,450,1023,1024"
 fi

 AC_CHECK_PROGS(CXX, [g++ gcc icpc icc pgCC pgcc xlC xlc KCC kcc], [""])
 if test "x$CXX" = "x"
 then
    hypre_using_cxx=no
    CXXFLAGS=""
 fi
 if test "$hypre_using_fortran" = "yes"
 then
    AC_CHECK_PROGS(FC, [g77 ifort pgf77 xlf], [""])
    if test "x$FC" = "x"
    then
       hypre_using_fortran=no
       FFLAGS=""
    fi
 fi

 AC_DEFINE(HYPRE_SEQUENTIAL,1,[No MPI being used])
 ;;
 esac]
)

dnl ***** MPI

AC_ARG_WITH(MPI-include,
AS_HELP_STRING([--with-MPI-include=DIR],
               [User specifies that mpi.h is in DIR.  The options
                --with-MPI-include --with-MPI-libs and
                --with-MPI-lib-dirs must be used together.]),
[for mpi_dir in $withval; do
    MPIINCLUDE="$MPIINCLUDE -I$mpi_dir"
 done;
 hypre_user_chose_mpi=yes],
[hypre_user_chose_mpi=no]
)

AC_ARG_WITH(MPI-libs,
AS_HELP_STRING([--with-MPI-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of library
                names needed for MPI, e.g. "nsl socket mpi".  The options
                --with-MPI-include --with-MPI-libs and --with-MPI-lib-dirs
                must be used together.]),
[for mpi_lib in $withval; do
    MPILIBS="$MPILIBS -l$mpi_lib"
 done;
 hypre_user_chose_mpi=yes]
)

AC_ARG_WITH(MPI-lib-dirs,
AS_HELP_STRING([--with-MPI-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries specified by
                --with-MPI-libs, e.g "usr/lib /usr/local/mpi/lib".
                The options --with-MPI-include --with-MPI-libs and
                --with-MPI-lib-dirs must be used together.]),
[for mpi_lib_dir in $withval; do
    MPILIBDIRS="-L$mpi_lib_dir $MPILIBDIRS"
 done;
 hypre_user_chose_mpi=yes]
)

AC_ARG_WITH(MPI-flags,
AS_HELP_STRING([--with-MPI-flags=FLAGS],
               [FLAGS is a space separated list (enclosed in quotes) of
                whatever flags other than -l and -L are needed to link
                with MPI libraries-- Does not de-activate autosearch for
                other MPI information. May be used with the other three
                MPI options or alone in conjunction with the automatic MPI
                search.]),
[case "${withval}" in
    yes) MPIFLAGS="" ;;
    no)  MPIFLAGS="" ;;
    *)   MPIFLAGS=$withval ;;
 esac],
[MPIFLAGS=""]
)

dnl ***** Node Aware MPI
AC_ARG_WITH(node-aware-mpi,
AS_HELP_STRING([--with-node-aware-mpi],
               [Use Node Aware MPI (default is NO).]),
[case "$withval" in
    yes) hypre_using_node_aware_mpi=yes;;
    no)  hypre_using_node_aware_mpi=no ;;
    *)   hypre_using_node_aware_mpi=no ;;
 esac],
[hypre_using_node_aware_mpi=no]
)

AC_ARG_WITH(node-aware-mpi-include,
AS_HELP_STRING([--with-node-aware-mpi-include=DIR],
               [User specifies that nap_comm.hpp is in DIR.]),
[for nap_dir in $withval; do
    HYPRE_NAP_INCLUDE="$HYPRE_NAP_INCLUDE -I$nap_dir"
 done;
 hypre_using_node_aware_mpi=yes]
)

dnl ***** memory tracker
AC_ARG_WITH(memory_tracker,
AS_HELP_STRING([--with-memory-tracker],
               [Use memory tracker in hypre (default is NO).]),
[case "$withval" in
    yes) hypre_using_memory_tracker=yes;;
    no)  hypre_using_memory_tracker=no ;;
    *)   hypre_using_memory_tracker=no ;;
 esac],
[hypre_using_memory_tracker=no]
)

dnl ***** hypre tests using host memory
AC_ARG_WITH(test_using_host,
AS_HELP_STRING([--with-test-using-host],
               [Use host memory in hypre test drivers (default is NO).]),
[case "$withval" in
    yes) hypre_test_using_host=yes;;
    no)  hypre_test_using_host=no ;;
    *)   hypre_test_using_host=no ;;
 esac],
[hypre_test_using_host=no]
)

dnl ***** BLAS

AC_ARG_WITH(blas-lib,
AS_HELP_STRING([--with-blas-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for BLAS. OK to use -L and -l flags in the list]),
[for blas_lib in $withval; do
dnl    [libprefix=`echo $blas_lib | cut -c1-2`]
dnl    if test $libprefix = "-L"
dnl    then
dnl       BLASLIBDIRS="$blas_lib $BLASLIBDIRS"
dnl    else
       BLASLIBS="$BLASLIBS $blas_lib"
dnl    fi
 done;
 hypre_user_chose_blas=yes]
)

AC_ARG_WITH(blas-libs,
AS_HELP_STRING([--with-blas-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of libraries
                needed for BLAS (base name only). The options --with-blas-libs and
                --with-blas-lib-dirs must be used together.]),
[for blas_lib in $withval; do
    BLASLIBS="$BLASLIBS -l$blas_lib"
 done;
 hypre_user_chose_blas=yes
 hypre_blas_lib_old_style=yes]
)

AC_ARG_WITH(blas-lib-dirs,
AS_HELP_STRING([--with-blas-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries specified by
                --with-blas-libs, e.g "usr/lib /usr/local/blas/lib".
                The  options --with-blas-libs and --with-blas-lib-dirs
                must be used together.]),
[for blas_lib_dir in $withval; do
    BLASLIBDIRS="-L$blas_lib_dir $BLASLIBDIRS"
 done;
 hypre_user_chose_blas=yes
 hypre_blas_lib_dir_old_style=yes]
)

dnl ***** LAPACK

AC_ARG_WITH(lapack-lib,
AS_HELP_STRING([--with-lapack-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for LAPACK. OK to use -L and -l flags in the list]),
[for lapack_lib in $withval; do
dnl    [libprefix=`echo $lapack_lib | cut -c1-2`]
dnl    if test $libprefix = "-L"
dnl    then
dnl       LAPACKLIBDIRS="$lapack_lib $LAPACKLIBDIRS"
dnl    else
       LAPACKLIBS="$LAPACKLIBS $lapack_lib"
dnl    fi
 done;
 hypre_user_chose_lapack=yes]
)

AC_ARG_WITH(lapack-libs,
AS_HELP_STRING([--with-lapack-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of libraries
                needed for LAPACK (base name only). The options --with-lapack-libs and
                --with-lapack-lib-dirs must be used together.]),
[for lapack_lib in $withval; do
    LAPACKLIBS="$LAPACKLIBS -l$lapack_lib"
 done;
 hypre_user_chose_lapack=yes
 hypre_lapack_lib_old_style=yes]
)

AC_ARG_WITH(lapack-lib-dirs,
AS_HELP_STRING([--with-lapack-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries specified by
                --with-lapack-libs, e.g "usr/lib /usr/local/lapack/lib".
                The options --with-lapack-libs and --with-lapack-lib-dirs
                must be used together.]),
[for lapack_lib_dir in $withval; do
    LAPACKLIBDIRS="-L$lapack_lib_dir $LAPACKLIBDIRS"
 done;
 hypre_user_chose_lapack=yes
 hypre_lapack_lib_dir_old_style=yes]
)

dnl * Define a generic macro to set hypre_fmangle based on withval
AC_DEFUN([AC_HYPRE_SET_FMANGLE],
[
 case "$withval" in
    no-underscores)      hypre_fmangle=1 ;;
    one-underscore)      hypre_fmangle=2 ;;
    two-underscores)     hypre_fmangle=3 ;;
    caps-no-underscores) hypre_fmangle=4 ;;
    one-before-after)    hypre_fmangle=5 ;;
 esac
])

dnl * Define --with-fmangle
AC_ARG_WITH(fmangle,
AS_HELP_STRING([--with-fmangle=FMANGLE],
               [FMANGLE contains a string indicating the type of name mangling
                to use when calling hypre from Fortran.  It can be set to:
                "no-underscores", "one-underscore", "two-underscores",
                "caps-no-underscores", and "one-before-after".]),
[hypre_fmangle=0; AC_HYPRE_SET_FMANGLE],
[hypre_fmangle=0]
)
AC_DEFINE_UNQUOTED(HYPRE_FMANGLE,
                   [$hypre_fmangle],
[Define as follows to set the Fortran name mangling scheme:
 0 = unspecified;
 1 = no underscores;
 2 = one underscore;
 3 = two underscores;
 4 = caps, no underscores;
 5 = one underscore before and after])

dnl * Define a generic macro to set hypre_fmangle_blaslapack based on withval
AC_DEFUN([AC_HYPRE_SET_FMANGLE_BLAS],
[
 case "$withval" in
    no-underscores)      hypre_fmangle_blas=1 ;;
    one-underscore)      hypre_fmangle_blas=2 ;;
    two-underscores)     hypre_fmangle_blas=3 ;;
    caps-no-underscores) hypre_fmangle_blas=4 ;;
    one-before-after)    hypre_fmangle_blas=5 ;;
 esac
])

dnl * Define --with-fmangle-blas
AC_ARG_WITH(fmangle-blas,
AS_HELP_STRING([--with-fmangle-blas=FMANGLE],
               [Name mangling for BLAS.  See --with-fmangle.]),
[hypre_fmangle_blas=0; AC_HYPRE_SET_FMANGLE_BLAS],
[hypre_fmangle_blas=0]
)
AC_DEFINE_UNQUOTED(HYPRE_FMANGLE_BLAS, [$hypre_fmangle_blas], [BLAS mangling])

dnl * Define a generic macro to set hypre_fmangle_blaslapack based on withval
dnl * This could use the same variable for blas, but it is redefined here for the
dnl * rare case that blas/ lapack manglings could be different
AC_DEFUN([AC_HYPRE_SET_FMANGLE_LAPACK],
[
 case "$withval" in
    no-underscores)      hypre_fmangle_lapack=1 ;;
    one-underscore)      hypre_fmangle_lapack=2 ;;
    two-underscores)     hypre_fmangle_lapack=3 ;;
    caps-no-underscores) hypre_fmangle_lapack=4 ;;
    one-before-after)    hypre_fmangle_lapack=5 ;;
 esac
])

dnl * Define --with-fmangle-lapack
AC_ARG_WITH(fmangle-lapack,
AS_HELP_STRING([--with-fmangle-lapack=FMANGLE],
               [Name mangling for LAPACK.  See --with-fmangle.]),
[hypre_fmangle_lapack=0; AC_HYPRE_SET_FMANGLE_LAPACK],
[hypre_fmangle_lapack=0]
)
AC_DEFINE_UNQUOTED(HYPRE_FMANGLE_LAPACK, [$hypre_fmangle_lapack], [LAPACK mangling])

AC_ARG_WITH(print-errors,
AS_HELP_STRING([--with-print-errors],
               [Print HYPRE errors.]),
[if test "$withval" = "yes"
 then
    AC_DEFINE(HYPRE_PRINT_ERRORS,1,[Print HYPRE errors])
 fi]
)

AC_ARG_WITH(timing,
AS_HELP_STRING([--with-timing],
               [Use HYPRE timing routines.]),
[if test "$withval" = "yes"
 then
    AC_DEFINE(HYPRE_TIMING,1,[Using HYPRE timing routines])
 fi]
)

AC_ARG_WITH(openmp,
AS_HELP_STRING([--with-openmp],
               [Use OpenMP.  This may affect which compiler is chosen.]),
[case "${withval}" in
    yes) hypre_using_openmp=yes;;
    no)  hypre_using_openmp=no ;;
 esac],
[hypre_using_openmp=no]
)

AC_ARG_WITH(device-openmp,
AS_HELP_STRING([--with-device-openmp],
               [Use OpenMP 4.5 Device Directives.  This may affect which compiler is chosen.]),
[case "${withval}" in
    yes) hypre_using_device_openmp=yes ;;
    no)  hypre_using_device_openmp=no ;;
 esac],
[hypre_using_device_openmp=no]
)

dnl ***** SuperLU

AC_ARG_WITH(superlu,
AS_HELP_STRING([--with-superlu],
               [Use external SuperLU library.]),
[case "${withval}" in
    no) hypre_using_superlu=no ;;
    *)  hypre_using_superlu=yes ;;
 esac]
)

AS_IF([test "x$with_superlu" = "xyes"],
      [AC_DEFINE(HAVE_SUPERLU, 1, [Define to 1 if using SuperLU])],
      [])

AC_ARG_WITH(superlu-include,
AS_HELP_STRING([--with-superlu-include=DIR],
               [Directory where SuperLU is installed.]),
[for superlu_inc_dir in $withval; do
    SUPERLU_INCLUDE="-I$superlu_inc_dir $SUPERLU_INCLUDE"
 done]
)

AC_ARG_WITH(superlu-lib,
AS_HELP_STRING([--with-superlu-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for SuperLU. OK to use -L and -l flags in the list]),
[for superlu_lib in $withval; do
    SUPERLU_LIBS="$SUPERLU_LIBS $superlu_lib"
 done]
)

dnl ***** DSuperLU

AC_ARG_WITH(dsuperlu,
AS_HELP_STRING([--with-dsuperlu],
               [Use external DSuperLU library.]),
[case "${withval}" in
    no) hypre_using_dsuperlu=no ;;
    *)  hypre_using_dsuperlu=yes ;;
 esac]
)

AS_IF([test "x$with_dsuperlu" = "xyes"],
      [AC_DEFINE(HYPRE_USING_DSUPERLU, 1, [Define to 1 if using DSuperLU])],
      [])

AC_ARG_WITH(dsuperlu-include,
AS_HELP_STRING([--with-dsuperlu-include=DIR],
               [Directory where DSuperLU is installed.]),
[for dsuperlu_inc_dir in $withval; do
    DSUPERLU_INCLUDE="-I$dsuperlu_inc_dir $DSUPERLU_INCLUDE"
 done]
)

AC_ARG_WITH(dsuperlu-lib,
AS_HELP_STRING([--with-dsuperlu-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for DSuperLU. OK to use -L and -l flags in the list]),
[for dsuperlu_lib in $withval; do
    DSUPERLU_LIBS="$DSUPERLU_LIBS $dsuperlu_lib"
 done]
)

dnl ***** FEI

AC_ARG_WITH(fei-inc-dir,
AS_HELP_STRING([--with-fei-inc-dir=DIR],
               [DIR is the directory containing the FEI distribution.]),
[HYPRE_FEI_BASE_DIR="$withval";
 hypre_using_fei=yes]
)

dnl ***** MLI

AC_ARG_WITH(mli,
AS_HELP_STRING([--with-mli],
               [Use MLI]),
[case "${withval}" in
    no) hypre_using_mli=no ;;
    *)  hypre_using_mli=yes ;;
 esac]
)

dnl ***** MPI

AC_ARG_WITH(MPI,
AS_HELP_STRING([--with-MPI],
               [DEFAULT: Compile with MPI.  Selecting --without-MPI
                may affect which compiler is chosen.]),
[case "$withval" in
    no) hypre_using_mpi=no ;;
    *)  hypre_using_mpi=yes ;;
 esac]
)

dnl ***** CUDA

AC_ARG_WITH(cuda,
AS_HELP_STRING([--with-cuda],
               [Use CUDA. Require cuda-8.0 or higher (default is NO).]),
[case "$withval" in
    yes) hypre_using_cuda=yes ;;
    no)  hypre_using_cuda=no ;;
    *)   hypre_using_cuda=no ;;
 esac],
[hypre_using_cuda=no]
)

dnl ***** HIP
AC_ARG_WITH(hip,
AS_HELP_STRING([--with-hip],
               [Use HIP for AMD GPUs. (default is NO).]),
[case "$withval" in
    yes) hypre_using_hip=yes ;;
    no)  hypre_using_hip=no ;;
    *)   hypre_using_hip=no ;;
 esac],
[hypre_using_hip=no]
)

dnl ***** SYCL
AC_ARG_WITH(sycl,
AS_HELP_STRING([--with-sycl],
               [Use SYCL for Intel GPUs. (default is NO).]),
[case "$withval" in
    yes) hypre_using_sycl=yes ;;
    no)  hypre_using_sycl=no ;;
    *)   hypre_using_sycl=no ;;
esac],
[hypre_using_sycl=no]
)

dnl ***** CUDA options

AC_ARG_WITH(cuda-home,
AS_HELP_STRING([--with-cuda-home=DIR],
               [User specifies CUDA_HOME in DIR.]),
[for cuda_dir in $withval; do
    CUDA_HOME="$cuda_dir"
 done;
 hypre_using_cuda=yes]
)

AC_ARG_WITH(gpu-arch,
AS_HELP_STRING([--with-gpu-arch=ARG],
               [User specifies NVIDIA GPU architecture that the CUDA files will be compiled for in ARG, where ARG is a space-separated
                list (enclosed in quotes) of numbers.]),
[
 if test "x${withval}" != "x"
 then
    if test "x${HYPRE_CUDA_SM}" = "x"
    then
       HYPRE_CUDA_SM="${withval}"
    fi
 fi
]
)

dnl ***** SYCL options

AC_ARG_WITH(sycl-target,
AS_HELP_STRING([--with-sycl-target=ARG],
               [User specifies sycl targets for AOT compilation in ARG, where ARG is a comma-separated
                list (enclosed in quotes), e.g. "spir64_gen".]),
[
 if test "x${withval}" != "x"
 then
    if test "x${HYPRE_SYCL_TARGET}" = "x"
    then
       HYPRE_SYCL_TARGET="${withval}"
    fi
 fi
]
)

AC_ARG_WITH(sycl-target-backend,
AS_HELP_STRING([--with-sycl-target-backend=ARG],
               [User specifies additional options for the sycl target backend for AOT compilation in ARG,
                where ARG contains the desired options (enclosed in double+single quotes),
                e.g. --with-sycl-target-backend="'-device 12.1.0,12.4.0'".]),
[
 if test "x${withval}" != "x"
 then
    if test "x${HYPRE_SYCL_TARGET_BACKEND}" = "x"
    then
       HYPRE_SYCL_TARGET_BACKEND="${withval}"
    fi
 fi
]
)

dnl ***** RAJA

AC_ARG_WITH(raja,
AS_HELP_STRING([--with-raja],
               [Use RAJA. Require RAJA package to be compiled properly (default is NO).]),
[case "$withval" in
    yes) hypre_using_raja=yes;;
    no)  hypre_using_raja=no ;;
    *)   hypre_using_raja=no ;;
 esac],
[hypre_using_raja=no]
)

AC_ARG_WITH(raja-include,
AS_HELP_STRING([--with-raja-include=DIR],
               [User specifies that RAJA/*.h is in DIR.  The options
                --with-raja-include --with-raja-libs and
                --with-raja-lib-dirs must be used together.]),
[for raja_dir in $withval; do
    HYPRE_RAJA_INCLUDE="-I$raja_dir $HYPRE_RAJA_INCLUDE"
 done;
 hypre_user_chose_raja=yes]
)

AC_ARG_WITH(raja-lib,
AS_HELP_STRING([--with-raja-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for RAJA. OK to use -L and -l flags in the list]),
[for raja_lib in $withval; do
       HYPRE_RAJA_LIB="$raja_lib $HYPRE_RAJA_LIB"
 done;
hypre_user_chose_raja=yes]
)

AC_ARG_WITH(raja-libs,
AS_HELP_STRING([--with-raja-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of libraries
                needed for RAJA (base name only). The options --with-raja-libs and
                --with-raja-lib-dirs must be used together.]),
[for raja_lib in $withval; do
    HYPRE_RAJA_LIB="-l$raja_lib $HYPRE_RAJA_LIB"
 done;
hypre_user_chose_raja=yes]
)

AC_ARG_WITH(raja-lib-dirs,
AS_HELP_STRING([--with-raja-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries specified by
                --with-raja-libs, e.g "usr/lib /usr/local/lib".
                The  options --with-raja-libs and --raja-blas-lib-dirs
                must be used together.]),
[for raja_lib_dir in $withval; do
    HYPRE_RAJA_LIB_DIR="-L$raja_lib_dir $HYPRE_RAJA_LIB_DIR"
 done;
 hypre_user_chose_raja=yes]
)

dnl ***** Kokkos

AC_ARG_WITH(kokkos,
AS_HELP_STRING([--with-kokkos],
               [Use Kokkos. Require kokkos package to be compiled properly(default is NO).]),
[case "$withval" in
    yes) hypre_using_kokkos=yes ;;
    no)  hypre_using_kokkos=no ;;
    *)   hypre_using_kokkos=no ;;
 esac],
[hypre_using_kokkos=no]
)

AC_ARG_WITH(kokkos-include,
AS_HELP_STRING([--with-kokkos-include=DIR],
               [User specifies that KOKKOS headers is in DIR.  The options
                --with-kokkos-include --with-kokkos-libs and
                --with-kokkos-dirs must be used together.]),
[for kokkos_dir in $withval; do
HYPRE_KOKKOS_INCLUDE="-I$kokkos_dir $HYPRE_KOKKOS_INCLUDE"
done;
hypre_user_chose_kokkos=yes]
)

AC_ARG_WITH(kokkos-lib,
AS_HELP_STRING([--with-kokkos-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for KOKKOS. OK to use -L and -l flags in the list]),
[for kokkos_lib in $withval; do
       HYPRE_KOKKOS_LIB="$kokkos_lib $HYPRE_KOKKOS_LIB"
 done;
hypre_user_chose_kokkos=yes]
)

AC_ARG_WITH(kokkos-libs,
AS_HELP_STRING([--with-kokkos-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of libraries
                needed for KOKKOS (base name only). The options --with-kokkos-libs and
                --with-kokkos-dirs must be used together.]),
[for kokkos_lib in $withval; do
    HYPRE_KOKKOS_LIB="-l$kokkos_lib $HYPRE_KOKKOS_LIB"
 done;
hypre_user_chose_kokkos=yes]
)

AC_ARG_WITH(kokkos-lib-dirs,
AS_HELP_STRING([--with-kokkos-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries and
                Makefile.kokkos is assumed to be in DIRS/../ .
                The  options --with-kokkos-libs and --with-kokkos-dirs
                must be used together.]),
[for kokkos_lib_dir in $withval; do
    HYPRE_KOKKOS_LIB_DIR="-L$kokkos_lib_dir $HYPRE_KOKKOS_LIB_DIR"
 done;
hypre_user_chose_kokkos=yes]
)

dnl **** Umpire

AC_ARG_WITH(umpire-host,
AS_HELP_STRING([--with-umpire-host],
               [Use Umpire Allocator for host memory (default is NO).]),
[case "${withval}" in
    yes) hypre_using_umpire_host=yes ;;
    no)  hypre_using_umpire_host=no ;;
    *)   hypre_using_umpire_host=no ;;
 esac],
[hypre_using_umpire_host=no]
)

AC_ARG_WITH(umpire-device,
AS_HELP_STRING([--with-umpire-device],
               [Use Umpire Allocator for device memory (default is NO).]),
[case "${withval}" in
    yes) hypre_using_umpire_device=yes ;;
    no)  hypre_using_umpire_device=no ;;
    *)   hypre_using_umpire_device=no ;;
 esac],
[hypre_using_umpire_device=no]
)

AC_ARG_WITH(umpire-um,
AS_HELP_STRING([--with-umpire-um],
               [Use Umpire Allocator for unified memory (default is NO).]),
[case "${withval}" in
    yes) hypre_using_umpire_um=yes ;;
    no)  hypre_using_umpire_um=no ;;
    *)   hypre_using_umpire_um=no ;;
 esac],
[hypre_using_umpire_um=no]
)

AC_ARG_WITH(umpire-pinned,
AS_HELP_STRING([--with-umpire-pinned],
               [Use Umpire Allocator for pinned memory (default is NO).]),
[case "${withval}" in
    yes) hypre_using_umpire_pinned=yes ;;
    no)  hypre_using_umpire_pinned=no ;;
    *)   hypre_using_umpire_pinned=no ;;
 esac],
[hypre_using_umpire_pinned=no]
)

dnl the default setting with Umpire, for device and um
AC_ARG_WITH(umpire,
AS_HELP_STRING([--with-umpire],
               [Use Umpire Allocator for device and unified memory (default is NO).]),
[case "${withval}" in
    yes) hypre_using_umpire_device=yes
         hypre_using_umpire_um=yes ;;
    no) ;;
    *) ;;
 esac],
[]
)

AC_ARG_WITH(umpire-include,
AS_HELP_STRING([--with-umpire-include=DIR],
               [User specifies that UMPIRE headers is in DIR.  The options
                --with-umpire-include --with-umpire-libs and
                --with-umpire-dirs must be used together.]),
[for umpire_dir in $withval; do
HYPRE_UMPIRE_INCLUDE="-I$umpire_dir $HYPRE_UMPIRE_INCLUDE"
done;
]
)

AC_ARG_WITH(umpire-lib,
AS_HELP_STRING([--with-umpire-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for UMPIRE. OK to use -L and -l flags in the list]),
[for umpire_lib in $withval; do
       HYPRE_UMPIRE_LIB="$umpire_lib $HYPRE_UMPIRE_LIB"
 done;
]
)

AC_ARG_WITH(umpire-libs,
AS_HELP_STRING([--with-umpire-libs=LIBS],
               [LIBS is space-separated list (enclosed in quotes) of libraries
                needed for UMPIRE (base name only). The options --with-umpire-libs and
                --with-umpire-dirs must be used together.]),
[for umpire_lib in $withval; do
    HYPRE_UMPIRE_LIB="-l$umpire_lib $HYPRE_UMPIRE_LIB"
 done;
]
)

AC_ARG_WITH(umpire-lib-dirs,
AS_HELP_STRING([--with-umpire-lib-dirs=DIRS],
               [DIRS is space-separated list (enclosed in quotes) of
                directories containing the libraries specified by
                --with-umpire-libs, e.g "usr/lib /usr/local/lib".
                The  options --with-umpire-libs and --with-umpire-dirs
                must be used together.]),
[for umpire_lib_dir in $withval; do
    HYPRE_UMPIRE_LIB_DIR="-L$umpire_lib_dir $HYPRE_UMPIRE_LIB_DIR"
 done;
]
)

dnl ***** Caliper

AC_ARG_WITH(caliper,
AS_HELP_STRING([--with-caliper],
               [Use Caliper instrumentation (default is NO).]),
[case "$withval" in
    yes) hypre_using_caliper=yes;;
    *)   hypre_using_caliper=no ;;
esac],
[hypre_using_caliper=no])

AS_IF([test "x$with_caliper" = "xyes"],
      [AC_DEFINE(HYPRE_USING_CALIPER, 1, [Define to 1 if Caliper instrumentation is enabled])],
      [])

AC_ARG_WITH(caliper-include,
AS_HELP_STRING([--with-caliper-include=DIR],
               [Directory where Caliper is installed.]),
[for caliper_inc_dir in $withval; do
    CALIPER_INCLUDE="-I$caliper_inc_dir $CALIPER_INCLUDE"
 done;
 hypre_user_gave_caliper_inc=yes]
)

AC_ARG_WITH(caliper-lib,
AS_HELP_STRING([--with-caliper-lib=LIBS],
               [LIBS is space-separated linkable list (enclosed in quotes) of libraries
                needed for Caliper. OK to use -L and -l flags in the list]),
[for caliper_lib in $withval; do
    CALIPER_LIBS="$CALIPER_LIBS $caliper_lib"
 done;
 hypre_user_gave_caliper_lib=yes]
)

dnl *********************************************************************
dnl * Select compilers if not already defined by command line options
dnl *********************************************************************
if test "$hypre_user_chose_ccompilers" = "no"
then
   if test "$hypre_using_mpi" = "no"
   then
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(CC, [xlc_r xlC_r xlc xlC icc icpc icx icpx gcc g++ pgcc pgCC cc CC kcc KCC])
      else
         AC_CHECK_PROGS(CC, [xlc xlC icc icpc icx icpx gcc g++ pgcc pgCC cc CC kcc KCC])
      fi
   else
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(CC, [mpxlc mpixlc_r mpixlc mpiicc mpiicx mpigcc mpicc mpipgcc mpipgicc])
      else
         AC_CHECK_PROGS(CC, [mpxlc mpixlc mpiicc mpiicx mpigcc mpicc mpipgcc mpipgicc])
      fi
   fi

   if test "x$CC" = "x"
   then
      hypre_using_c=no
   fi
fi

if test "$hypre_user_chose_cxxcompilers" = "no"
then
   if test "$hypre_using_mpi" = "no"
   then
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(CXX, [xlC_r xlc_r xlC xlc icpc icc icpx icx g++ gcc pgCC pgcc pgc++ CC cc KCC kcc])
      else
         AC_CHECK_PROGS(CXX, [xlC xlc icpc icc icpx icx g++ gcc pgCC pgcc pgc++ CC cc KCC kcc])
      fi
   else
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(CXX, [mpxlC mpixlcxx_r mpixlcxx mpixlC mpiicpc mpiicpx mpig++ mpic++ mpicxx mpiCC mpipgCC mpipgic++])
      else
         AC_CHECK_PROGS(CXX, [mpxlC mpixlcxx mpixlC mpiicpc mpiicpx mpig++ mpic++ mpicxx mpiCC mpipgCC mpipgic++])
      fi
   fi

   if test "x$CXX" = "x"
   then
      hypre_using_cxx=no
   fi
fi

if test "$hypre_using_fortran" = "yes" -a "$hypre_user_chose_fcompilers" = "no"
then
   if test "$hypre_using_mpi" = "no"
   then
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(FC, [xlf_r ifort ifx gfortran g77 g95 pgf77 pgfortran f77])
      else
         AC_CHECK_PROGS(FC, [xlf ifort ifx gfortran g77 g95 pgf77 pgfortran f77])
      fi
   else
      if test "$hypre_using_openmp" = "yes"
      then
         AC_CHECK_PROGS(FC, [mpxlf mpixlf77_r mpiifort mpiifx mpif77 mpipgf77 mpipgifort])
      else
         AC_CHECK_PROGS(FC, [mpxlf mpixlf77 mpiifort mpiifx mpif77 mpipgf77 mpipgifort])
      fi
   fi

   if test "x$FC" = "x"
   then
      hypre_using_fortran=no
   fi
fi

if [test "x$hypre_using_cuda" = "xyes" && test "x$hypre_using_device_openmp" = "xyes"]
then
   AC_MSG_ERROR([--with-cuda and --with-device-openmp are mutually exclusive])
fi

if [test "x$hypre_using_cuda" = "xyes" && test "x$hypre_using_hip" = "xyes"]
then
   AC_MSG_ERROR([--with-cuda and --with-hip are mutually exclusive])
fi

if [test "x$hypre_using_hip" = "xyes" && test "x$hypre_using_device_openmp" = "xyes"]
then
   AC_MSG_ERROR([--with-hip and --with-device-openmp are mutually exclusive])
fi


if test "$hypre_user_chose_cudacompilers" = "no"
then
   if test "$hypre_using_device_openmp" = "yes"
   then
      if test "x$hypre_using_kokkos" = "xyes"
      then
         if test "$hypre_using_mpi" = "no"
         then
            AC_CHECK_PROGS(CUCC, [clang++-gpu icpx])
         else
            AC_CHECK_PROGS(CUCC, [mpiclang++-gpu mpiicpx])
         fi
      else
         if test "$hypre_using_mpi" = "no"
         then
            AC_CHECK_PROGS(CUCC, [xlc-gpu clang-gpu icx])
         else
            AC_CHECK_PROGS(CUCC, [mpixlc-gpu mpiclang-gpu mpiicx])
         fi
      fi
   fi

   if test "$hypre_using_cuda" = "yes"
   then
      AC_CHECK_PROGS(CUCC, nvcc, [""], ["${CUDA_HOME}/bin"])
      CUCC="\${HYPRE_CUDA_PATH}/bin/${CUCC} -ccbin=\${CXX}"
   fi

   if test "$hypre_using_hip" = "yes"
   then
      AC_CHECK_PROGS(CUCC, hipcc)
   fi

   if test "$hypre_using_sycl" = "yes"
   then
      AC_CHECK_PROGS(CUCC, dpcpp)
   fi
fi

dnl *********************************************************************
dnl * Check for general programs
dnl *********************************************************************
AC_PROG_MAKE_SET
AC_PROG_RANLIB
dnl AC_PROG_INSTALL
dnl AC_PROG_AWK
dnl AC_PROG_LN_S

dnl *********************************************************************
dnl * Check for compiler related programs
dnl * Most of these AC_PROG_ macros check to see if the compilers works.
dnl *********************************************************************
if test "$hypre_using_c" = "yes"
then
   AC_PROG_CC
fi

if test "$hypre_using_cxx" = "yes"
then
   AC_PROG_CXX
fi

if test "$hypre_using_fortran" = "yes"
then
   AC_PROG_FC
   AC_FC_WRAPPERS
fi

dnl *********************************************************************
dnl * For MPI, set the following:
dnl *********************************************************************
if test "$hypre_using_mpi" = "no"
then
   AC_DEFINE(HYPRE_SEQUENTIAL, 1, [Disable MPI, enable serial codes.])
else
   AC_HYPRE_CHECK_MPI([LIBS="$LIBS $MPILIBS"])
   AC_CHECK_FUNCS([MPI_Comm_f2c])
   AC_CACHE_CHECK([whether MPI_Comm_f2c is a macro],
     hypre_cv_func_MPI_Comm_f2c_macro,
     [AC_EGREP_CPP([mpi_header_defines_MPI_Comm_f2c], [
#include <mpi.h>
#ifdef MPI_Comm_f2c
  mpi_header_defines_MPI_Comm_f2c
#endif],
       hypre_cv_func_MPI_Comm_f2c_macro=yes,
       hypre_cv_func_MPI_Comm_f2c_macro=no)])
   if test $ac_cv_func_MPI_Comm_f2c = yes \
      || test $hypre_cv_func_MPI_Comm_f2c_macro = yes; then
     AC_DEFINE(HYPRE_HAVE_MPI_COMM_F2C,1,[Define to 1 if the routine MPI_Comm_f2c is found])
   fi
fi

if test "$hypre_using_node_aware_mpi" = "yes"
then
   AC_DEFINE(HYPRE_USING_NODE_AWARE_MPI, 1, [Define to 1 if Node Aware MPI library is used])
fi

if test "$hypre_using_memory_tracker" = "yes"
then
   AC_DEFINE(HYPRE_USING_MEMORY_TRACKER, 1, [Define to 1 if want to track memory operations in hypre])
fi

if test "$hypre_test_using_host" = "yes"
then
   AC_DEFINE(HYPRE_TEST_USING_HOST, 1, [Define to 1 if want to use host in hypre tests])
fi

dnl *********************************************************************
dnl * Define appropriate variables if user set blas to either essl or dxml
dnl *********************************************************************
if test "$hypre_user_chose_blas" = "yes"
then
   for blas_lib in $BLASLIBS; do
      if test $blas_lib = "-ldxml"
      then
         AC_DEFINE(HYPRE_USING_DXML, 1, [Using DXML for BLAS])
      fi

      if test $blas_lib = "-lessl"
      then
         AC_DEFINE(HYPRE_USING_ESSL, 1, [Using ESSL for BLAS])
      fi
   done
fi

dnl *********************************************************************
dnl * Find BLAS library if not already set by the user
dnl * If user specified --without-blas or a system one cannot be found,
dnl * default to internal HYPRE routines
dnl *********************************************************************
if test "$hypre_user_chose_blas" = "no"
then
   hypre_using_hypre_blas=yes
   if test "$hypre_using_fortran" = "yes"
   then
      AC_HYPRE_FIND_BLAS
      if test "$BLASLIBS" = "null"
      then
         AC_MSG_WARN([***************************************])
         AC_MSG_WARN([Cannot find BLAS library])
         AC_MSG_WARN([  configuring --without-blas])
         AC_MSG_WARN([***************************************])
      elif test "$BLASLIBS" != "internal"
      then
         hypre_using_hypre_blas=no
      fi
   fi
   if test "$hypre_using_hypre_blas" = "yes"
   then
      BLASLIBDIRS=""
      BLASLIBS=""
      AC_DEFINE(HYPRE_USING_HYPRE_BLAS, 1, [Using internal HYPRE routines])
   fi
fi

dnl *********************************************************************
dnl * Define appropriate variables if user set lapack to essl
dnl *********************************************************************
if test "$hypre_user_chose_lapack" = "yes"
then
   for lapack_lib in $LAPACKLIBS; do
      if test $lapack_lib = "-lessl"
      then
         AC_DEFINE(HYPRE_USING_ESSL, 1, [Using ESSL for Lapack])
      fi
   done
fi

dnl *********************************************************************
dnl * Find LAPACK library if not already set by the user
dnl * If user specified --without-lapack or a system one cannot be found,
dnl * default to internal HYPRE routines
dnl *********************************************************************
if test "$hypre_user_chose_lapack" = "no"
then
   hypre_using_hypre_lapack=yes
   if test "$hypre_using_fortran" = "yes"
   then
      AC_HYPRE_FIND_LAPACK
      if test "$LAPACKLIBS" = "null"
      then
         AC_MSG_WARN([***************************************])
         AC_MSG_WARN([Cannot find LAPACK library])
         AC_MSG_WARN([  configuring --without-lapack])
         AC_MSG_WARN([***************************************])
      elif test "$LAPACKLIBS" != "internal"
      then
         hypre_using_hypre_lapack=no
      fi
   fi
   if test "$hypre_using_hypre_lapack" = "yes"
   then
      LAPACKLIBDIRS=""
      LAPACKLIBS=""
      AC_DEFINE(HYPRE_USING_HYPRE_LAPACK, 1, [Using internal HYPRE routines])
   fi
fi

dnl *********************************************************************
dnl * Determine if FEI and MLI are needed.
dnl * Note that MLI requires both FEI and SuperLU.
dnl *********************************************************************
if test "$hypre_using_fei" = "yes"
then
   HYPRE_FEI_SRC_DIR="$HYPRE_SRCDIR/FEI_mv"
   HYPRE_FEI_SUBDIRS="fei-hypre"
   HYPRE_FEI_HYPRE_FILES="$HYPRE_SRCDIR/FEI_mv/fei-hypre/*.o"
   HYPRE_FEI_FEMLI_FILES=
   if test "$hypre_using_mli" = "yes"
   then
      if test "$hypre_using_superlu" = "yes"
      then
         HYPRE_FEI_SUBDIRS="femli $HYPRE_FEI_SUBDIRS"
         HYPRE_FEI_FEMLI_FILES="$HYPRE_SRCDIR/FEI_mv/femli/*.o"
         AC_DEFINE(HAVE_MLI, 1, [Define to 1 if using MLI])
      fi
   fi
   AC_CHECK_LIB(stdc++, __gxx_personality_v0, LIBS="$LIBS -lstdc++")
else
   HYPRE_FEI_SRC_DIR=
   HYPRE_FEI_BASE_DIR=
   HYPRE_FEI_HYPRE_FILES=
   HYPRE_FEI_FEMLI_FILES=
fi

dnl *********************************************************************
dnl * Determine if Euclid, ParaSails, and Pilut are needed
dnl *********************************************************************
if test "$hypre_using_distributed_ls" = "yes"
then
   HYPRE_DISTRIBUTED_LS_DIR="$HYPRE_SRCDIR/distributed_ls"
   HYPRE_EUCLID_FILES="$HYPRE_SRCDIR/distributed_ls/Euclid/*.o"
   HYPRE_PARASAILS_FILES="$HYPRE_SRCDIR/distributed_ls/ParaSails/*.o"
   HYPRE_PILUT_FILES="$HYPRE_SRCDIR/distributed_ls/pilut/*.o"
else
   HYPRE_DISTRIBUTED_LS_DIR=
   HYPRE_EUCLID_FILES=
   HYPRE_PARASAILS_FILES=
   HYPRE_PILUT_FILES=
fi

dnl *********************************************************************
dnl * Set debug/optimization flags
dnl *********************************************************************
if test "$hypre_using_debug" = "yes"
then
   AC_HYPRE_DEBUG_FLAGS
   AC_DEFINE([HYPRE_DEBUG], 1, [Define to 1 if in debug mode])
else
   AC_HYPRE_OPTIMIZATION_FLAGS
fi

CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}"
CXXFLAGS="${CXXFLAGS} ${EXTRA_CXXFLAGS}"

dnl *********************************************************************
dnl * Set large page option that is needed by all AIX platforms.
dnl *********************************************************************
hypre_platform=`uname`
case $hypre_platform in
   AIX* | aix* | Aix*) LDFLAGS="${LDFLAGS} -blpdata"
                       CFLAGS="${CFLAGS} -blpdata"
                       CXXFLAGS="${CXXFLAGS} -blpdata"
                       FFLAGS="${FFLAGS} -blpdata" ;;
esac

dnl *********************************************************************
dnl * Set default link commands and suffix values
dnl *********************************************************************
dnl LINK_F77="${F77}"
LINK_FC='${FC}'
LINK_CC='${CC}'
LINK_CXX='${CXX}'

HYPRE_LIBSUFFIX=".a"

BUILD_PYTHON=0
PYTHON=""
if test "$hypre_using_python" = "yes"
then
   BUILD_PYTHON=1
   PYTHON="${hypre_python}"
fi

BUILD_JAVA=0
if test "$hypre_using_java" = "yes"
then
   BUILD_JAVA=1
fi

dnl *********************************************************************
dnl * Set INSURE options
dnl *********************************************************************
if test "$hypre_using_insure" = "yes"
then
dnl   LINK_F77="insure"
   LINK_FC="insure"
   LINK_CC="insure"
   LINK_CXX="insure"
   LDFLAGS=`mpicc -link-info | awk '{$1=""; print}'`
   LDFLAGS="$LDFLAGS ${hypre_insure_flags}"
dnl   F77="insure"
   FC="insure"
   CC="insure"
   CXX="insure"
   FFLAGS="`mpicc -link-info | awk '{$1=""; print}'` $FFLAGS"
   CFLAGS="`mpicc -link-info | awk '{$1=""; print}'` $CFLAGS"
   CXXFLAGS="`mpicc -link-info | awk '{$1=""; print}'` $CXXFLAGS"
fi

dnl *********************************************************************
dnl * FIND libraries needed to link with hypre
dnl *********************************************************************
AC_CHECK_LIB(m, cabs, LIBS="$LIBS -lm")
dnl * Commenting this out because it doesn't really behave correctly.
dnl * This should probably be deleted altogether at some point. (RDF)
dnl AC_HYPRE_FIND_G2C

dnl *********************************************************************
dnl * Check working user provided blas and lapack libraries
dnl *********************************************************************
 if test "$hypre_user_chose_blas" = "yes";
 then
   if test "$hypre_blas_lib_old_style" = "yes" -a "$hypre_blas_lib_dir_old_style" = "no";
   then
         AC_MSG_ERROR([*********** Unspecified BLASLIBDIRS error: ******************************
                       --with-blas-libs set without setting corresponding --with-blas-lib-dirs.
                       Please specify directory paths to preferred blas libraries.
                       Otherwise use --with-blas to search for library on the system.
                       See "configure --help" for usage details.
                       ********************************************************************],[9])
   fi
   if test "$hypre_blas_lib_old_style" = "no" -a "$hypre_blas_lib_dir_old_style" = "yes";
   then
         AC_MSG_ERROR([*********** Unspecified BLASLIB error: **********************************
                       --with-blas-lib-dirs set without setting corresponding --with-blas-libs.
                       Please specify base names of preferred blas libraries in the provided dir paths.
                       Otherwise use --with-blas to search for library on the system.
                       See "configure --help" for usage details.
                       ********************************************************************],[9])
   fi
dnl   AC_HYPRE_CHECK_USER_BLASLIBS
 fi

 if test "$hypre_user_chose_lapack" = "yes";
 then
   if test "$hypre_lapack_lib_old_style" = "yes" -a "$hypre_lapack_lib_dir_old_style" = "no";
   then
         AC_MSG_ERROR([*********** Unspecified LAPACKLIBDIRS error: ******************************
                       --with-lapack-libs set without setting corresponding --with-lapack-lib-dirs.
                       Please specify directory paths to preferred lapack libraries.
                       Otherwise use --with-lapack to search for library on the system.
                       See "configure --help" for usage details.
                       ********************************************************************],[9])
   fi
   if test "$hypre_lapack_lib_old_style" = "no" -a "$hypre_lapack_lib_dir_old_style" = "yes";
   then
         AC_MSG_ERROR([*********** Unspecified LAPACKLIB error: **********************************
                       --with-lapack-lib-dirs set without setting corresponding --with-lapack-libs.
                       Please specify base names of preferred lapack libraries in the provided dir paths.
                       Otherwise use --with-lapack to search for library on the system.
                       See "configure --help" for usage details.
                       ********************************************************************],[9])
   fi
dnl   AC_HYPRE_CHECK_USER_LAPACKLIBS
 fi


dnl *********************************************************************
dnl * Set flags if needed to enable shared libraries and Python, Java
dnl *********************************************************************
if test "$hypre_using_shared" = "yes"
then
   HYPRE_LIBSUFFIX=".so"
   SHARED_SET_SONAME="-Wl,-soname,"
   SHARED_OPTIONS="-Wl,-z,defs"

   dnl if test "$hypre_using_cuda" = "yes"
   dnl then
   dnl   SHARED_SET_SONAME="-Xlinker=-soname,"
   dnl   SHARED_OPTIONS="-Xlinker=-z,defs"
   dnl else
   dnl   SHARED_SET_SONAME="-Wl,-soname,"
   dnl   SHARED_OPTIONS="-Wl,-z,defs"
   dnl fi

   SHARED_COMPILE_FLAG="-fPIC"
   case $hypre_platform in
      AIX* | aix* | Aix*) SHARED_COMPILE_FLAG="-qmkshrobj"
                          SHARED_BUILD_FLAG="-G"
dnl                          LINK_F77="${F77} -brtl"
                          LINK_FC='${FC} -brtl'
                          LINK_CC='${CC} -brtl'
                          LINK_CXX='${CXX} -brtl' ;;
      DARWIN* | darwin* | Darwin*) SHARED_BUILD_FLAG="-dynamiclib -undefined dynamic_lookup"
                                   HYPRE_LIBSUFFIX=".dylib"
                                   SHARED_SET_SONAME="-install_name @rpath/"
                                   SHARED_OPTIONS="-undefined error" ;;
                       *) SHARED_BUILD_FLAG="-shared" ;;
   esac
   SHARED_BUILD_FLAG="${SHARED_BUILD_FLAG} ${EXTRA_BUILDFLAGS}"
   FFLAGS="${FFLAGS} ${SHARED_COMPILE_FLAG}"
   CFLAGS="${CFLAGS} ${SHARED_COMPILE_FLAG}"
   CXXFLAGS="${CXXFLAGS} ${SHARED_COMPILE_FLAG}"

dnl   BUILD_F77_SHARED="${F77} ${SHARED_BUILD_FLAG}"
   BUILD_FC_SHARED="\${FC} ${SHARED_BUILD_FLAG}"
   if test "$hypre_using_fei" = "yes"
   then
      BUILD_CC_SHARED="\${CXX} ${SHARED_BUILD_FLAG}"
   else
      BUILD_CC_SHARED="\${CC} ${SHARED_BUILD_FLAG}"
   fi
   BUILD_CXX_SHARED="\${CXX} ${SHARED_BUILD_FLAG}"
   if test "$hypre_using_cuda" == "yes" || test "$hypre_using_hip" == "yes" || test "$hypre_using_kokkos" == "yes"
   then
      dnl BUILD_CC_SHARED="\${CUCC} ${SHARED_BUILD_FLAG}"
      BUILD_CC_SHARED="\${CXX} ${SHARED_BUILD_FLAG}"
   fi
   dnl TODO HIP
fi


dnl *********************************************************************
dnl * Warn if caliper options are incomplete
dnl *********************************************************************
if test "$hypre_using_caliper" = "yes"
then
   if test "$hypre_user_gave_caliper_inc" != "yes"
   then
       AC_MSG_WARN([*******************************************************])
       AC_MSG_WARN([Configuring with --with-caliper=yes without providing])
       AC_MSG_WARN([--with-caliper-include=<path-to-caliper-install>.])
       AC_MSG_WARN([Using default user include path.])
       AC_MSG_WARN([NOTE: Caliper annotations may not work.])
       AC_MSG_WARN([*******************************************************])
   fi
   if test "$hypre_user_gave_caliper_lib" != "yes"
   then
       AC_MSG_WARN([*******************************************************])
       AC_MSG_WARN([Configuring with --with-caliper=yes without providing])
       AC_MSG_WARN([--with-caliper-lib=<path-to-caliper-lib>.])
       AC_MSG_WARN([Using default user library path.])
       AC_MSG_WARN([NOTE: Caliper annotations may not work.])
       AC_MSG_WARN([*******************************************************])
   fi
fi

if [test "x$hypre_using_um" = "xyes"]
then
   if [test "x$hypre_using_cuda" != "xyes" && test "x$hypre_using_device_openmp" != "xyes" && test "x$hypre_using_hip" != "xyes" && test "x$hypre_using_sycl" != "xyes"]
   then
      AC_MSG_ERROR([Asked for unified memory, but not using CUDA, HIP, SYCL, or device OpenMP!])
   fi
fi dnl hypre_using_um

dnl CUDA
if [test "$hypre_using_cuda" = "yes"]
then
   AC_CHECK_HEADERS(["${CUDA_HOME}/include/cuda.h"], [hypre_found_cuda=yes; HYPRE_CUDA_PATH=${CUDA_HOME}])

   if test "x$hypre_found_cuda" != "xyes"
   then
      AC_CHECK_HEADERS(["${CUDA_PATH}/include/cuda.h"], [hypre_found_cuda=yes; HYPRE_CUDA_PATH=${CUDA_PATH}])
   fi

   if test "x$hypre_found_cuda" != "xyes"
   then
      AC_MSG_ERROR([unable to find cuda.h ... Ensure that CUDA_HOME or CUDA_PATH is set])
   fi
fi

dnl *********************************************************************
dnl * Check for HIP header
dnl *********************************************************************

dnl If the user has requested to use HIP, we first check the environment
dnl for ROCM_PATH to point at the ROCm installation. If that is not found,
dnl then we default to `/opt/rocm`.
dnl
dnl TODO: Add an ARG_WITH for rocm so the user can control the ROCm path
dnl       through the configure line
AS_IF([ test x"$hypre_using_hip" == x"yes" ],
      [ AS_IF([ test -n "$ROCM_PATH"],
              [ HYPRE_ROCM_PREFIX=$ROCM_PATH ],
              [ HYPRE_ROCM_PREFIX=/opt/rocm ])

        AC_SUBST(HYPRE_ROCM_PREFIX)
        AC_CHECK_HEADERS( ["${HYPRE_ROCM_PREFIX}/include/hip/hip_common.h"],
                          [hypre_found_hip=yes],
                          [AC_MSG_ERROR([unable to find ${HYPRE_ROCM_PREFIX}/include/hip/hip_common.h ... Ensure ROCm is installed and set ROCM_PATH environment variable to ROCm installation path.])] )],
      [])

dnl *********************************************************************
dnl * Set raja options
dnl *********************************************************************
if test "x$hypre_using_raja" = "xyes"
then
   AC_DEFINE(HYPRE_USING_RAJA, 1, [Define to 1 if executing on host/device with RAJA])

   if test "$hypre_user_chose_cxxflags" = "no"
   then
      if test "$hypre_using_cuda" != "yes"
      then
         if [test "$CXX" = "mpixlC" || test "$CXX" = "xlC_r"]
         then
            CXXFLAGS="${CXXFLAGS} -+ -std=c++${hypre_cxxstd}"
         fi
      fi
   fi

   dnl let CC be CXX
   CC=${CXX}
   LINK_CC=${LINK_CXX}
   CFLAGS=${CXXFLAGS}
fi

dnl *********************************************************************
dnl * Set kokkos options
dnl *********************************************************************
if test "x$hypre_using_kokkos" = "xyes"
then
   AC_DEFINE(HYPRE_USING_KOKKOS, 1, [Define to 1 if executing on host/device with KOKKOS])

   if test "$hypre_user_chose_cxxflags" = "no"
   then
      CXXFLAGS="${CXXFLAGS} -std=c++${hypre_cxxstd}"

      if [test "$CXX" = "mpiclang++" || test "$CXX" = "mpiclang++-gpu" || test "$CXX" = "clang++" || test "$CXX" = "clang++-gpu" || test "$CXX" = "icpx" || test "$CXX" = "mpiicpx"]
      then
         CXXFLAGS="${CXXFLAGS} -x c++"
      fi

      if [test "$CXX" = "mpixlC" || test "$CXX" = "mpixlC-gpu" || test "$CXX" = "xlC" || test "$CXX" = "xlC-gpu"]
      then
         CXXFLAGS="${CXXFLAGS} -+"
      fi
   fi

   dnl let CC be CXX
   dnl CC=${CXX}
   LINK_CC=${LINK_CXX}
   dnl CFLAGS=${CXXFLAGS}
fi

dnl *********************************************************************
dnl * Set umpire options
dnl *********************************************************************
if test "x$hypre_using_umpire_host" = "xyes"
then
   hypre_using_umpire=yes
   AC_DEFINE(HYPRE_USING_UMPIRE_HOST, 1, [Define to 1 if using UMPIRE for host memory])
fi

if test "x$hypre_using_umpire_device" = "xyes"
then
   hypre_using_umpire=yes
   AC_DEFINE(HYPRE_USING_UMPIRE_DEVICE, 1, [Define to 1 if using UMPIRE for device memory])
fi

if test "x$hypre_using_umpire_um" = "xyes"
then
   hypre_using_umpire=yes
   AC_DEFINE(HYPRE_USING_UMPIRE_UM, 1, [Define to 1 if using UMPIRE for unified memory])
fi

if test "x$hypre_using_umpire_pinned" = "xyes"
then
   hypre_using_umpire=yes
   AC_DEFINE(HYPRE_USING_UMPIRE_PINNED, 1, [Define to 1 if using UMPIRE for pinned memory])
fi

if test "x$hypre_using_umpire" = "xyes"
then
   AC_DEFINE(HYPRE_USING_UMPIRE, 1, [Define to 1 if using UMPIRE])
fi

dnl *********************************************************************
dnl * Set CUDA options
dnl *********************************************************************
if test "$hypre_using_cuda" = "yes"
then
   AC_DEFINE(HYPRE_USING_GPU, 1, [Define to 1 if executing on GPU device])

   AC_DEFINE(HYPRE_USING_CUDA, 1, [Define to 1 if executing on device with CUDA])


   LINK_CC=${LINK_CXX}
   dnl LINK_CC='${CUCC}'
   dnl LINK_CXX='${CUCC}'

   dnl CUDA SM
   if test "x$HYPRE_CUDA_SM" = "x"
   then
      HYPRE_CUDA_SM=70
   fi

   HYPRE_CUDA_GENCODE=""
   for sm in ${HYPRE_CUDA_SM}; do
      HYPRE_CUDA_GENCODE="${HYPRE_CUDA_GENCODE}-gencode arch=compute_${sm},code=sm_${sm} "
   done

   if test "$hypre_user_chose_cuflags" = "no"
   then
      CUFLAGS="-lineinfo -expt-extended-lambda -std=c++${hypre_cxxstd} --x cu"
      if test "$hypre_using_debug" = "yes"
      then
         CUFLAGS="-g -O0 ${CUFLAGS}"
      else
         CUFLAGS="-O2 ${CUFLAGS}"
      fi

      dnl if [test "${CXX}" = "mpixlC" || test "${CXX}" = "xlC_r" || test "${CXX}" = "xlC"]
      dnl then
      dnl   CUFLAGS="${CUFLAGS} -Xcompiler \"-Wno-deprecated-register -Wenum-compare\""
      dnl fi

      CUFLAGS="${CUFLAGS} -Xcompiler \"${CXXFLAGS}\""
   fi

   dnl if test "$hypre_using_shared" = "yes"
   dnl then
   dnl   CUFLAGS="${CUFLAGS} -Xcompiler ${SHARED_COMPILE_FLAG}"
   dnl fi

   dnl CFLAGS=${CXXFLAGS}
   dnl LDFLAGS="-Xcompiler \"${LDFLAGS}\""
   HYPRE_CUDA_INCLUDE='-I${HYPRE_CUDA_PATH}/include'
   HYPRE_CUDA_LIBS='-L${HYPRE_CUDA_PATH}/lib64 -lcudart'

   if test "$hypre_using_gpu_profiling" = "yes"
   then
      AC_DEFINE(HYPRE_USING_NVTX, 1, [Define to 1 if using NVIDIA Tools Extension (NVTX)])
      HYPRE_CUDA_LIBS+=" -lnvToolsExt"
   fi

   if test "$hypre_using_cusparse" = "yes"
   then
      AC_DEFINE(HYPRE_USING_CUSPARSE, 1, [Define to 1 if using cuSPARSE])
      HYPRE_CUDA_LIBS+=" -lcusparse"
   fi

   if test "$hypre_using_cublas" = "yes"
   then
      AC_DEFINE(HYPRE_USING_CUBLAS, 1, [Define to 1 if using cuBLAS])
      HYPRE_CUDA_LIBS+=" -lcublas"
   fi

   if test "$hypre_using_curand" = "yes"
   then
      AC_DEFINE(HYPRE_USING_CURAND, 1, [Define to 1 if using cuRAND])
      HYPRE_CUDA_LIBS+=" -lcurand"
   fi

   if test "$hypre_using_cusolver" = "yes"
   then
      AC_DEFINE(HYPRE_USING_CUSOLVER, 1, [Define to 1 if using cuSolver])
      HYPRE_CUDA_LIBS+=" -lcusolver"
   fi

   if test "$hypre_using_device_pool" = "yes"
   then
      AC_DEFINE(HYPRE_USING_DEVICE_POOL, 1, [Define to 1 if using device pooling allocator])
   fi

   if test "$hypre_using_device_malloc_async" = "yes"
   then
      AC_DEFINE(HYPRE_USING_DEVICE_MALLOC_ASYNC, 1, [Define to 1 if using device async malloc])
   fi

   if test "x$hypre_using_cuda_streams" = "xyes"
   then
      AC_DEFINE([HYPRE_USING_CUDA_STREAMS], 1, [Define to 1 if using streams])
   fi
fi

dnl *********************************************************************
dnl * Set HIP options
dnl *********************************************************************
AS_IF([test x"$hypre_using_hip" == x"yes"],
      [
        AC_DEFINE(HYPRE_USING_GPU, 1, [Define to 1 if executing on GPU device])
        AC_DEFINE(HYPRE_USING_HIP, 1, [HIP being used])

        dnl hipcc is just a perl script that wraps things like detection
        dnl of the AMD GPU and the actual invocation of the clang compiler
        dnl from ROCm that supports HIP and all the command line foo needed
        dnl by the compiler. You can force hipcc to emit what it actually does
        dnl by setting HIPCC_VERBOSE=7 in your environment.
        dnl AC_CHECK_PROGS(HIPCC, hipcc)

        dnl (Ab)Using CUCC when compiling HIP
        dnl At this time, we need the linker to be hipcc in order to link
        dnl in device code.
        LINK_CC=${LINK_CXX}
        dnl LINK_CC='${CUCC}'
        dnl LINK_CXX='${CUCC}'


        if test "x${HYPRE_CUDA_SM}" != "x"
        then
           HYPRE_CUDA_GENCODE="--amdgpu-target="
           for sm in ${HYPRE_CUDA_SM}; do
              HYPRE_CUDA_GENCODE="${HYPRE_CUDA_GENCODE}${sm},"
           done
           HYPRE_CUDA_GENCODE="`echo ${HYPRE_CUDA_GENCODE}|sed 's/,$//'`"
        fi

        dnl The "-x hip" is necessary to override the detection of .c files which clang
        dnl interprets as C and therefore invokes the C compiler rather than the HIP part
        dnl of clang. Put HIPCXXFLAGS at the end so the user can override from
        dnl from the configure line.
        HIPCXXFLAGS="-x hip -std=c++14 ${HIPCXXFLAGS}"

        dnl If not in debug mode, at least -O2, but the user can override with
        dnl with HIPCXXFLAGS on the configure line. If in debug mode, -O0 -Wall
        dnl plus flags for debugging symbols
        AS_IF([test x"$hypre_using_debug" == x"yes"],
              [HIPCXXFLAGS="-O1 -Wall -g -ggdb ${HIPCXXFLAGS}"],
              [HIPCXXFLAGS="-O2 ${HIPCXXFLAGS}"],)


        dnl If we're doing a shared build, we need the compile flag for it
        dnl Note we're not just using CXXFLAGS here because that can suck other
        dnl things that don't play nice, like openmp.
        if test "$hypre_using_shared" = "yes"
        then
           HIPCXXFLAGS="${SHARED_COMPILE_FLAG} ${HIPCXXFLAGS}"
        fi

        dnl (Ab)Use CUFLAGS to capture HIP compilation flags
        dnl Put HIPCXXFLAGS at the end so the user can override the optimization level.
        if test "$hypre_user_chose_cuflags" = "no"
        then
           CUFLAGS="${HIPCPPFLAGS} ${HIPCXXFLAGS}"
        fi

        dnl PB: ROCm 5.2 parked all the headers in /opt/rocm-X.Y/include so we just point there.
        dnl     This is backwards compatible to previous ROCm versions.
        dnl These are header-only so no linking needed.
        HYPRE_HIP_INCL="-I${HYPRE_ROCM_PREFIX}/include"

        dnl HIP library
        HYPRE_HIP_LIBS="-L${HYPRE_ROCM_PREFIX}/lib -lamdhip64"

        dnl rocSPARSE, for things like dcsrmv on AMD GPUs
        AS_IF([test x"$hypre_using_rocsparse" == x"yes"],
              [AC_DEFINE(HYPRE_USING_ROCSPARSE, 1, [rocSPARSE being used])
               HYPRE_HIP_LIBS="${HYPRE_HIP_LIBS} -lrocsparse"
               ])

        dnl Note rocSPARSE requires rocBLAS, so this is only controlling
        dnl whether HYPRE explicitly uses rocBLAS in other places or not.
        dnl So we don't need to add any extra libs or anything.
        AS_IF([test x"$hypre_using_rocblas" == x"yes"],
              [AC_DEFINE(HYPRE_USING_ROCBLAS, 1, [rocBLAS being used])
              ])

        dnl rocRAND: random number generation on AMD GPUs
        AS_IF([test x"$hypre_using_rocrand" == x"yes"],
              [AC_DEFINE(HYPRE_USING_ROCRAND, 1, [rocRAND being used])
               HYPRE_HIP_LIBS="${HYPRE_HIP_LIBS} -lrocrand"
               ])

        dnl rocTX tracing API
        AS_IF([test x"$hypre_using_gpu_profiling" == x"yes"],
              [AC_DEFINE(HYPRE_USING_ROCTX, 1, [Define to 1 if using AMD rocTX profiling])
               HYPRE_HIP_LIBS="${HYPRE_HIP_LIBS} -lroctx64"
               ])

        AS_IF([test x"$hypre_using_cuda_streams" == x"yes"],
              [AC_DEFINE(HYPRE_USING_CUDA_STREAMS, 1, [Define to 1 if using streams])
               ])

      ]) dnl AS_IF([test x"$hypre_using_hip" == x"yes"]


dnl *********************************************************************
dnl * Set SYCL options
dnl *********************************************************************
AS_IF([test x"$hypre_using_sycl" == x"yes"],
      [
        AC_DEFINE(HYPRE_USING_GPU,  1, [Define to 1 if executing on GPU device])
        AC_DEFINE(HYPRE_USING_SYCL, 1, [SYCL being used])

        dnl (Ab)Using CUCC when compiling SYCL
        LINK_CC=${CUCC}
        LINK_CXX=${CUCC}

        SYCLFLAGS="-fsycl -fsycl-unnamed-lambda -fsycl-device-code-split=per_kernel"
        if test "$hypre_using_debug" = "yes"
        then
           SYCLFLAGS="-Wall -g ${SYCLFLAGS}"
        else
           SYCLFLAGS="-g -O3 ${SYCLFLAGS}"
        fi

        dnl AOT compilation for specific devices
        if test "x${HYPRE_SYCL_TARGET}" != "x"
        then
           LDFLAGS+=" -fsycl-targets=${HYPRE_SYCL_TARGET}"
        fi
        if test "x${HYPRE_SYCL_TARGET_BACKEND}" != "x"
        then
           LDFLAGS+=" -Xsycl-target-backend ${HYPRE_SYCL_TARGET_BACKEND}"
        fi

        dnl (Ab)Use CUFLAGS to capture SYCL compilation flags
        if test "$hypre_user_chose_cuflags" = "no"
        then
           CUFLAGS="${SYCLFLAGS}"
        fi

        AS_IF([test x"$hypre_using_onemklsparse" == x"yes" || test x"$hypre_using_onemklblas" == x"yes" || test x"$hypre_using_onemklrand" == x"yes"],
              [AC_CHECK_HEADERS(["${MKLROOT}/include/mkl.h"],
                                [hypre_found_mkl=yes],
                                AC_MSG_ERROR([unable to find oneMKL ... Ensure that MKLROOT is set]))
               HYPRE_SYCL_LIBS="${HYPRE_SYCL_LIBS} ${MKLROOT}/lib/intel64/libmkl_sycl.a -Wl,-export-dynamic -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lsycl -lOpenCL -lpthread -lm -ldl"
               HYPRE_SYCL_INCL="${HYPRE_SYCL_INCL} -I${DPLROOT}/include -I${MKLROOT}/include"
               ])

        AS_IF([test x"$hypre_using_onemklsparse" == x"yes"], [AC_DEFINE(HYPRE_USING_ONEMKLSPARSE, 1, [onemkl::SPARSE being used])])

        AS_IF([test x"$hypre_using_onemklblas" == x"yes"], [AC_DEFINE(HYPRE_USING_ONEMKLBLAS, 1, [onemkl::BLAS being used])])

        AS_IF([test x"$hypre_using_onemklrand" == x"yes"], [AC_DEFINE(HYPRE_USING_ONEMKLRAND, 1, [onemkl::rng being used])])

        dnl SYCL should always use streams
        AC_DEFINE(HYPRE_USING_CUDA_STREAMS, 1, [Define to 1 if using streams])

      ]) dnl AS_IF([test x"$hypre_using_sycl" == x"yes"]


dnl *********************************************************************
dnl * Set unified memory options
dnl *********************************************************************
if test "$hypre_using_um" != "yes"
then
   dnl Without UM
   if test "$hypre_using_cuda" = "yes"
   then
      AC_MSG_NOTICE([***********************************************************************])
      AC_MSG_NOTICE([Configuring with --with-cuda=yes without unified memory.])
      AC_MSG_NOTICE([It only works for structured solvers and selected unstructured solvers])
      AC_MSG_NOTICE([Use --enable-unified-memory to compile with unified memory.])
      AC_MSG_NOTICE([***********************************************************************])
   fi
   if test "$hypre_using_hip" = "yes"
   then
      AC_MSG_NOTICE([***********************************************************************])
      AC_MSG_NOTICE([Configuring with --with-hip=yes without unified memory.])
      AC_MSG_NOTICE([It only works for structured solvers and selected unstructured solvers])
      AC_MSG_NOTICE([Use --enable-unified-memory to compile with unified memory.])
      AC_MSG_NOTICE([***********************************************************************])
   fi
   if test "$hypre_using_sycl" = "yes"
   then
      AC_MSG_NOTICE([***********************************************************])
      AC_MSG_NOTICE([Configuring with --with-sycl=yes without unified memory.])
      AC_MSG_NOTICE([It only works for struct interface.])
      AC_MSG_NOTICE([Use --enable-unified-memory to compile with unified memory.])
      AC_MSG_NOTICE([***********************************************************])
   fi
   if test "$hypre_using_device_openmp" = "yes"
   then
      AC_MSG_NOTICE([***********************************************************************])
      AC_MSG_NOTICE([Configuring with --with-device-openmp=yes without unified memory.])
      AC_MSG_NOTICE([It only works for structured solvers and selected unstructured solvers])
      AC_MSG_NOTICE([Use --enable-unified-memory to compile with unified memory.])
      AC_MSG_NOTICE([***********************************************************************])
   fi
fi

dnl *********************************************************************
dnl * Set OpenMP options
dnl *********************************************************************
if test "$hypre_using_openmp" = "yes"
then
   AC_DEFINE([HYPRE_USING_OPENMP],1,[Enable OpenMP support])
fi

dnl *********************************************************************
dnl * Set Device OpenMP options
dnl *********************************************************************
if test "$hypre_using_device_openmp" = "yes"
then
   AC_DEFINE(HYPRE_USING_DEVICE_OPENMP, 1, [Define to 1 if executing on device with OpenMP])

   AC_DEFINE(HYPRE_USING_GPU, 1, [Define to 1 if executing on GPU device])

   AC_DEFINE(HYPRE_DEVICE_OPENMP_ALLOC, 1, [Define to 1 if using OpenMP on device [target alloc version]])

   dnl AC_DEFINE(HYPRE_DEVICE_OPENMP_MAPPED, 1, [Define to 1 if using OpenMP on device [target mapped version]])

   if test "$hypre_user_chose_cuflags" = "no"
   then
      CUFLAGS="${CXXFLAGS} ${CUFLAGS}"
      dnl if [test "$CUCC" = "clang-gpu" || test "$CUCC" = "mpiclang-gpu" || test "$CUCC" = "clang++-gpu" || test "$CUCC" = "mpiclang++-gpu"]
      dnl then
         # dnl this is too old
         #CUFLAGS+=" -fopenmp-nonaliased-maps"
      dnl fi
      if [test "$CUCC" = "icx" || test "$CUCC" = "icpx" || test "$CUCC" = "mpiicx" || test "$CUCC" = "mpiicpx"]
      then
         CUFLAGS+="-qopenmp -fopenmp-targets=spir64"
      fi
   fi

   if test "$hypre_user_chose_ldflags" = "no"
   then
      if [test "$CUCC" = "icx" || test "$CUCC" = "icpx" || test "$CUCC" = "mpiicx" || test "$CUCC" = "mpiicpx"]
      then
         LDFLAGS+="-qopenmp -fopenmp-targets=spir64"
      fi
   fi

   if test "$hypre_using_debug" = "yes"
   then
      AC_DEFINE(HYPRE_DEVICE_OPENMP_CHECK, 1, [Define to 1 if strictly checking OpenMP offload directives])
   fi

   dnl let CC be CXX
   dnl CC=${CXX}
   LINK_CC='${CUCC}'
   LINK_CXX='${CUCC}'
   dnl CXXFLAGS="-x c++ ${CXXFLAGS}"
   dnl CFLAGS=${CXXFLAGS}
fi

dnl *********************************************************************
dnl * Set memory env
dnl *********************************************************************
if test "x$hypre_using_um" = "xyes"
then
   AC_DEFINE([HYPRE_USING_UNIFIED_MEMORY],1,[Define to 1 if using unified memory])
else
   if [test "x$hypre_using_cuda" = "xyes" || test "x$hypre_using_device_openmp" = "xyes" || test "x$hypre_using_hip" = "xyes" || test "x$hypre_using_sycl" = "xyes"]
   then
      AC_DEFINE([HYPRE_USING_DEVICE_MEMORY],1,[Define to 1 if using device memory without UM])
   else
      AC_DEFINE([HYPRE_USING_HOST_MEMORY],1,[Define to 1 if using host memory only])
   fi
fi

if test "$hypre_gpu_mpi" = "yes"
then
   AC_DEFINE([HYPRE_WITH_GPU_AWARE_MPI],1,[Define to 1 if using GPU aware MPI])
fi

CUFLAGS="${CUFLAGS} ${EXTRA_CUFLAGS}"

dnl *********************************************************************
dnl * Set installation directories
dnl *********************************************************************
HYPRE_INSTALLDIR="${prefix}"
HYPRE_LIBINSTALL="${libdir}"
HYPRE_INCINSTALL="${includedir}"

dnl *********************************************************************
dnl * Define machine architecture
dnl *********************************************************************
AC_HYPRE_SET_ARCH

dnl *********************************************************************
dnl * AC_SUBST performs the variable substitutions so they may be used in
dnl * the Makefile.in files. Some macros call AC_SUBST for some of these
dnl * variables, but it does no damage to call it again.
dnl *********************************************************************

dnl *********************************************************************
dnl * compilers and load flags
dnl *********************************************************************

AC_SUBST(CC)
AC_SUBST(CXX)
dnl AC_SUBST(F77)
AC_SUBST(FC)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
dnl AC_SUBST(F77FLAGS)
AC_SUBST(FCFLAGS)
AC_SUBST(FFLAGS)
AC_SUBST(LDFLAGS)

dnl AC_SUBST(LINK_F77)
AC_SUBST(LINK_FC)
AC_SUBST(LINK_CC)
AC_SUBST(LINK_CXX)

dnl AC_SUBST(BUILD_F77_SHARED)
AC_SUBST(BUILD_FC_SHARED)
AC_SUBST(BUILD_CC_SHARED)
AC_SUBST(BUILD_CXX_SHARED)
AC_SUBST(SHARED_COMPILE_FLAG)
AC_SUBST(SHARED_BUILD_FLAG)
AC_SUBST(SHARED_SET_SONAME)
AC_SUBST(SHARED_OPTIONS)

AC_SUBST(BUILD_PYTHON)
AC_SUBST(PYTHON)

AC_SUBST(BUILD_JAVA)

dnl *********************************************************************
dnl * Installation Directories
dnl *********************************************************************
AC_SUBST(HYPRE_INSTALLDIR)
AC_SUBST(HYPRE_LIBINSTALL)
AC_SUBST(HYPRE_INCINSTALL)

dnl *********************************************************************
dnl * General purpose header files, libraries and directories
dnl *********************************************************************
AC_SUBST(LIBS)
AC_SUBST(FLIBS)
AC_SUBST(FCLIBS)
dnl *********************************************************************
dnl * suffix for hypre libraries
dnl *********************************************************************
AC_SUBST(HYPRE_LIBSUFFIX)

dnl *********************************************************************
dnl * MPI-related header files and libraries and directories for
dnl * those libraries
dnl *********************************************************************
AC_SUBST(MPIINCLUDE)
AC_SUBST(MPILIBS)
AC_SUBST(MPILIBDIRS)
AC_SUBST(MPIFLAGS)

dnl *********************************************************************
dnl * distributed_ls related files, libraries and directories
dnl *********************************************************************
AC_SUBST(HYPRE_DISTRIBUTED_LS_DIR)
AC_SUBST(HYPRE_EUCLID_FILES)
AC_SUBST(HYPRE_PARASAILS_FILES)
AC_SUBST(HYPRE_PILUT_FILES)

dnl *********************************************************************
dnl * Node_Aware_MPI
dnl *********************************************************************
AC_SUBST(HYPRE_NAP_INCLUDE)

dnl *********************************************************************
dnl * FEI-related files, libraries and directories
dnl *********************************************************************
AC_SUBST(HYPRE_FEI_SRC_DIR)
AC_SUBST(HYPRE_FEI_BASE_DIR)
AC_SUBST(HYPRE_FEI_SUBDIRS)
AC_SUBST(HYPRE_FEI_HYPRE_FILES)
AC_SUBST(HYPRE_FEI_FEMLI_FILES)

dnl *********************************************************************
dnl * BLAS & LAPACK related information
dnl *********************************************************************
AC_SUBST(BLASLIBDIRS)
AC_SUBST(BLASLIBS)
AC_SUBST(LAPACKLIBDIRS)
AC_SUBST(LAPACKLIBS)

dnl *********************************************************************
dnl * RAJA information
dnl *********************************************************************
AC_SUBST(HYPRE_RAJA_LIB_DIR)
AC_SUBST(HYPRE_RAJA_INCLUDE)
AC_SUBST(HYPRE_RAJA_LIB)

dnl *********************************************************************
dnl * KOKKOS information
dnl *********************************************************************
AC_SUBST(HYPRE_KOKKOS_SRC_DIR)
AC_SUBST(HYPRE_KOKKOS_LIB_DIR)
AC_SUBST(HYPRE_KOKKOS_INCLUDE)
AC_SUBST(HYPRE_KOKKOS_LIB)

dnl *********************************************************************
dnl * UMPIRE information
dnl *********************************************************************
AC_SUBST(HYPRE_UMPIRE_LIB_DIR)
AC_SUBST(HYPRE_UMPIRE_INCLUDE)
AC_SUBST(HYPRE_UMPIRE_LIB)

dnl *********************************************************************
dnl * CUDA stuff
dnl *********************************************************************
AC_SUBST(CUFLAGS)
AC_SUBST(CUCC)
AC_SUBST(HYPRE_CUDA_GENCODE)
AC_SUBST(HYPRE_CUDA_PATH)
AC_SUBST(HYPRE_CUDA_INCLUDE)
AC_SUBST(HYPRE_CUDA_LIBS)

dnl *********************************************************************
dnl * HIP stuff
dnl *********************************************************************
AC_SUBST(HYPRE_HIP_INCL)
AC_SUBST(HYPRE_HIP_LIBS)

dnl *********************************************************************
dnl * SYCL stuff
dnl *********************************************************************
AC_SUBST(HYPRE_SYCL_INCL)
AC_SUBST(HYPRE_SYCL_LIBS)

dnl *********************************************************************
dnl * Caliper instrumentation
dnl *********************************************************************
AC_SUBST(CALIPER_INCLUDE)
AC_SUBST(CALIPER_LIBS)

dnl *********************************************************************
dnl * SuperLU instrumentation
dnl *********************************************************************
AC_SUBST(SUPERLU_INCLUDE)
AC_SUBST(SUPERLU_LIBS)

dnl *********************************************************************
dnl * DSuperLU instrumentation
dnl *********************************************************************
AC_SUBST(DSUPERLU_INCLUDE)
AC_SUBST(DSUPERLU_LIBS)

dnl *********************************************************************
dnl * ar & ranlib substitution
dnl *********************************************************************
AC_SUBST(AR)
AC_SUBST(RANLIB)

dnl *********************************************************************
dnl * Define the files to be configured and made
dnl *********************************************************************
AC_CONFIG_FILES([config/Makefile.config])

AC_OUTPUT()
