diff options
author | Peter Simons <simons@cryp.to> | 2012-10-11 11:05:19 +0200 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2012-10-11 11:05:19 +0200 |
commit | 0bb51fea15dc4ded71b29708aefa87b0c94ca8d4 (patch) | |
tree | 2845a760877109f411f72c00c90f2025789b8bf9 /m4/ax_count_cpus.m4 | |
parent | 8542f1cbfec0436633447b4342ade809a156130f (diff) | |
download | autoconf-archive-0bb51fea15dc4ded71b29708aefa87b0c94ca8d4.tar.gz |
AX_COUNT_CPUS: improve style and clean-up use of AS_IF
See <http://savannah.gnu.org/patch/?7860> for further details.
Diffstat (limited to 'm4/ax_count_cpus.m4')
-rw-r--r-- | m4/ax_count_cpus.m4 | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/m4/ax_count_cpus.m4 b/m4/ax_count_cpus.m4 index 4de1f27..d4f3d29 100644 --- a/m4/ax_count_cpus.m4 +++ b/m4/ax_count_cpus.m4 @@ -15,6 +15,7 @@ # # LICENSE # +# Copyright (c) 2012 Brian Aker <brian@tangent.org> # Copyright (c) 2008 Michael Paul Bailey <jinxidoru@byu.net> # Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net> # @@ -23,29 +24,34 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 9 +#serial 10 -AC_DEFUN([AX_COUNT_CPUS], [ - AC_REQUIRE([AC_PROG_EGREP]) - AC_MSG_CHECKING(the number of available CPUs) - CPU_COUNT="0" + AC_DEFUN([AX_COUNT_CPUS],[ + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_PROG_EGREP]) + AC_MSG_CHECKING([the number of available CPUs]) + CPU_COUNT="0" - #On MacOS - if test -x /usr/sbin/sysctl; then - if test `/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu`; then + AS_CASE([$host_os],[ + *darwin*],[ + AS_IF([test -x /usr/sbin/sysctl],[ + sysctl_a=`/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.cpu` + AS_IF([test sysctl_a],[ CPU_COUNT=`/usr/sbin/sysctl -n hw.ncpu` - fi - fi + ]) + ])],[ + *linux*],[ + AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[ + AS_IF([test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo],[ + CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo` + ]) + ]) + ]) - #On Linux - if test "x$CPU_COUNT" = "x0" -a -e /proc/cpuinfo; then - CPU_COUNT=`$EGREP -c '^processor' /proc/cpuinfo` - fi - - if test "x$CPU_COUNT" = "x0"; then + AS_IF([test "x$CPU_COUNT" = "x0"],[ CPU_COUNT="1" AC_MSG_RESULT( [unable to detect (assuming 1)] ) - else + ],[ AC_MSG_RESULT( $CPU_COUNT ) - fi -]) + ]) + ]) |