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