Grab CI configuration from master
[ghc.git] / mk / detect-cpu-count.sh
1 #!/bin/sh
2
3 detect_cpu_count () {
4 if [ "$CPUS" = "" ]; then
5 # Windows standard environment variable
6 CPUS="$NUMBER_OF_PROCESSORS"
7 fi
8
9 if [ "$CPUS" = "" ]; then
10 # Linux
11 CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
12 fi
13
14 if [ "$CPUS" = "" ]; then
15 # FreeBSD
16 CPUS=`getconf NPROCESSORS_ONLN 2>/dev/null`
17 fi
18
19 if [ "$CPUS" = "" ]; then
20 # nothing helped
21 CPUS="1"
22 fi
23 }
24
25 detect_cpu_count
26 echo "$CPUS"