1#!/bin/sh 2 3# Count processors in the system 4# 5# Copyright 2017 Robert Krawitz (rlk@alum.mit.edu) 6# 7# This program is free software; you can redistribute it and/or modify it 8# under the terms of the GNU General Public License as published by the Free 9# Software Foundation; either version 2 of the License, or (at your option) 10# any later version. 11# 12# This program is distributed in the hope that it will be useful, but 13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15# for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20# Use explicit /bin/sh in the shebang line to allow this to work in 21# a non-initialized workspace. 22 23# User-specified value takes priority 24if [ -n "$STP_PARALLEL" ] ; then 25 echo $STP_PARALLEL 26 exit 0 27fi 28 29# Linux 30nproc=$(type -p nproc) 31if [ -n "$nproc" ] ; then 32 nproc 33else 34 echo 1 35fi 36