aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2006-08-01 13:57:23 +0200
committerH. Peter Anvin <hpa@zytor.com>2006-08-01 19:52:10 -0700
commitdf05b2f9694955e802916b4545fa552b3a35a108 (patch)
treec44a1d4ec4ea95586e68afcb3be1eb5fb72ae81d
parent94137bf8d2ac697efba8f9851ac27024518cf6f8 (diff)
downloadklibc-df05b2f9694955e802916b4545fa552b3a35a108.tar.gz
klibc/kbuild: proper library support for klibc programsklibc-1.4.17
resume introduced a dependency on a few .o files located in usr/kinit/ which confused kbuild. Add proper library support so any targets specified with lib-y is build before visiting subdirectories and thus the resulting lib.a may be used from the subdirectory Kbuild files. This also removes the ugly hack committed a few days ago solving the same problem in a very unelegant way. Tested on x86_64 with "make -j". Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--scripts/Kbuild.klibc28
-rw-r--r--usr/kinit/Kbuild13
-rw-r--r--usr/kinit/resume/Kbuild10
3 files changed, 31 insertions, 20 deletions
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index f80345d7da00d..9101d51602592 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -17,10 +17,10 @@
# If the userspace program consist of composite files do the following:
# Kbuild:
#
-# static-y := kinit
-# kinit-y := main.o netdev.c
-# So ipconfig will be linked statically using the two .o files
-# specified with ipconfig-y.
+# static-y := kinit
+# kinit-y := main.o netdev.c
+# So kinit will be linked statically using the two .o files
+# specified with kinit-y.
#
# Are part of the program located in a sub-directory do like this:
# kinit-y += ipconfig/
@@ -28,6 +28,9 @@
# And in the subdirectory:
# ipconfig/Kbuild:
# lib-y := packet.o dhcp_proto.o
+# # All .o files listed with lib-y will be used to create a single .a file.
+# # The .a file is created before any subdirectories are visited so it
+# # may be used in the sub-directory programs.
#
#####
# For a klibc libary file do like this
@@ -313,15 +316,18 @@ $(sort $(addsuffix /lib.a,$(kprog-dirs))): $(kprog-dirs) ;
stripobj = $(subst $(obj)/,,$@)
addliba = $(addprefix $(obj)/, $(patsubst %/, %/lib.a, $(1)))
-link-deps = $(if $($(stripobj)-y), $(call addliba, $($(stripobj)-y)), $@.o) $(use-libs)
+link-deps = $(if $($(stripobj)-y), $(call addliba, $($(stripobj)-y)), $@.o) \
+ $(call objectify,$($(stripobj)-lib))
quiet_cmd_ld-static = KLIBCLD $@
cmd_ld-static = $(KLIBCLD) $(KLIBCLDFLAGS) -o $@ \
$(EXTRA_KLIBCLDFLAGS) \
$(KLIBCCRT0) \
+ --start-group \
$(link-deps) \
- --start-group $(KLIBCLIBC) \
- $(KLIBCLIBGCC) --end-group ; \
+ $(KLIBCLIBC) \
+ $(KLIBCLIBGCC) \
+ --end-group ; \
cp -f $@ $@.g ; \
$(KLIBCSTRIP) $(KLIBCSTRIPFLAGS) $@
@@ -333,9 +339,11 @@ quiet_cmd_ld-shared = KLIBCLD $@
cmd_ld-shared = $(KLIBCLD) $(KLIBCLDFLAGS) -o $@ \
$(EXTRA_KLIBCLDFLAGS) \
$(KLIBCEMAIN) $(KLIBCCRTSHARED) \
+ --start-group \
$(link-deps) \
- --start-group -R $(KLIBCLIBCSHARED) \
- $(KLIBCLIBGCC) --end-group ; \
+ -R $(KLIBCLIBCSHARED) \
+ $(KLIBCLIBGCC) \
+ --end-group ; \
cp -f $@ $@.g ; \
$(KLIBCSTRIP) $(KLIBCSTRIPFLAGS) $@
@@ -363,7 +371,7 @@ endif
# ---------------------------------------------------------------------------
.PHONY: $(subdir-y) $(kprog-dirs) $(klib-dirs)
-$(sort $(subdir-y) $(kprog-dirs) $(klib-dirs)): $(before-descend)
+$(sort $(subdir-y) $(kprog-dirs) $(klib-dirs)): $(lib-target)
$(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 f0c95413613dd..ff1d449041b82 100644
--- a/usr/kinit/Kbuild
+++ b/usr/kinit/Kbuild
@@ -2,12 +2,12 @@
# 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
+# library part of kinit. Is used by programs in sub-directories (resume et al)
+lib-y := name_to_dev.o devname.o getarg.o
+# use lib for kinit
+kinit-y := lib.a
+
+kinit-y += kinit.o do_mounts.o ramdisk_load.o initrd.o
kinit-y += getintfile.o readfile.o xpio.o
kinit-y += do_mounts_md.o do_mounts_mtd.o nfsroot.o
@@ -17,6 +17,7 @@ kinit-y += run-init/
kinit-y += fstype/
kinit-y += resume/
+static-y := kinit
shared-y := kinit.shared
kinit.shared-y := $(kinit-y)
diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
index 32b924e31365c..034195d2ad2a9 100644
--- a/usr/kinit/resume/Kbuild
+++ b/usr/kinit/resume/Kbuild
@@ -7,19 +7,21 @@ shared-y := shared/resume
# common .o files
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?
-# Create built-in.o with all object files (used by kinit)
+# Create lib.a with all object files (used by kinit)
lib-y := $(objs)
# Additional include paths files
KLIBCCFLAGS += -I$(srctree)/$(src)/..
# .o files used to built executables
-static/resume-y := $(objs)
-shared/resume-y := $(objs)
+static/resume-y := $(objs)
+static/resume-lib := ../lib.a
+shared/resume-y := $(objs)
+shared/resume-lib := ../lib.a
# Cleaning
clean-dirs := static shared