]> granicus.if.org Git - sudo/commitdiff
If using GNU make on a multi-cpu system, use the -j flag to run
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 3 Aug 2016 12:15:25 +0000 (06:15 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 3 Aug 2016 12:15:25 +0000 (06:15 -0600)
make jobs in parallel, up to the number of cpus/cores.

mkpkg

diff --git a/mkpkg b/mkpkg
index 2a2cc2620b58fd7e620e9c69257f163644eb4162..ab10cd768618c1caef126f028453af4e517e7215 100755 (executable)
--- 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