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