e109217
From ed41a33ca22f46b123df4132d376247682af07af Mon Sep 17 00:00:00 2001
e109217
From: David Tardon <dtardon@redhat.com>
e109217
Date: Tue, 8 Mar 2016 06:23:24 +0100
e109217
Subject: [PATCH 3/4] detect Boost.Filesystem
e109217
e109217
Change-Id: I86c268f49f44bd1e208a9de781a16bf19450c64c
e109217
---
e109217
 config_host.mk.in         |   1 +
e109217
 configure.ac              |   1 +
e109217
 m4/ax_boost_filesystem.m4 | 118 ++++++++++++++++++++++++++++++++++++++++++++++
e109217
 3 files changed, 120 insertions(+)
e109217
 create mode 100644 m4/ax_boost_filesystem.m4
e109217
e109217
diff --git a/config_host.mk.in b/config_host.mk.in
e109217
index 89081ca..0a2ec0b 100644
e109217
--- a/config_host.mk.in
e109217
+++ b/config_host.mk.in
e109217
@@ -37,6 +37,7 @@ export BARCODE_EXTENSION_PACK=@BARCODE_EXTENSION_PACK@
e109217
 export BOOST_CPPFLAGS=@BOOST_CPPFLAGS@
e109217
 export BOOST_CXXFLAGS=@BOOST_CXXFLAGS@
e109217
 export BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@
e109217
+export BOOST_FILESYSTEM_LIB=@BOOST_FILESYSTEM_LIB@
e109217
 export BOOST_IOSTREAMS_LIB=@BOOST_IOSTREAMS_LIB@
e109217
 export BOOST_LDFLAGS=@BOOST_LDFLAGS@
e109217
 export BOOST_SYSTEM_LIB=@BOOST_SYSTEM_LIB@
e109217
diff --git a/configure.ac b/configure.ac
e109217
index dab1919..7b5cedd 100644
e109217
--- a/configure.ac
e109217
+++ b/configure.ac
e109217
@@ -8836,6 +8836,7 @@ if test "$with_system_boost" = "yes"; then
e109217
     SYSTEM_BOOST=TRUE
e109217
     AX_BOOST_BASE(1.47)
e109217
     AX_BOOST_DATE_TIME
e109217
+    AX_BOOST_FILESYSTEM
e109217
     AX_BOOST_IOSTREAMS
e109217
     mingw_boost_date_time_dll=`echo $BOOST_DATE_TIME_LIB | sed -e 's/^-l//' -e 's/\.dll$//'`
e109217
     libo_MINGW_TRY_DLL([$mingw_boost_date_time_dll])
