[klibc] [PATCH] kbuild: support single targets for klibc and klibc
programs
Sam Ravnborg
sam at ravnborg.org
Mon Apr 17 13:16:11 PDT 2006
With the following patch kbuild now supports:
make usr/dash/arith_yylex.i
make usr/klibc/umount.o
make usr/klibc/umount.s
Patch does also fix indention of CPP command
Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
---
That was my number 5) item on the kbuild list (added by akpm).
Modulus the next bug hpa discover this should clear all kbuild
issues with klibc.
So I hope to see it in next -mm !
Sam
diff --git a/Makefile b/Makefile
index e469623..a3c4cb1 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,11 @@ UTS_MACHINE := $(ARCH)
# Architecture used to compile user-space code
KLIBCARCH ?= $(subst powerpc,ppc,$(ARCH))
+# klibc definitions
+export KLIBCINC := usr/include
+export KLIBCSRC := $(srctree)/usr/klibc
+export KLIBCOBJ := $(objtree)/usr/klibc
+
# SHELL used by kbuild
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -1283,39 +1288,42 @@ # Single targets are compatible with:
# - build whith mixed source and output
# - build with separate output dir 'make O=...'
# - external modules
+# - klibc library and klibc programs (everything under usr/)
#
# target-dir => where to store outputfile
# build-dir => directory in kernel source tree to use
ifeq ($(KBUILD_EXTMOD),)
+ singlebld = $(if $(filter usr/%,$(dir $@)),$(klibc),$(build))
build-dir = $(patsubst %/,%,$(dir $@))
target-dir = $(dir $@)
else
+ singlebld = $(build)
zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
endif
%.s: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
%.i: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
%.lst: %.c prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
%.s: %.S prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.S prepare scripts FORCE
- $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
+ $(Q)$(MAKE) $(singlebld)=$(build-dir) $(target-dir)$(notdir $@)
# Modules
/ %/: prepare scripts FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
- $(build)=$(build-dir)
+ $(singlebld)=$(build-dir)
%.ko: prepare scripts FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
- $(build)=$(build-dir) $(@:.ko=.o)
+ $(singlebld)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
# FIXME Should go into a make.lib or something
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index b0d067b..3c90468 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -87,6 +87,11 @@ # Usage:
# $(Q)$(MAKE) $(build)=dir
build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+# Shorthand for $(Q)$(MAKE) -f scripts/Kbuild.klibc obj=
+# Usage:
+# $(Q)$(MAKE) $(klibc)=dir
+klibc := -f $(srctree)/scripts/Kbuild.klibc obj
+
# Prefix -I with $(srctree) if it is not an absolute path
addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
# Find all -I options and call addtree
diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc
index 1030a97..3b83de8 100644
--- a/scripts/Kbuild.klibc
+++ b/scripts/Kbuild.klibc
@@ -204,7 +204,7 @@ quiet_cmd_cc_o_c = KLIBCCC $@
%.o: %.c FORCE
$(call if_changed_dep,cc_o_c)
-quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@
+quiet_cmd_cc_i_c = CPP $@
cmd_cc_i_c = $(KLIBCCC) -E $(klibccflags) -o $@ $<
%.i: %.c FORCE
$(call if_changed_dep,cc_i_c)
diff --git a/usr/Kbuild b/usr/Kbuild
index 6ac1959..6a2a85d 100644
--- a/usr/Kbuild
+++ b/usr/Kbuild
@@ -2,10 +2,6 @@ #
# kbuild file for usr/ - including initramfs image and klibc
#
-# klibc definitions - to be moved to top-level Makefile later
-export KLIBCSRC := $(srctree)/$(src)/klibc
-export KLIBCINC := $(src)/include
-export KLIBCOBJ := $(objtree)/$(obj)/klibc
CONFIG_KLIBC := 1
klibc-subdir := klibc
@@ -17,7 +13,6 @@ klibc-subdir := $(addprefix _usr_,$(klib
# Klibc binaries
ifdef CONFIG_KLIBC
-klibc := -f $(srctree)/scripts/Kbuild.klibc obj
# .initramfs_data.cpio.gz.d is used to identify all files included
# in initramfs and to detect if any files are added/removed.
More information about the klibc
mailing list