Temporary fix for the kinit parallel build problem

How to deal with the kinit stuff...

On Thu, Jul 27, 2006 at 01:33:18PM -0700, H. Peter Anvin wrote:
> Hi Sam,
>
> Any thoughts about how to deal with the kinit stuff?

Here is a quick hack.

The way I try to solve it is:

1) define a list of targets that must be build before descending.
   This is the "common/" stuff.
2) In resume/ define a number of .o files that shall be linked but
   not know as target by make.

Naming of variables are bad and they need better integration (kbuild
shall do objectify, assign targets etc.).
This was just something so you had a possibility to toy with it while
I'm having fun.

	Sam
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index 3aa40cd..f80345d 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -313,7 +313,7 @@
 
 stripobj  = $(subst $(obj)/,,$@)
 addliba   = $(addprefix $(obj)/, $(patsubst %/, %/lib.a, $(1)))
-link-deps = $(if $($(stripobj)-y), $(call addliba, $($(stripobj)-y)), $@.o)
+link-deps = $(if $($(stripobj)-y), $(call addliba, $($(stripobj)-y)), $@.o) $(use-libs)
 
 quiet_cmd_ld-static = KLIBCLD $@
       cmd_ld-static = $(KLIBCLD) $(KLIBCLDFLAGS) -o $@		\
@@ -363,7 +363,7 @@
 # ---------------------------------------------------------------------------
 
 .PHONY: $(subdir-y) $(kprog-dirs) $(klib-dirs)
-$(sort $(subdir-y) $(kprog-dirs) $(klib-dirs)):
+$(sort $(subdir-y) $(kprog-dirs) $(klib-dirs)): $(before-descend)
 	$(Q)$(MAKE) $(klibc)=$@
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
index 59db29b..8b4620e 100644
--- a/usr/kinit/Kbuild
+++ b/usr/kinit/Kbuild
@@ -2,6 +2,10 @@
 # Kbuild file for kinit
 #
 
+before-descend := name_to_dev.o devname.o getarg.o
+targets := $(before-descend)
+before-descend := $(call objectify, $(before-descend))
+use-libs := $(before-descend)
 static-y := kinit
 kinit-y  := kinit.o do_mounts.o ramdisk_load.o initrd.o
 kinit-y  += getintfile.o open.o readfile.o xpio.o
@@ -24,7 +28,7 @@
  	       -I$(srctree)/$(src)/run-init
 
 # Cleaning
-targets := kinit kinit.g kinit.shared kinit.shared.g
+targets += kinit kinit.g kinit.shared kinit.shared.g
 subdir- := fstype ipconfig nfsmount resume run-init
 
 
diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
index ce6d0ce..32b924e 100644
--- a/usr/kinit/resume/Kbuild
+++ b/usr/kinit/resume/Kbuild
@@ -6,8 +6,8 @@
 shared-y := shared/resume
 
 # common .o files
-objs := resume.o resumelib.o ../getarg.o ../name_to_dev.o ../devname.o
-
+objs := resume.o resumelib.o
+use-libs := $(call objectify, ../getarg.o ../name_to_dev.o ../devname.o)
 # TODO - do we want a stripped version
 # TODO - do we want the static.g + shared.g directories?