Salome HOME
0bb9e1326a724ba1cec5e05a2f9a2177ab1b27c1
[modules/med.git] / adm_local / unix / config_files / check_scotch.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_SCOTCH],[
24
25 AC_CHECKING(for scotch)
26
27 AC_LANG_SAVE
28 AC_LANG_C
29
30 dnl
31 dnl default values
32 dnl
33 SCOTCH_CPPFLAGS="SCOTCH_CPPFLAGS_NOT_DEFINED"
34 SCOTCH_LIBS="SCOTCH_LIBS_NOT_FOUND"
35 SCOTCH_LIBSUFFIX="-not-defined"
36
37 ENABLE_SCOTCH="no"
38
39 AC_CHECKING(for scotch location)
40
41 AC_ARG_WITH(scotch,
42             [  --with-scotch=DIR      root directory path to SCOTCH library installation ],
43             [SCOTCHDIR="$withval"
44              AC_MSG_RESULT([Select $withval as path to SCOTCH library])])
45
46 if test "x${SCOTCHDIR}" = "x" ; then
47   AC_MSG_WARN(SCOTCHDIR is not specified)
48   AC_MSG_NOTICE(Trying native scotch...)
49   SCOTCHDIR=/usr
50 fi
51
52 CPPFLAGS_old="${CPPFLAGS}"
53 LIBS_old=$LIBS
54
55 scotch_ok=no
56 scotch_headers_ok=no
57 scotch_binaries_ok=no
58
59 dnl
60 dnl SCOTCH headers
61 dnl
62 AC_CHECKING(for SCOTCH headers)
63
64 for d in ${SCOTCHDIR}/include ${SCOTCHDIR}/include/scotch ${SCOTCHDIR}/bin ${SCOTCHDIR} ; do
65   dnl
66   dnl check scotch.h file availability
67   dnl
68   AC_CHECK_FILE([${d}/scotch.h],
69                 [scotch_include_dir_ok=yes],
70                 [scotch_include_dir_ok=no])
71
72   if test "x${scotch_include_dir_ok}" = "xyes" ; then
73     LOCAL_INCLUDES="-DMED_ENABLE_SCOTCH -I${d} ${MPI_INCLUDES}"
74     CPPFLAGS="${CPPFLAGS_old} ${LOCAL_INCLUDES} -std=c99"
75     AC_TRY_COMPILE([
76       #include <stdio.h>
77       #include <scotch.h>
78       ],
79       [SCOTCH_Graph* graph; SCOTCH_graphInit(graph)],
80       [scotch_headers_ok=yes],
81       [scotch_headers_ok=no])
82     if test "x${scotch_headers_ok}" = "xyes" ; then
83       break;
84     fi
85   fi
86 done
87
88 dnl
89 dnl result for headers
90 dnl
91 AC_MSG_RESULT(for scotch headers: $scotch_headers_ok)
92
93 dnl
94 dnl SCOTCH libraries
95 dnl
96 if test "x${scotch_headers_ok}" = "xyes" ; then
97   AC_CHECKING(for scotch libraries)
98
99   for d in ${SCOTCHDIR}/lib ${SCOTCHDIR}/lib64 ${SCOTCHDIR}/lib/scotch ${SCOTCHDIR}/lib64/scotch ${SCOTCHDIR}/bin ${SCOTCHDIR} ; do
100     LOCAL_LIBS="-L${d} -lscotch -lscotcherr"
101     LIBS="${LIBS_old} ${LOCAL_LIBS}"
102     AC_TRY_LINK([
103       #include <stdio.h>
104       #include <scotch.h>
105       ],
106       [SCOTCH_Graph* graph; SCOTCH_graphInit(graph)],
107       [scotch_binaries_ok=yes],
108       [scotch_binaries_ok=no])
109     if test "x${scotch_binaries_ok}" = "xyes" ; then
110       break;
111     fi
112   done
113 fi
114
115 dnl
116 dnl result for libraries
117 dnl
118 AC_MSG_RESULT(for scotch libraries: $scotch_binaries_ok)
119
120 dnl
121 dnl summary
122 dnl
123 if test "x${scotch_binaries_ok}" = "xyes" ; then
124   SCOTCH_CPPFLAGS=${LOCAL_INCLUDES}
125   SCOTCH_LIBS=${LOCAL_LIBS}
126   SCOTCH_LIBSUFFIX=""
127   ENABLE_SCOTCH="yes"
128   scotch_ok=yes
129   AC_MSG_RESULT(\$SCOTCH_CPPFLAGS  = ${SCOTCH_CPPFLAGS})
130   AC_MSG_RESULT(\$SCOTCH_LIBS      = ${SCOTCH_LIBS})
131   AC_MSG_RESULT(\$SCOTCH_LIBSUFFIX = ${SCOTCH_LIBSUFFIX})
132 fi
133 AC_MSG_RESULT(for scotch: $scotch_ok)
134
135 CPPFLAGS="${CPPFLAGS_old}"
136 LIBS="${LIBS_old}"
137
138 AC_SUBST(SCOTCH_CPPFLAGS)
139 AC_SUBST(SCOTCH_LIBSUFFIX)
140 AC_SUBST(SCOTCH_LIBS)
141 AC_SUBST(ENABLE_SCOTCH)
142
143 AC_LANG_RESTORE
144
145 ])dnl
146
147