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 | |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 14 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 15 | extra-y = demo |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 16 | |
Peter Tyser | acce4eb | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 17 | # Source files located in the examples/api directory |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 18 | OBJ-y += crt0.o |
| 19 | OBJ-y += demo.o |
| 20 | OBJ-y += glue.o |
| 21 | OBJ-y += libgenwrap.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 22 | |
Peter Tyser | acce4eb | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 23 | # Source files which exist outside the examples/api directory |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 24 | EXT_COBJ-y += lib/crc32.o |
| 25 | EXT_COBJ-y += lib/ctype.o |
| 26 | EXT_COBJ-y += lib/div64.o |
| 27 | EXT_COBJ-y += lib/string.o |
| 28 | EXT_COBJ-y += lib/time.o |
| 29 | EXT_COBJ-y += lib/vsprintf.o |
| 30 | EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 31 | |
Peter Tyser | bdb925e | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 32 | # Create a list of object files to be compiled |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 33 | OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y)) |
| 34 | targets += $(OBJS) |
| 35 | OBJS := $(addprefix $(obj)/,$(OBJS)) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 36 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 37 | ######################################################################### |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 38 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 39 | quiet_cmd_link_demo = LD $@ |
| 40 | cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS) |
| 41 | |
| 42 | $(obj)/demo: $(OBJS) FORCE |
| 43 | $(call if_changed,link_demo) |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 44 | |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 45 | # demo.bin is never genrated. Is this necessary? |
| 46 | OBJCOPYFLAGS_demo.bin := -O binary |
| 47 | $(obj)/demo.bin: $(obj)/demo FORCE |
| 48 | $(call if_changed,objcopy) |
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 | # Rule to build generic library C files |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 51 | $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 52 | $(call cmd,force_checksrc) |
| 53 | $(call if_changed_rule,cc_o_c) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | |
Peter Tyser | bdb925e | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 55 | # Rule to build architecture-specific library assembly files |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 56 | $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 57 | $(call if_changed_dep,as_o_S) |