blob: dab6398bab824d83f4b90674cec10ddf55ec9f64 [file] [log] [blame]
Rafal Jaworowskia19be782008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowskia19be782008-01-09 19:39:36 +01005#
6
Stefan Roese88fbf932010-04-15 16:07:28 +02007ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +01008LOAD_ADDR = 0x40000
9endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010010ifeq ($(ARCH),arm)
11LOAD_ADDR = 0x1000000
12endif
Stanislav Galabov35d35e82016-02-04 12:13:44 +020013ifeq ($(ARCH),mips)
Stanislav Galabov10c7a572016-02-17 15:23:31 +020014ifdef CONFIG_64BIT
15LOAD_ADDR = 0xffffffff80200000
16else
Stanislav Galabov35d35e82016-02-04 12:13:44 +020017LOAD_ADDR = 0x80200000
18endif
Stanislav Galabov10c7a572016-02-17 15:23:31 +020019endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010020
Peter Tyser2dcb4e12009-06-22 18:01:39 -050021# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090022extra-y = demo
Rafal Jaworowskia19be782008-01-09 19:39:36 +010023
Peter Tyseracce4eb2009-07-20 19:02:21 -050024# Source files located in the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090025OBJ-y += crt0.o
26OBJ-y += demo.o
27OBJ-y += glue.o
28OBJ-y += libgenwrap.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010029
Peter Tyseracce4eb2009-07-20 19:02:21 -050030# Source files which exist outside the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090031EXT_COBJ-y += lib/crc32.o
32EXT_COBJ-y += lib/ctype.o
33EXT_COBJ-y += lib/div64.o
34EXT_COBJ-y += lib/string.o
35EXT_COBJ-y += lib/time.o
36EXT_COBJ-y += lib/vsprintf.o
37EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Tom Rini443b5162017-01-12 13:16:02 -050038ifeq ($(ARCH),arm)
39EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
40endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050041
Peter Tyserbdb925e2009-06-22 18:01:41 -050042# Create a list of object files to be compiled
Masahiro Yamada020a1f22014-02-24 11:12:19 +090043OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
44targets += $(OBJS)
45OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010046
Rafal Jaworowskia19be782008-01-09 19:39:36 +010047#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010048
Masahiro Yamada020a1f22014-02-24 11:12:19 +090049quiet_cmd_link_demo = LD $@
50cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
51
52$(obj)/demo: $(OBJS) FORCE
53 $(call if_changed,link_demo)
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090054
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090055# demo.bin is never genrated. Is this necessary?
56OBJCOPYFLAGS_demo.bin := -O binary
57$(obj)/demo.bin: $(obj)/demo FORCE
58 $(call if_changed,objcopy)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010059
Peter Tyserbdb925e2009-06-22 18:01:41 -050060# Rule to build generic library C files
Masahiro Yamada020a1f22014-02-24 11:12:19 +090061$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090062 $(call cmd,force_checksrc)
63 $(call if_changed_rule,cc_o_c)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010064
Peter Tyserbdb925e2009-06-22 18:01:41 -050065# Rule to build architecture-specific library assembly files
Tom Rini443b5162017-01-12 13:16:02 -050066$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090067 $(call if_changed_dep,as_o_S)