[PATCH 1/2] boost: enhance main makefile to build against arbitrary boost

13 views
Skip to first unread message

Waldemar Kozaczuk

unread,
Feb 7, 2021, 3:41:16 PM2/7/21
to osv...@googlegroups.com, Waldemar Kozaczuk
On some distributions like CentOS version of boost it comes with
is very old and it is desirable to use version of boost built
independently using the scripts/download_and_build_boost.sh script.

This patch enhances the make makefile to detect and handle new parameter -
boost_base - that points to the base of the folder where boost was
built.

Here is an example of how kernel can be built against arbitrary boost:
boost_base=./build/downloaded_packages/x86_64/boost/install ./scripts/build -j4 image=native-example

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
Makefile | 48 ++++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/Makefile b/Makefile
index 66448a9b..9d80f095 100644
--- a/Makefile
+++ b/Makefile
@@ -1845,32 +1845,40 @@ else
endif
endif

-ifeq ($(CROSS_PREFIX),)
- # link with -mt if present, else the base version (and hope it is multithreaded)
- boost-mt := -mt
- boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
- ifeq ($(filter /%,$(boost-lib-dir)),)
- boost-mt :=
+#Allow user specify non-default location of boost
+ifeq ($(boost_base),)
+ ifeq ($(CROSS_PREFIX),)
+ # link with -mt if present, else the base version (and hope it is multithreaded)
+ boost-mt := -mt
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
ifeq ($(filter /%,$(boost-lib-dir)),)
- $(error Error: libboost_system.a needs to be installed.)
+ boost-mt :=
+ boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
+ ifeq ($(filter /%,$(boost-lib-dir)),)
+ $(error Error: libboost_system.a needs to be installed.)
+ endif
+ endif
+ # When boost_env=host, we won't use "-nostdinc", so the build machine's
+ # header files will be used normally. So we don't need to add anything
+ # special for Boost.
+ boost-includes =
+ else
+ ifeq ($(arch),aarch64)
+ aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
+ ifeq (,$(wildcard $(aarch64_boostbase)))
+ $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ endif
+
+ boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
+ boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
+ boost-includes = -isystem $(aarch64_boostbase)/usr/include
endif
endif
- # When boost_env=host, we won't use "-nostdinc", so the build machine's
- # header files will be used normally. So we don't need to add anything
- # special for Boost.
- boost-includes =
else
-ifeq ($(arch),aarch64)
- aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
- ifeq (,$(wildcard $(aarch64_boostbase)))
- $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
- endif
-
- boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
+ # Use boost specified by the user
+ boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a)))
boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
- boost-includes = -isystem $(aarch64_boostbase)/usr/include
-endif
+ boost-includes = -isystem $(boost_base)/usr/include
endif

boost-libs := $(boost-lib-dir)/libboost_system$(boost-mt).a
--
2.29.2

Waldemar Kozaczuk

unread,
Feb 7, 2021, 3:41:19 PM2/7/21
to osv...@googlegroups.com, Waldemar Kozaczuk
On some distributions like CentOS version of boost it comes with
is very old and it is desirable to use version of boost built
independently using the scripts/download_and_build_boost.sh script.

This patch enhances the modules common.gmk (used by tests, and other
modules) to detect and handle new parameter - boost_base - that points
to the base of the folder where boost was built.

Here is an example of how kernel and the tests modules can be built against arbitrary boost:
boost_base=./build/downloaded_packages/x86_64/boost/install ./scripts/build -j4 image=tests

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>
---
modules/common.gmk | 45 +++++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/modules/common.gmk b/modules/common.gmk
index 8f04244a..e0814b42 100644
--- a/modules/common.gmk
+++ b/modules/common.gmk
@@ -121,26 +121,39 @@ endif

#
# Let us detect presence of boost headers and library
-ifeq ($(CROSS_PREFIX),)
- boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
- ifeq ($(filter /%,$(boost-lib-dir)),)
- $(error Error: libboost_system.a needs to be installed.)
+# Allow user specify non-default location of boost
+ifeq ($(boost_base),)
+ ifeq ($(CROSS_PREFIX),)
+ boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
+ ifeq ($(filter /%,$(boost-lib-dir)),)
+ $(error Error: libboost_system.so needs to be installed.)
+ endif
+ # When boost_env=host, we won't use "-nostdinc", so the build machine's
+ # header files will be used normally. So we don't need to add anything
+ # special for Boost.
+ boost-includes =
+ else
+ ifeq ($(arch),aarch64)
+ aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install
+ ifeq (,$(wildcard $(aarch64_boostbase)))
+ $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ endif
+
+ boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so)))
+ LDFLAGS += -L$(boost-lib-dir)
+ boost-includes = -isystem $(aarch64_boostbase)/usr/include
+ endif
endif
- # When boost_env=host, we won't use "-nostdinc", so the build machine's
- # header files will be used normally. So we don't need to add anything
- # special for Boost.
- boost-includes =
else
-ifeq ($(arch),aarch64)
- aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install
- ifeq (,$(wildcard $(aarch64_boostbase)))
- $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ ifeq ($(filter /%,$(boost_base)),)
+ absolute_boost_base := $(src)/$(boost_base)# It must be relative OSv root
+ else
+ absolute_boost_base := $(boost_base)# It is absolute already
endif
-
- boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so)))
+ # Use boost specified by the user
+ boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_system.so)))
LDFLAGS += -L$(boost-lib-dir)
- boost-includes = -isystem $(aarch64_boostbase)/usr/include
-endif
+ boost-includes = -isystem $(absolute_boost_base)/usr/include
endif

