1*4882a593Smuzhiyun#!/bin/sh 2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0+ 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# Figure out if we should follow a specific parallelism from the make 5*4882a593Smuzhiyun# environment (as exported by scripts/jobserver-exec), or fall back to 6*4882a593Smuzhiyun# the "auto" parallelism when "-jN" is not specified at the top-level 7*4882a593Smuzhiyun# "make" invocation. 8*4882a593Smuzhiyun 9*4882a593Smuzhiyunsphinx="$1" 10*4882a593Smuzhiyunshift || true 11*4882a593Smuzhiyun 12*4882a593Smuzhiyunparallel="$PARALLELISM" 13*4882a593Smuzhiyunif [ -z "$parallel" ] ; then 14*4882a593Smuzhiyun # If no parallelism is specified at the top-level make, then 15*4882a593Smuzhiyun # fall back to the expected "-jauto" mode that the "htmldocs" 16*4882a593Smuzhiyun # target has had. 17*4882a593Smuzhiyun auto=$(perl -e 'open IN,"'"$sphinx"' --version 2>&1 |"; 18*4882a593Smuzhiyun while (<IN>) { 19*4882a593Smuzhiyun if (m/([\d\.]+)/) { 20*4882a593Smuzhiyun print "auto" if ($1 >= "1.7") 21*4882a593Smuzhiyun } 22*4882a593Smuzhiyun } 23*4882a593Smuzhiyun close IN') 24*4882a593Smuzhiyun if [ -n "$auto" ] ; then 25*4882a593Smuzhiyun parallel="$auto" 26*4882a593Smuzhiyun fi 27*4882a593Smuzhiyunfi 28*4882a593Smuzhiyun# Only if some parallelism has been determined do we add the -jN option. 29*4882a593Smuzhiyunif [ -n "$parallel" ] ; then 30*4882a593Smuzhiyun parallel="-j$parallel" 31*4882a593Smuzhiyunfi 32*4882a593Smuzhiyun 33*4882a593Smuzhiyunexec "$sphinx" $parallel "$@" 34