xref: /openbmc/u-boot/examples/api/Makefile (revision e5c5301f)
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
13
14include $(TOPDIR)/config.mk
15
16# Resulting ELF and binary exectuables will be named demo and demo.bin
17OUTPUT-$(CONFIG_API) = $(obj)demo
18OUTPUT = $(OUTPUT-y)
19
20# Source files located in the examples/api directory
21SOBJ_FILES-$(CONFIG_API) += crt0.o
22COBJ_FILES-$(CONFIG_API) += demo.o
23COBJ_FILES-$(CONFIG_API) += glue.o
24COBJ_FILES-$(CONFIG_API) += libgenwrap.o
25
26# Source files which exist outside the examples/api directory
27EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o
28EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o
29EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o
30EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o
31EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o
32EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o
33ifeq ($(ARCH),powerpc)
34EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
35endif
36
37# Create a list of source files so their dependencies can be auto-generated
38SRCS	+= $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
39SRCS	+= $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
40SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
41SRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
42
43# Create a list of object files to be compiled
44OBJS	+= $(addprefix $(obj),$(SOBJ_FILES-y))
45OBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
46OBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
47OBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
48
49CPPFLAGS += -I..
50
51all:	$(obj).depend $(OUTPUT)
52
53#########################################################################
54
55$(OUTPUT):	$(OBJS)
56		$(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
57		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
58
59# Rule to build generic library C files
60$(obj)%.o: $(SRCTREE)/lib/%.c
61	$(CC) -g $(CFLAGS) -c -o $@ $<
62
63# Rule to build architecture-specific library assembly files
64$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
65	$(CC) -g $(CFLAGS) -c -o $@ $<
66
67#########################################################################
68
69# defines $(obj).depend target
70include $(SRCTREE)/rules.mk
71
72sinclude $(obj).depend
73
74#########################################################################
75