[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

automatically parallized autoconf'd apt



The large patch adds some autoconf macros that detect the number of cpus in
the build machine, and parallize the build evironment.

The 2nd patch was done because I hate seeing rm done that way.  It is has no
effect on anything.

On my dual machine, these patches make apt compile with 4 gcc's at once.  Very
nice.  It also allows for buildd's to override the parallelization, by force
setting NUM_PROCS to 1(or some other number).

Have fun!

----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCS d- s: a-- c+++ UL++++ P+ L++++ !E W+ M o+ K- W--- !O M- !V PS--
PE++ Y+ PGP++ t* 5++ X+ tv b+ D++ G e h*! !r z?
-----END GEEK CODE BLOCK-----
----BEGIN PGP INFO----
Adam Heath <doogie@debian.org>        Finger Print | KeyID
67 01 42 93 CA 37 FB 1E    63 C9 80 1D 08 CF 84 0A | DE656B05 PGP
AD46 C888 F587 F8A3 A6DA  3261 8A2C 7DC2 8BD4 A489 | 8BD4A489 GPG
-----END PGP INFO-----
diff -ruN apt-0.3.15.orig/buildlib/defaults.mak apt-0.3.15/buildlib/defaults.mak
--- apt-0.3.15.orig/buildlib/defaults.mak	Tue May 11 00:55:31 1999
+++ apt-0.3.15/buildlib/defaults.mak	Wed Dec  8 00:01:29 1999
@@ -134,3 +134,11 @@
   endef
  endif
 endif	
+
+ifneq ($(NUM_PROCS),)
+ifndef PARALLEL_RUN
+PARALLEL_RUN=1
+MAKEFLAGS += -j $(NUM_PROCS)
+.EXPORT: PARALLEL_RUN
+endif
+endif
diff -ruN apt-0.3.15.orig/buildlib/environment.mak.in apt-0.3.15/buildlib/environment.mak.in
--- apt-0.3.15.orig/buildlib/environment.mak.in	Sun Nov  7 22:20:37 1999
+++ apt-0.3.15/buildlib/environment.mak.in	Wed Dec  8 00:01:49 1999
@@ -6,6 +6,7 @@
 CPPFLAGS+= @CPPFLAGS@ @DEFS@ -D_REENTRANT
 CXX = @CXX@
 CXXFLAGS+= @CXXFLAGS@ @X_CFLAGS@
+NUM_PROCS = @NUM_PROCS@
 
 # Linker stuff
 PICFLAGS+= -fPIC -DPIC
diff -ruN apt-0.3.15.orig/buildlib/tools.m4 apt-0.3.15/buildlib/tools.m4
--- apt-0.3.15.orig/buildlib/tools.m4	Mon Jul 13 00:05:53 1998
+++ apt-0.3.15/buildlib/tools.m4	Wed Dec  8 00:03:43 1999
@@ -229,3 +229,73 @@
 AC_MSG_RESULT($ac_cv_prog_cxx_cross)
 cross_compiling=$ac_cv_prog_cxx_cross
 ])
+
+AC_DEFUN(ah_HAVE_GETCONF,
+	[AC_ARG_WITH(getconf,
+		[  --with-getconf          Enable automagical buildtime configuration],
+		[if test "$withval" = "yes"; then
+			AC_PATH_PROG(GETCONF, getconf)
+		elif test ! "$withval" = "no";then 
+			AC_MSG_CHECKING([getconf])
+			AC_MSG_RESULT([$withval])
+			GETCONF=$withval
+		fi],
+		[AC_PATH_PROG(GETCONF, getconf)]
+	)
+	AC_SUBST(GETCONF)
+])
+
+AC_DEFUN(ah_NUM_CPUS,
+	[AC_REQUIRE([ah_HAVE_GETCONF])
+	AC_MSG_CHECKING([number of cpus])
+	AC_ARG_WITH(cpus,
+		[  --with-cpus             The number of cpus to be used for building(see --with-procs, default 1)],
+		[if test "$withval" = "yes"; then
+			if test "$GETCONF";then
+				NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
+			else
+				NUM_CPUS=1
+			fi
+		elif test ! "$withval" = "no";then
+			NUM_CPUS=$withval
+		fi],
+		[if test "$GETCONF";then
+			NUM_CPUS=`$GETCONF _NPROCESSORS_ONLN 2>/dev/null`
+		else
+			NUM_CPUS=1
+		fi]
+	)
+	AC_MSG_RESULT([$NUM_CPUS])
+	AC_SUBST(NUM_CPUS)
+])
+AC_DEFUN(ah_PROC_MULTIPLY,
+	[AC_MSG_CHECKING([processor multiplier])
+	AC_ARG_WITH(proc-multiply,
+		[  --with-proc-multiply    Multiply this * number of cpus for parallel making(default 2).],
+		[if test "$withval" = "yes"; then
+			PROC_MULTIPLY=2
+		elif test ! "$withval" = "no";then
+			PROC_MULTIPLY=$withval
+		fi],
+		[PROC_MULTIPLY=2]
+	)
+	AC_MSG_RESULT([$PROC_MULTIPLY])
+	AC_SUBST(PROC_MULTIPLY)
+])
+
+AC_DEFUN(ah_NUM_PROCS,
+	[AC_REQUIRE([ah_PROC_MULTIPLY])
+	AC_REQUIRE([ah_NUM_CPUS])
+	AC_MSG_CHECKING([number of processes to run during make])
+	AC_ARG_WITH(procs,
+		[  --with-procs            The number of processes to run in parallel during make(num_cpus * multiplier).],
+		[if test "$withval" = "yes"; then
+			let "NUM_PROCS=$NUM_CPUS*$PROC_MULTIPLY"
+		elif test ! "$withval" = "no";then
+			NUM_PROCS=$withval
+		fi],
+		[let "NUM_PROCS=$NUM_CPUS*$PROC_MULTIPLY"]
+	)
+	AC_MSG_RESULT([$NUM_PROCS])
+	AC_SUBST(NUM_PROCS)
+])
diff -ruN apt-0.3.15.orig/configure.in apt-0.3.15/configure.in
--- apt-0.3.15.orig/configure.in	Sat Dec  4 23:14:17 1999
+++ apt-0.3.15/configure.in	Tue Dec  7 23:53:15 1999
@@ -123,4 +123,6 @@
 dnl Check for YODL
 AC_CHECK_PROG(YODL_MAN,yodl2man,"yes","")
 
+ah_NUM_PROCS
+
 AC_OUTPUT(environment.mak:buildlib/environment.mak.in makefile:buildlib/makefile.in,make dirs)
diff -ruN apt-0.3.15.orig/buildlib/makefile.in apt-0.3.15/buildlib/makefile.in
--- apt-0.3.15.orig/buildlib/makefile.in	Sun Nov  7 22:20:38 1999
+++ apt-0.3.15/buildlib/makefile.in	Tue Dec  7 23:58:19 1999
@@ -24,8 +24,8 @@
 # Purge everything.
 .PHONY: maintainer-clean dist-clean pristine sanity distclean
 maintainer-clean dist-clean pristine sanity distclean:
-	-rm -rf $(DIRS)
-	-rm -f config.cache config.log config.status environment.mak makefile
+	rm -rf $(DIRS)
+	rm -f config.cache config.log config.status environment.mak makefile
 	
 # This makes any missing directories
 .PHONY: dirs

Reply to: