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