Salome HOME
Copyright update: 2016
[modules/med.git] / adm_local / unix / config_files / check_metis.m4
1 dnl Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 dnl
3 dnl Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 dnl
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License, or (at your option) any later version.
10 dnl
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl Lesser General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library; if not, write to the Free Software
18 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 dnl
20 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 dnl
22
23 AC_DEFUN([CHECK_METIS],[
24
25 dnl metis could be already found by CHECK_PARMETIS procedure
26
27 if [[ "x${metis_ok}" != "xyes" ]] ; then
28
29 AC_CHECKING(for METIS Library)
30
31 AC_LANG_SAVE
32 AC_LANG_C
33
34 METIS_CPPFLAGS=""
35 METIS_LIBSUFFIX=""
36 METIS_LIBS=""
37 ENABLE_METIS="no"
38
39 AC_CHECKING(for METIS location)
40 AC_ARG_WITH(metis,
41             [  --with-metis=DIR      root directory path to METIS library installation ],
42             [METISDIR="$withval"
43              AC_MSG_RESULT("select $withval as path to METIS library")])
44
45 AC_MSG_RESULT(\$METISDIR = ${METISDIR})
46
47 CPPFLAGS_old="${CPPFLAGS}"
48 LIBS_old=$LIBS
49
50 if test "x${METISDIR}" != "x" ; then
51   METIS_CPPFLAGS="-DMED_ENABLE_METIS -I${METISDIR}/Lib"
52   METIS_LIBS="-L${METISDIR} -lmetis"
53 fi
54
55 metis_ok=no
56 metis_headers_ok=no
57 metis_binaries_ok=no
58
59 dnl METIS headers
60 AC_CHECKING(for METIS headers)
61 CPPFLAGS="${CPPFLAGS_old} ${METIS_CPPFLAGS}"
62
63 metis_include_dir_ok=yes
64 if test "x${METISDIR}" != "x" ; then
65   AC_CHECK_FILE(${METISDIR}/Lib/metis.h,
66                 metis_include_dir_ok=yes,
67                 metis_include_dir_ok=no)
68 fi
69
70 if test "x${metis_include_dir_ok}" = "xyes" ; then
71   AC_TRY_COMPILE([#include <metis.h>],
72                  [Change2CNumbering(0,0,0)],
73                  metis_headers_ok=yes,
74                  metis_headers_ok=no)
75 fi
76
77 if test "x${metis_headers_ok}" = "xno" ; then
78   METIS_CPPFLAGS="METIS_CPPFLAGS_NOT_DEFINED"
79 else
80   AC_MSG_RESULT(\$METIS_CPPFLAGS = ${METIS_CPPFLAGS})
81 fi
82 AC_MSG_RESULT(for metis headers: $metis_headers_ok)
83
84 if test "x${metis_headers_ok}" = "xyes" ; then
85   dnl METIS binaries
86   AC_CHECKING(for METIS binaries)
87   metis_lib_dir_ok=yes
88   if test "x${METISDIR}" != "x" ; then
89     AC_CHECK_FILE(${METISDIR}/libmetis.a,
90                   metis_lib_dir_ok=yes,
91                   metis_lib_dir_ok=no)
92     if test "x${metis_lib_dir_ok}" = "xno" ; then
93       METIS_LIBSUFFIX=""
94       AC_CHECK_FILE(${METISDIR}/libmetis.a,
95                     metis_lib_dir_ok=yes,
96                     metis_lib_dir_ok=no)
97     fi
98   fi
99   if test "x${metis_lib_dir_ok}" = "xyes" ; then
100     LIBS="${LIBS_old} ${METIS_LIBS}"
101     AC_TRY_LINK([#include <metis.h>],
102                 [Change2CNumbering(0,0,0)],
103                 metis_binaries_ok=yes,
104                 metis_binaries_ok=no)
105     if test "x${metis_binaries_ok}" = "xno" ; then
106       METIS_LIBSUFFIX=""
107       LIBS="${LIBS_old} ${METIS_LIBS} "
108       AC_TRY_LINK([#include <metis.h>],
109                   [Change2CNumbering(0,0,0)],
110                   metis_binaries_ok=yes,
111                   metis_binaries_ok=no)
112     fi
113   fi
114 fi
115
116 if test "x${metis_binaries_ok}" = "xno" ; then
117   METIS_LIBS="METIS_LIBS_NOT_FOUND"
118   METIS_LIBSUFFIX="-not-defined"
119 else
120   AC_MSG_RESULT(\$METIS_LIBSUFFIX = ${METIS_LIBSUFFIX})
121   AC_MSG_RESULT(\$METIS_LIBS = ${METIS_LIBS})
122 fi
123 AC_MSG_RESULT(for metis binaries: $metis_binaries_ok)
124
125 CPPFLAGS="${CPPFLAGS_old}"
126 LIBS="${LIBS_old}"
127
128 if test "x${metis_headers_ok}" = "xyes" ; then
129   if test "x${metis_binaries_ok}" = "xyes" ; then
130     metis_ok=yes
131     ENABLE_METIS="yes"
132   fi
133 fi
134
135 AC_MSG_RESULT(for metis: $metis_ok)
136
137 AC_SUBST(METIS_CPPFLAGS)
138 AC_SUBST(METIS_LIBSUFFIX)
139 AC_SUBST(METIS_LIBS)
140 AC_SUBST(ENABLE_METIS)
141
142 AC_LANG_RESTORE
143
144 fi
145
146 ])dnl