don't add (LIBLTDL) to LDFLAGS, libltdl is part of libgnashbase.
[gnash.git] / macros / boost.m4
blob9901c61b455d629d6c0a9814eb51e030852c4eeb
1 dnl  
2 dnl    Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
3 dnl  
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 3 of the License, or
7 dnl  (at your option) any later version.
8 dnl  
9 dnl  This program 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
12 dnl  GNU General Public License for more details.
13 dnl  You should have received a copy of the GNU General Public License
14 dnl  along with this program; if not, write to the Free Software
15 dnl  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 dnl Boost modules are:
19 dnl date-time, filesystem. graph. iostreams, program options,
20 dnl regex, serialization, signals, unit test, thead, and wave.
22 AC_DEFUN([GNASH_PATH_BOOST],
24   dnl start variables with a known value
25   gnash_boost_version=""
26   gnash_boost_topdir=""
27   gnash_boost_libdir=""
28   missing_headers=""
29   missing_libs=""
30   cygnal_missing_libs=""
31   gcc_version=""
32   dirname=""
33   libname=""
34   dnl this is a list of *required* headers. If any of these are missing, this
35   dnl test will return a failure, and Gnash won't build.
36   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"
37   dnl this is a list of *required* libraries. If any of these are missing, this
38   dnl test will return a failure, and Gnash won't build.
39   boost_libs="thread program_options"
41   dnl this is a list of *recommended* libraries. If any of these are missing, this
42   dnl test will return a warning, and Gnash will build, but testing won't work.
43   cygnal_boost_libs="serialization date_time"
45   dnl this is the default list for paths to search. This gets
46   dnl redefined if --with-boost-incl= is specified.
47   newlist=$incllist
49   dnl Look for the header
50   AC_ARG_WITH(boost_incl, AC_HELP_STRING([--with-boost-incl], [directory where boost headers are]), with_boost_incl=${withval})
51   if test x"${with_boost_incl}" != x ; then
52     gnash_boost_topdir="`(cd ${with_boost_incl}; pwd)`"
53     gnash_boost_version="`echo ${gnash_boost_topdir} | sed -e 's:.*boost-::'`"
54     newlist=${gnash_boost_topdir}
55   fi
57   dnl munge the GCC version number, which Boost uses to label it's libraries.
58   if test x"${GXX}" = xyes; then
59         gcc_version="`${CXX} --version | head -1 | cut -d ' ' -f 3 | cut -d '.' -f 1-2 | tr -d '.'`"
60   fi
62   if test x"${gnash_boost_topdir}" = x; then
63     dnl Attempt to find the top level directory, which unfortunately has a
64     dnl version number attached. At least on Debian based systems, this
65     dnl doesn't seem to get a directory that is unversioned.
66     if test x$cross_compiling = xno; then
67       if test x"$PKG_CONFIG" != x; then
68         AC_MSG_CHECKING([for the Boost Version])
69         $PKG_CONFIG --exists boost && gnash_boost_version="`$PKG_CONFIG --modversion boost | cut -d "." -f 1 | awk '{print $'0'".0"}'`"
70         AC_MSG_RESULT(${gnash_boost_version})
71       fi
72     fi
73   fi
75   AC_MSG_CHECKING([for boost header])
76   for i in $newlist; do
77     dirs="`ls -dr $i/boost* 2>/dev/null | xargs`"
78     for u in ${dirs}; do
79         if test -n "$u" -a -d "$u" -a x"$u" != x"/usr/include/boost"; then
80         gnash_boost_topdir="`(cd $u; pwd)`"
81         gnash_boost_subdir="`dirname ${gnash_boost_topdir}`"
82         gnash_boost_version="`echo ${gnash_boost_topdir} | sed -e 's:.*boost-::'`"
83         dnl Fix for packaging systems not adding extra fluff to the path-name.
84         for k in ${boost_headers}; do
85                 if test ! -f ${gnash_boost_topdir}/boost/$k; then
86                   if test ! -f ${gnash_boost_subdir}/boost/$k; then
87                             missing_headers="${missing_headers} $k"
88                         else
89                         gnash_boost_topdir=${gnash_boost_subdir}
90                         fi
91                 fi
92         done
93       if test x"${missing_headers}" = x ; then
94         ac_cv_path_boost_incl="-I${gnash_boost_topdir}"
95         AC_MSG_RESULT(${ac_cv_path_boost_incl})
96         break
97       else
98         AC_MSG_RESULT([headers missing])
99         AC_MSG_WARN([You need to install ${missing_headers}])
100       fi
101     fi
102     done
103   done
105   dnl this is the default list for paths to search. This gets
106   dnl redefined if --with-boost-lib= is specified.
107   newlist=$libslist
109   dnl Look for the library
110   AC_ARG_WITH(boost_lib, AC_HELP_STRING([--with-boost-lib], [directory where boost libraries are]), with_boost_lib=${withval})
111   if test x"${with_boost_lib}" != x ; then
112     gnash_boost_libdir="`(cd ${with_boost_lib}; pwd)`"
113     newlist="${gnash_boost_libdir}"
114   fi
116   dnl Specify the list of probable names. Boost creates 8 identical
117   dnl libraries with different names. The prefered order is to always
118   dnl use the one with -mt on it, because it's the thread safe
119   dnl version. Then look for the version with -gcc in it, as it's the
120   dnl version compiled with GCC instead of the native
121   dnl compiler. Finally look for the library without any qualitfying
122   dnl attributes.
123   if test x${ac_cv_path_boost_lib} = x; then
124     AC_MSG_CHECKING([for Boost libraries])
125     for i in $newlist; do
126       if test x"${ac_cv_path_boost_lib}" != x; then
127         break
128       else
129         missing_libs=""
130       fi
131       for j in ${boost_libs}; do
132         dirs="`ls -dr $i/libboost_${j}*.${shlibext} $i/libboost_${j}*.a 2>/dev/null`"
133         if test -n "${dirs}"; then
134           libname="`echo ${dirs} | sed -e 's:^.*/lib::' -e "s:\.${shlibext}::" -e "s:\.a::"`"
135           if test x$dirname = x; then
136             dirname="`echo ${dirs} | sed -e 's:/libboost.*$::'`"
137            if test x"${dirname}" != "x/usr/lib"; then
138               ac_cv_path_boost_lib="-L${dirname}"
139             fi
140           fi
141           ac_cv_path_boost_lib="${ac_cv_path_boost_lib} -l${libname}"
142         else
143           missing_libs="${missing_libs} $j"
144         fi
145       done
146     done
147     for j in ${cygnal_boost_libs}; do
148       dirs="`ls -dr ${dirname}/libboost_${j}*.${shlibext} ${dirname}/libboost_${j}*.a 2>/dev/null`"
149       if test -n "${dirs}"; then
150           libname="`echo ${dirs} | sed -e 's:^.*/lib::' -e "s:\.${shlibext}::" -e "s:\.a::"`"
151         ac_cv_path_boost_cygnal_lib="${ac_cv_path_boost_cygnal_lib} -l${libname}"
152       else
153         cygnal_missing_libs="${cygnal_missing_libs} $j"
154       fi
155     done
156   fi
158   if test x"${missing_libs}" != x ; then
159     AC_MSG_WARN([Libraries ${missing_libs} ${cygnal_missing_libs} aren't installed ])
160   fi
161   AC_MSG_RESULT(${ac_cv_path_boost_lib})
163   if test x"${ac_cv_path_boost_incl}" != x; then
164     BOOST_CFLAGS="$ac_cv_path_boost_incl"
165   fi
167   if test x"${ac_cv_path_boost_lib}" != x; then
168     BOOST_LIBS="$ac_cv_path_boost_lib"
169   fi
171   if test x"${ac_cv_path_boost_cygnal_lib}" != x; then
172     BOOST_CYGNAL_LIBS="$ac_cv_path_boost_cygnal_lib" 
173   fi
175   dnl ------------------------------------------------------------------
176   dnl Set HAVE_BOOST conditional, BOOST_CFLAGS and BOOST_LIBS variables
177   dnl ------------------------------------------------------------------
179   AC_SUBST(BOOST_CFLAGS)
180   AC_SUBST(BOOST_LIBS)
181   AC_SUBST(BOOST_CYGNAL_LIBS)
183   dnl This isn't right: you don't need boot date-time installed unless u build
184   dnl cygnal, and it is sometimes a separate package from Boost core and thread.
185   dnl TODO: why is this needed, lack of boost being a fatal error?
186   AM_CONDITIONAL(HAVE_BOOST, [test -n "${BOOST_LIBS}"])
189 # Local Variables:
190 # c-basic-offset: 2
191 # tab-width: 2
192 # indent-tabs-mode: nil
193 # End: