|
| 1 | +# =========================================================================== |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_boost_process.html |
| 3 | +# =========================================================================== |
| 4 | +# |
| 5 | +# SYNOPSIS |
| 6 | +# |
| 7 | +# AX_BOOST_PROCESS |
| 8 | +# |
| 9 | +# DESCRIPTION |
| 10 | +# |
| 11 | +# Test for Process library from the Boost C++ libraries. The macro |
| 12 | +# requires a preceding call to AX_BOOST_BASE. Further documentation is |
| 13 | +# available at <http://randspringer.de/boost/index.html>. |
| 14 | +# |
| 15 | +# This macro calls: |
| 16 | +# |
| 17 | +# AC_SUBST(BOOST_PROCESS_LIB) |
| 18 | +# |
| 19 | +# And sets: |
| 20 | +# |
| 21 | +# HAVE_BOOST_PROCESS |
| 22 | +# |
| 23 | +# LICENSE |
| 24 | +# |
| 25 | +# Copyright (c) 2008 Thomas Porschberg <[email protected]> |
| 26 | +# Copyright (c) 2008 Michael Tindal |
| 27 | +# Copyright (c) 2008 Daniel Casimiro <[email protected]> |
| 28 | +# |
| 29 | +# Copying and distribution of this file, with or without modification, are |
| 30 | +# permitted in any medium without royalty provided the copyright notice |
| 31 | +# and this notice are preserved. This file is offered as-is, without any |
| 32 | +# warranty. |
| 33 | + |
| 34 | +#serial 2 |
| 35 | + |
| 36 | +AC_DEFUN([AX_BOOST_PROCESS], |
| 37 | +[ |
| 38 | + AC_ARG_WITH([boost-process], |
| 39 | + AS_HELP_STRING([--with-boost-process@<:@=special-lib@:>@], |
| 40 | + [use the Process library from boost - it is possible to specify a certain library for the linker |
| 41 | + e.g. --with-boost-process=boost_process-gcc-mt ]), |
| 42 | + [ |
| 43 | + if test "$withval" = "no"; then |
| 44 | + want_boost_process="no" |
| 45 | + elif test "$withval" = "yes"; then |
| 46 | + want_boost_process="yes" |
| 47 | + ax_boost_user_process_lib="" |
| 48 | + else |
| 49 | + want_boost_process="yes" |
| 50 | + ax_boost_user_process_lib="$withval" |
| 51 | + fi |
| 52 | + ], |
| 53 | + [want_boost_process="yes"] |
| 54 | + ) |
| 55 | +
|
| 56 | + if test "x$want_boost_process" = "xyes"; then |
| 57 | + AC_REQUIRE([AC_PROG_CC]) |
| 58 | + AC_REQUIRE([AC_CANONICAL_BUILD]) |
| 59 | + CPPFLAGS_SAVED="$CPPFLAGS" |
| 60 | + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
| 61 | + export CPPFLAGS |
| 62 | +
|
| 63 | + LDFLAGS_SAVED="$LDFLAGS" |
| 64 | + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
| 65 | + export LDFLAGS |
| 66 | +
|
| 67 | + AC_CACHE_CHECK(whether the Boost::Process library is available, |
| 68 | + ax_cv_boost_process, |
| 69 | + [AC_LANG_PUSH([C++]) |
| 70 | + CXXFLAGS_SAVE=$CXXFLAGS |
| 71 | + CXXFLAGS= |
| 72 | +
|
| 73 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/process.hpp>]], |
| 74 | + [[boost::process::child* child = new boost::process::child; delete child;]])], |
| 75 | + ax_cv_boost_process=yes, ax_cv_boost_process=no) |
| 76 | + CXXFLAGS=$CXXFLAGS_SAVE |
| 77 | + AC_LANG_POP([C++]) |
| 78 | + ]) |
| 79 | + if test "x$ax_cv_boost_process" = "xyes"; then |
| 80 | + AC_SUBST(BOOST_CPPFLAGS) |
| 81 | +
|
| 82 | + AC_DEFINE(HAVE_BOOST_PROCESS,,[define if the Boost::Process library is available]) |
| 83 | + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` |
| 84 | +
|
| 85 | + LDFLAGS_SAVE=$LDFLAGS |
| 86 | + if test "x$ax_boost_user_process_lib" = "x"; then |
| 87 | + for libextension in `ls -r $BOOSTLIBDIR/libboost_process* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do |
| 88 | + ax_lib=${libextension} |
| 89 | + AC_CHECK_LIB($ax_lib, exit, |
| 90 | + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], |
| 91 | + [link_process="no"]) |
| 92 | + done |
| 93 | + if test "x$link_process" != "xyes"; then |
| 94 | + for libextension in `ls -r $BOOSTLIBDIR/boost_process* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do |
| 95 | + ax_lib=${libextension} |
| 96 | + AC_CHECK_LIB($ax_lib, exit, |
| 97 | + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], |
| 98 | + [link_process="no"]) |
| 99 | + done |
| 100 | + fi |
| 101 | +
|
| 102 | + else |
| 103 | + for ax_lib in $ax_boost_user_process_lib boost_process-$ax_boost_user_process_lib; do |
| 104 | + AC_CHECK_LIB($ax_lib, exit, |
| 105 | + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], |
| 106 | + [link_process="no"]) |
| 107 | + done |
| 108 | +
|
| 109 | + fi |
| 110 | + if test "x$ax_lib" = "x"; then |
| 111 | + AC_MSG_ERROR(Could not find a version of the Boost::Process library!) |
| 112 | + fi |
| 113 | + if test "x$link_process" = "xno"; then |
| 114 | + AC_MSG_ERROR(Could not link against $ax_lib !) |
| 115 | + fi |
| 116 | + fi |
| 117 | +
|
| 118 | + CPPFLAGS="$CPPFLAGS_SAVED" |
| 119 | + LDFLAGS="$LDFLAGS_SAVED" |
| 120 | + fi |
| 121 | +]) |
0 commit comments