blob: 5666f489b939176f07310679915bd41520f9adb7 [file] [log] [blame]
Rafal Jaworowski500856e2008-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
26
27#ifeq ($(ARCH),arm)
28#LOAD_ADDR = 0xc100000
29#endif
30
31include $(TOPDIR)/config.mk
32
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010033ELF-$(CONFIG_API) += demo
34BIN-$(CONFIG_API) += demo.bin
35ELF := $(ELF-y)
36BIN := $(BIN-y)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010037
38#CFLAGS += -v
39
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010040COBJS-$(CONFIG_API) += $(ELF:=.o)
41SOBJS-$(CONFIG_API) += crt0.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010042ifeq ($(ARCH),ppc)
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010043SOBJS-$(CONFIG_API) += ppcstring.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010044endif
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010045COBJS := $(COBJS-y)
46SOBJS := $(SOBJS-y)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010047
48LIB = $(obj)libglue.a
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010049LIBCOBJS-$(CONFIG_API) += glue.o crc32.o ctype.o string.o vsprintf.o \
50 libgenwrap.o
51LIBCOBJS := $(LIBCOBJS-y)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010052
53LIBOBJS = $(addprefix $(obj),$(SOBJS) $(LIBCOBJS))
54
55SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(SOBJS:.o=.S)
56OBJS := $(addprefix $(obj),$(COBJS))
57ELF := $(addprefix $(obj),$(ELF))
58BIN := $(addprefix $(obj),$(BIN))
59
60gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
61
62CPPFLAGS += -I..
63
Rafal Jaworowski0dc1fc22008-01-29 16:57:38 +010064all: $(obj).depend $(OBJS) $(LIB) $(ELF) $(BIN)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010065
66#########################################################################
67$(LIB): $(obj).depend $(LIBOBJS)
68 $(AR) $(ARFLAGS) $@ $(LIBOBJS)
69
70$(ELF):
71$(obj)%: $(obj)%.o $(LIB)
72 $(LD) $(obj)crt0.o -Ttext $(LOAD_ADDR) \
73 -o $@ $< $(LIB) \
74 -L$(gcclibdir) -lgcc
75
76$(BIN):
77$(obj)%.bin: $(obj)%
78 $(OBJCOPY) -O binary $< $@ 2>/dev/null
79
Wolfgang Denkd3a65322008-01-10 00:55:14 +010080$(obj)crc32.c:
Rafal Jaworowski500856e2008-01-09 19:39:36 +010081 @rm -f $(obj)crc32.c
82 ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
83
84$(obj)ctype.c:
85 @rm -f $(obj)ctype.c
86 ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c
87
88$(obj)string.c:
89 @rm -f $(obj)string.c
90 ln -s $(src)../lib_generic/string.c $(obj)string.c
91
92$(obj)vsprintf.c:
93 @rm -f $(obj)vsprintf.c
94 ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c
95
96ifeq ($(ARCH),ppc)
97$(obj)ppcstring.S:
98 @rm -f $(obj)ppcstring.S
99 ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S
100endif
101
102#########################################################################
103
104# defines $(obj).depend target
105include $(SRCTREE)/rules.mk
106
107sinclude $(obj).depend
108
109#########################################################################