xref: /openbmc/u-boot/examples/api/Makefile (revision 87a62bce)
1# SPDX-License-Identifier: GPL-2.0+
2#
3# (C) Copyright 2007 Semihalf
4
5# Provide symbol API_BUILD to signal that the API example is being built.
6KBUILD_CPPFLAGS += -DAPI_BUILD
7
8ifeq ($(ARCH),powerpc)
9LOAD_ADDR = 0x40000
10endif
11ifeq ($(ARCH),arm)
12LOAD_ADDR = 0x1000000
13endif
14ifeq ($(ARCH),mips)
15ifdef CONFIG_64BIT
16LOAD_ADDR = 0xffffffff80200000
17else
18LOAD_ADDR = 0x80200000
19endif
20endif
21
22# Resulting ELF and binary exectuables will be named demo and demo.bin
23extra-y = demo
24
25# Source files located in the examples/api directory
26OBJ-y += crt0.o
27OBJ-y += demo.o
28OBJ-y += glue.o
29OBJ-y += libgenwrap.o
30
31# Source files which exist outside the examples/api directory
32EXT_COBJ-y += lib/crc32.o
33EXT_COBJ-y += lib/ctype.o
34EXT_COBJ-y += lib/div64.o
35EXT_COBJ-y += lib/string.o
36EXT_COBJ-y += lib/time.o
37EXT_COBJ-y += lib/vsprintf.o
38EXT_COBJ-y += lib/charset.o
39EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
40EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
41ifeq ($(ARCH),arm)
42EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
43endif
44
45# Create a list of object files to be compiled
46OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
47targets += $(OBJS)
48OBJS := $(addprefix $(obj)/,$(OBJS))
49
50#########################################################################
51
52quiet_cmd_link_demo = LD      $@
53cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
54
55$(obj)/demo: $(OBJS) FORCE
56	$(call if_changed,link_demo)
57
58# demo.bin is never genrated. Is this necessary?
59OBJCOPYFLAGS_demo.bin := -O binary
60$(obj)/demo.bin: $(obj)/demo FORCE
61	$(call if_changed,objcopy)
62
63# Rule to build generic library C files
64$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
65	$(call cmd,force_checksrc)
66	$(call if_changed_rule,cc_o_c)
67
68# Rule to build architecture-specific library assembly files
69$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
70	$(call if_changed_dep,as_o_S)
71