加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
acsm_scrape_petsc_configure.m4 10.53 KB
一键复制 编辑 原始数据 按行查看 历史
Roy Stogner 提交于 2023-11-08 15:37 . Scrape $CC from PETSc, not just $CXX
#---------------------------------------------------------
# Scrape configuration information from PETSc, but don't
# try to verify the installation yet. We need to establish
# a compiler first
#---------------------------------------------------------
AC_DEFUN([ACSM_SCRAPE_PETSC_CONFIGURE],
[
dnl We need to verify that we've done AC_ARG_ENABLE(petsc)
dnl which occurs in ACSM_COMPILER_CONTROL_ARGS
AC_REQUIRE([ACSM_COMPILER_CONTROL_ARGS])
# Trump --enable-petsc with --disable-mpi
AS_IF([test "x$enablempi" = xno],
[enablepetsc=no;enablepetsc_mpi=no])
AC_ARG_VAR([PETSC_DIR], [path to PETSc installation])
AC_ARG_VAR([PETSC_ARCH], [PETSc build architecture])
AS_IF([test "$enablepetsc" != no],
[
# If the user doesn't have any PETSC directory specified, let's check to
# see if it's installed via Ubuntu module
AS_IF([test "x${PETSC_DIR}" = x],
[
AC_PATH_PROG(PETSCARCH, petscarch)
AS_IF([test "x$PETSCARCH" != x],
[
export PETSC_DIR=/usr/lib/petsc
export PETSC_ARCH=`$PETSCARCH`
AS_IF([test -d ${PETSC_DIR}],
[
AC_MSG_RESULT([using system-provided PETSC_DIR ${PETSC_DIR}])
AC_MSG_RESULT([using system-provided PETSC_ARCH ${PETSC_ARCH}])
])
])
])
AS_IF([test x"$PETSC_DIR" = x], [enablepetsc=no;enablepetsc_mpi=no])
])
AS_IF([test "$enablepetsc" != no],
[
dnl Check for snoopable MPI
AS_IF([test -r ${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf], dnl 2.3.x
[PETSC_MPI=`grep MPIEXEC ${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf | grep -v mpiexec.uni`],
[test -r ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables], dnl 3.0.x
[PETSC_MPI=`grep MPIEXEC ${PETSC_DIR}/${PETSC_ARCH}/conf/petscvariables | grep -v mpiexec.uni`],
[test -r ${PETSC_DIR}/conf/petscvariables], dnl 3.0.x
[PETSC_MPI=`grep MPIEXEC ${PETSC_DIR}/conf/petscvariables | grep -v mpiexec.uni`],
[test -r ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables], dnl 3.6.x
[PETSC_MPI=`grep MPIEXEC ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables | grep -v mpiexec.uni`],
[test -r ${PETSC_DIR}/lib/petsc/conf/petscvariables], dnl 3.6.x
[PETSC_MPI=`grep MPIEXEC ${PETSC_DIR}/lib/petsc/conf/petscvariables | grep -v mpiexec.uni`])
AS_IF([test "x$PETSC_MPI" != x],
[
],
[
enablepetsc_mpi=no
])
# Figure out whether this PETSC_DIR is a PETSc source tree or an installed PETSc.
AS_IF(dnl pre-3.6.0 non-installed PETSc
[test -r ${PETSC_DIR}/makefile && test -r ${PETSC_DIR}/${PETSC_ARCH}/conf/variables],
[PREFIX_INSTALLED_PETSC=no
PETSC_VARS_FILE=${PETSC_DIR}/${PETSC_ARCH}/conf/variables],
dnl 3.6.0+ non-installed PETSc
[test -r ${PETSC_DIR}/makefile && test -r ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/variables],
[PREFIX_INSTALLED_PETSC=no
PETSC_VARS_FILE=${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/variables],
dnl pre 3.6.0 prefix-installed PETSc
[test -r ${PETSC_DIR}/conf/variables],
[PREFIX_INSTALLED_PETSC=yes
PETSC_VARS_FILE=${PETSC_DIR}/conf/variables],
dnl 3.6.0 prefix-installed PETSc
[test -r ${PETSC_DIR}/lib/petsc/conf/variables],
[PREFIX_INSTALLED_PETSC=yes
PETSC_VARS_FILE=${PETSC_DIR}/lib/petsc/conf/variables],
dnl Ubuntu PETSc dpkg
[test -r ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/variables],
[PREFIX_INSTALLED_PETSC=yes
PETSC_VARS_FILE=${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/variables],
dnl Support having a non-prefix-installed PETSc with an
dnl *incorrectly* set PETSC_ARCH environment variable. This is
dnl a less desirable configuration, but we need to support it
dnl for backwards compatibility.
dnl pre-3.6.0 non-installed PETSc with invalid $PETSC_ARCH
[test -r ${PETSC_DIR}/makefile && test -r ${PETSC_DIR}/conf/variables],
[PREFIX_INSTALLED_PETSC=no
PETSC_VARS_FILE=${PETSC_DIR}/conf/variables],
dnl 3.6.0+ non-installed PETSc with invalid $PETSC_ARCH
[test -r ${PETSC_DIR}/makefile && test -r ${PETSC_DIR}/lib/petsc/conf/variables],
[PREFIX_INSTALLED_PETSC=no
PETSC_VARS_FILE=${PETSC_DIR}/lib/petsc/conf/variables],
dnl If nothing else matched
[
AC_MSG_RESULT([<<< Could not find a viable PETSc Makefile to determine PETSC_CC_INCLUDES, etc. >>>])
enablepetsc=no; enablepetsc_mpi=no
]) dnl determining PETSC_VARS_FILE
]) dnl AS_IF(enablepetsc)
dnl If we haven't been disabled yet...
AS_IF([test "$enablepetsc" != no],
[
dnl Set some include and link variables by building and running temporary Makefiles.
dnl Some users may (perhaps foolishly) have an installed PETSc with
dnl configuration information from a system that is incompatible with ours.
dnl One potentially horrible compatibility is a SHELL=/usr/bin/sh variable
dnl definition in petscvariables when we do not have /usr/bin/sh. All
dnl nixes are supposed to have /bin/sh so it should be safe to set
dnl SHELL=/bin/sh always
AS_IF([test "$PREFIX_INSTALLED_PETSC" = "no"],
[
PETSCLINKLIBS=`make -s -C ${PETSC_DIR} SHELL=/bin/sh getlinklibs`
PETSCINCLUDEDIRS=`make -s -C ${PETSC_DIR} SHELL=/bin/sh getincludedirs`
PETSC_CXX=`make -s -C $PETSC_DIR SHELL=/bin/sh getcxxcompiler`
PETSC_CC=`make -s -C $PETSC_DIR SHELL=/bin/sh getccompiler`
PETSC_MPI_INCLUDE_DIRS=`make -s -C $PETSC_DIR SHELL=/bin/sh getmpiincludedirs`
PETSC_MPI_LINK_LIBS=`make -s -C $PETSC_DIR SHELL=/bin/sh getmpilinklibs`
printf '%s\n' "include $PETSC_VARS_FILE" > Makefile_config_petsc
printf '%s\n' "getPETSC_CC_INCLUDES:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(PETSC_CC_INCLUDES)" >> Makefile_config_petsc
printf '%s\n' "getPETSC_FC_INCLUDES:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(PETSC_FC_INCLUDES)" >> Makefile_config_petsc
PETSC_CC_INCLUDES=`make -s -f Makefile_config_petsc SHELL=/bin/sh getPETSC_CC_INCLUDES`
PETSC_FC_INCLUDES=`make -s -f Makefile_config_petsc SHELL=/bin/sh getPETSC_FC_INCLUDES`
rm -f Makefile_config_petsc
],
[
printf '%s\n' "include $PETSC_VARS_FILE" > Makefile_config_petsc
printf '%s\n' "getincludedirs:" >> Makefile_config_petsc
printf '\t%s' "echo " >> Makefile_config_petsc
AS_IF([test -d ${PETSC_DIR}/include],
[printf '%s ' "-I\$(PETSC_DIR)/include" >> Makefile_config_petsc])
AS_IF([test -d ${PETSC_DIR}/${PETSC_ARCH}/include],
[printf '%s ' "-I\$(PETSC_DIR)/\$(PETSC_ARCH)/include" >> Makefile_config_petsc])
printf '%s\n' "\$(BLOCKSOLVE_INCLUDE) \$(HYPRE_INCLUDE) \$(PACKAGES_INCLUDES)" >> Makefile_config_petsc
printf '%s\n' "getPETSC_CC_INCLUDES:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(PETSC_CC_INCLUDES)" >> Makefile_config_petsc
printf '%s\n' "getPETSC_FC_INCLUDES:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(PETSC_FC_INCLUDES)" >> Makefile_config_petsc
printf '%s\n' "getlinklibs:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(PETSC_SNES_LIB)" >> Makefile_config_petsc
printf '%s\n' "getcxxcompiler:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(CXX)" >> Makefile_config_petsc
printf '%s\n' "getccompiler:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(CC)" >> Makefile_config_petsc
printf '%s\n' "getmpiincludedirs:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(MPI_INCLUDE)" >> Makefile_config_petsc
printf '%s\n' "getmpilinklibs:" >> Makefile_config_petsc
printf '\t%s\n' "echo \$(MPI_LIB)" >> Makefile_config_petsc
PETSCLINKLIBS=`make -s -f Makefile_config_petsc SHELL=/bin/sh getlinklibs`
PETSCINCLUDEDIRS=`make -s -f Makefile_config_petsc SHELL=/bin/sh getincludedirs`
PETSC_CC_INCLUDES=`make -s -f Makefile_config_petsc SHELL=/bin/sh getPETSC_CC_INCLUDES`
PETSC_FC_INCLUDES=`make -s -f Makefile_config_petsc SHELL=/bin/sh getPETSC_FC_INCLUDES`
PETSC_CXX=`make -s -f Makefile_config_petsc SHELL=/bin/sh getcxxcompiler`
PETSC_CC=`make -s -f Makefile_config_petsc SHELL=/bin/sh getccompiler`
PETSC_MPI_INCLUDE_DIRS=`make -s -f Makefile_config_petsc SHELL=/bin/sh getmpiincludedirs`
PETSC_MPI_LINK_LIBS=`make -s -f Makefile_config_petsc SHELL=/bin/sh getmpilinklibs`
rm -f Makefile_config_petsc
]) dnl scrape petsc cxx, includes, and libs
dnl Debugging: see what actually got set for PETSCINCLUDEDIRS
dnl echo ""
dnl echo "PETSCLINKLIBS=$PETSCLINKLIBS"
dnl echo "PETSCINCLUDEDIRS=$PETSCINCLUDEDIRS"
dnl echo ""
# We sometimes need the full CC_INCLUDES to access a
# PETSc-snooped MPI
PETSCINCLUDEDIRS="$PETSCINCLUDEDIRS $PETSC_CC_INCLUDES"
]) dnl AS_IF(enable_petsc)
AS_IF([test "$enablepetsc" = no && test "$enablepetsc_mpi" != no],
[
AC_MSG_ERROR([petsc was disabled but petscs mpi was not disabled])
AC_MSG_ERROR([something wrong must have happened during the configure process])
AC_MSG_ERROR([please contact the libmesh-users mailing list for support])
])
AS_IF([test "$enablepetsc_mpi" != no], [PETSC_HAVE_MPI=1])
])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化