2 dnl Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl 2011 Free Software Foundation, Inc.
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 dnl Boost modules are:
20 dnl date-time, filesystem. graph. iostreams, program options,
21 dnl regex, serialization, signals, unit test, thead, and wave.
23 AC_DEFUN([GNASH_PATH_BOOST],
25 dnl start variables with a known value
26 gnash_boost_version=""
31 cygnal_missing_libs=""
35 dnl this is a list of *required* headers. If any of these are missing, this
36 dnl test will return a failure, and Gnash won't build.
37 boost_headers="detail/lightweight_mutex.hpp thread/thread.hpp multi_index_container.hpp multi_index/key_extractors.hpp thread/mutex.hpp program_options/options_description.hpp"
38 dnl this is a list of *required* libraries. If any of these are missing, this
39 dnl test will return a failure, and Gnash won't build.
40 boost_libs="thread program_options"
42 dnl this is a list of *recommended* libraries. If any of these are missing, this
43 dnl test will return a warning, and Gnash will build, but testing won't work.
44 cygnal_boost_libs="serialization date_time"
46 dnl this is the default list for paths to search. This gets
47 dnl redefined if --with-boost-incl= is specified.
50 dnl Look for the header
51 AC_ARG_WITH(boost_incl, AC_HELP_STRING([--with-boost-incl], [directory where boost headers are]), with_boost_incl=${withval})
52 if test x"${with_boost_incl}" != x ; then
53 gnash_boost_topdir="`(cd ${with_boost_incl}; pwd)`"
54 gnash_boost_version="`echo ${gnash_boost_topdir} | sed -e 's:.*boost-::'`"
55 newlist=${gnash_boost_topdir}
58 dnl munge the GCC version number, which Boost uses to label it's libraries.
59 if test x"${GXX}" = xyes; then
60 gcc_version="`${CXX} --version | head -1 | cut -d ' ' -f 3 | cut -d '.' -f 1-2 | tr -d '.'`"
63 if test x"${gnash_boost_topdir}" = x; then
64 dnl Attempt to find the top level directory, which unfortunately has a
65 dnl version number attached. At least on Debian based systems, this
66 dnl doesn't seem to get a directory that is unversioned.
67 if test x$cross_compiling = xno; then
68 if test x"$PKG_CONFIG" != x; then
69 AC_MSG_CHECKING([for the Boost Version])
70 $PKG_CONFIG --exists boost && gnash_boost_version="`$PKG_CONFIG --modversion boost | cut -d "." -f 1 | awk '{print $'0'".0"}'`"
71 AC_MSG_RESULT(${gnash_boost_version})
76 AC_MSG_CHECKING([for boost header])
78 dirs="`ls -dr $i/boost* 2>/dev/null | xargs`"
80 if test -n "$u" -a -d "$u" -a x"$u" != x"/usr/include/boost"; then
81 gnash_boost_topdir="`(cd $u; pwd)`"
82 gnash_boost_subdir="`dirname ${gnash_boost_topdir}`"
83 gnash_boost_version="`echo ${gnash_boost_topdir} | sed -e 's:.*boost-::'`"
84 dnl Fix for packaging systems not adding extra fluff to the path-name.
85 for k in ${boost_headers}; do
86 if test ! -f ${gnash_boost_topdir}/boost/$k; then
87 if test ! -f ${gnash_boost_subdir}/boost/$k; then
88 missing_headers="${missing_headers} $k"
90 gnash_boost_topdir=${gnash_boost_subdir}
94 if test x"${missing_headers}" = x ; then
95 ac_cv_path_boost_incl="-I${gnash_boost_topdir}"
96 AC_MSG_RESULT(${ac_cv_path_boost_incl})
99 AC_MSG_RESULT([headers missing])
100 AC_MSG_WARN([You need to install ${missing_headers}])
106 dnl this is the default list for paths to search. This gets
107 dnl redefined if --with-boost-lib= is specified.
110 dnl Look for the library
111 AC_ARG_WITH(boost_lib, AC_HELP_STRING([--with-boost-lib], [directory where boost libraries are]), with_boost_lib=${withval})
112 if test x"${with_boost_lib}" != x ; then
113 gnash_boost_libdir="`(cd ${with_boost_lib}; pwd)`"
114 newlist="${gnash_boost_libdir}"
117 dnl Specify the list of probable names. Boost creates 8 identical
118 dnl libraries with different names. The prefered order is to always
119 dnl use the one with -mt on it, because it's the thread safe
120 dnl version. Then look for the version with -gcc in it, as it's the
121 dnl version compiled with GCC instead of the native
122 dnl compiler. Finally look for the library without any qualitfying
124 if test x${ac_cv_path_boost_lib} = x; then
125 AC_MSG_CHECKING([for Boost libraries])
126 for i in $newlist; do
127 if test x"${ac_cv_path_boost_lib}" != x; then
132 for j in ${boost_libs}; do
133 dirs="`ls -dr $i/libboost_${j}*.${shlibext} $i/libboost_${j}*.a 2>/dev/null`"
134 if test -n "${dirs}"; then
135 libname="`echo ${dirs} | sed -e 's:^.*/lib::' -e "s:\.${shlibext}::" -e "s:\.a::"`"
136 if test x$dirname = x; then
137 dirname="`echo ${dirs} | sed -e 's:/libboost.*$::'`"
138 if test x"${dirname}" != "x/usr/lib"; then
139 ac_cv_path_boost_lib="-L${dirname}"
142 ac_cv_path_boost_lib="${ac_cv_path_boost_lib} -l${libname}"
144 missing_libs="${missing_libs} $j"
148 for j in ${cygnal_boost_libs}; do
149 dirs="`ls -dr ${dirname}/libboost_${j}*.${shlibext} ${dirname}/libboost_${j}*.a 2>/dev/null`"
150 if test -n "${dirs}"; then
151 libname="`echo ${dirs} | sed -e 's:^.*/lib::' -e "s:\.${shlibext}::" -e "s:\.a::"`"
152 ac_cv_path_boost_cygnal_lib="${ac_cv_path_boost_cygnal_lib} -l${libname}"
154 cygnal_missing_libs="${cygnal_missing_libs} $j"
159 if test x"${missing_libs}" != x ; then
160 AC_MSG_WARN([Libraries ${missing_libs} ${cygnal_missing_libs} aren't installed ])
162 AC_MSG_RESULT(${ac_cv_path_boost_lib})
164 if test x"${ac_cv_path_boost_incl}" != x; then
165 BOOST_CFLAGS="$ac_cv_path_boost_incl"
168 if test x"${ac_cv_path_boost_lib}" != x; then
169 BOOST_LIBS="$ac_cv_path_boost_lib"
172 if test x"${ac_cv_path_boost_cygnal_lib}" != x; then
173 BOOST_CYGNAL_LIBS="$ac_cv_path_boost_cygnal_lib"
176 dnl ------------------------------------------------------------------
177 dnl Set HAVE_BOOST conditional, BOOST_CFLAGS and BOOST_LIBS variables
178 dnl ------------------------------------------------------------------
180 AC_SUBST(BOOST_CFLAGS)
182 AC_SUBST(BOOST_CYGNAL_LIBS)
184 dnl This isn't right: you don't need boot date-time installed unless u build
185 dnl cygnal, and it is sometimes a separate package from Boost core and thread.
186 dnl TODO: why is this needed, lack of boost being a fatal error?
187 AM_CONDITIONAL(HAVE_BOOST, [test -n "${BOOST_LIBS}"])
193 # indent-tabs-mode: nil