Skip to content

Commit b97deca

Browse files
authored
Merge pull request #1721 from pmienk/master
Add ax_boost_url.m4.
2 parents 0a05c0e + 7028192 commit b97deca

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

m4/ax_boost_url.m4

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#
2+
# SYNOPSIS
3+
#
4+
# AX_BOOST_URL
5+
#
6+
# DESCRIPTION
7+
#
8+
# Test for the Boost.URL library from the Boost C++ Libraries. This macro
9+
# checks whether the Boost.URL library is available and usable. It requires
10+
# the AX_BOOST_BASE macro to be called beforehand to set up Boost paths.
11+
#
12+
# This macro sets:
13+
# - HAVE_BOOST_URL to "yes" or "no" in the configure script.
14+
# - BOOST_URL_LIB to the linker flags for Boost.URL, if found.
15+
#
16+
# If Boost.URL is not found, the macro can either error out (if required)
17+
# or continue with a warning, depending on the --with-boost-url option.
18+
#
19+
# USAGE
20+
#
21+
# AX_BOOST_BASE([1.74]) # Minimum Boost version with Boost.URL
22+
# AX_BOOST_URL
23+
#
24+
# LICENSE
25+
#
26+
# Copyright (c) 2025
27+
#
28+
# Copying and distribution of this file, with or without modification, are
29+
# permitted in any medium without royalty provided the copyright notice
30+
# and this notice are preserved. This file is offered as-is, without any
31+
# warranty.
32+
33+
AC_DEFUN([AX_BOOST_URL],
34+
[
35+
AC_PREREQ([2.69])
36+
AC_REQUIRE([AX_BOOST_BASE])
37+
38+
AC_ARG_WITH([boost-url],
39+
[AS_HELP_STRING([--with-boost-url@<:@=special-lib@:>@],
40+
[use the Boost.URL library from boost - it is the first found or the one in special-lib])],
41+
[],
42+
[with_boost_url=yes])
43+
44+
AS_IF([test "x$with_boost_url" != xno],
45+
[
46+
# Save original flags
47+
ax_boost_url_save_LIBS="$LIBS"
48+
ax_boost_url_save_CPPFLAGS="$CPPFLAGS"
49+
ax_boost_url_save_LDFLAGS="$LDFLAGS"
50+
51+
# Initialize variables
52+
BOOST_URL_LIB=""
53+
HAVE_BOOST_URL=no
54+
55+
# Use Boost include and library paths from AX_BOOST_BASE
56+
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
57+
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
58+
59+
# Check for Boost.URL header
60+
AC_CHECK_HEADER([boost/url.hpp],
61+
[HAVE_BOOST_URL=yes],
62+
[HAVE_BOOST_URL=no])
63+
64+
AS_IF([test "x$HAVE_BOOST_URL" = xyes],
65+
[
66+
# Try to find the Boost.URL library
67+
# Boost.URL is header-only in newer versions, but we check for linking
68+
# to ensure compatibility with older setups or custom builds
69+
AC_MSG_CHECKING([whether the Boost.URL library links correctly])
70+
LIBS="$LIBS -lboost_url"
71+
AC_LINK_IFELSE(
72+
[AC_LANG_PROGRAM([#include <boost/url.hpp>],
73+
[boost::urls::url u; u.set_scheme("https");])],
74+
[BOOST_URL_LIB="-lboost_url"
75+
AC_MSG_RESULT([yes])],
76+
[AC_MSG_RESULT([no])
77+
HAVE_BOOST_URL=no])
78+
])
79+
80+
# Handle the result
81+
AS_IF([test "x$HAVE_BOOST_URL" = xyes],
82+
[
83+
AC_DEFINE([HAVE_BOOST_URL], [1], [Define if Boost.URL is available])
84+
AC_SUBST([BOOST_URL_LIB])
85+
],
86+
[
87+
if test "x$with_boost_url" = xyes; then
88+
AC_MSG_ERROR([Boost.URL library not found. Try specifying --with-boost-url=/path/to/boost.])
89+
else
90+
AC_MSG_WARN([Boost.URL library not found; continuing without it.])
91+
fi
92+
])
93+
94+
# Restore original flags
95+
LIBS="$ax_boost_url_save_LIBS"
96+
CPPFLAGS="$ax_boost_url_save_CPPFLAGS"
97+
LDFLAGS="$ax_boost_url_save_LDFLAGS"
98+
],
99+
[
100+
AC_MSG_NOTICE([Boost.URL support disabled by --without-boost-url])
101+
])
102+
103+
]) # AX_BOOST_URL

0 commit comments

Comments
 (0)