Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 1 | # |
| 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 | |
| 23 | ifeq ($(ARCH),ppc) |
| 24 | LOAD_ADDR = 0x40000 |
| 25 | endif |
Rafal Jaworowski | 9d9689f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 26 | ifeq ($(ARCH),arm) |
| 27 | LOAD_ADDR = 0x1000000 |
| 28 | endif |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 29 | |
| 30 | include $(TOPDIR)/config.mk |
| 31 | |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 32 | ELF-$(CONFIG_API) += demo |
| 33 | BIN-$(CONFIG_API) += demo.bin |
| 34 | ELF := $(ELF-y) |
| 35 | BIN := $(BIN-y) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 36 | |
| 37 | #CFLAGS += -v |
| 38 | |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 39 | COBJS-$(CONFIG_API) += $(ELF:=.o) |
| 40 | SOBJS-$(CONFIG_API) += crt0.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 41 | ifeq ($(ARCH),ppc) |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 42 | SOBJS-$(CONFIG_API) += ppcstring.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 43 | endif |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 44 | COBJS := $(COBJS-y) |
| 45 | SOBJS := $(SOBJS-y) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 46 | |
| 47 | LIB = $(obj)libglue.a |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 48 | LIBCOBJS-$(CONFIG_API) += glue.o crc32.o ctype.o string.o vsprintf.o \ |
| 49 | libgenwrap.o |
| 50 | LIBCOBJS := $(LIBCOBJS-y) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 51 | |
| 52 | LIBOBJS = $(addprefix $(obj),$(SOBJS) $(LIBCOBJS)) |
| 53 | |
| 54 | SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(SOBJS:.o=.S) |
| 55 | OBJS := $(addprefix $(obj),$(COBJS)) |
| 56 | ELF := $(addprefix $(obj),$(ELF)) |
| 57 | BIN := $(addprefix $(obj),$(BIN)) |
| 58 | |
| 59 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
| 60 | |
| 61 | CPPFLAGS += -I.. |
| 62 | |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 63 | all: $(obj).depend $(OBJS) $(LIB) $(ELF) $(BIN) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 64 | |
| 65 | ######################################################################### |
| 66 | $(LIB): $(obj).depend $(LIBOBJS) |
| 67 | $(AR) $(ARFLAGS) $@ $(LIBOBJS) |
| 68 | |
| 69 | $(ELF): |
| 70 | $(obj)%: $(obj)%.o $(LIB) |
| 71 | $(LD) $(obj)crt0.o -Ttext $(LOAD_ADDR) \ |
| 72 | -o $@ $< $(LIB) \ |
| 73 | -L$(gcclibdir) -lgcc |
| 74 | |
| 75 | $(BIN): |
| 76 | $(obj)%.bin: $(obj)% |
| 77 | $(OBJCOPY) -O binary $< $@ 2>/dev/null |
| 78 | |
Wolfgang Denk | 545b06a | 2008-01-10 00:55:14 +0100 | [diff] [blame] | 79 | $(obj)crc32.c: |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 80 | @rm -f $(obj)crc32.c |
| 81 | ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c |
| 82 | |
| 83 | $(obj)ctype.c: |
| 84 | @rm -f $(obj)ctype.c |
| 85 | ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c |
| 86 | |
| 87 | $(obj)string.c: |
| 88 | @rm -f $(obj)string.c |
| 89 | ln -s $(src)../lib_generic/string.c $(obj)string.c |
| 90 | |
| 91 | $(obj)vsprintf.c: |
| 92 | @rm -f $(obj)vsprintf.c |
| 93 | ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c |
| 94 | |
| 95 | ifeq ($(ARCH),ppc) |
| 96 | $(obj)ppcstring.S: |
| 97 | @rm -f $(obj)ppcstring.S |
| 98 | ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S |
| 99 | endif |
| 100 | |
| 101 | ######################################################################### |
| 102 | |
| 103 | # defines $(obj).depend target |
| 104 | include $(SRCTREE)/rules.mk |
| 105 | |
| 106 | sinclude $(obj).depend |
| 107 | |
| 108 | ######################################################################### |