summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2014-02-04 17:24:28 +0900
committerTom Rini <trini@ti.com>2014-02-19 11:07:50 -0500
commit6825a95b0ba72c4e5667d02d8b31986e2e9abd5a (patch)
treef4c6e81fa45afba6662781eeee3f32b11f0b090d /examples
parent22433fc54b19b0578c43a9983fa45f22ca262a0f (diff)
downloadu-boot-6825a95b0ba72c4e5667d02d8b31986e2e9abd5a.tar.gz
u-boot-6825a95b0ba72c4e5667d02d8b31986e2e9abd5a.tar.bz2
u-boot-6825a95b0ba72c4e5667d02d8b31986e2e9abd5a.zip
kbuild: use Linux Kernel build scripts
Now we are ready to switch over to real Kbuild. This commit disables temporary scripts: scripts/{Makefile.build.tmp, Makefile.host.tmp} and enables real Kbuild scripts: scripts/{Makefile.build,Makefile.host,Makefile.lib}. This switch is triggered by the line in scripts/Kbuild.include -build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj +build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj We need to adjust some build scripts for U-Boot. But smaller amount of modification is preferable. Additionally, we need to fix compiler flags which are locally added or removed. In Kbuild, it is not allowed to change CFLAGS locally. Instead, ccflags-y, asflags-y, cppflags-y, CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o are prepared for that purpose. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Gerhard Sittig <gsi@denx.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/api/Makefile15
-rw-r--r--examples/standalone/Makefile22
2 files changed, 18 insertions, 19 deletions
diff --git a/examples/api/Makefile b/examples/api/Makefile
index db0bb34afe..8b79886074 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -5,7 +5,7 @@
#
ifdef FTRACE
-CFLAGS += -finstrument-functions -DFTRACE
+ccflags-y += -finstrument-functions -DFTRACE
endif
ifeq ($(ARCH),powerpc)
@@ -33,12 +33,6 @@ EXT_COBJ_FILES-y += lib/time.o
EXT_COBJ_FILES-y += lib/vsprintf.o
EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
-# Create a list of source files so their dependencies can be auto-generated
-SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
-SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
-SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
-SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
-
# Create a list of object files to be compiled
OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y))
OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y))
@@ -54,9 +48,10 @@ $(obj)/demo.bin: $(obj)/demo
$(OBJCOPY) -O binary $< $@ 2>/dev/null
# Rule to build generic library C files
-$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
- $(CC) -g $(CFLAGS) -c -o $@ $<
+$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c FORCE
+ $(call cmd,force_checksrc)
+ $(call if_changed_rule,cc_o_c)
# Rule to build architecture-specific library assembly files
$(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
- $(CC) -g $(CFLAGS) -c -o $@ $<
+ $(call if_changed_dep,as_o_S)
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index a6819f7792..90e173b83e 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -6,7 +6,7 @@
#
ifdef FTRACE
-CFLAGS += -finstrument-functions -DFTRACE
+ccflags-y += -finstrument-functions -DFTRACE
endif
extra-y := hello_world
@@ -39,10 +39,11 @@ LIBAOBJS := $(LIBAOBJS-y)
LIBCOBJS = stubs.o
+.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))
gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
@@ -52,19 +53,22 @@ 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)