Skip to content

Commit fc68650

Browse files
committed
Simplify the use of J for both GNU parallel and GNU make
1 parent a3fe685 commit fc68650

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CFLAGS += ${EXTRA_CFLAGS}
1515
CXXFLAGS += ${EXTRA_CXXFLAGS}
1616
LDFLAGS += $(EXTRA_LDFLAGS)
1717
MACHINE ?= $(shell uname -m)
18+
NPROC ?= $(shell nproc)
1819
ARFLAGS = ${EXTRA_ARFLAGS} rs
1920
STRIPFLAGS = -S -x
2021

@@ -917,11 +918,13 @@ prioritize_long_running_tests = \
917918
| sed 's/^[.0-9]* //'
918919

919920
# "make check" uses
920-
# Run with "make J=1 check" to disable parallelism in "make check".
921-
# Run with "make J=200% check" to run two parallel jobs per core.
922-
# The default is to run one job per core (J=100%).
923-
# See "man parallel" for its "-j ..." option.
924-
J ?= 100%
921+
# Run with "make J=1 check" to disable parallelism in "make check" or (Docker) container builds.
922+
# Run with "make J=$((`nproc`*2)) check" to run two parallel jobs per core.
923+
# The default is to run one job per core, but leave one core free for the OS, i.e.: J=$((`nproc`-1)).
924+
# This is used both to inform GNU `parrallel` of the number of parallel jobs to execute,
925+
# and also as the number of jobs for Make when executed in (Docker) containers
926+
# See "man parallel" and "man make" for their "-j ..." option syntax.
927+
J ?= $(shell expr $(NPROC) - 1)
925928

926929
# Use this regexp to select the subset of tests whose names match.
927930
tests-regexp = .

0 commit comments

Comments
 (0)