Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / adm_local / unix / config_files / check_metis.m4
1 dnl Copyright (C) 2007-2012  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.
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 AC_CHECKING(for METIS Library)
26
27 AC_LANG_SAVE
28 AC_LANG_C
29
30 METIS_CPPFLAGS=""
31 METIS_LIBSUFFIX=""
32 METIS_LIBS=""
33 ENABLE_METIS="no"
34
35 AC_CHECKING(for METIS location)
36 AC_ARG_WITH(metis,
37             [  --with-metis=DIR      root directory path to METIS library installation ],
38             [METISDIR="$withval"
39              AC_MSG_RESULT("select $withval as path to METIS library")])
40
41 AC_MSG_RESULT(\$METISDIR = ${METISDIR})
42
43 CPPFLAGS_old="${CPPFLAGS}"
44 LIBS_old=$LIBS
45
46 if test "x${METISDIR}" != "x" ; then
47   METIS_CPPFLAGS="-DMED_ENABLE_METIS -I${METISDIR}/Lib"
48   METIS_LIBS="-L${METISDIR} -lmetis"
49 fi
50
51 metis_ok=no
52 metis_headers_ok=no
53 metis_binaries_ok=no
54
55 dnl METIS headers
56 AC_CHECKING(for METIS headers)
57 CPPFLAGS="${CPPFLAGS_old} ${METIS_CPPFLAGS}"
58
59 metis_include_dir_ok=yes
60 if test "x${METISDIR}" != "x" ; then
61   AC_CHECK_FILE(${METISDIR}/Lib/metis.h,
62                 metis_include_dir_ok=yes,
63                 metis_include_dir_ok=no)
64 fi
65
66 if test "x${metis_include_dir_ok}" = "xyes" ; then
67   AC_TRY_COMPILE([#include <metis.h>],
68                  [Change2CNumbering(0,0,0)],
69                  metis_headers_ok=yes,
70                  metis_headers_ok=no)
71 fi
72
73 if test "x${metis_headers_ok}" = "xno" ; then
74   METIS_CPPFLAGS="METIS_CPPFLAGS_NOT_DEFINED"
75 else
76   AC_MSG_RESULT(\$METIS_CPPFLAGS = ${METIS_CPPFLAGS})
77 fi
78 AC_MSG_RESULT(for metis headers: $metis_headers_ok)
79
80 if test "x${metis_headers_ok}" = "xyes" ; then
81   dnl METIS binaries
82   AC_CHECKING(for METIS binaries)
83   metis_lib_dir_ok=yes
84   if test "x${METISDIR}" != "x" ; then
85     AC_CHECK_FILE(${METISDIR}/libmetis.a,
86                   metis_lib_dir_ok=yes,
87                   metis_lib_dir_ok=no)
88     if test "x${metis_lib_dir_ok}" = "xno" ; then
89       METIS_LIBSUFFIX=""
90       AC_CHECK_FILE(${METISDIR}/libmetis.a,
91                     metis_lib_dir_ok=yes,
92                     metis_lib_dir_ok=no)
93     fi
94   fi
95   if test "x${metis_lib_dir_ok}" = "xyes" ; then
96     LIBS="${LIBS_old} ${METIS_LIBS}"
97     AC_TRY_LINK([#include <metis.h>],
98                 [Change2CNumbering(0,0,0)],
99                 metis_binaries_ok=yes,
100                 metis_binaries_ok=no)
101     if test "x${metis_binaries_ok}" = "xno" ; then
102       METIS_LIBSUFFIX=""
103       LIBS="${LIBS_old} ${METIS_LIBS} "
104       AC_TRY_LINK([#include <metis.h>],
105                   [Change2CNumbering(0,0,0)],
106                   metis_binaries_ok=yes,
107                   metis_binaries_ok=no)
108     fi
109   fi
110 fi
111
112 if test "x${metis_binaries_ok}" = "xno" ; then
113   METIS_LIBS="METIS_LIBS_NOT_FOUND"
114   METIS_LIBSUFFIX="-not-defined"
115 else
116   AC_MSG_RESULT(\$METIS_LIBSUFFIX = ${METIS_LIBSUFFIX})
117   AC_MSG_RESULT(\$METIS_LIBS = ${METIS_LIBS})
118 fi
119 AC_MSG_RESULT(for metis binaries: $metis_binaries_ok)
120
121 CPPFLAGS="${CPPFLAGS_old}"
122 LIBS="${LIBS_old}"
123
124 if test "x${metis_headers_ok}" = "xyes" ; then
125   if test "x${metis_binaries_ok}" = "xyes" ; then
126     metis_ok=yes
127     ENABLE_METIS="yes"
128   fi
129 fi
130
131 AC_MSG_RESULT(for metis: $metis_ok)
132
133 AC_SUBST(METIS_CPPFLAGS)
134 AC_SUBST(METIS_LIBSUFFIX)
135 AC_SUBST(METIS_LIBS)
136 AC_SUBST(ENABLE_METIS)
137
138 AC_LANG_RESTORE
139
140 ])dnl