From: Todd C. Miller Date: Wed, 3 Aug 2016 12:15:25 +0000 (-0600) Subject: If using GNU make on a multi-cpu system, use the -j flag to run X-Git-Tag: SUDO_1_8_18^2~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=820934082fb057228ba2a0543087ab54de53ce3c;p=sudo If using GNU make on a multi-cpu system, use the -j flag to run make jobs in parallel, up to the number of cpus/cores. --- diff --git a/mkpkg b/mkpkg index 2a2cc2620..ab10cd768 100755 --- a/mkpkg +++ b/mkpkg @@ -92,6 +92,31 @@ top_srcdir=`dirname $0` test -n "$osversion" || exit 1 osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'` +# If using GNU make, set number of jobs +if make --version 2>&1 | grep GNU >/dev/null; then + NJOBS=1 + case "`uname`" in + Darwin) + # Mac OS X + NJOBS=`sysctl -n hw.ncpu` + ;; + Linux) + if [ -x /usr/bin/lscpu ]; then + NJOBS=`/usr/bin/lscpu -p=cpu | grep -v '^#' | wc -l` + fi + ;; + SunOS) + # Solaris + if [ -x /usr/sbin/psrinfo ]; then + NJOBS=`/usr/sbin/psrinfo | wc -l` + fi + ;; + esac + if [ $NJOBS -gt 1 ]; then + make_opts="-j$NJOBS" + fi +fi + # Choose compiler options by osversion if not cross-compiling. if [ "$crossbuild" = "false" ]; then case "$osversion" in @@ -207,7 +232,7 @@ case "$osversion" in --with-sendmail=/usr/sbin/sendmail $configure_opts" - make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)' + make_opts='${make_opts}${make_opts+ }docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)' ;; deb*|ubu*) # Man pages should be compressed in .deb files