Newer
Older
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
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lib_petsc.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_PETSC()
#
# DESCRIPTION
#
# This macro provides tests of the availability of PETSC library.
#
#
# The macro adds a --with-petsc option accepting one of three values:
#
# no - do not check for the PETSC library.
# yes - do check for PETSC library in standard locations.
# path - complete path to the PETSC library.
#
# If PETSC is successfully found, this macro calls
#
# AC_SUBST(PETSC_INCLUDE)
# AC_SUBST(PETSC_LIB)
# AC_DEFINE(HAVE_PETSC)
#
# and sets with_petsc="yes"
#
# If PETSC is disabled or not found, this macros sets with_petsc="no"
#
# Your configuration script can test $with_petsc to take any further
# actions. PETSC_{INCLUDE,LIB} may be used when building with C or C++.
#
# To use the macro, one would code one of the following in "configure.ac"
# before AC_OUTPUT:
#
# 1) dnl Check for PETSC support
# AX_LIB_PETSC()
#
# One could test $with_petsc for the outcome or display it as follows
#
# echo "PETSC support: $with_petsc"
#
# You could also for example, override the default CC in "configure.ac"
#
# LICENSE
#
# Copyright (c) 2009 Timothy Brown <tbrown@freeshell.org>
# Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 12
AC_DEFUN([AX_LIB_PETSC], [
AC_MSG_CHECKING(for PETSC library)
AC_REQUIRE([AC_PROG_CC])
#
# User hints...
#
AC_ARG_VAR([PETSC], [PETSC library location])
AC_ARG_WITH([petsc],
[AC_HELP_STRING([--with-petsc],
[user defined path to PETSC library])],
[
if test -n "$PETSC" ; then
AC_MSG_RESULT(yes)
with_petsc=$PETSC
elif test "$withval" != no ; then
AC_MSG_RESULT(yes)
with_petsc=$withval
else
AC_MSG_RESULT(no)
fi
],
[
if test -n "$PETSC" ; then
with_petsc=$PETSC
AC_MSG_RESULT(yes)
else
with_petsc=/usr
if test ! -f "$with_petsc/include/petsc.h" ; then
with_petsc=/usr/local
if test ! -f "$with_petsc/include/petsc.h" ; then
with_petsc=""
AC_MSG_RESULT(failed)
else
AC_MSG_RESULT(yes)
fi
else
AC_MSG_RESULT(yes)
fi
fi
])
#
# locate PETSC library
#
if test -n "$with_petsc" ; then
old_CC=$CC
old_CFLAGS=$CFLAGS
old_LDFLAGS=$LDFLAGS
CFLAGS="-I$with_petsc/include"
LDFLAGS="-L$with_petsc/lib"
CC=$CXX
AC_LANG_SAVE
AC_LANG_C
AC_CHECK_HEADER([petsc.h],petsc_h=yes,## Copy LIB and include in the target directory
AC_MSG_WARN([could not find header file petsc.h]))
AC_CHECK_LIB([petsc],[PetscTrMalloc],petsc_lib=yes,AC_MSG_WARN([could not find libpetsc]))
AC_LANG_RESTORE
CFLAGS=$old_CFLAGS
LDFLAGS=$old_LDFLAGS
CC=$old_CC
AC_MSG_CHECKING(PETSC in $with_petsc)
if test "$petsc_lib" = "yes" -a "$petsc_h" = "yes" ; then
AC_SUBST(PETSC_INCLUDE, [-I$with_petsc/include])
AC_SUBST(PETSC_LIB, [-L$with_petsc/lib])
AC_MSG_RESULT(ok)
AC_DEFINE(HAVE_PETSC,1,[Define if you have PETSC library])
else
AC_MSG_RESULT(failed)
fi
fi
#
#
#
if test x = x"$PETSC_LIB" ; then
ifelse([$2],,[AC_MSG_ERROR(Failed to find valid PETSC library)],[$2])
:
else
ifelse([$1],,[],[$1])
:
fi
])dnl AX_LIB_PETSC