From b71bb50e7ddfe1cbbaa57830f1e7f0ae3a0ecacf Mon Sep 17 00:00:00 2001 From: Mike Eberdt Date: Fri, 15 Jul 2011 03:15:29 -0500 Subject: Properly determine number of CPUs on FreeBSD --- configure.in | 27 ++++++++++++++++++--------- 1 file 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) -- cgit v1.2.3