On Tue, Apr 18, 2006 at 06:19:47PM +0200, maximilian attems
wrote:> add object rules so that the division, remainder and friends get
> really build on sparc, patch from Fabio M. Di Nitto
<fabbione@ubuntu.com>.
> reworked to apply on latest git tree.
>
> Signed-off-by: maximilian attems <maks@sternwelten.at>
>
> ---
> Has been since long in the Debian and Ubuntu klibc.
>
> diff --git a/klibc/arch/sparc/Makefile.inc b/klibc/arch/sparc/Makefile.inc
> index 41c23c5..d77030d 100644
> --- a/klibc/arch/sparc/Makefile.inc
> +++ b/klibc/arch/sparc/Makefile.inc
> @@ -23,25 +23,33 @@ KLIBCARCHOBJS = \
> libgcc/__umoddi3.o \
> libgcc/__udivmoddi4.o
>
> -arch/$(KLIBCARCH)/sdiv.S: arch/$(KLIBCARCH)/divrem.m4
> +arch/$(KLIBCARCH)/sdiv.o: arch/$(KLIBCARCH)/sdiv.S
This is wrong. It will not work in the kernel.
You have to use:
$(obj)/$(KLIBCARCH)/file.o: $(obj)/$(KLIBCARCH)/file.S
> +
> +klibc/arch/$(KLIBCARCH)/sdiv.S: klibc/arch/$(KLIBCARCH)/divrem.m4
> @echo 'building $@ from $^'
> @(echo
"define(NAME,\`.div')define(OP,\`div')define(S,\`true')";
\
> cat $^) | m4 > $@
> @chmod 444 $@
The chmod seems pointless here. Needed due to some strange umask
setting?
And there is room for some consolidation and we also want to rebuild
if commandline changes.
Care to test following untested patch (has no sparc toolchain atm)
Sam
Makefile.inc | 44 +++++++++++++++++---------------------------
1 file changed, 17 insertions(+), 27 deletions(-)
diff --git a/klibc/arch/sparc/Makefile.inc b/klibc/arch/sparc/Makefile.inc
index 41c23c5..41b568b 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.S arch/$(KLIBCARCH)/srem.S \
+ arch/$(KLIBCARCH)/udiv.S arch/$(KLIBCARCH)/urem.S
+
+KLIBCARCHOBJS = $(m4-targets:.S=.o) \
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)/$(KLIBCARCH)/divrem.m4
+ $(call if_changed,m4)