Salome HOME
Epuration des éléments obsolètes après analyse de la procédure de construction.
[modules/kernel.git] / salome_adm / unix / config_files / check_cas.m4
1 dnl  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 dnl  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 dnl 
4 dnl  This library is free software; you can redistribute it and/or 
5 dnl  modify it under the terms of the GNU Lesser General Public 
6 dnl  License as published by the Free Software Foundation; either 
7 dnl  version 2.1 of the License. 
8 dnl 
9 dnl  This library is distributed in the hope that it will be useful, 
10 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 dnl  Lesser General Public License for more details. 
13 dnl 
14 dnl  You should have received a copy of the GNU Lesser General Public 
15 dnl  License along with this library; if not, write to the Free Software 
16 dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 dnl 
18 dnl  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19 dnl
20 dnl
21 dnl
22 AC_DEFUN([CHECK_CAS],[
23 AC_REQUIRE([AC_PROG_CXX])dnl
24 AC_REQUIRE([AC_PROG_CXXCPP])dnl
25
26 AC_CHECKING(for OpenCascade)
27
28 AC_LANG_SAVE
29 AC_LANG_CPLUSPLUS
30
31 AC_SUBST(CAS_CPPFLAGS)
32 AC_SUBST(CAS_CXXFLAGS)
33 AC_SUBST(CAS_KERNEL)
34 AC_SUBST(CAS_VIEWER)
35 AC_SUBST(CAS_MODELER)
36 AC_SUBST(CAS_OCAF)
37 AC_SUBST(CAS_DATAEXCHANGE)
38 AC_SUBST(CAS_LDFLAGS)
39 AC_SUBST(CAS_LDPATH)
40 AC_SUBST(CAS_STDPLUGIN)
41
42 CAS_CPPFLAGS=""
43 CAS_CXXFLAGS=""
44 CAS_LDFLAGS=""
45 occ_ok=no
46 config_h=no
47
48 dnl libraries directory location
49 case $host_os in
50    linux*)
51       casdir=Linux
52       ;;
53    freebsd*)
54       casdir=Linux
55       ;;
56    irix5.*)
57       casdir=Linux
58       ;;
59    irix6.*)
60       casdir=Linux
61       ;;
62    osf*)
63       casdir=Linux
64       ;;
65    solaris2.*)
66       casdir=Linux
67       ;;
68    *)
69       casdir=Linux
70       ;;
71 esac
72
73 AC_MSG_CHECKING(for OpenCascade directories)
74
75 if test -z $CASROOT; then
76   AC_MSG_RESULT(CASROOT not defined)
77   for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do
78     if test -f $d/libTKernel.so ; then
79       AC_MSG_RESULT(libTKernel.so detected in $d)
80       CASROOT=$d
81       CASROOT=`echo ${CASROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"`
82       break
83     fi
84   done
85 fi
86
87 if test -d ${CASROOT}/${casdir}/lib; then
88   CAS_LDPATH="-L$CASROOT/$casdir/lib "
89   AC_MSG_RESULT(yes)
90 else
91   if test -d ${CASROOT}/lib; then
92     CAS_LDPATH="-L$CASROOT/lib "
93     AC_MSG_RESULT(yes)
94   else
95     AC_MSG_RESULT(no)
96   fi
97 fi
98
99
100 dnl were is OCC ?
101 if test -z $CASROOT; then
102   AC_MSG_WARN(You must provide CASROOT variable : see OCC installation manual)
103 else
104   occ_ok=yes
105   OCC_VERSION_MAJOR=0
106   OCC_VERSION_MINOR=0
107   ff=$CASROOT/inc/Standard_Version.hxx
108   if test -f $ff ; then
109     grep "define OCC_VERSION_MAJOR" $ff > /dev/null
110     if test $? = 0 ; then
111       OCC_VERSION_MAJOR=`grep "define OCC_VERSION_MAJOR" $ff | awk '{i=3 ; print $i}'`
112     fi
113     grep "define OCC_VERSION_MINOR" $ff > /dev/null
114     if test $? = 0 ; then
115       OCC_VERSION_MINOR=`grep "define OCC_VERSION_MINOR" $ff | awk '{i=3 ; print $i}'`
116     fi
117   fi
118 fi
119
120 if test "x$occ_ok" = "xyes"; then
121
122 dnl test c++ compiler flag for unsigned character
123   for opt in -funsigned-char -unsigned ; do
124     AC_CXX_OPTION($opt,CAS_CXXFLAGS,flag=yes,flag=no)
125     if test "$flag" = "yes"; then
126       break
127     fi
128   done
129   
130 dnl cascade headers
131
132   CPPFLAGS_old="$CPPFLAGS"
133 case $host_os in
134    linux*)
135       CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DHAVE_WOK_CONFIG_H -I$CASROOT/inc"
136       ;;
137    osf*)
138       CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DHAVE_WOK_CONFIG_H -I$CASROOT/inc"
139       ;;
140 esac
141   CPPFLAGS="$CPPFLAGS $CAS_CPPFLAGS"
142
143   if test -n $KERNEL_ROOT_DIR; then
144       if test -d $KERNEL_ROOT_DIR/include/salome; then
145           CAS_CPPFLAGS="$CAS_CPPFLAGS -I$KERNEL_ROOT_DIR/include/salome"
146           CPPFLAGS="$CPPFLAGS -I$KERNEL_ROOT_DIR/include/salome"
147       fi
148   fi
149   CAS_CPPFLAGS="$CAS_CPPFLAGS -I${ROOT_BUILDDIR}/include/salome"
150   CPPFLAGS="$CPPFLAGS -I${ROOT_BUILDDIR}/salome_adm/unix"
151
152   echo
153   echo testing config.h
154
155   AC_CHECK_HEADER(config.h, config_h=yes, [
156         echo "config.h file not found!"
157   ])
158
159   if test "x$config_h" = xno ; then
160       AC_MSG_WARN(config.h file not found)
161       dnl There is no consequence for SALOME building because
162       dnl this file is not used. SALOME uses SALOMEconfig.h instead!
163   else
164       AC_MSG_RESULT(config.h file ok)    
165   fi
166
167   AC_CHECK_HEADER(Standard_Type.hxx,occ_ok=yes ,occ_ok=no)
168
169 fi
170
171 if test "x$occ_ok" = xyes ; then
172
173   AC_MSG_CHECKING(for OpenCascade libraries)
174
175   LIBS_old="$LIBS"
176   LIBS="$LIBS $CAS_LDPATH -lTKernel"
177   
178   AC_CACHE_VAL(salome_cv_lib_occ,[
179     AC_TRY_LINK(
180 #include <Standard_Type.hxx>
181 ,   size_t size;
182     const Standard_CString aName="toto";
183     Standard_Type myST(aName) ; 
184     myST.Find(aName);,
185     eval "salome_cv_lib_occ=yes",eval "salome_cv_lib_occ=no")
186   ])
187   occ_ok="$salome_cv_lib_occ"
188
189 fi
190 CPPFLAGS="$CPPFLAGS_old"
191 LIBS="$LIBS_old"
192
193 if test "x$occ_ok" = xno ; then
194   AC_MSG_RESULT(no)
195   AC_MSG_WARN(Opencascade libraries not found)
196 else
197   AC_MSG_RESULT(yes)
198   CAS_KERNEL="$CAS_LDPATH -lTKernel -lTKMath"
199
200   # E.A. compatibility version 4 and 5.x  
201   CAS_OCAF="$CAS_LDPATH -lPTKernel -lTKPShape -lTKCDF -lTKCAF -lTKShapeSchema -lTKPCAF -lFWOSPlugin -lTKStdSchema"
202   if test $OCC_VERSION_MAJOR -lt 5 ; then
203     CAS_OCAF="$CAS_OCAF -lTKPAppStd"
204   fi
205   if test -f $CASROOT/$casdir/lib/libPAppStdPlugin.so ; then
206     # this library is absent in CASCADE 5.2.3
207     CAS_OCAF="$CAS_OCAF -lPAppStdPlugin"
208     CAS_STDPLUGIN="PAppStdPlugin"
209   fi
210   if test -f $CASROOT/$casdir/lib/libStdPlugin.so ; then
211     # this libraries are only for CASCADE 5.2.3
212     CAS_STDPLUGIN="StdPlugin"
213     CAS_OCAF="$CAS_OCAF -lStdPlugin -lStdLPlugin -lTKLCAF -lTKPLCAF -lTKStdLSchema"
214   fi
215   
216   CAS_VIEWER="$CAS_LDPATH -lTKOpenGl -lTKV3d -lTKService"
217   CAS_MODELER="$CAS_LDPATH -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lTKPrim -lTKBO -lTKBool -lTKHLR -lTKFillet -lTKOffset -lTKFeat"
218
219   # E.A. compatibility version 4 and 5.x  
220   CAS_DATAEXCHANGE="$CAS_LDPATH -lTKXSBase -lTKIGES -lTKSTEP -lTKShHealing"
221   if test $OCC_VERSION_MAJOR -lt 5 ; then
222     CAS_DATAEXCHANGE="$CAS_DATAEXCHANGE -lTKShHealingStd"
223   fi
224
225
226   CAS_LDFLAGS="$CAS_KERNEL $CAS_OCAF $CAS_VIEWER $CAS_MODELER $CAS_DATAEXCHANGE"  
227
228 fi
229
230 AC_LANG_RESTORE
231
232 ])dnl
233
234