diff options
-rwxr-xr-x | build | 13 | ||||
-rwxr-xr-x | libexec/build-num-cpus | 17 |
2 files changed, 25 insertions, 5 deletions
@@ -315,11 +315,6 @@ export BUILDER_PATH PATH # include our default config test -f "${BUILDER_CFGDIR}/config" && include config -# FIXME MAKE_OPTS should default to #CPUS + 1, until we can detect #CPUS, we -# just set it to 2 for uni-processor systems. -MAKE_OPTS="${MAKE_OPTS:--j2}" -export MAKE_OPTS - # Default build target # FIXME this should default to all/all TARGET="${TARGET:-all/all}" @@ -339,6 +334,14 @@ export ARCH CHOST="${CHOST:-${CBUILD}}" export CHOST +MAKE_OPTS= +if test -z "${MAKE_OPTS}"; then + num_cpus="$(build-num-cpus)" + MAKE_OPTS="-j$((${num_cpus} + 1))" + unset num_cpus +fi +export MAKE_OPTS + # if we aren't given an action then we do everything ACTION="install" if [ "$#" -gt "0" ]; then diff --git a/libexec/build-num-cpus b/libexec/build-num-cpus new file mode 100755 index 0000000..ab88f3f --- /dev/null +++ b/libexec/build-num-cpus @@ -0,0 +1,17 @@ +#!/usr/bin/env build + +case "${CBUILD:-$(build-dumpmachine)}" in +(*linux*) eval 'build_num_cpus() { nproc; }';; +(*) die "unknown host '${CBUILD}'";; +esac + +if test "${BUILDER_CALL_STACK}" = '__main__'; then + for arg; do + case "${arg}" in + (-h|-help|--help) echo 'usage: build num-cpus'; exit 0;; + esac + done + build_num_cpus "${@}" +fi + +# vim: filetype=sh |