blob: 98506a07d0e3e238d993a90608456b7ff5fb4c78 [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
23ifeq ($(ARCH),ppc)
24LOAD_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
Rafal Jaworowskia19be782008-01-09 19:39:36 +010034
35#CFLAGS += -v
36
Rafal Jaworowskif42e3412008-01-29 16:57:38 +010037SOBJS-$(CONFIG_API) += crt0.o
Peter Tyser2dcb4e12009-06-22 18:01:39 -050038COBJS-$(CONFIG_API) += demo.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010039ifeq ($(ARCH),ppc)
Rafal Jaworowskif42e3412008-01-29 16:57:38 +010040SOBJS-$(CONFIG_API) += ppcstring.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010041endif
Peter Tyser2dcb4e12009-06-22 18:01:39 -050042
43OUTPUT := $(OUTPUT-y)
Rafal Jaworowskif42e3412008-01-29 16:57:38 +010044COBJS := $(COBJS-y)
45SOBJS := $(SOBJS-y)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010046
47LIB = $(obj)libglue.a
Peter Tyser085c8752009-06-22 18:01:38 -050048LIBCOBJS-$(CONFIG_API) += glue.o
49LIBCOBJS-$(CONFIG_API) += crc32.o
50LIBCOBJS-$(CONFIG_API) += ctype.o
51LIBCOBJS-$(CONFIG_API) += string.o
52LIBCOBJS-$(CONFIG_API) += vsprintf.o
53LIBCOBJS-$(CONFIG_API) += libgenwrap.o
Rafal Jaworowskif42e3412008-01-29 16:57:38 +010054LIBCOBJS := $(LIBCOBJS-y)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010055
Peter Tyser085c8752009-06-22 18:01:38 -050056LIBOBJS += $(addprefix $(obj),$(SOBJS))
57LIBOBJS += $(addprefix $(obj),$(LIBCOBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010058
Peter Tyser085c8752009-06-22 18:01:38 -050059SRCS += $(COBJS:.o=.c)
60SRCS += $(LIBCOBJS:.o=.c)
61SRCS += $(SOBJS:.o=.S)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010062OBJS := $(addprefix $(obj),$(COBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010063
64gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
65
66CPPFLAGS += -I..
67
Peter Tyser2dcb4e12009-06-22 18:01:39 -050068all: $(obj).depend $(OBJS) $(LIB) $(OUTPUT)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010069
70#########################################################################
71$(LIB): $(obj).depend $(LIBOBJS)
72 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
73
Peter Tyser2dcb4e12009-06-22 18:01:39 -050074$(OUTPUT):
Rafal Jaworowskia19be782008-01-09 19:39:36 +010075$(obj)%: $(obj)%.o $(LIB)
76 $(LD) $(obj)crt0.o -Ttext $(LOAD_ADDR) \
77 -o $@ $< $(LIB) \
78 -L$(gcclibdir) -lgcc
Peter Tyser2dcb4e12009-06-22 18:01:39 -050079 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
Rafal Jaworowskia19be782008-01-09 19:39:36 +010080
Wolfgang Denk545b06a2008-01-10 00:55:14 +010081$(obj)crc32.c:
Rafal Jaworowskia19be782008-01-09 19:39:36 +010082 @rm -f $(obj)crc32.c
83 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
84
85$(obj)ctype.c:
86 @rm -f $(obj)ctype.c
87 ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c
88
89$(obj)string.c:
90 @rm -f $(obj)string.c
91 ln -s $(src)../lib_generic/string.c $(obj)string.c
92
93$(obj)vsprintf.c:
94 @rm -f $(obj)vsprintf.c
95 ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c
96
97ifeq ($(ARCH),ppc)
98$(obj)ppcstring.S:
99 @rm -f $(obj)ppcstring.S
100 ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S
101endif
102
103#########################################################################
104
105# defines $(obj).depend target
106include $(SRCTREE)/rules.mk
107
108sinclude $(obj).depend
109
110#########################################################################