diff options
author | William Wennerström <william@wstrm.dev> | 2020-04-01 14:21:12 +0200 |
---|---|---|
committer | William Wennerström <william@wstrm.dev> | 2020-04-01 14:21:12 +0200 |
commit | 06f8299e7c353e592fe520ff5658b230a59f2ac6 (patch) | |
tree | 19e601293fe7794cce07ff7b9f3cae9a42693dcf | |
parent | 7eec3107fc57b9a43fc9e9edaae3315f56fd9523 (diff) | |
download | profani-tty-06f8299e7c353e592fe520ff5658b230a59f2ac6.tar.gz |
Fallback for nproc for systems without GNU coreutils
-rwxr-xr-x | ci-build.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ci-build.sh b/ci-build.sh index 438388b0..0a42e099 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -11,10 +11,21 @@ error_handler() trap error_handler ERR +num_cores() +{ + # Check for cores, for systems with: + # Line 1. Linux w/ coreutils, or... + # Line 2. OpenBSD, FreeBSD, NetBSD or macOS, or... + # Line 3. Fallback for Linux w/o coreutils (glibc). + nproc \ + || sysctl -n hw.ncpu \ + || getconf _NPROCESSORS_ONLN 2>/dev/null +} + ./bootstrap.sh tests=() -MAKE="make --quiet -j$(nproc)" +MAKE="make --quiet -j$(num_cores)" CC="gcc" case $(uname | tr '[:upper:]' '[:lower:]') in |