[Buildroot] [PATCH 21/29 v2] package/boost: use positive logic to enable libraries

Yann E. MORIN yann.morin.1998 at free.fr
Wed Apr 9 20:03:36 UTC 2025


boostrap.sh has supported --with-libraries since its inception on
2005-10-07, with upstream commit a3595d0d7570 (Initial shot at a
configure script for Boost), and since its was first available in a
release, with Boost 1.34.0 released on 2013-04-13.

Using negative logic is counter-intuitive, and we avoid doing that in
Buildroot whenever possible, especially when using positive logic is
just as powerful.

Additionally, if a new version of Boost incldues a new library that we
missed, and that `./bootstrap.sh --show-libraries` also does not report,
then that new library would be built with the current use of negative
logic (i.e. all that is not disabled is built). By using positive logic,
only what gets explicitly enabled gets built, and such a new library
would not be built; thus, an interested party would late rnotice, and
add the necessary support.

Furthermore, by using positive logic here, and because we know that the
'headers' library will always be enabled, we know the list is not empty,
and thus we can simplify the code slightly.

Note that we would have liked to also explicitly disable libraries not
enabled in the configuration, but that is not possible: Boost's
buildsystem only accepts one of --with-libraries or --without-libraries.

Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
Cc: Michael Nosthoff <buildroot at heine.tech>
Cc: Yegor Yefremov <yegorslists at googlemail.com>
---
 package/boost/boost.mk | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/package/boost/boost.mk b/package/boost/boost.mk
index 7538dcb8f4..aa7b93a375 100644
--- a/package/boost/boost.mk
+++ b/package/boost/boost.mk
@@ -74,13 +74,13 @@ HOST_BOOST_FLAGS = \
 	--without-icu \
 	--with-toolset=gcc
 
-HOST_BOOST_WITHOUT_FLAGS = \
+HOST_BOOST_LIBS = \
 	$(foreach lib, $(BOOST_ALL_LIBS), \
-		$(if $(BR2_PACKAGE_HOST_BOOST_$(call UPPERCASE,$(lib))),,$(lib)) \
+		$(if $(BR2_PACKAGE_HOST_BOOST_$(call UPPERCASE,$(lib))),$(lib)) \
 	)
 
-HOST_BOOST_WITHOUT_FLAGS_COMMASEPARATED = $(subst $(space),$(comma),$(strip $(HOST_BOOST_WITHOUT_FLAGS)))
-HOST_BOOST_FLAGS += $(if $(HOST_BOOST_WITHOUT_FLAGS_COMMASEPARATED), --without-libraries=$(HOST_BOOST_WITHOUT_FLAGS_COMMASEPARATED))
+HOST_BOOST_FLAGS += \
+	--with-libraries=$(subst $(space),$(comma),$(strip $(HOST_BOOST_LIBS)))
 
 HOST_BOOST_OPTS += toolset=gcc threading=multi \
 	variant=release link=shared runtime-link=shared -j$(PARALLEL_JOBS) -q \
@@ -130,13 +130,13 @@ endif
 BOOST_DEPENDENCIES += $(if $(BR2_ENABLE_LOCALE),,libiconv)
 endif
 
-BOOST_WITHOUT_FLAGS = \
+BOOST_LIBS = \
 	$(foreach lib, $(BOOST_ALL_LIBS), \
-		$(if $(BR2_PACKAGE_BOOST_$(call UPPERCASE,$(lib))),,$(lib)) \
+		$(if $(BR2_PACKAGE_BOOST_$(call UPPERCASE,$(lib))),$(lib)) \
 	)
 
-BOOST_WITHOUT_FLAGS_COMMASEPARATED += $(subst $(space),$(comma),$(strip $(BOOST_WITHOUT_FLAGS)))
-BOOST_FLAGS += $(if $(BOOST_WITHOUT_FLAGS_COMMASEPARATED), --without-libraries=$(BOOST_WITHOUT_FLAGS_COMMASEPARATED))
+BOOST_FLAGS += \
+	--with-libraries=$(subst $(space),$(comma),$(strip $(BOOST_LIBS)))
 
 # how verbose should the build be?
 BOOST_OPTS += $(if $(QUIET),-d0,-d+1)
@@ -201,7 +201,7 @@ endef
 BOOST_PRE_INSTALL_TARGET_HOOKS += BOOST_REMOVE_TARGET_LIBRARIES
 
 define BOOST_CHECK_TARGET_LIBRARIES
-	@$(foreach disabled,$(BOOST_WITHOUT_FLAGS),\
+	@$(foreach disabled, $(filter-out $(BOOST_LIBS),$(BOOST_ALL_LIBS)), \
 		! ls $(TARGET_DIR)/usr/lib/libboost_$(disabled)* 1>/dev/null 2>&1 || \
 			! echo "libboost_$(disabled) shouldn't have been installed: missing select in boost/Config.in" || \
 			exit 1;)
-- 
2.47.0



More information about the buildroot mailing list