]> gitweb @ CieloNegro.org - build-hc-pkg.git/commitdiff
build-hc-pkg (detect_number_of_cpus): support for Linux
authorPHO <pho@cielonegro.org>
Fri, 16 Mar 2012 03:44:18 +0000 (12:44 +0900)
committerPHO <pho@cielonegro.org>
Fri, 16 Mar 2012 03:44:18 +0000 (12:44 +0900)
build-hc-pkg

index 0c9069e613629c07e20bc6335d94be429c31d9bd..6e0e1fa59e51d566f1500d86dcec1eff23207f25 100755 (executable)
@@ -12,7 +12,13 @@ function detect_platform_type () {
 }
 
 function detect_number_of_cpus () {
-    if ! sysctl -n hw.ncpu 2>/dev/null; then
+    if sysctl -n "hw.ncpu" 2>/dev/null; then
+        # This works for most BSDs.
+        :
+    elif grep -qF processor /proc/cpuinfo; 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