File: cs_petsc.m4

package info (click to toggle)
code-saturne 4.3.3+repack-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 77,992 kB
  • sloc: ansic: 281,257; f90: 122,305; python: 56,490; makefile: 3,915; xml: 3,285; cpp: 3,183; sh: 1,139; lex: 176; yacc: 101; sed: 16
file content (115 lines) | stat: -rw-r--r-- 4,066 bytes parent folder | download
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
dnl--------------------------------------------------------------------------------
dnl
dnl This file is part of Code_Saturne, a general-purpose CFD tool.
dnl
dnl Copyright (C) 1998-2016 EDF S.A.
dnl
dnl This program is free software; you can redistribute it and/or modify it under
dnl the terms of the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any later
dnl version.
dnl
dnl This program is distributed in the hope that it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dnl FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dnl details.
dnl
dnl You should have received a copy of the GNU General Public License along with
dnl this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
dnl Street, Fifth Floor, Boston, MA 02110-1301, USA.
dnl
dnl--------------------------------------------------------------------------------

# CS_AC_TEST_PETSC
#----------------
# modifies or sets cs_have_petsc, PETSC_CPPFLAGS, PETSC_LDFLAGS, and PETSC_LIBS
# depending on libraries found

AC_DEFUN([CS_AC_TEST_PETSC], [

cs_have_petsc=no
cs_have_petsc_header=no
petsc_prefix=""
cs_abs_srcdir=`cd $srcdir && pwd`

AC_ARG_WITH(petsc,
            [AS_HELP_STRING([--with-petsc=PATH],
                            [specify prefix directory for PETSc])],
            [if test "x$withval" = "x"; then
               with_petsc=no
             fi],
            [with_petsc=no])

AC_ARG_WITH(petsc-lib,
            [AS_HELP_STRING([--with-petsc-lib=PATH],
                            [specify directory for PETSc library])],
            [if test "x$with_petsc" != "xno"; then
               with_petsc=yes  saved_LIBS="$LIBS"
             fi
             PETSC_DIR="$with_petsc_lib/petsc"],
            [if test "x$with_petsc" != "xno" -a "x$with_petsc" != "xyes" \
	          -a "x$with_petsc" != "xcheck"; then
               PETSC_DIR="$with_petsc/lib/petsc"
             fi])

if test "x$with_petsc" != "xno" ; then
  if test -f ${PETSC_DIR}/conf/variables ; then
    PETSC_CPPFLAGS=$(make -s -f "$cs_abs_srcdir/build-aux/petsc-variables.makefile" PETSC_DIR="${PETSC_DIR}" getincludedirs)
    PETSC_LDFLAGS=""
    PETSC_LIBS=$(make -s -f "$cs_abs_srcdir/build-aux/petsc-variables.makefile"  PETSC_DIR="${PETSC_DIR}" getlinklibs)
  elif test -f ${PETSC_DIR}/conf/petscvariables ; then
    PETSC_CPPFLAGS=$(make -s -f "$cs_abs_srcdir/build-aux/petsc-petscvariables.makefile" PETSC_DIR="${PETSC_DIR}" getincludedirs)
    PETSC_LDFLAGS=""
    PETSC_LIBS=$(make -s -f "$cs_abs_srcdir/build-aux/petsc-petscvariables.makefile" PETSC_DIR="${PETSC_DIR}" getlinklibs)
  else
      AC_MSG_FAILURE([${PETSC_DIR}/conf/variables or ${PETSC_DIR}/conf/petscvariables not found.
Check --with-petsc or --with-petsc-lib option or PETSc directory structure
({--with-petsc}/lib/conf/variables or {--with-petsc_lib}/conf/variables or
 {--with-petsc}/lib/conf/petscvariables or {--with-petsc_lib}/conf/petscvariables
should be present).])
  fi

  saved_CPPFLAGS="$CPPFLAGS"
  saved_LDFLAGS="$LDFLAGS"
  saved_LIBS="$LIBS"

  CPPFLAGS="${CPPFLAGS} ${PETSC_CPPFLAGS}"
  LDFLAGS="${LDFLAGS}"
  LIBS="${LIBS} ${PETSC_LIBS}"

  AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <petscsys.h>]],
[[PetscInitializeNoArguments();]])
                   ],
                   [ AC_DEFINE([HAVE_PETSC], 1, [PETSc support])
                     cs_have_petsc=yes
                   ],
                   [ AC_MSG_WARN([no PETSc support])
                     cs_have_petsc=no
                   ],
                  )

  if test "x$cs_have_petsc" = "xno"; then
    PETSC_CPPFLAGS=""
    PETSC_LDFLAGS=""
    PETSC_LIBS=""
  fi

  CPPFLAGS="$saved_CPPFLAGS"
  LDFLAGS="$saved_LDFLAGS"
  LIBS="$saved_LIBS"

  unset saved_CPPFLAGS
  unset saved_LDFLAGS
  unset saved_LIBS

fi

AM_CONDITIONAL(HAVE_PETSC, test x$cs_have_petsc = xyes)

AC_SUBST(cs_have_petsc)
AC_SUBST(PETSC_CPPFLAGS)
AC_SUBST(PETSC_LDFLAGS)
AC_SUBST(PETSC_LIBS)
])dnl