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