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 | |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 32 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
| 33 | OUTPUT-$(CONFIG_API) = $(obj)demo |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 34 | |
| 35 | #CFLAGS += -v |
| 36 | |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 37 | SOBJS-$(CONFIG_API) += crt0.o |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 38 | COBJS-$(CONFIG_API) += demo.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 39 | ifeq ($(ARCH),ppc) |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 40 | SOBJS-$(CONFIG_API) += ppcstring.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 41 | endif |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 42 | |
| 43 | OUTPUT := $(OUTPUT-y) |
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 | |
Peter Tyser | 085c875 | 2009-06-22 18:01:38 -0500 | [diff] [blame] | 47 | LIBCOBJS-$(CONFIG_API) += glue.o |
| 48 | LIBCOBJS-$(CONFIG_API) += crc32.o |
| 49 | LIBCOBJS-$(CONFIG_API) += ctype.o |
| 50 | LIBCOBJS-$(CONFIG_API) += string.o |
| 51 | LIBCOBJS-$(CONFIG_API) += vsprintf.o |
| 52 | LIBCOBJS-$(CONFIG_API) += libgenwrap.o |
Rafal Jaworowski | f42e341 | 2008-01-29 16:57:38 +0100 | [diff] [blame] | 53 | LIBCOBJS := $(LIBCOBJS-y) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | |
Peter Tyser | 085c875 | 2009-06-22 18:01:38 -0500 | [diff] [blame] | 55 | LIBOBJS += $(addprefix $(obj),$(SOBJS)) |
Peter Tyser | 341a9fd | 2009-06-22 18:01:40 -0500 | [diff] [blame^] | 56 | LIBOBJS += $(addprefix $(obj),$(COBJS)) |
Peter Tyser | 085c875 | 2009-06-22 18:01:38 -0500 | [diff] [blame] | 57 | LIBOBJS += $(addprefix $(obj),$(LIBCOBJS)) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 58 | |
Peter Tyser | 085c875 | 2009-06-22 18:01:38 -0500 | [diff] [blame] | 59 | SRCS += $(COBJS:.o=.c) |
| 60 | SRCS += $(LIBCOBJS:.o=.c) |
| 61 | SRCS += $(SOBJS:.o=.S) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 62 | OBJS := $(addprefix $(obj),$(COBJS)) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 63 | |
| 64 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
| 65 | |
| 66 | CPPFLAGS += -I.. |
| 67 | |
Peter Tyser | 341a9fd | 2009-06-22 18:01:40 -0500 | [diff] [blame^] | 68 | all: $(obj).depend $(OBJS) $(OUTPUT) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 69 | |
| 70 | ######################################################################### |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 71 | |
Peter Tyser | 341a9fd | 2009-06-22 18:01:40 -0500 | [diff] [blame^] | 72 | $(OUTPUT): $(LIBOBJS) |
| 73 | $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 74 | $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 75 | |
Wolfgang Denk | 545b06a | 2008-01-10 00:55:14 +0100 | [diff] [blame] | 76 | $(obj)crc32.c: |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 77 | @rm -f $(obj)crc32.c |
| 78 | ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c |
| 79 | |
| 80 | $(obj)ctype.c: |
| 81 | @rm -f $(obj)ctype.c |
| 82 | ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c |
| 83 | |
| 84 | $(obj)string.c: |
| 85 | @rm -f $(obj)string.c |
| 86 | ln -s $(src)../lib_generic/string.c $(obj)string.c |
| 87 | |
| 88 | $(obj)vsprintf.c: |
| 89 | @rm -f $(obj)vsprintf.c |
| 90 | ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c |
| 91 | |
| 92 | ifeq ($(ARCH),ppc) |
| 93 | $(obj)ppcstring.S: |
| 94 | @rm -f $(obj)ppcstring.S |
| 95 | ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S |
| 96 | endif |
| 97 | |
| 98 | ######################################################################### |
| 99 | |
| 100 | # defines $(obj).depend target |
| 101 | include $(SRCTREE)/rules.mk |
| 102 | |
| 103 | sinclude $(obj).depend |
| 104 | |
| 105 | ######################################################################### |