diff mbox

[U-Boot,RFC,1/7] Adapt config.mk for usage in spl/Makefile

Message ID 1309352967-5719-2-git-send-email-aneesh@ti.com
State RFC
Headers show

Commit Message

Aneesh V June 29, 2011, 1:09 p.m. UTC
From: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>

[aneesh@ti.com:
1. Changed the definition of OBJTREE and the way 'obj' is defined.
2. Defined a flag to identify regular U-Boot build
3. Taking care of autoconf.mk etc for SPL due to changed OBJTREE
]
Signed-off-by: Aneesh V <aneesh@ti.com>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
 config.mk |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

Comments

Mike Frysinger June 29, 2011, 6:52 p.m. UTC | #1
On Wednesday, June 29, 2011 09:09:21 Aneesh V wrote:
> -$(obj)%.s:	%.S
> +$(obj)%.s:	$(src)%.S

why ?  i dont see any explanation for this.
-mike
Aneesh V June 30, 2011, 5:12 a.m. UTC | #2
On Thursday 30 June 2011 12:22 AM, Mike Frysinger wrote:
> On Wednesday, June 29, 2011 09:09:21 Aneesh V wrote:
>> -$(obj)%.s:	%.S
>> +$(obj)%.s:	$(src)%.S

I too didn't understand why that was done. But I noticed it just before
sending the patches so decided to give it a try later. I tried removing
them now and it doesn't harm. Maybe, some of the changes I did to the
definition of OBJTREE obj etc would have rendered it irrelevant?

Daniel,
Can you throw some light on this?

best regards,
Aneesh
Daniel Schwierzeck June 30, 2011, 11:09 a.m. UTC | #3
Hi Aneesh,

On Thu, Jun 30, 2011 at 7:12 AM, Aneesh V <aneesh@ti.com> wrote:
> On Thursday 30 June 2011 12:22 AM, Mike Frysinger wrote:
>>
>> On Wednesday, June 29, 2011 09:09:21 Aneesh V wrote:
>>>
>>> -$(obj)%.s:     %.S
>>> +$(obj)%.s:     $(src)%.S
>
> I too didn't understand why that was done. But I noticed it just before
> sending the patches so decided to give it a try later. I tried removing
> them now and it doesn't harm. Maybe, some of the changes I did to the
> definition of OBJTREE obj etc would have rendered it irrelevant?
>
> Daniel,
> Can you throw some light on this?
>

In my original patch I tweaked the src and obj variables to use spl as remote
build directory. As a consequence I had to change the implicite make rules too.

The regular way is:
src = $(TOPDIR)/arch/ARCH/cpu/CPU/start.S
obj = $(TOPDIR)/arch/ARCH/cpu/CPU/start.o (in-tree builds)
obj = $(BUILDDIR)/arch/ARCH/cpu/CPU/start.o (out-of-tree builds)

with spl as build directory:
src = $(TOPDIR)/arch/ARCH/cpu/CPU/start.S
obj = $(TOPDIR)/spl/arch/ARCH/cpu/CPU/start.o (in-tree builds)
obj = $(BUILDDIR)/spl/arch/ARCH/cpu/CPU/start.o (out-of-tree builds)

in the latter case I saw that $(src) got the value
$(TOPDIR)/spl/arch/ARCH/cpu/CPU/start.S
and the implicite make rules did not work anymore.

I'am glad if this works without those changes. I'll try
this for my boards too.

Best regards,
Daniel
diff mbox

Patch

diff --git a/config.mk b/config.mk
index 7ce554e..2ad15c6 100644
--- a/config.mk
+++ b/config.mk
@@ -116,8 +116,14 @@  RANLIB	= $(CROSS_COMPILE)RANLIB
 #########################################################################
 
 # Load generated board configuration
+ifdef CONFIG_UBOOT_SPL_BUILD
+# OBJTREE points to /spl/obj inside the original OBJTREE for SPL
+sinclude $(OBJTREE)/../../include/autoconf.mk
+sinclude $(OBJTREE)/../../include/config.mk
+else
 sinclude $(OBJTREE)/include/autoconf.mk
 sinclude $(OBJTREE)/include/config.mk
+endif
 
 # Some architecture config.mk files need to know what CPUDIR is set to,
 # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
@@ -194,13 +200,24 @@  ifneq ($(CONFIG_SYS_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
 endif
 
+ifneq ($(CONFIG_SPL_TEXT_BASE),)
+CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE)
+endif
+
+CONFIG_NORMAL_UBOOT = $(if $(CONFIG_UBOOT_SPL_BUILD),,y)
+
 ifneq ($(RESET_VECTOR_ADDRESS),)
 CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
 endif
 
 ifneq ($(OBJTREE),$(SRCTREE))
+ifdef CONFIG_UBOOT_SPL_BUILD
+# OBJTREE points to /spl/obj inside the original OBJTREE for SPL
+CPPFLAGS += -I$(OBJTREE)/../../include2 -I$(OBJTREE)/../../include
+else
 CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
 endif
+endif
 
 CPPFLAGS += -I$(TOPDIR)/include
 CPPFLAGS += -fno-builtin -ffreestanding -nostdinc	\
@@ -236,6 +253,11 @@  ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
+LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SPL_TEXT_BASE),)
+LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
+endif
+
 # Location of a usable BFD library, where we define "usable" as
 # "built for ${HOST}, supports ${TARGET}".  Sensible values are
 # - When cross-compiling: the root of the cross-environment
@@ -271,15 +293,15 @@  export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
 ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
-$(obj)%.s:	%.S
+$(obj)%.s:	$(src)%.S
 	$(CPP) $(ALL_AFLAGS) -o $@ $<
-$(obj)%.o:	%.S
+$(obj)%.o:	$(src)%.S
 	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
-$(obj)%.o:	%.c
+$(obj)%.o:	$(src)%.c
 	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.i:	%.c
+$(obj)%.i:	$(src)%.c
 	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
-$(obj)%.s:	%.c
+$(obj)%.s:	$(src)%.c
 	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
 
 #########################################################################