blob: bad05afbddb6f9677f2b8ce992f116974463e10b [file] [log] [blame]
Rafal Jaworowskia19be782008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
4# See file CREDITS for list of people who contributed to this
5# project.
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundatio; either version 2 of
10# the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20# MA 02111-1307 USA
21#
22
Stefan Roese88fbf932010-04-15 16:07:28 +020023ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010024LOAD_ADDR = 0x40000
25endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010026ifeq ($(ARCH),arm)
27LOAD_ADDR = 0x1000000
28endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010029
30include $(TOPDIR)/config.mk
31
Peter Tyser2dcb4e12009-06-22 18:01:39 -050032# Resulting ELF and binary exectuables will be named demo and demo.bin
33OUTPUT-$(CONFIG_API) = $(obj)demo
Peter Tyserbdb925e2009-06-22 18:01:41 -050034OUTPUT = $(OUTPUT-y)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010035
Peter Tyseracce4eb2009-07-20 19:02:21 -050036# Source files located in the examples/api directory
Peter Tyserbdb925e2009-06-22 18:01:41 -050037SOBJ_FILES-$(CONFIG_API) += crt0.o
38COBJ_FILES-$(CONFIG_API) += demo.o
39COBJ_FILES-$(CONFIG_API) += glue.o
40COBJ_FILES-$(CONFIG_API) += libgenwrap.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010041
Peter Tyseracce4eb2009-07-20 19:02:21 -050042# Source files which exist outside the examples/api directory
Peter Tyser685b7f52010-04-12 22:28:05 -050043EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o
44EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o
45EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o
46EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o
47EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o
48EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o
Stefan Roese88fbf932010-04-15 16:07:28 +020049ifeq ($(ARCH),powerpc)
50EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010051endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050052
Peter Tyserbdb925e2009-06-22 18:01:41 -050053# Create a list of source files so their dependencies can be auto-generated
54SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
55SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
Peter Tyseracce4eb2009-07-20 19:02:21 -050056SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
57SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010058
Peter Tyserbdb925e2009-06-22 18:01:41 -050059# Create a list of object files to be compiled
60OBJS += $(addprefix $(obj),$(SOBJ_FILES-y))
61OBJS += $(addprefix $(obj),$(COBJ_FILES-y))
62OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
63OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010064
Rafal Jaworowskia19be782008-01-09 19:39:36 +010065CPPFLAGS += -I..
66
Peter Tyserbdb925e2009-06-22 18:01:41 -050067all: $(obj).depend $(OUTPUT)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010068
69#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010070
Peter Tyserbdb925e2009-06-22 18:01:41 -050071$(OUTPUT): $(OBJS)
Che-liang Chioud74a67f2011-10-17 21:04:15 +000072 $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Peter Tyser2dcb4e12009-06-22 18:01:39 -050073 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
Rafal Jaworowskia19be782008-01-09 19:39:36 +010074
Peter Tyserbdb925e2009-06-22 18:01:41 -050075# Rule to build generic library C files
Peter Tyser685b7f52010-04-12 22:28:05 -050076$(obj)%.o: $(SRCTREE)/lib/%.c
Peter Tyserbdb925e2009-06-22 18:01:41 -050077 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowskia19be782008-01-09 19:39:36 +010078
Peter Tyserbdb925e2009-06-22 18:01:41 -050079# Rule to build architecture-specific library assembly files
Peter Tysercede5d82010-04-12 22:28:04 -050080$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Peter Tyserbdb925e2009-06-22 18:01:41 -050081 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowskia19be782008-01-09 19:39:36 +010082
83#########################################################################
84
85# defines $(obj).depend target
86include $(SRCTREE)/rules.mk
87
88sinclude $(obj).depend
89
90#########################################################################