blob: ec1643e48750eb98b070efe027d64cca1045b618 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowskia19be782008-01-09 19:39:36 +01002#
3# (C) Copyright 2007 Semihalf
Rafal Jaworowskia19be782008-01-09 19:39:36 +01004
Heinrich Schuchardt218d3892018-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 Roese88fbf932010-04-15 16:07:28 +02008ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +01009LOAD_ADDR = 0x40000
10endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010011ifeq ($(ARCH),arm)
Heinrich Schuchardt8ce7f882024-11-03 06:35:50 +010012ifdef CONFIG_64BIT
13LOAD_ADDR = 0x40400000
14else
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010015LOAD_ADDR = 0x1000000
16endif
Heinrich Schuchardt8ce7f882024-11-03 06:35:50 +010017endif
Stanislav Galabov35d35e82016-02-04 12:13:44 +020018ifeq ($(ARCH),mips)
Stanislav Galabov10c7a572016-02-17 15:23:31 +020019ifdef CONFIG_64BIT
20LOAD_ADDR = 0xffffffff80200000
21else
Stanislav Galabov35d35e82016-02-04 12:13:44 +020022LOAD_ADDR = 0x80200000
23endif
Stanislav Galabov10c7a572016-02-17 15:23:31 +020024endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010025
Peter Tyser2dcb4e12009-06-22 18:01:39 -050026# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090027extra-y = demo
Rafal Jaworowskia19be782008-01-09 19:39:36 +010028
Peter Tyseracce4eb2009-07-20 19:02:21 -050029# Source files located in the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090030OBJ-y += crt0.o
31OBJ-y += demo.o
32OBJ-y += glue.o
33OBJ-y += libgenwrap.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010034
Peter Tyseracce4eb2009-07-20 19:02:21 -050035# Source files which exist outside the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090036EXT_COBJ-y += lib/crc32.o
37EXT_COBJ-y += lib/ctype.o
38EXT_COBJ-y += lib/div64.o
Alexey Brodkin2d2fa492018-06-05 17:17:57 +030039EXT_COBJ-y += lib/hexdump.o
Masahiro Yamada020a1f22014-02-24 11:12:19 +090040EXT_COBJ-y += lib/string.o
41EXT_COBJ-y += lib/time.o
42EXT_COBJ-y += lib/vsprintf.o
Rob Clark8adf37f2017-09-09 06:47:41 -040043EXT_COBJ-y += lib/charset.o
Rob Clarkc82342f2017-09-09 06:47:42 -040044EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
Masahiro Yamada020a1f22014-02-24 11:12:19 +090045EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Tom Rini443b5162017-01-12 13:16:02 -050046ifeq ($(ARCH),arm)
47EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
48endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050049
Peter Tyserbdb925e2009-06-22 18:01:41 -050050# Create a list of object files to be compiled
Masahiro Yamada020a1f22014-02-24 11:12:19 +090051OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
52targets += $(OBJS)
53OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010054
Rafal Jaworowskia19be782008-01-09 19:39:36 +010055#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010056
Masahiro Yamada020a1f22014-02-24 11:12:19 +090057quiet_cmd_link_demo = LD $@
58cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
59
60$(obj)/demo: $(OBJS) FORCE
61 $(call if_changed,link_demo)
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090062
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090063# demo.bin is never genrated. Is this necessary?
64OBJCOPYFLAGS_demo.bin := -O binary
65$(obj)/demo.bin: $(obj)/demo FORCE
66 $(call if_changed,objcopy)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010067
Peter Tyserbdb925e2009-06-22 18:01:41 -050068# Rule to build generic library C files
Masahiro Yamada020a1f22014-02-24 11:12:19 +090069$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090070 $(call cmd,force_checksrc)
71 $(call if_changed_rule,cc_o_c)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010072
Peter Tyserbdb925e2009-06-22 18:01:41 -050073# Rule to build architecture-specific library assembly files
Tom Rini443b5162017-01-12 13:16:02 -050074$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090075 $(call if_changed_dep,as_o_S)