]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - examples/standalone/Makefile
kbuild: use Linux Kernel build scripts
[karo-tx-uboot.git] / examples / standalone / Makefile
index cad440954e1e2d8e6e6e8b4aaf73c9f00670b855..90e173b83ee8f1750962890dfdad66927e2bb9ed 100644 (file)
@@ -5,6 +5,10 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
+ifdef FTRACE
+ccflags-y += -finstrument-functions -DFTRACE
+endif
+
 extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
@@ -27,7 +31,7 @@ clean-files  := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-
 
 COBJS  := $(ELF:=.o)
 
-LIB    = $(obj)libstubs.o
+LIB    = $(obj)/libstubs.o
 
 LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
 LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
@@ -35,11 +39,12 @@ LIBAOBJS := $(LIBAOBJS-y)
 
 LIBCOBJS = stubs.o
 
-LIBOBJS        = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
+.SECONDARY: $(call objectify,$(COBJS))
+targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBAOBJS) $(LIBCOBJS)
+
+LIBOBJS        = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
 
-SRCS   := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
-OBJS   := $(addprefix $(obj),$(COBJS))
-ELF    := $(addprefix $(obj),$(ELF))
+ELF    := $(addprefix $(obj)/,$(ELF))
 
 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 
@@ -48,28 +53,31 @@ gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 # also causes the entry point of the standalone application to be
 # inconsistent.
 ifeq ($(ARCH),powerpc)
-AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
-CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
-CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
+# FIX ME
+CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS))
 endif
 
 # We don't want gcc reordering functions if possible.  This ensures that an
 # application's entry point will be the first function in the application's
 # source file.
-CFLAGS += $(call cc-option,-fno-toplevel-reorder)
+ccflags-y += $(call cc-option,-fno-toplevel-reorder)
 
 #########################################################################
-$(LIB):        $(LIBOBJS)
-       $(call cmd_link_o_target, $(LIBOBJS))
+
+quiet_cmd_link_lib = LD      $@
+      cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
+
+$(LIB):        $(LIBOBJS) FORCE
+       $(call if_changed,link_lib)
 
 $(ELF):
-$(obj)%:       $(obj)%.o $(LIB)
+$(obj)/%:      $(obj)/%.o $(LIB)
                $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
                        -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
                        -L$(gcclibdir) -lgcc
 
-$(obj)%.srec:  $(obj)%
+$(obj)/%.srec: $(obj)/%
                $(OBJCOPY) -O srec $< $@ 2>/dev/null
 
-$(obj)%.bin:   $(obj)%
+$(obj)/%.bin:  $(obj)/%
                $(OBJCOPY) -O binary $< $@ 2>/dev/null