[klibc] [PATCH] klibc: fix sparc build
Sam Ravnborg
sam at ravnborg.org
Wed Apr 19 03:48:47 PDT 2006
Fix build of klibc on sparc. Following patch is only tested on a kernel
build but should work on a native klibc build too.
The patch fixes a bug in klibc/Kbuild so assignments to the variable
targets in arch/$(KLIBCARCH)/Makefile.inc is not lost.
Without this 'make clean' did not work as expected.
Based on input from maximilian attems <maks at sternwelten.at> and
Fabio Massimo Di Nitto <fabbione at ubuntu.com>.
Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
---
I installed a sparc toolchain - fix is compiltime tested only.
And patch is handedited to fit the klibc tree.
Sam
diff --git a/klibc/Kbuild b/klibc/Kbuild
index 6533860..fb50a1c 100644
--- a/klibc/Kbuild
+++ b/klibc/Kbuild
@@ -81,7 +81,7 @@ INTERP_O := $(call objectify,$(INTERP_O)
SOLIBHASH = $(shell cat $(SOLIB).hash)
-targets := arch/$(KLIBCARCH)/crt0.o
+targets += arch/$(KLIBCARCH)/crt0.o
targets += $(libc-y) $(KLIBCARCHOBJS)
# Generate syscall stubs
diff --git a/klibc/arch/sparc/Makefile.inc b/klibc/arch/sparc/Makefile.inc
index 41c23c5..3389a16 100644
--- a/klibc/arch/sparc/Makefile.inc
+++ b/klibc/arch/sparc/Makefile.inc
@@ -7,11 +7,10 @@ # included from the main Makefile, and t
# accordingly.
#
-KLIBCARCHOBJS = \
- arch/$(KLIBCARCH)/sdiv.o \
- arch/$(KLIBCARCH)/udiv.o \
- arch/$(KLIBCARCH)/srem.o \
- arch/$(KLIBCARCH)/urem.o \
+m4-targets := arch/$(KLIBCARCH)/sdiv.o arch/$(KLIBCARCH)/srem.o \
+ arch/$(KLIBCARCH)/udiv.o arch/$(KLIBCARCH)/urem.o
+
+KLIBCARCHOBJS = $(m4-targets) \
arch/$(KLIBCARCH)/smul.o \
arch/$(KLIBCARCH)/umul.o \
arch/$(KLIBCARCH)/setjmp.o \
@@ -23,29 +22,20 @@ KLIBCARCHOBJS = \
libgcc/__umoddi3.o \
libgcc/__udivmoddi4.o
-arch/$(KLIBCARCH)/sdiv.S: arch/$(KLIBCARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
+adir := $(obj)/arch/$(KLIBCARCH)
-arch/$(KLIBCARCH)/udiv.S: arch/$(KLIBCARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
+$(adir)/sdiv.S: m4 := define(NAME,\`.div')define(OP,\`div')define(S,\`true')
+$(adir)/srem.S: m4 := define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')
+$(adir)/udiv.S: m4 := define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')
+$(adir)/urem.S: m4 := define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')
-arch/$(KLIBCARCH)/srem.S: arch/$(KLIBCARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
+targets += $(m4-targets) $(m4-targets:.o=.S)
-arch/$(KLIBCARCH)/urem.S: arch/$(KLIBCARCH)/divrem.m4
- @echo 'building $@ from $^'
- @(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \
- cat $^) | m4 > $@
- @chmod 444 $@
+quiet_cmd_m4 = M4 $@
+ cmd_m4 = (echo "$(m4)"; cat $^) | m4 > $@
-archclean:
- rm -f arch/$(KLIBCARCH)/?div.S arch/$(KLIBCARCH)/?rem.S
+# build .o from .S
+$(addprefix $(obj)/,$(m4-targets)): $(adir)/%.o : $(adir)/%.S
+# build .S from .m4
+$(addprefix $(obj)/,$(m4-targets:.o=.S)): $(src)/arch/$(KLIBCARCH)/divrem.m4
+ $(call if_changed,m4)
More information about the klibc
mailing list