blob: ca4eb1f71adfeea83cbe41e0949acb0e4838428d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski500856e2008-01-09 19:39:36 +01002#
3# (C) Copyright 2007 Semihalf
Rafal Jaworowski500856e2008-01-09 19:39:36 +01004
Heinrich Schuchardt256060e2018-01-10 18:06:08 +01005# Provide symbol API_BUILD to signal that the API example is being built.
6KBUILD_CPPFLAGS += -DAPI_BUILD
7
Stefan Roesea47a12b2010-04-15 16:07:28 +02008ifeq ($(ARCH),powerpc)
Rafal Jaworowski500856e2008-01-09 19:39:36 +01009LOAD_ADDR = 0x40000
10endif
Rafal Jaworowski7fb6c4f2009-01-23 13:27:16 +010011ifeq ($(ARCH),arm)
12LOAD_ADDR = 0x1000000
13endif
Stanislav Galabov7c604232016-02-04 12:13:44 +020014ifeq ($(ARCH),mips)
Stanislav Galabov78757d52016-02-17 15:23:31 +020015ifdef CONFIG_64BIT
16LOAD_ADDR = 0xffffffff80200000
17else
Stanislav Galabov7c604232016-02-04 12:13:44 +020018LOAD_ADDR = 0x80200000
19endif
Stanislav Galabov78757d52016-02-17 15:23:31 +020020endif
Rafal Jaworowski500856e2008-01-09 19:39:36 +010021
Peter Tyser117d0ab2009-06-22 18:01:39 -050022# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada4a20df32014-02-04 17:24:12 +090023extra-y = demo
Rafal Jaworowski500856e2008-01-09 19:39:36 +010024
Peter Tyserd4abc752009-07-20 19:02:21 -050025# Source files located in the examples/api directory
Masahiro Yamada04a34c92014-02-24 11:12:19 +090026OBJ-y += crt0.o
27OBJ-y += demo.o
28OBJ-y += glue.o
29OBJ-y += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010030
Peter Tyserd4abc752009-07-20 19:02:21 -050031# Source files which exist outside the examples/api directory
Masahiro Yamada04a34c92014-02-24 11:12:19 +090032EXT_COBJ-y += lib/crc32.o
33EXT_COBJ-y += lib/ctype.o
34EXT_COBJ-y += lib/div64.o
Alexey Brodkinf8c987f2018-06-05 17:17:57 +030035EXT_COBJ-y += lib/hexdump.o
Masahiro Yamada04a34c92014-02-24 11:12:19 +090036EXT_COBJ-y += lib/string.o
37EXT_COBJ-y += lib/time.o
38EXT_COBJ-y += lib/vsprintf.o
Rob Clark274325c2017-09-09 06:47:41 -040039EXT_COBJ-y += lib/charset.o
Rob Clark22ada0c2017-09-09 06:47:42 -040040EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
Masahiro Yamada04a34c92014-02-24 11:12:19 +090041EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Tom Rini40d55342017-01-12 13:16:02 -050042ifeq ($(ARCH),arm)
43EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
44endif
Peter Tyser117d0ab2009-06-22 18:01:39 -050045
Peter Tyser876b3ce2009-06-22 18:01:41 -050046# Create a list of object files to be compiled
Masahiro Yamada04a34c92014-02-24 11:12:19 +090047OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
48targets += $(OBJS)
49OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010050
Rafal Jaworowski500856e2008-01-09 19:39:36 +010051#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010052
Masahiro Yamada04a34c92014-02-24 11:12:19 +090053quiet_cmd_link_demo = LD $@
54cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
55
56$(obj)/demo: $(OBJS) FORCE
57 $(call if_changed,link_demo)
Masahiro Yamada4a20df32014-02-04 17:24:12 +090058
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090059# demo.bin is never genrated. Is this necessary?
60OBJCOPYFLAGS_demo.bin := -O binary
61$(obj)/demo.bin: $(obj)/demo FORCE
62 $(call if_changed,objcopy)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010063
Peter Tyser876b3ce2009-06-22 18:01:41 -050064# Rule to build generic library C files
Masahiro Yamada04a34c92014-02-24 11:12:19 +090065$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090066 $(call cmd,force_checksrc)
67 $(call if_changed_rule,cc_o_c)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010068
Peter Tyser876b3ce2009-06-22 18:01:41 -050069# Rule to build architecture-specific library assembly files
Tom Rini40d55342017-01-12 13:16:02 -050070$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090071 $(call if_changed_dep,as_o_S)