- case "$(detect_platform_type)" in
- *-*-darwin)
- ioreg -r -c IOCPU | fgrep -c IOCPUNumber
- ;;
- *)
- echo "WARNING: I don't know how to detect the number of processors on this platform." >&2
- echo "WARNING: GHC will be built using only 1 processor. Expect some slowdown." >&2
- echo 1
- ;;
- esac
+ if sysctl -n "hw.ncpu" 2>/dev/null; then
+ # This works for most BSDs.
+ :
+ elif grep -qF processor /proc/cpuinfo 2>/dev/null; then
+ # Linux sucks...
+ grep -cF processor /proc/cpuinfo
+ else
+ echo "WARNING: I don't know how to detect the number of processors on this platform." >&2
+ echo "WARNING: GHC will be built using only 1 processor. Expect some slowdown." >&2
+ echo 1
+ fi
+}
+
+function detect_gnu_tar () {
+ if which gnutar >/dev/null 2>&1; then
+ echo "gnutar"
+ elif which gtar >/dev/null 2>&1; then
+ echo "gtar"
+ else
+ echo "We need GNU tar to be installed." >&2
+ exit 1
+ fi
+}
+
+function detect_gnu_sed () {
+ if which gsed >/dev/null 2>&1; then
+ echo "gsed"
+ elif sed --version | grep -qF GNU; then
+ echo "sed"
+ else
+ echo "We need GNU sed to be installed." >&2
+ exit 1
+ fi