diff options
author | Mike Eberdt <libreme@comcast.net> | 2011-07-15 03:15:29 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2011-07-15 03:15:29 -0500 |
commit | b71bb50e7ddfe1cbbaa57830f1e7f0ae3a0ecacf (patch) | |
tree | e9fb3d9641da8ebde49917c8cef683ff156b39ef | |
parent | 74e2dd57c3ef82738edfa24037f133c399177d3c (diff) |
Properly determine number of CPUs on FreeBSD
-rwxr-xr-x | configure.in | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/configure.in b/configure.in index c61685cc7..9ad2f5247 100755 --- a/configure.in +++ b/configure.in @@ -8699,16 +8699,25 @@ dnl =================================================================== dnl Number of CPUs to use during the build dnl =================================================================== AC_MSG_CHECKING([for number of processors to use]) -if test "z`uname -s`" = "zDarwin" -o "z`uname -s`" = "zNetBSD" -o "z`uname -s`" = "zOpenBSD"; then - BUILD_NCPUS=`sysctl -n hw.ncpu` -else - BUILD_NCPUS=`grep $'^processor\t*:' /proc/cpuinfo | wc -l` -fi -if test "z$with_num_cpus" != "z"; then +if test -n "$with_num_cpus"; then BUILD_NCPUS=$with_num_cpus -fi -if echo "$BUILD_NCPUS" | $EGREP -q '^[[[:space:]]]*0[[[:space:]]]*$' ; then - BUILD_NCPUS=1 +else + case `uname -s` in + + Darwin|FreeBSD|NetBSD|OpenBSD) + BUILD_NCPUS=`sysctl -n hw.ncpu` + ;; + + *) + BUILD_NCPUS=`grep $'^processor\t*:' /proc/cpuinfo | wc -l` + ;; + esac + + # If we hit the catch-all case, but /proc/cpuinfo doesn't exist or has an + # unexpected format, 'wc -l' will have returned 0. + if test "$BUILD_NCPUS" -eq 0; then + BUILD_NCPUS=1 + fi fi AC_MSG_RESULT([$BUILD_NCPUS]) AC_SUBST(BUILD_NCPUS) |