# Let us set INCLUDES given all paths identified above
--
2.29.2

Commit Bot

unread,
Feb 10, 2021, 12:17:20 AM2/10/21
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

boost: enhance main makefile to build against arbitrary boost

On some distributions like CentOS version of boost it comes with
is very old and it is desirable to use version of boost built
independently using the scripts/download_and_build_boost.sh script.

This patch enhances the make makefile to detect and handle new parameter -
boost_base - that points to the base of the folder where boost was
built.

Here is an example of how kernel can be built against arbitrary boost:
boost_base=./build/downloaded_packages/x86_64/boost/install ./scripts/build -j4 image=native-example

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1845,32 +1845,40 @@ else
endif
endif

-ifeq ($(CROSS_PREFIX),)
- # link with -mt if present, else the base version (and hope it is multithreaded)
- boost-mt := -mt
- boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
- ifeq ($(filter /%,$(boost-lib-dir)),)
- boost-mt :=
+#Allow user specify non-default location of boost
+ifeq ($(boost_base),)
+ ifeq ($(CROSS_PREFIX),)
+ # link with -mt if present, else the base version (and hope it is multithreaded)
+ boost-mt := -mt
boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
ifeq ($(filter /%,$(boost-lib-dir)),)
- $(error Error: libboost_system.a needs to be installed.)
+ boost-mt :=
+ boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system$(boost-mt).a))
+ ifeq ($(filter /%,$(boost-lib-dir)),)
+ $(error Error: libboost_system.a needs to be installed.)
+ endif
+ endif
+ # When boost_env=host, we won't use "-nostdinc", so the build machine's
+ # header files will be used normally. So we don't need to add anything
+ # special for Boost.
+ boost-includes =
+ else
+ ifeq ($(arch),aarch64)
+ aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
+ ifeq (,$(wildcard $(aarch64_boostbase)))
+ $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ endif
+
+ boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
+ boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
+ boost-includes = -isystem $(aarch64_boostbase)/usr/include
endif
endif
- # When boost_env=host, we won't use "-nostdinc", so the build machine's
- # header files will be used normally. So we don't need to add anything
- # special for Boost.
- boost-includes =
else
-ifeq ($(arch),aarch64)
- aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
- ifeq (,$(wildcard $(aarch64_boostbase)))
- $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
- endif
-
- boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
+ # Use boost specified by the user
+ boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a)))
boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
- boost-includes = -isystem $(aarch64_boostbase)/usr/include
-endif

Commit Bot

unread,
Feb 10, 2021, 12:17:21 AM2/10/21
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

boost: enhance modules/common.gmk to build against arbitrary boost

On some distributions like CentOS version of boost it comes with
is very old and it is desirable to use version of boost built
independently using the scripts/download_and_build_boost.sh script.

This patch enhances the modules common.gmk (used by tests, and other
modules) to detect and handle new parameter - boost_base - that points
to the base of the folder where boost was built.

Here is an example of how kernel and the tests modules can be built against arbitrary boost:
boost_base=./build/downloaded_packages/x86_64/boost/install ./scripts/build -j4 image=tests

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/modules/common.gmk b/modules/common.gmk
--- a/modules/common.gmk
+++ b/modules/common.gmk
@@ -121,26 +121,39 @@ endif

#
# Let us detect presence of boost headers and library
-ifeq ($(CROSS_PREFIX),)
- boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
- ifeq ($(filter /%,$(boost-lib-dir)),)
- $(error Error: libboost_system.a needs to be installed.)
+# Allow user specify non-default location of boost
+ifeq ($(boost_base),)
+ ifeq ($(CROSS_PREFIX),)
+ boost-lib-dir := $(dir $(shell $(CC) --print-file-name libboost_system.so))
+ ifeq ($(filter /%,$(boost-lib-dir)),)
+ $(error Error: libboost_system.so needs to be installed.)
+ endif
+ # When boost_env=host, we won't use "-nostdinc", so the build machine's
+ # header files will be used normally. So we don't need to add anything
+ # special for Boost.
+ boost-includes =
+ else
+ ifeq ($(arch),aarch64)
+ aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install
+ ifeq (,$(wildcard $(aarch64_boostbase)))
+ $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ endif
+
+ boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so)))
+ LDFLAGS += -L$(boost-lib-dir)
+ boost-includes = -isystem $(aarch64_boostbase)/usr/include
+ endif
endif
- # When boost_env=host, we won't use "-nostdinc", so the build machine's
- # header files will be used normally. So we don't need to add anything
- # special for Boost.
- boost-includes =
else
-ifeq ($(arch),aarch64)
- aarch64_boostbase = $(src)/build/downloaded_packages/aarch64/boost/install
- ifeq (,$(wildcard $(aarch64_boostbase)))
- $(error Missing $(aarch64_boostbase) directory. Please run "./scripts/download_aarch64_packages.py")
+ ifeq ($(filter /%,$(boost_base)),)
+ absolute_boost_base := $(src)/$(boost_base)# It must be relative OSv root
+ else
+ absolute_boost_base := $(boost_base)# It is absolute already
endif
-
- boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system.so)))
+ # Use boost specified by the user
+ boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_system.so)))
LDFLAGS += -L$(boost-lib-dir)
- boost-includes = -isystem $(aarch64_boostbase)/usr/include
-endif
Reply all
Reply to author
Forward
0 new messages