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