diff mbox

[U-Boot] Makefile : fix generation of cpu related asm-offsets.h

Message ID 1313575934-15552-1-git-send-email-sbabic@denx.de
State Superseded
Headers show

Commit Message

Stefano Babic Aug. 17, 2011, 10:12 a.m. UTC
commit 0edf8b5b2fa0d210ebc4d6da0fd1aceeb7e44e47 breaks
building on a different directory with the O= parameter.
The patch wil fix this issue, generating always asm-offsets.h before
the other targets.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Note: the patch fixes the issue, however I generate an empty asm-offsets.c
for boards that do not have one. Is there a better way to reach the goal ?

 Makefile |   19 ++++++++++++++++++-
 rules.mk |   10 ----------
 2 files changed, 18 insertions(+), 11 deletions(-)

Comments

Matthias Weisser Aug. 17, 2011, 1:02 p.m. UTC | #1
Dear Stefano

Am 17.08.2011 12:12, schrieb Stefano Babic:
> commit 0edf8b5b2fa0d210ebc4d6da0fd1aceeb7e44e47 breaks
> building on a different directory with the O= parameter.
> The patch wil fix this issue, generating always asm-offsets.h before
> the other targets.
>
> Signed-off-by: Stefano Babic<sbabic@denx.de>
> ---
>
> Note: the patch fixes the issue, however I generate an empty asm-offsets.c
> for boards that do not have one. Is there a better way to reach the goal ?

Wouldn't it be possible to just create an empty asm-offsets.h if there 
is no asm-offsets.c?

And maybe it is handy to add the auto-generated files (asm-offsets.s/h) 
to the list of removed files of the clean or distclean target.

Regards
Matthias
Stefano Babic Aug. 17, 2011, 1:15 p.m. UTC | #2
On 08/17/2011 03:02 PM, Matthias Weißer wrote:
> Dear Stefano
> 
> Am 17.08.2011 12:12, schrieb Stefano Babic:
>> commit 0edf8b5b2fa0d210ebc4d6da0fd1aceeb7e44e47 breaks
>> building on a different directory with the O= parameter.
>> The patch wil fix this issue, generating always asm-offsets.h before
>> the other targets.
>>
>> Signed-off-by: Stefano Babic<sbabic@denx.de>
>> ---
>>
>> Note: the patch fixes the issue, however I generate an empty
>> asm-offsets.c
>> for boards that do not have one. Is there a better way to reach the
>> goal ?
> 
> Wouldn't it be possible to just create an empty asm-offsets.h if there
> is no asm-offsets.c?

Yes, this is surely possible - but I do not know another clean way to do
this as adding an if..then..fi script inside the rule, as I did now
creating an empty asm-offsets.c.

Really I wanted to fix this issue changing the dependencies, but I have
not found a solution. Now it works (as for generic-asm-offsets.h)
because asm-offsets.h is always generated as first target.

> And maybe it is handy to add the auto-generated files (asm-offsets.s/h)
> to the list of removed files of the clean or distclean target.

Agree, they must be added as well.

Regards,
Stefano
diff mbox

Patch

diff --git a/Makefile b/Makefile
index f8ae883..10b2498 100644
--- a/Makefile
+++ b/Makefile
@@ -460,7 +460,8 @@  updater:
 # parallel sub-makes creating .depend files simultaneously.
 depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
 		$(obj)include/autoconf.mk \
-		$(obj)include/generated/generic-asm-offsets.h
+		$(obj)include/generated/generic-asm-offsets.h \
+		$(obj)include/asm/arch/asm-offsets.h
 		for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \
 			$(MAKE) -C $$dir _depend ; done
 
@@ -519,6 +520,22 @@  $(obj)lib/asm-offsets.s:	$(obj)include/autoconf.mk.dep \
 		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
 		-o $@ $(src)lib/asm-offsets.c -c -S
 
+$(obj)include/asm/arch/asm-offsets.h:	$(obj)include/autoconf.mk.dep \
+	$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
+	@echo Generating $@
+	tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
+
+$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:	$(obj)include/autoconf.mk.dep check_cpu_asm_offsets
+	@mkdir -p $(obj)$(CPUDIR)/$(SOC)
+	$(CC) -DDO_DEPS_ONLY \
+		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
+		-o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S
+
+#	$(src)$(CPUDIR)/$(SOC)/asm-offsets.c
+check_cpu_asm_offsets:
+	if [ ! -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
+        touch $(src)$(CPUDIR)/$(SOC)/asm-offsets.c;fi
+
 #########################################################################
 else	# !config.mk
 all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
diff --git a/rules.mk b/rules.mk
index 5fd12a0..c2860e5 100644
--- a/rules.mk
+++ b/rules.mk
@@ -42,14 +42,4 @@  $(HOSTOBJS): $(obj)%.o: %.c
 $(NOPEDOBJS): $(obj)%.o: %.c
 	$(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
 
-$(TOPDIR)/include/asm/arch/asm-offsets.h:	$(TOPDIR)/include/autoconf.mk.dep \
-	$(TOPDIR)/$(CPUDIR)/$(SOC)/asm-offsets.s
-	@echo Generating $@
-	$(TOPDIR)/tools/scripts/make-asm-offsets $(TOPDIR)/$(CPUDIR)/$(SOC)/asm-offsets.s $@
-
-$(TOPDIR)/$(CPUDIR)/$(SOC)/asm-offsets.s:	$(TOPDIR)/include/autoconf.mk.dep \
-	$(TOPDIR)/$(CPUDIR)/$(SOC)/asm-offsets.c
-	$(CC) -DDO_DEPS_ONLY \
-		$(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
-		-o $@ $(TOPDIR)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S
 #########################################################################