]> SALOME platform Git repositories - tools/medcoupling.git/blob - adm_local/unix/config_files/check_scotch.m4
Salome HOME
d38f2ea858a1496acdeb97cbf12c8d688a3003fc
[tools/medcoupling.git] / adm_local / unix / config_files / check_scotch.m4
1 dnl Copyright (C) 2007-2023  CEA, EDF, 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_RESULT(for \${SCOTCH_ROOT_DIR}: ${SCOTCH_ROOT_DIR})
48    # --with-scotch option is not used
49    if test "x${SCOTCH_ROOT_DIR}" != "x" ; then
50       SCOTCHDIR=${SCOTCH_ROOT_DIR}
51    fi
52 fi
53
54 if test "x${SCOTCHDIR}" = "x" ; then
55   AC_MSG_WARN(SCOTCHDIR is not specified)
56   AC_MSG_NOTICE(Trying native scotch...)
57   SCOTCHDIR=/usr
58 fi
59
60 CPPFLAGS_old="${CPPFLAGS}"
61 LIBS_old=$LIBS
62
63 scotch_ok=no
64 scotch_headers_ok=no
65 scotch_binaries_ok=no
66
67 dnl
68 dnl SCOTCH headers
69 dnl
70 AC_CHECKING(for SCOTCH headers)
71
72 for d in ${SCOTCHDIR}/include ${SCOTCHDIR}/include/scotch ${SCOTCHDIR}/bin ${SCOTCHDIR} ; do
73   dnl
74   dnl check scotch.h file availability
75   dnl
76   AC_CHECK_FILE([${d}/scotch.h],
77                 [scotch_include_dir_ok=yes],
78                 [scotch_include_dir_ok=no])
79
80   if test "x${scotch_include_dir_ok}" = "xyes" ; then
81     LOCAL_INCLUDES="-DMED_ENABLE_SCOTCH -I${d} ${MPI_INCLUDES}"
82     CPPFLAGS="${CPPFLAGS_old} ${LOCAL_INCLUDES} -std=c99"
83     AC_TRY_COMPILE([
84       #include <stdio.h>
85       #include <scotch.h>
86       ],
87       [SCOTCH_Graph* graph; SCOTCH_graphInit(graph)],
88       [scotch_headers_ok=yes],
89       [scotch_headers_ok=no])
90     if test "x${scotch_headers_ok}" = "xyes" ; then
91       break;
92     fi
93   fi
94 done
95
96 dnl
97 dnl result for headers
98 dnl
99 AC_MSG_RESULT(for scotch headers: $scotch_headers_ok)
100
101 dnl
102 dnl SCOTCH libraries
103 dnl
104 if test "x${scotch_headers_ok}" = "xyes" ; then
105   AC_CHECKING(for scotch libraries)
106
107   for d in ${SCOTCHDIR}/lib ${SCOTCHDIR}/lib64 ${SCOTCHDIR}/lib/scotch ${SCOTCHDIR}/lib64/scotch ${SCOTCHDIR}/bin ${SCOTCHDIR} ; do
108     LOCAL_LIBS="-L${d} -lscotch -lscotcherr"
109     LIBS="${LIBS_old} ${LOCAL_LIBS}"
110     AC_TRY_LINK([
111       #include <stdio.h>
112       #include <scotch.h>
113       ],
114       [SCOTCH_Graph* graph; SCOTCH_graphInit(graph)],
115       [scotch_binaries_ok=yes],
116       [scotch_binaries_ok=no])
117     if test "x${scotch_binaries_ok}" = "xyes" ; then
118       break;
119     fi
120   done
121 fi
122
123 dnl
124 dnl result for libraries
125 dnl
126 AC_MSG_RESULT(for scotch libraries: $scotch_binaries_ok)
127
128 dnl
129 dnl summary
130 dnl
131 if test "x${scotch_binaries_ok}" = "xyes" ; then
132   SCOTCH_CPPFLAGS=${LOCAL_INCLUDES}
133   SCOTCH_LIBS=${LOCAL_LIBS}
134   SCOTCH_LIBSUFFIX=""
135   ENABLE_SCOTCH="yes"
136   scotch_ok=yes
137   AC_MSG_RESULT(\$SCOTCH_CPPFLAGS  = ${SCOTCH_CPPFLAGS})
138   AC_MSG_RESULT(\$SCOTCH_LIBS      = ${SCOTCH_LIBS})
139   AC_MSG_RESULT(\$SCOTCH_LIBSUFFIX = ${SCOTCH_LIBSUFFIX})
140 fi
141 AC_MSG_RESULT(for scotch: $scotch_ok)
142
143 CPPFLAGS="${CPPFLAGS_old}"
144 LIBS="${LIBS_old}"
145
146 AC_SUBST(SCOTCH_CPPFLAGS)
147 AC_SUBST(SCOTCH_LIBSUFFIX)
148 AC_SUBST(SCOTCH_LIBS)
149 AC_SUBST(ENABLE_SCOTCH)
150
151 AC_LANG_RESTORE
152
153 ])dnl
154
155