blob: 9068727b98b46cc5d84569de577c00a215769373 [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
Heinrich Schuchardt218d3892018-01-10 18:06:08 +01007# Provide symbol API_BUILD to signal that the API example is being built.
8KBUILD_CPPFLAGS += -DAPI_BUILD
9
Stefan Roese88fbf932010-04-15 16:07:28 +020010ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010011LOAD_ADDR = 0x40000
12endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010013ifeq ($(ARCH),arm)
14LOAD_ADDR = 0x1000000
15endif
Stanislav Galabov35d35e82016-02-04 12:13:44 +020016ifeq ($(ARCH),mips)
Stanislav Galabov10c7a572016-02-17 15:23:31 +020017ifdef CONFIG_64BIT
18LOAD_ADDR = 0xffffffff80200000
19else
Stanislav Galabov35d35e82016-02-04 12:13:44 +020020LOAD_ADDR = 0x80200000
21endif
Stanislav Galabov10c7a572016-02-17 15:23:31 +020022endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010023
Peter Tyser2dcb4e12009-06-22 18:01:39 -050024# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090025extra-y = demo
Rafal Jaworowskia19be782008-01-09 19:39:36 +010026
Peter Tyseracce4eb2009-07-20 19:02:21 -050027# Source files located in the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090028OBJ-y += crt0.o
29OBJ-y += demo.o
30OBJ-y += glue.o
31OBJ-y += libgenwrap.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010032
Peter Tyseracce4eb2009-07-20 19:02:21 -050033# Source files which exist outside the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090034EXT_COBJ-y += lib/crc32.o
35EXT_COBJ-y += lib/ctype.o
36EXT_COBJ-y += lib/div64.o
37EXT_COBJ-y += lib/string.o
38EXT_COBJ-y += lib/time.o
39EXT_COBJ-y += lib/vsprintf.o
Rob Clark8adf37f2017-09-09 06:47:41 -040040EXT_COBJ-y += lib/charset.o
Rob Clarkc82342f2017-09-09 06:47:42 -040041EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
Masahiro Yamada020a1f22014-02-24 11:12:19 +090042EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Tom Rini443b5162017-01-12 13:16:02 -050043ifeq ($(ARCH),arm)
44EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
45endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050046
Peter Tyserbdb925e2009-06-22 18:01:41 -050047# Create a list of object files to be compiled
Masahiro Yamada020a1f22014-02-24 11:12:19 +090048OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
49targets += $(OBJS)
50OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010051
Rafal Jaworowskia19be782008-01-09 19:39:36 +010052#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010053
Masahiro Yamada020a1f22014-02-24 11:12:19 +090054quiet_cmd_link_demo = LD $@
55cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
56
57$(obj)/demo: $(OBJS) FORCE
58 $(call if_changed,link_demo)
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090059
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090060# demo.bin is never genrated. Is this necessary?
61OBJCOPYFLAGS_demo.bin := -O binary
62$(obj)/demo.bin: $(obj)/demo FORCE
63 $(call if_changed,objcopy)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010064
Peter Tyserbdb925e2009-06-22 18:01:41 -050065# Rule to build generic library C files
Masahiro Yamada020a1f22014-02-24 11:12:19 +090066$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090067 $(call cmd,force_checksrc)
68 $(call if_changed_rule,cc_o_c)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010069
Peter Tyserbdb925e2009-06-22 18:01:41 -050070# Rule to build architecture-specific library assembly files
Tom Rini443b5162017-01-12 13:16:02 -050071$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090072 $(call if_changed_dep,as_o_S)