e109217
diff --git a/m4/ax_boost_filesystem.m4 b/m4/ax_boost_filesystem.m4
e109217
new file mode 100644
e109217
index 0000000..f162163
e109217
--- /dev/null
e109217
+++ b/m4/ax_boost_filesystem.m4
e109217
@@ -0,0 +1,118 @@
e109217
+# ===========================================================================
e109217
+#    http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html
e109217
+# ===========================================================================
e109217
+#
e109217
+# SYNOPSIS
e109217
+#
e109217
+#   AX_BOOST_FILESYSTEM
e109217
+#
e109217
+# DESCRIPTION
e109217
+#
e109217
+#   Test for Filesystem library from the Boost C++ libraries. The macro
e109217
+#   requires a preceding call to AX_BOOST_BASE. Further documentation is
e109217
+#   available at <http://randspringer.de/boost/index.html>.
e109217
+#
e109217
+#   This macro calls:
e109217
+#
e109217
+#     AC_SUBST(BOOST_FILESYSTEM_LIB)
e109217
+#
e109217
+#   And sets:
e109217
+#
e109217
+#     HAVE_BOOST_FILESYSTEM
e109217
+#
e109217
+# LICENSE
e109217
+#
e109217
+#   Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
e109217
+#   Copyright (c) 2009 Michael Tindal
e109217
+#   Copyright (c) 2009 Roman Rybalko <libtorrent@romanr.info>
e109217
+#
e109217
+#   Copying and distribution of this file, with or without modification, are
e109217
+#   permitted in any medium without royalty provided the copyright notice
e109217
+#   and this notice are preserved. This file is offered as-is, without any
e109217
+#   warranty.
e109217
+
e109217
+#serial 26
e109217
+
e109217
+AC_DEFUN([AX_BOOST_FILESYSTEM],
e109217
+[
e109217
+	AC_ARG_WITH([boost-filesystem],
e109217
+	AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
e109217
+                   [use the Filesystem library from boost - it is possible to specify a certain library for the linker
e109217
+                        e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
e109217
+        [
e109217
+        if test "$withval" = "no"; then
e109217
+			want_boost="no"
e109217
+        elif test "$withval" = "yes"; then
e109217
+            want_boost="yes"
e109217
+            ax_boost_user_filesystem_lib=""
e109217
+        else
e109217
+		    want_boost="yes"
e109217
+		ax_boost_user_filesystem_lib="$withval"
e109217
+		fi
e109217
+        ],
e109217
+        [want_boost="yes"]
e109217
+	)
e109217
+
e109217
+	if test "x$want_boost" = "xyes"; then
e109217
+        AC_REQUIRE([AC_PROG_CC])
e109217
+		CPPFLAGS_SAVED="$CPPFLAGS"
e109217
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
e109217
+		export CPPFLAGS
e109217
+
e109217
+		LDFLAGS_SAVED="$LDFLAGS"
e109217
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
e109217
+		export LDFLAGS
e109217
+
e109217
+		LIBS_SAVED=$LIBS
e109217
+		LIBS="$LIBS $BOOST_SYSTEM_LIB"
e109217
+		export LIBS
e109217
+
e109217
+        AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
e109217
+					   ax_cv_boost_filesystem,
e109217
+        [AC_LANG_PUSH([C++])
e109217
+         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
e109217
+                                   [[using namespace boost::filesystem;
e109217
+                                   path my_path( "foo/bar/data.txt" );
e109217
+                                   return 0;]])],
e109217
+					       ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
e109217
+         AC_LANG_POP([C++])
e109217
+		])
e109217
+		if test "x$ax_cv_boost_filesystem" = "xyes"; then
e109217
+			AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
e109217
+            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
e109217
+            if test "x$ax_boost_user_filesystem_lib" = "x"; then
e109217
+                for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
e109217
+                     ax_lib=${libextension}
e109217
+				    AC_CHECK_LIB($ax_lib, exit,
e109217
+                                 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
e109217
+                                 [link_filesystem="no"])
e109217
+				done
e109217
+                if test "x$link_filesystem" != "xyes"; then
e109217
+                for libextension in `ls -r $BOOSTLIBDIR/boost_filesystem* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
e109217
+                     ax_lib=${libextension}
e109217
+				    AC_CHECK_LIB($ax_lib, exit,
e109217
+                                 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
e109217
+                                 [link_filesystem="no"])
e109217
+				done
e109217
+		    fi
e109217
+            else
e109217
+               for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
e109217
+				      AC_CHECK_LIB($ax_lib, exit,
e109217
+                                   [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
e109217
+                                   [link_filesystem="no"])
e109217
+                  done
e109217
+
e109217
+            fi
e109217
+            if test "x$ax_lib" = "x"; then
e109217
+                AC_MSG_ERROR(Could not find a version of the library!)
e109217
+            fi
e109217
+			if test "x$link_filesystem" != "xyes"; then
e109217
+				AC_MSG_ERROR(Could not link against $ax_lib !)
e109217
+			fi
e109217
+		fi
e109217
+
e109217
+		CPPFLAGS="$CPPFLAGS_SAVED"
e109217
+		LDFLAGS="$LDFLAGS_SAVED"
e109217
+		LIBS="$LIBS_SAVED"
e109217
+	fi
e109217
+])
e109217
-- 
e109217
2.5.0
e109217