make.sh: Introduce MAX_PARALLELISM

This will now adjust MAKETUNING to not launch more processes
than MAX_PARALLELISM. Handy to limit builds that use a lot of memory.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2019-03-04 11:51:08 +00:00
parent eeee108f18
commit 7691a1bfe7
2 changed files with 10 additions and 2 deletions

View File

@@ -33,7 +33,15 @@
# Cleanup environment from any variables
unexport BUILD_ARCH BUILD_PLATFORM BUILDTARGET CROSSTARGET TOOLCHAIN TOOLS_DIR
MAKETUNING = -j $(DEFAULT_PARALLELISM)
PARALLELISM = $(shell echo $$( \
if [ -n "$(MAX_PARALLELISM)" ] && [ $(MAX_PARALLELISM) -lt $(DEFAULT_PARALLELISM) ]; then \
echo $(MAX_PARALLELISM); \
else \
echo $(DEFAULT_PARALLELISM); \
fi) \
)
MAKETUNING = -j $(PARALLELISM)
ifeq "$(BUILD_ARCH)" "aarch64"
IS_64BIT = 1

View File

@@ -38,7 +38,7 @@ CXXFLAGS += -O3 -fno-strict-aliasing
# The compiler uses a lot of memory to compile boost, hence we reduce
# the total number of processes a little bit to be able to build on
# smaller machines
override MAKETUNING = -j$(shell echo $$(( $(SYSTEM_MEMORY) / 512)))
MAX_PARALLELISM = $(shell echo $$(( $(SYSTEM_MEMORY) / 512)))
CONFIGURE_OPTIONS = \
--prefix=/usr \