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