]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-firmware/ks2-boot-monitor.git/commitdiff
Makefile: Allow build so that objects are built in seperate directory
authorNishanth Menon <nm@ti.com>
Tue, 1 Sep 2015 22:21:30 +0000 (17:21 -0500)
committerNishanth Menon <nm@ti.com>
Fri, 2 Oct 2015 03:54:47 +0000 (22:54 -0500)
With this change the object files can be routed as necessary

Now, we can do make O=<some_path> and build objects there.

By default, we now start building the objects in corresponding SoC
specific directories.

Signed-off-by: Nishanth Menon <nm@ti.com>
Makefile
make.rules
non-sec/Makefile
non-sec/nonsec.lds
sec/Makefile
sec/s-kernel.lds

index 1791afbce113fa04b993118580ae0c184c93d49b..c05558500d3bc9a9554b7e54097b2a07c07afe51 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,9 @@ NONSECPADBIN = non-sec/nonsec_pad.bin
 SECPADBIN = sec/s-kernel_pad.bin
 IMAGE = skern
 
+ifneq ($(O),)
+export OBJROOT=$(O)
+endif
 
 BOOTROM_VERSION = 1
 
index 07b597bf140079c37ebb7a90adb5e9582dadb507..ad1fa5ab5815b24c86f94c4a449b19910cb3e0ea 100644 (file)
 #  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #  *
 #  */
-.PHONY: all clean
 
-all: $(EXE).bin $(EXE)_pad.bin
+.PHONY: all clean build_dir image
+
+OBJROOT ?= $(ROOT)
+OBJDIR ?= $(OBJROOT)/soc/$(SOC)
+OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(CSOURCES))
+OBJS += $(patsubst %.S,$(OBJDIR)/%.o,$(ASOURCES))
+
+all: build_dir image
+
+image: $(EXE).bin $(EXE)_pad.bin
 
 $(EXE)_pad.bin: $(EXE).bin
        objcopy -I binary -O binary --gap-fill 0x00 --pad-to $(PADSIZE) $< $@
@@ -45,3 +53,14 @@ $(EXE).out: $(OBJS)
 
 clean:
        rm -rf $(OBJS) *.bin *.out *.map
+
+build_dir:
+       if test ! -d $(OBJDIR); then \
+               mkdir -p $(OBJDIR) ;\
+       fi
+
+$(OBJDIR)/%.o: %.c
+       $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<
+
+$(OBJDIR)/%.o: %.S
+       $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c -o $@ $<
index 44497cb8cba4b4f7a6a460ff1af1a3e523ad7b0e..770e11791c39de9487e3f6032f68d2a85d67f937 100644 (file)
@@ -35,7 +35,7 @@ include $(ROOT)/makedefs
 
 PADSIZE = $(NONSEC_IMAGE_SIZE)
 
-OBJS =  init.o
+ASOURCES =  init.S
 
 EXE = nonsec
 
index 307791b32860e75bab569ba77642c60a25006617..134f3bdd5e8bde4c8788905a5433b418384eb912 100644 (file)
@@ -40,7 +40,7 @@ SECTIONS
        __start__ = . ;
        .text :
        {
-               init.o (.text)
+               *init.o (.text)
                *(.text .stub .text.* .gnu.linkonce.t.*)
        } =0
        PROVIDE (__etext = .);
index f9436c30d25b3d3672ee9115a6fd018f1475d527..44474ffea31c117506ad03635c294f668753896e 100644 (file)
@@ -35,7 +35,8 @@ include $(ROOT)/makedefs
 
 PADSIZE = $(SEC_IMAGE_SIZE)
 
-OBJS = skern.o skernel.o debug.o
+CSOURCES = skern.c debug.c
+ASOURCES = skernel.S
 
 EXE = s-kernel
 
index 549ef05db30e5241ad48253ce1c9f6393850b8c4..50a9c82decb981c9b991c21df395fb0805851736 100644 (file)
@@ -40,8 +40,8 @@ SECTIONS
        __start__ = . ;
        .text :
        {
-               skernel.o (.text)
-               skern.o (.text)
+               *skernel.o (.text)
+               *skern.o (.text)
                *(.text .stub .text.* .gnu.linkonce.t.*)
        } =0
        PROVIDE (__etext = .);