Skip to content

Commit df53819

Browse files
devurandomdvc94ch
authored andcommitted
Support setting build parallelism, part 2
This extends usage of the "nproc" mechanism to all remaining parts and adds another "makeflags" variable to prevent too much logic from being scattered throughout the Makefile. This variable could also be used to pass arbitrary flags to `make`. For the sake of simplicity, we assume for now that Ninja understands all flags that GNU Make does. If we ever need flags that only one of the two supports, we would have to add another "ninjaflags" variable. Signed-Off-By: Dennis Schridde <devurandom@gmx.net>
1 parent 0be0f54 commit df53819

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build_dir := $(root_dir)/build
33
sysroot_dir := $(root_dir)/toolchain
44
target := riscv32-unknown-elf
55
nproc :=
6+
makeflags := $(if $(nproc),-j$(nproc))
67
ccache := $(shell which ccache)
78

89

@@ -40,7 +41,7 @@ llvm-configure: $(llvm_src)
4041
$(llvm_build): llvm-configure
4142

4243
llvm-build: $(llvm_build)
43-
cmake --build $(llvm_build) -- $(if $(nproc),-j$(nproc))
44+
cmake --build $(llvm_build) -- $(makeflags)
4445
$(llvm_build)/bin/llc: llvm-build
4546

4647
llvm-install: $(llvm_build)/bin/llc
@@ -82,7 +83,7 @@ rust-build: $(sysroot_dir)/bin/cc
8283
--llvm-root=$(llvm_dest) \
8384
--enable-llvm-link-shared \
8485
--enable-ccache
85-
cd $(rust_src) && make
86+
cd $(rust_src) && make $(makeflags)
8687
cd $(rust_src) && make install
8788
$(rust_dest)/bin/rustc: rust-build
8889
rust: $(rust_dest)/bin/rustc
@@ -114,7 +115,7 @@ openocd-build: $(openocd_src)
114115
--enable-ftdi \
115116
$(if $(ccache),CC="$(ccache) $(CC)") \
116117
$(if $(ccache),CXX="$(ccache) $(CXX)")
117-
$(MAKE) -C $(openocd_build)
118+
$(MAKE) -C $(openocd_build) $(makeflags)
118119
$(MAKE) -C $(openocd_build) install
119120
$(openocd_dest)/bin/openocd: openocd-build
120121
openocd: $(openocd_dest)/bin/openocd
@@ -136,7 +137,7 @@ binutils-build: $(binutils_src)
136137
--enable-python \
137138
$(if $(ccache),CC="$(ccache) $(CC)") \
138139
$(if $(ccache),CXX="$(ccache) $(CXX)")
139-
$(MAKE) -C $(binutils_build)
140+
$(MAKE) -C $(binutils_build) $(makeflags)
140141
$(MAKE) -C $(binutils_build) install
141142
$(binutils_dest)/bin/$(target)-gdb: binutils-build
142143
binutils: $(binutils_dest)/bin/$(target)-gdb

0 commit comments

Comments
 (0)