xref: /openbmc/u-boot/examples/api/Makefile (revision 942828a0)
1d4abc757SPeter Tyser#
2d4abc757SPeter Tyser# (C) Copyright 2007 Semihalf
3d4abc757SPeter Tyser#
4d4abc757SPeter Tyser# See file CREDITS for list of people who contributed to this
5d4abc757SPeter Tyser# project.
6d4abc757SPeter Tyser#
7d4abc757SPeter Tyser# This program is free software; you can redistribute it and/or
8d4abc757SPeter Tyser# modify it under the terms of the GNU General Public License as
9d4abc757SPeter Tyser# published by the Free Software Foundatio; either version 2 of
10d4abc757SPeter Tyser# the License, or (at your option) any later version.
11d4abc757SPeter Tyser#
12d4abc757SPeter Tyser# This program is distributed in the hope that it will be useful,
13d4abc757SPeter Tyser# but WITHOUT ANY WARRANTY; without even the implied warranty of
14d4abc757SPeter Tyser# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15d4abc757SPeter Tyser# GNU General Public License for more details.
16d4abc757SPeter Tyser#
17d4abc757SPeter Tyser# You should have received a copy of the GNU General Public License
18d4abc757SPeter Tyser# along with this program; if not, write to the Free Software
19d4abc757SPeter Tyser# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20d4abc757SPeter Tyser# MA 02111-1307 USA
21d4abc757SPeter Tyser#
22d4abc757SPeter Tyser
23d4abc757SPeter Tyserifeq ($(ARCH),ppc)
24d4abc757SPeter TyserLOAD_ADDR = 0x40000
25d4abc757SPeter Tyserendif
26d4abc757SPeter Tyserifeq ($(ARCH),arm)
27d4abc757SPeter TyserLOAD_ADDR = 0x1000000
28d4abc757SPeter Tyserendif
29d4abc757SPeter Tyser
30d4abc757SPeter Tyserinclude $(TOPDIR)/config.mk
31d4abc757SPeter Tyser
32d4abc757SPeter Tyser# Resulting ELF and binary exectuables will be named demo and demo.bin
33d4abc757SPeter TyserOUTPUT-$(CONFIG_API) = $(obj)demo
34d4abc757SPeter TyserOUTPUT = $(OUTPUT-y)
35d4abc757SPeter Tyser
36d4abc757SPeter Tyser# Source files located in the examples/api directory
37d4abc757SPeter TyserSOBJ_FILES-$(CONFIG_API) += crt0.o
38d4abc757SPeter TyserCOBJ_FILES-$(CONFIG_API) += demo.o
39d4abc757SPeter TyserCOBJ_FILES-$(CONFIG_API) += glue.o
40d4abc757SPeter TyserCOBJ_FILES-$(CONFIG_API) += libgenwrap.o
41d4abc757SPeter Tyser
42d4abc757SPeter Tyser# Source files which exist outside the examples/api directory
43d4abc757SPeter TyserEXT_COBJ_FILES-$(CONFIG_API) += lib_generic/crc32.o
44d4abc757SPeter TyserEXT_COBJ_FILES-$(CONFIG_API) += lib_generic/ctype.o
45*942828a0SWolfgang DenkEXT_COBJ_FILES-$(CONFIG_API) += lib_generic/div64.o
46d4abc757SPeter TyserEXT_COBJ_FILES-$(CONFIG_API) += lib_generic/string.o
47d4abc757SPeter TyserEXT_COBJ_FILES-$(CONFIG_API) += lib_generic/vsprintf.o
48d4abc757SPeter Tyserifeq ($(ARCH),ppc)
49d4abc757SPeter TyserEXT_SOBJ_FILES-$(CONFIG_API) += lib_ppc/ppcstring.o
50d4abc757SPeter Tyserendif
51d4abc757SPeter Tyser
52d4abc757SPeter Tyser# Create a list of source files so their dependencies can be auto-generated
53d4abc757SPeter TyserSRCS	+= $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
54d4abc757SPeter TyserSRCS	+= $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
55d4abc757SPeter TyserSRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
56d4abc757SPeter TyserSRCS	+= $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
57d4abc757SPeter Tyser
58d4abc757SPeter Tyser# Create a list of object files to be compiled
59d4abc757SPeter TyserOBJS	+= $(addprefix $(obj),$(SOBJ_FILES-y))
60d4abc757SPeter TyserOBJS	+= $(addprefix $(obj),$(COBJ_FILES-y))
61d4abc757SPeter TyserOBJS	+= $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
62d4abc757SPeter TyserOBJS	+= $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
63d4abc757SPeter Tyser
64d4abc757SPeter Tysergcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
65d4abc757SPeter Tyser
66d4abc757SPeter TyserCPPFLAGS += -I..
67d4abc757SPeter Tyser
68d4abc757SPeter Tyserall:	$(obj).depend $(OUTPUT)
69d4abc757SPeter Tyser
70d4abc757SPeter Tyser#########################################################################
71d4abc757SPeter Tyser
72d4abc757SPeter Tyser$(OUTPUT):	$(OBJS)
73d4abc757SPeter Tyser		$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
74d4abc757SPeter Tyser		$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
75d4abc757SPeter Tyser
76d4abc757SPeter Tyser# Rule to build generic library C files
77d4abc757SPeter Tyser$(obj)%.o: $(SRCTREE)/lib_generic/%.c
78d4abc757SPeter Tyser	$(CC) -g $(CFLAGS) -c -o $@ $<
79d4abc757SPeter Tyser
80d4abc757SPeter Tyser# Rule to build architecture-specific library assembly files
81d4abc757SPeter Tyser$(obj)%.o: $(SRCTREE)/lib_$(ARCH)/%.S
82d4abc757SPeter Tyser	$(CC) -g $(CFLAGS) -c -o $@ $<
83d4abc757SPeter Tyser
84d4abc757SPeter Tyser#########################################################################
85d4abc757SPeter Tyser
86d4abc757SPeter Tyser# defines $(obj).depend target
87d4abc757SPeter Tyserinclude $(SRCTREE)/rules.mk
88d4abc757SPeter Tyser
89d4abc757SPeter Tysersinclude $(obj).depend
90d4abc757SPeter Tyser
91d4abc757SPeter Tyser#########################################################################
92