-
Notifications
You must be signed in to change notification settings - Fork 3
/
acsm_scrape_petsc_configure.m4
191 lines (170 loc) · 10.5 KB
/
acsm_scrape_petsc_configure.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#---------------------------------------------------------
# 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])
])