151e46c7aSKees Cook#!/bin/sh 251e46c7aSKees Cook# SPDX-License-Identifier: GPL-2.0+ 351e46c7aSKees Cook# 451e46c7aSKees Cook# Figure out if we should follow a specific parallelism from the make 551e46c7aSKees Cook# environment (as exported by scripts/jobserver-exec), or fall back to 651e46c7aSKees Cook# the "auto" parallelism when "-jN" is not specified at the top-level 751e46c7aSKees Cook# "make" invocation. 851e46c7aSKees Cook 951e46c7aSKees Cooksphinx="$1" 1051e46c7aSKees Cookshift || true 1151e46c7aSKees Cook 1251e46c7aSKees Cookparallel="$PARALLELISM" 1351e46c7aSKees Cookif [ -z "$parallel" ] ; then 1451e46c7aSKees Cook # If no parallelism is specified at the top-level make, then 1551e46c7aSKees Cook # fall back to the expected "-jauto" mode that the "htmldocs" 1651e46c7aSKees Cook # target has had. 1751e46c7aSKees Cook auto=$(perl -e 'open IN,"'"$sphinx"' --version 2>&1 |"; 1851e46c7aSKees Cook while (<IN>) { 1951e46c7aSKees Cook if (m/([\d\.]+)/) { 2051e46c7aSKees Cook print "auto" if ($1 >= "1.7") 2151e46c7aSKees Cook } 2251e46c7aSKees Cook } 2351e46c7aSKees Cook close IN') 2451e46c7aSKees Cook if [ -n "$auto" ] ; then 2551e46c7aSKees Cook parallel="$auto" 2651e46c7aSKees Cook fi 2751e46c7aSKees Cookfi 2851e46c7aSKees Cook# Only if some parallelism has been determined do we add the -jN option. 2951e46c7aSKees Cookif [ -n "$parallel" ] ; then 3051e46c7aSKees Cook parallel="-j$parallel" 3151e46c7aSKees Cookfi 3251e46c7aSKees Cook 33*adc10f5bSKees Cookexec "$sphinx" $parallel "$@" 34