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 | |
Masahiro Yamada | d958002 | 2014-02-04 17:24:23 +0900 | [diff] [blame] | 7 | ifdef FTRACE |
| 8 | CFLAGS += -finstrument-functions -DFTRACE |
| 9 | endif |
| 10 | |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 11 | ifeq ($(ARCH),powerpc) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 12 | LOAD_ADDR = 0x40000 |
| 13 | endif |
Rafal Jaworowski | 7fb6c4f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 14 | ifeq ($(ARCH),arm) |
| 15 | LOAD_ADDR = 0x1000000 |
| 16 | endif |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 17 | |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 18 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 19 | extra-y = demo |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 20 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 21 | # Source files located in the examples/api directory |
Masahiro Yamada | 8a7e7d5 | 2013-11-18 11:08:35 +0900 | [diff] [blame] | 22 | SOBJ_FILES-y += crt0.o |
| 23 | COBJ_FILES-y += demo.o |
| 24 | COBJ_FILES-y += glue.o |
| 25 | COBJ_FILES-y += libgenwrap.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 26 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 27 | # Source files which exist outside the examples/api directory |
Masahiro Yamada | 8a7e7d5 | 2013-11-18 11:08:35 +0900 | [diff] [blame] | 28 | EXT_COBJ_FILES-y += lib/crc32.o |
| 29 | EXT_COBJ_FILES-y += lib/ctype.o |
| 30 | EXT_COBJ_FILES-y += lib/div64.o |
| 31 | EXT_COBJ_FILES-y += lib/string.o |
| 32 | EXT_COBJ_FILES-y += lib/time.o |
| 33 | EXT_COBJ_FILES-y += lib/vsprintf.o |
| 34 | EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 35 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 36 | # Create a list of source files so their dependencies can be auto-generated |
| 37 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c)) |
| 38 | SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S)) |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 39 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) |
| 40 | SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 41 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 42 | # Create a list of object files to be compiled |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 43 | OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y)) |
| 44 | OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y)) |
| 45 | OBJS += $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))) |
| 46 | OBJS += $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 47 | |
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 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 50 | $(obj)/demo: $(OBJS) |
Rob Herring | e32a268 | 2013-10-04 10:22:40 -0500 | [diff] [blame] | 51 | $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 52 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 53 | $(obj)/demo.bin: $(obj)/demo |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 54 | $(OBJCOPY) -O binary $< $@ 2>/dev/null |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 55 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 56 | # Rule to build generic library C files |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 57 | $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 58 | $(CC) -g $(CFLAGS) -c -o $@ $< |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 59 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 60 | # Rule to build architecture-specific library assembly files |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame^] | 61 | $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 62 | $(CC) -g $(CFLAGS) -c -o $@ $< |