xref: /openbmc/u-boot/examples/api/Makefile (revision 0b45a79f)
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)
14LOAD_ADDR = 0x80200000
15endif
16
17# Resulting ELF and binary exectuables will be named demo and demo.bin
18extra-y = demo
19
20# Source files located in the examples/api directory
21OBJ-y += crt0.o
22OBJ-y += demo.o
23OBJ-y += glue.o
24OBJ-y += libgenwrap.o
25
26# Source files which exist outside the examples/api directory
27EXT_COBJ-y += lib/crc32.o
28EXT_COBJ-y += lib/ctype.o
29EXT_COBJ-y += lib/div64.o
30EXT_COBJ-y += lib/string.o
31EXT_COBJ-y += lib/time.o
32EXT_COBJ-y += lib/vsprintf.o
33EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
34
35# Create a list of object files to be compiled
36OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
37targets += $(OBJS)
38OBJS := $(addprefix $(obj)/,$(OBJS))
39
40#########################################################################
41
42quiet_cmd_link_demo = LD      $@
43cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
44
45$(obj)/demo: $(OBJS) FORCE
46	$(call if_changed,link_demo)
47
48# demo.bin is never genrated. Is this necessary?
49OBJCOPYFLAGS_demo.bin := -O binary
50$(obj)/demo.bin: $(obj)/demo FORCE
51	$(call if_changed,objcopy)
52
53# Rule to build generic library C files
54$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
55	$(call cmd,force_checksrc)
56	$(call if_changed_rule,cc_o_c)
57
58# Rule to build architecture-specific library assembly files
59$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
60	$(call if_changed_dep,as_o_S)
61