Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 1 | # |
| 2 | # (C) Copyright 2007 Semihalf |
| 3 | # |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | # SPDX-License-Identifier: GPL-2.0+ |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 5 | # |
| 6 | |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 7 | ifeq ($(ARCH),powerpc) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 8 | LOAD_ADDR = 0x40000 |
| 9 | endif |
Rafal Jaworowski | 7fb6c4f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 10 | ifeq ($(ARCH),arm) |
| 11 | LOAD_ADDR = 0x1000000 |
| 12 | endif |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 13 | |
| 14 | include $(TOPDIR)/config.mk |
| 15 | |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 16 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
| 17 | OUTPUT-$(CONFIG_API) = $(obj)demo |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 18 | OUTPUT = $(OUTPUT-y) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 19 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 20 | # Source files located in the examples/api directory |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 21 | SOBJ_FILES-$(CONFIG_API) += crt0.o |
| 22 | COBJ_FILES-$(CONFIG_API) += demo.o |
| 23 | COBJ_FILES-$(CONFIG_API) += glue.o |
| 24 | COBJ_FILES-$(CONFIG_API) += libgenwrap.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 25 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 26 | # Source files which exist outside the examples/api directory |
Peter Tyser | 78acc47 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 27 | EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o |
| 28 | EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o |
| 29 | EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o |
| 30 | EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o |
| 31 | EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o |
| 32 | EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 33 | ifeq ($(ARCH),powerpc) |
| 34 | EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 35 | endif |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 36 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 37 | # Create a list of source files so their dependencies can be auto-generated |
| 38 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c)) |
| 39 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S)) |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 40 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) |
| 41 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 42 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 43 | # Create a list of object files to be compiled |
| 44 | OBJS += $(addprefix $(obj),$(SOBJ_FILES-y)) |
| 45 | OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) |
| 46 | OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) |
| 47 | OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 48 | |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 49 | CPPFLAGS += -I.. |
| 50 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 51 | all: $(obj).depend $(OUTPUT) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 52 | |
| 53 | ######################################################################### |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 55 | $(OUTPUT): $(OBJS) |
Che-liang Chiou | 349e83f | 2011-10-17 21:04:15 +0000 | [diff] [blame] | 56 | $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 57 | $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 58 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 59 | # Rule to build generic library C files |
Peter Tyser | 78acc47 | 2010-04-12 22:28:05 -0500 | [diff] [blame] | 60 | $(obj)%.o: $(SRCTREE)/lib/%.c |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 61 | $(CC) -g $(CFLAGS) -c -o $@ $< |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 62 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 63 | # Rule to build architecture-specific library assembly files |
Peter Tyser | ea0364f | 2010-04-12 22:28:04 -0500 | [diff] [blame] | 64 | $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 65 | $(CC) -g $(CFLAGS) -c -o $@ $< |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 66 | |
| 67 | ######################################################################### |
| 68 | |
| 69 | # defines $(obj).depend target |
| 70 | include $(SRCTREE)/rules.mk |
| 71 | |
| 72 | sinclude $(obj).depend |
| 73 | |
| 74 | ######################################################################### |