Salome HOME
Copyright update 2021
[tools/configuration.git] / autotools / m4 / check_med3.m4
1 dnl Copyright (C) 2007-2021  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_MED3],[
24 AC_REQUIRE([AC_PROG_CC])dnl
25 AC_REQUIRE([AC_PROG_CPP])dnl
26 AC_REQUIRE([CHECK_HDF5])dnl
27 #AC_REQUIRE([MED_CHECK_SIZEOF_MEDINT]) # seems not required
28
29 AC_CHECKING(for MED3)
30
31 AC_ARG_WITH(med3,
32     [  --with-med3=DIR                 root directory path to med3 installation ],
33     [MED3HOME="$withval"
34       AC_MSG_RESULT("select $withval as path to med3")
35     ])
36
37 AC_SUBST(MED3_INCLUDES)
38 AC_SUBST(MED3_LIBS)
39 AC_SUBST(MED3_LIBS_C_ONLY)
40 AC_SUBST(MED3_MT_LIBS)
41 AC_SUBST(MED_CPPFLAGS)
42 AC_SUBST(MED3HOME)
43
44 MED3_INCLUDES=""
45 MED3_LIBS=""
46 MED3_MT_LIBS=""
47 #MED_CPPFLAGS="$DEFINED_F77INT64"
48
49 med3_ok=no
50
51 LOCAL_INCLUDES="$HDF5_INCLUDES"
52 LOCAL_LIBS="-lmed -lmedimport $HDF5_LIBS"
53 LOCAL_LIBS_C_ONLY="-lmedC $HDF5_LIBS"
54
55 if test -z $MED3HOME
56 then
57    AC_MSG_WARN(undefined MED3HOME variable which specify med3 installation directory)
58    AC_PATH_PROG(MDUMP, mdump)
59    if test "xMDUMP" != "x" ; then
60       MED3HOME=$MDUMP
61       MED3HOME=`echo ${MED3HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
62       MED3HOME=`echo ${MED3HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
63    fi
64 fi
65 if test ! -z $MED3HOME
66 then
67    LOCAL_INCLUDES="$LOCAL_INCLUDES -I$MED3HOME/include"
68    if test "x$MED3HOME" = "x/usr"
69    then
70      LOCAL_LIBS="-lmed  $LOCAL_LIBS"
71      LOCAL_LIBS_C_ONLY="-lmedC $LOCAL_LIBS_C_ONLY"
72    else
73      LOCAL_LIBS="-L$MED3HOME/lib $LOCAL_LIBS"
74      LOCAL_LIBS_C_ONLY="-L$MED3HOME/lib $LOCAL_LIBS_C_ONLY"
75    fi
76 fi
77
78 dnl check med3 header
79
80 f77int="F77INT32"
81 case  $host_os in
82    irix5.* | irix6.* | osf4.* | osf5.* | linux*  )
83
84         linux64="true"
85 # porting on intel processor 64 bits
86         expr "$host_os" : 'linux' >/dev/null && ( test ! x"$host_cpu" = x"x86_64" && test ! x"$host_cpu" = x"ia64" ) && linux64="false"
87         if test ! x"$linux64" = "xfalse" ; then
88           echo "$as_me:$LINENO: checking for 64bits integers size in F77/F90" >&5
89 echo $ECHO_N "checking for 64bits integers size in F77/F90... $ECHO_C" >&6
90           # Check whether --enable-int64 or --disable-int64 was given.
91 if test "${enable_int64+set}" = set; then
92   enableval="$enable_int64"
93
94 fi;
95           case "X-$enable_int64" in
96             X-no)
97              echo "$as_me:$LINENO: result: \"disabled\"" >&5
98 echo "${ECHO_T}\"disabled\"" >&6
99              SUFFIXES="_32"
100              ;;
101             *)
102              echo "$as_me:$LINENO: result: \"enabled\"" >&5
103 echo "${ECHO_T}\"enabled\"" >&6
104              SUFFIXES=""
105              f77int="F77INT64"
106              ;;
107           esac
108         fi
109      ;;
110    *)
111      ;;
112 esac
113
114 case $host_os in
115     linux*)
116         test x"$linux64" = x"true" && \
117           MACHINE="PCLINUX64${SUFFIXES}" || \
118         MACHINE=PCLINUX
119         ;;
120     hpux*)
121         MACHINE=HP9000
122         ;;
123     aix4.*)
124         MACHINE=RS6000
125         host_os_novers=aix4.x
126         ;;
127     irix5.*)
128         MACHINE="IRIX64${SUFFIXES}"
129         host_os_novers=irix5.x
130         ;;
131     irix6.*)
132         MACHINE="IRIX64${SUFFIXES}"
133         host_os_novers=irix6.x
134         ;;
135     osf4.*)
136         MACHINE="OSF1${SUFFIXES}"
137         host_os_novers=osf4.x
138         ;;
139     osf5.*)
140         MACHINE="OSF1${SUFFIXES}"
141          host_os_novers=osf5.x
142          ;;
143     solaris2.*)
144         MACHINE=SUN4SOL2
145          host_os_novers=solaris2.x
146          ;;
147     uxpv*)
148         MACHINE=VPP5000
149          ;;
150     *)
151         MACHINE=
152          host_os_novers=$host_os
153          ;;
154 esac
155
156 CPPFLAGS_old="$CPPFLAGS"
157 dnl we must test system : linux = -DPCLINUX
158 dnl we must test system : Alpha-OSF = -DOSF1
159 case $host_os in
160    linux*)
161       CPPFLAGS="$CPPFLAGS -D$MACHINE $LOCAL_INCLUDES"
162 dnl      CPPFLAGS="$CPPFLAGS -DPCLINUX $LOCAL_INCLUDES"
163       ;;
164    osf*)
165       CPPFLAGS="$CPPFLAGS -DOSF1 $LOCAL_INCLUDES"
166       ;;
167 esac
168 AC_CHECK_HEADER(med.h,med3_ok=yes ,med3_ok=no)
169 CPPFLAGS="$CPPFLAGS_old"
170
171 if  test "x$med3_ok" = "xyes"
172 then
173
174 dnl check med3 library
175
176   LIBS_old="$LIBS"
177   # $LOCAL_LIBS_C_ONLY is added to next line because on Fedora, check error :
178   #/usr/bin/ld: /tmp/ccQHybYu.o: undefined reference to symbol 'MEDfileOpen'                                                     
179   #/usr/bin/ld: note: 'MEDfileOpen' is defined in DSO /data/tmplgls/salome/prerequis/install/FD18_64/med-dev/FROM_hdf5-1.8.10/lib/libmedC.so so try adding it to the linker command line
180   # See http://comments.gmane.org/gmane.linux.redhat.fedora.devel/160632
181   LIBS="$LIBS $LOCAL_LIBS $LOCAL_LIBS_C_ONLY"
182   AC_CHECK_LIB(med,MEDfileOpen,med3_ok=yes,med3_ok=no)
183
184   if  test "x$med3_ok" = "xyes"
185   then
186    AC_CHECK_LIB(medimport,HAVE_MEDimport,med3_ok=yes,med3_ok=no)
187   fi
188   LIBS="$LIBS_old"
189  
190 fi
191
192 if  test "x$med3_ok" = "xyes"
193 then
194 case $host_os in
195    linux*)
196       MED3_INCLUDES="-D$MACHINE $LOCAL_INCLUDES"
197 dnl      MED3_INCLUDES="-DPCLINUX $LOCAL_INCLUDES"
198       ;;
199    osf*)
200       MED3_INCLUDES="-DOSF1 $LOCAL_INCLUDES"
201       ;;
202 esac
203   MED3_LIBS="$LOCAL_LIBS"
204   MED3_LIBS_C_ONLY="$LOCAL_LIBS_C_ONLY"
205   MED3_MT_LIBS="$LOCAL_LIBS"
206 fi
207
208
209 AC_MSG_RESULT(for med3: $med3_ok)
210
211 ])dnl