Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / wrappergen / src / HXX2SALOME_GENERIC_CLASS_NAME_SRC / adm_local / unix / config_files / check_boost.m4
1 dnl  Copyright (C) 2006-2008  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.
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 AC_DEFUN([CHECK_BOOST],[
20
21 AC_CHECKING(for BOOST Library)
22
23 AC_REQUIRE([ENABLE_PTHREADS])dnl
24
25 AC_LANG_SAVE
26 AC_LANG_CPLUSPLUS
27
28 BOOST_CPPFLAGS=""
29 BOOST_LIBSUFFIX="-mt"
30 BOOST_LIBS=""
31
32 AC_CHECKING(for BOOST location)
33 AC_ARG_WITH(boost,
34    [AC_HELP_STRING([--with-boost=DIR],[root directory path to BOOST library installation])],
35    [BOOSTDIR="$withval"
36     AC_MSG_RESULT("select $withval as path to BOOST library")
37    ])
38    
39 if test "x${BOOSTDIR}" = "x" ; then
40   BOOSTDIR="/usr"
41 fi
42
43 AC_MSG_RESULT(\$BOOSTDIR = ${BOOSTDIR})
44
45 CPPFLAGS_old="${CPPFLAGS}"
46 LIBS_old=$LIBS
47
48 if test "x${BOOSTDIR}" != "x" ; then
49   BOOST_CPPFLAGS="-I${BOOSTDIR}/include"
50   BOOST_LIBS="-L${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}"
51 fi
52
53 boost_ok=no
54 boost_headers_ok=no
55 boost_binaries_ok=no
56
57 dnl BOOST headers
58 AC_CHECKING(for BOOST headers)
59 CPPFLAGS="${CPPFLAGS_old} ${BOOST_CPPFLAGS}"
60
61 boost_include_dir_ok=yes
62 if test "x${BOOSTDIR}" != "x" ; then
63   AC_CHECK_FILE(${BOOSTDIR}/include/boost/shared_ptr.hpp,
64                 boost_include_dir_ok=yes,
65                 boost_include_dir_ok=no)
66 fi
67
68 if test "x${boost_include_dir_ok}" = "xyes" ; then
69   AC_TRY_COMPILE([#include <boost/shared_ptr.hpp>],
70                  [boost::shared_ptr<int>(new int)],
71                  boost_headers_ok=yes,
72                  boost_headers_ok=no)
73 fi
74
75 if test "x${boost_headers_ok}" = "xno" ; then
76   BOOST_CPPFLAGS="BOOST_CPPFLAGS_NOT_DEFINED"
77 else
78   AC_MSG_RESULT(\$BOOST_CPPFLAGS = ${BOOST_CPPFLAGS})
79 fi
80 AC_MSG_RESULT(for boost headers: $boost_headers_ok)
81
82 if test "x${boost_headers_ok}" = "xyes" ; then
83   dnl BOOST binaries
84   AC_CHECKING(for BOOST binaries)
85   boost_lib_dir_ok=yes
86   if test "x${BOOSTDIR}" != "x" ; then
87     AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so,
88                   boost_lib_dir_ok=yes,
89                   boost_lib_dir_ok=no)
90     if test "x${boost_lib_dir_ok}" = "xno" ; then
91       BOOST_LIBSUFFIX=""
92       AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so,
93                     boost_lib_dir_ok=yes,
94                     boost_lib_dir_ok=no)
95     fi
96   fi
97   if test "x${boost_lib_dir_ok}" = "xyes" ; then
98     LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}"
99     AC_TRY_LINK([#include <boost/thread/thread.hpp>],
100                 [struct TBody{ void operator()(){} }; boost::thread(TBody())],
101                 boost_binaries_ok=yes,
102                 boost_binaries_ok=no)
103     if test "x${boost_binaries_ok}" = "xno" ; then
104       BOOST_LIBSUFFIX=""
105       LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}"
106       AC_TRY_LINK([#include <boost/thread/thread.hpp>],
107                   [struct TBody{ void operator()(){} }; boost::thread(TBody())],
108                   boost_binaries_ok=yes,
109                   boost_binaries_ok=no)
110     fi
111   fi
112 fi
113
114 if test "x${boost_binaries_ok}" = "xno" ; then
115   BOOST_LIBS="BOOST_LIBS_NOT_FOUND"
116   BOOST_LIBSUFFIX="-not-defined"
117 else
118   AC_MSG_RESULT(\$BOOST_LIBSUFFIX = ${BOOST_LIBSUFFIX})
119   AC_MSG_RESULT(\$BOOST_LIBS = ${BOOST_LIBS})
120 fi
121 AC_MSG_RESULT(for boost binaries: $boost_binaries_ok)
122
123 CPPFLAGS="${CPPFLAGS_old}"
124 LIBS="${LIBS_old}"
125
126 if test "x${boost_headers_ok}" = "xyes" ; then
127   if test "x${boost_binaries_ok}" = "xyes" ; then
128     boost_ok=yes
129   fi
130 fi
131
132 AC_MSG_RESULT(for boost: $boost_ok)
133
134 AC_SUBST(BOOST_CPPFLAGS)
135 AC_SUBST(BOOST_LIBSUFFIX)
136 AC_SUBST(BOOST_LIBS)
137
138 AC_LANG_RESTORE
139
140 ])dnl
141
142