Salome HOME
b169fee4d3a62add6088b2421e237a95eb4c343b
[modules/homard.git] / adm_local / unix / config_files / check_Med2.m4
1 dnl Copyright (C) 2011-2023  CEA/DEN, EDF R&D
2 dnl
3 dnl This library is free software; you can redistribute it and/or
4 dnl modify it under the terms of the GNU Lesser General Public
5 dnl License as published by the Free Software Foundation; either
6 dnl version 2.1 of the License, or (at your option) any later version.
7 dnl
8 dnl This library is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 dnl Lesser General Public License for more details.
12 dnl
13 dnl You should have received a copy of the GNU Lesser General Public
14 dnl License along with this library; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 dnl
17 dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 dnl
19
20 AC_DEFUN([CHECK_MED2],[
21 AC_REQUIRE([AC_PROG_CC])dnl
22 AC_REQUIRE([AC_PROG_CPP])dnl
23 AC_REQUIRE([CHECK_HDF5])dnl
24
25 AC_CHECKING(for MED2)
26
27 AC_ARG_WITH(med2,
28     [  --with-med2=DIR                 root directory path to med2 installation ],
29     [MED2HOME="$withval"
30       AC_MSG_RESULT("select $withval as path to med2")
31     ])
32
33 AC_SUBST(MED2_INCLUDES)
34 AC_SUBST(MED2_LIBS)
35 AC_SUBST(MED2_MT_LIBS)
36
37 MED2_INCLUDES=""
38 MED2_LIBS=""
39 MED2_MT_LIBS=""
40
41 med2_ok=no
42
43 LOCAL_INCLUDES="$HDF5_INCLUDES"
44 LOCAL_LIBS="-lmed $HDF5_LIBS"
45
46 if test -z $MED2HOME
47 then
48    AC_MSG_WARN(undefined MED2HOME variable which specify med2 installation directory)
49    AC_PATH_PROG(MDUMP, mdump)
50    if test "xMDUMP" != "x" ; then
51       MED2HOME=$MDUMP
52       MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
53       MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
54    fi
55 fi
56 if test ! -z $MED2HOME
57 then
58    LOCAL_INCLUDES="$LOCAL_INCLUDES -I$MED2HOME/include"
59    if test "x$MED2HOME" = "x/usr"
60    then
61      LOCAL_LIBS="-lmed  $LOCAL_LIBS"
62    else
63      LOCAL_LIBS="-L$MED2HOME/lib $LOCAL_LIBS"
64    fi
65 fi
66
67 dnl check med2 header
68
69 CPPFLAGS_old="$CPPFLAGS"
70 dnl we must test system : linux = -DPCLINUX
71 dnl we must test system : Alpha-OSF = -DOSF1
72 case $host_os in
73    linux*)
74       CPPFLAGS="$CPPFLAGS -DPCLINUX $LOCAL_INCLUDES"
75       ;;
76    osf*)
77       CPPFLAGS="$CPPFLAGS -DOSF1 $LOCAL_INCLUDES"
78       ;;
79 esac
80 AC_CHECK_HEADER(med.h,med2_ok=yes ,med2_ok=no)
81 CPPFLAGS="$CPPFLAGS_old"
82
83 if  test "x$med2_ok" = "xyes"
84 then
85
86 dnl check med2 library
87
88   LIBS_old="$LIBS"
89   LIBS="$LIBS $LOCAL_LIBS"
90   AC_CHECK_LIB(med,MEDouvrir,med2_ok=yes,med2_ok=no)
91   LIBS="$LIBS_old"
92
93 fi
94
95 if  test "x$med2_ok" = "xyes"
96 then
97 case $host_os in
98    linux*)
99         MED2_INCLUDES="-DPCLINUX $LOCAL_INCLUDES"
100       ;;
101    osf*)
102       MED2_INCLUDES="-DOSF1 $LOCAL_INCLUDES"
103       ;;
104 esac
105   MED2_LIBS="$LOCAL_LIBS"
106   MED2_MT_LIBS="$LOCAL_LIBS"
107 fi
108
109 AC_MSG_RESULT(for med2: $med2_ok)
110
111 ])dnl