34 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.0+3#4# Figure out if we should follow a specific parallelism from the make5# environment (as exported by scripts/jobserver-exec), or fall back to6# the "auto" parallelism when "-jN" is not specified at the top-level7# "make" invocation.8 9sphinx="$1"10shift || true11 12parallel="$PARALLELISM"13if [ -z "$parallel" ] ; then14 # If no parallelism is specified at the top-level make, then15 # fall back to the expected "-jauto" mode that the "htmldocs"16 # target has had.17 auto=$(perl -e 'open IN,"'"$sphinx"' --version 2>&1 |";18 while (<IN>) {19 if (m/([\d\.]+)/) {20 print "auto" if ($1 >= "1.7")21 }22 }23 close IN')24 if [ -n "$auto" ] ; then25 parallel="$auto"26 fi27fi28# Only if some parallelism has been determined do we add the -jN option.29if [ -n "$parallel" ] ; then30 parallel="-j$parallel"31fi32 33exec "$sphinx" $parallel "$@"34