Rafal Jaworowski | 500856e | 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 | 7fb6c4f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 26 | ifeq ($(ARCH),arm) |
| 27 | LOAD_ADDR = 0x1000000 |
| 28 | endif |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 29 | |
| 30 | include $(TOPDIR)/config.mk |
| 31 | |
Peter Tyser | 117d0ab | 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 |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 34 | OUTPUT = $(OUTPUT-y) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 35 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame^] | 36 | # Source files located in the examples/api directory |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 37 | SOBJ_FILES-$(CONFIG_API) += crt0.o |
| 38 | COBJ_FILES-$(CONFIG_API) += demo.o |
| 39 | COBJ_FILES-$(CONFIG_API) += glue.o |
| 40 | COBJ_FILES-$(CONFIG_API) += libgenwrap.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 41 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame^] | 42 | # Source files which exist outside the examples/api directory |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 43 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/crc32.o |
| 44 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/ctype.o |
| 45 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/string.o |
| 46 | EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/vsprintf.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 47 | ifeq ($(ARCH),ppc) |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 48 | EXT_SOBJ_FILES-$(CONFIG_API) += lib_ppc/ppcstring.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 49 | endif |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 50 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 51 | # Create a list of source files so their dependencies can be auto-generated |
| 52 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c)) |
| 53 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S)) |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame^] | 54 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) |
| 55 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 56 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 57 | # Create a list of object files to be compiled |
| 58 | OBJS += $(addprefix $(obj),$(SOBJ_FILES-y)) |
| 59 | OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) |
| 60 | OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) |
| 61 | OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 62 | |
| 63 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
| 64 | |
| 65 | CPPFLAGS += -I.. |
| 66 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 67 | all: $(obj).depend $(OUTPUT) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 68 | |
| 69 | ######################################################################### |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 70 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 71 | $(OUTPUT): $(OBJS) |
Peter Tyser | 522f6f0 | 2009-06-22 18:01:40 -0500 | [diff] [blame] | 72 | $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 73 | $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 74 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 75 | # Rule to build generic library C files |
| 76 | $(obj)%.o: $(SRCTREE)/lib_generic/%.c |
| 77 | $(CC) -g $(CFLAGS) -c -o $@ $< |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 78 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 79 | # Rule to build architecture-specific library assembly files |
| 80 | $(obj)%.o: $(SRCTREE)/lib_$(ARCH)/%.S |
| 81 | $(CC) -g $(CFLAGS) -c -o $@ $< |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 82 | |
| 83 | ######################################################################### |
| 84 | |
| 85 | # defines $(obj).depend target |
| 86 | include $(SRCTREE)/rules.mk |
| 87 | |
| 88 | sinclude $(obj).depend |
| 89 | |
| 90 | ######################################################################### |