]> SALOME platform Git repositories - modules/kernel.git/blob - salome_adm/unix/config_files/check_boost.m4
Salome HOME
37ff78d4f2484352371a3d9af704b70faf98752e
[modules/kernel.git] / salome_adm / unix / config_files / check_boost.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_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 AC_MSG_RESULT(\$BOOSTDIR = ${BOOSTDIR})
43
44 CPPFLAGS_old="${CPPFLAGS}"
45 LIBS_old=$LIBS
46
47 if test "x${BOOSTDIR}" != "x" ; then
48   BOOST_CPPFLAGS="-I${BOOSTDIR}/include"
49   BOOST_LIBS="-L${BOOSTDIR}/lib"
50 fi
51
52 boost_ok=no
53 boost_headers_ok=no
54 boost_binaries_ok=no
55
56 dnl BOOST headers
57 AC_CHECKING(for BOOST headers)
58 CPPFLAGS="${CPPFLAGS_old} ${BOOST_CPPFLAGS}"
59
60 boost_include_dir_ok=yes
61 if test "x${BOOSTDIR}" != "x" ; then
62   AC_CHECK_FILE(${BOOSTDIR}/include/boost/shared_ptr.hpp,
63                 boost_include_dir_ok=yes,
64                 boost_include_dir_ok=no)
65 fi
66
67 if test "x${boost_include_dir_ok}" = "xyes" ; then
68   AC_TRY_COMPILE([#include <boost/shared_ptr.hpp>],
69                  [boost::shared_ptr<int>(new int)],
70                  boost_headers_ok=yes,
71                  boost_headers_ok=no)
72 fi
73
74 if test "x${boost_headers_ok}" = "xno" ; then
75   BOOST_CPPFLAGS="BOOST_CPPFLAGS_NOT_DEFINED"
76 else
77   AC_MSG_RESULT(\$BOOST_CPPFLAGS = ${BOOST_CPPFLAGS})
78 fi
79 AC_MSG_RESULT(for boost headers: $boost_headers_ok)
80
81 if test "x${boost_headers_ok}" = "xyes" ; then
82   dnl BOOST binaries
83   AC_CHECKING(for BOOST binaries)
84   boost_lib_dir_ok=yes
85   if test "x${BOOSTDIR}" != "x" ; then
86     AC_CHECK_FILE(${BOOSTDIR}/lib/libboost_thread${BOOST_LIBSUFFIX}.so,
87                   boost_lib_dir_ok=yes,
88                   boost_lib_dir_ok=no)
89     if test "x${boost_lib_dir_ok}" = "xno" ; then
90       BOOST_LIBSUFFIX=""
91       AC_CHECK_FILE(${BOOSTDIR}/lib/libboost_thread${BOOST_LIBSUFFIX}.so,
92                     boost_lib_dir_ok=yes,
93                     boost_lib_dir_ok=no)
94     fi
95   fi
96   if test "x${boost_lib_dir_ok}" = "xyes" ; then
97     LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}"
98     AC_TRY_LINK([#include <boost/thread/thread.hpp>],
99                 [struct TBody{ void operator()(){} }; boost::thread(TBody())],
100                 boost_binaries_ok=yes,
101                 boost_binaries_ok=no)
102     if test "x${boost_binaries_ok}" = "xno" ; then
103       BOOST_LIBSUFFIX=""
104       LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}"
105       AC_TRY_LINK([#include <boost/thread/thread.hpp>],
106                   [struct TBody{ void operator()(){} }; boost::thread(TBody())],
107                   boost_binaries_ok=yes,
108                   boost_binaries_ok=no)
109     fi
110   fi
111 fi
112
113 if test "x${boost_binaries_ok}" = "xno" ; then
114   BOOST_LIBS="BOOST_LIBS_NOT_FOUND"
115   BOOST_LIBSUFFIX="-not-defined"
116 else
117   AC_MSG_RESULT(\$BOOST_LIBSUFFIX = ${BOOST_LIBSUFFIX})
118   AC_MSG_RESULT(\$BOOST_LIBS = ${BOOST_LIBS})
119 fi
120 AC_MSG_RESULT(for boost binaries: $boost_binaries_ok)
121
122 CPPFLAGS="${CPPFLAGS_old}"
123 LIBS="${LIBS_old}"
124
125 if test "x${boost_headers_ok}" = "xyes" ; then
126   if test "x${boost_binaries_ok}" = "xyes" ; then
127     boost_ok=yes
128   fi
129 fi
130
131 AC_MSG_RESULT(for boost: $boost_ok)
132
133 AC_SUBST(BOOST_CPPFLAGS)
134 AC_SUBST(BOOST_LIBSUFFIX)
135 AC_SUBST(BOOST_LIBS)
136
137 AC_LANG_RESTORE
138
139 ])dnl
140
141