changeset 2143:51f35c22d7b6

Handle yes/no in --with-parallel-jobs, detecting the number of processors when yes is specified. 2010-01-16 Andrew John Hughes <ahughes@redhat.com> * acinclude.m4: (IT_CHECK_NUMBER_OF_PARALLEL_JOBS): Handle --with-parallel-jobs and --without-parallel-jobs correctly. --with-parallel-jobs (no arguments) uses available processors + 1, while --without-parallel-jobs (the default) uses 2. (IT_FIND_NUMBER_OF_PROCESSORS): Dependency of above. Uses getconf to obtain the number of available processors.
author Andrew John Hughes <ahughes@redhat.com>
date Wed, 12 May 2010 10:31:37 +0100
parents f6febe400063
children b2902a555f12
files ChangeLog acinclude.m4
diffstat 2 files changed, 37 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 12 10:22:50 2010 +0100
+++ b/ChangeLog	Wed May 12 10:31:37 2010 +0100
@@ -1,3 +1,16 @@
+2010-01-16 Andrew John Hughes  <ahughes@redhat.com>
+
+	* acinclude.m4:
+	(IT_CHECK_NUMBER_OF_PARALLEL_JOBS):
+	Handle --with-parallel-jobs and
+	--without-parallel-jobs correctly.
+	--with-parallel-jobs (no arguments) uses
+	available processors + 1, while
+	--without-parallel-jobs (the default) uses 2.
+	(IT_FIND_NUMBER_OF_PROCESSORS):
+	Dependency of above.  Uses getconf to
+	obtain the number of available processors.
+	
 2010-01-16 Andrew John Hughes  <ahughes@redhat.com>
 
 	configure output and option cleanup
--- a/acinclude.m4	Wed May 12 10:22:50 2010 +0100
+++ b/acinclude.m4	Wed May 12 10:31:37 2010 +0100
@@ -1838,16 +1838,36 @@
 AC_PROVIDE([$0])dnl
 ])
 
-AC_DEFUN([IT_CHECK_NUMBER_OF_PARALLEL_JOBS],
+# Finds number of available processors using sysconf
+AC_DEFUN_ONCE([IT_FIND_NUMBER_OF_PROCESSORS],[
+  FIND_TOOL([GETCONF], [getconf])
+  AC_CACHE_CHECK([the number of online processors], it_cv_proc, [
+    if number=$($GETCONF _NPROCESSORS_ONLN); then
+      it_cv_proc=$number;
+    else
+      it_cv_proc=2;
+    fi
+  ])
+  AC_PROVIDE([$0])dnl
+])
+
+# Provides the option --with-parallel-jobs
+#  * --with-parallel-jobs; use jobs=processors + 1
+#  * --with-parallel-jobs=x; use jobs=x
+#  * --without-parallel-jobs (default); use jobs=2
+AC_DEFUN_ONCE([IT_CHECK_NUMBER_OF_PARALLEL_JOBS],
 [
+AC_REQUIRE([IT_FIND_NUMBER_OF_PROCESSORS])
+proc_default=$(($it_cv_proc + 1))
 AC_MSG_CHECKING([how many parallel build jobs to execute])
 AC_ARG_WITH([parallel-jobs],
 	[AS_HELP_STRING([--with-parallel-jobs],
 			[build IcedTea using the specified number of parallel jobs])],
 	[
-          if test "x${withval}" = x
-          then
-            PARALLEL_JOBS=2
+          if test "x${withval}" = xyes; then
+            PARALLEL_JOBS=${proc_default}
+	  elif test "x${withval}" = xno; then
+	    PARALLEL_JOBS=2
           else
             PARALLEL_JOBS=${withval}
           fi