Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 2 | # |
| 3 | # (C) Copyright 2007 Semihalf |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 4 | |
Heinrich Schuchardt | 218d389 | 2018-01-10 18:06:08 +0100 | [diff] [blame] | 5 | # Provide symbol API_BUILD to signal that the API example is being built. |
| 6 | KBUILD_CPPFLAGS += -DAPI_BUILD |
| 7 | |
Stefan Roese | 88fbf93 | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 8 | ifeq ($(ARCH),powerpc) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 9 | LOAD_ADDR = 0x40000 |
| 10 | endif |
Rafal Jaworowski | 9d9689f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 11 | ifeq ($(ARCH),arm) |
Heinrich Schuchardt | 8ce7f88 | 2024-11-03 06:35:50 +0100 | [diff] [blame] | 12 | ifdef CONFIG_64BIT |
| 13 | LOAD_ADDR = 0x40400000 |
| 14 | else |
Rafal Jaworowski | 9d9689f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 15 | LOAD_ADDR = 0x1000000 |
| 16 | endif |
Heinrich Schuchardt | 8ce7f88 | 2024-11-03 06:35:50 +0100 | [diff] [blame] | 17 | endif |
Stanislav Galabov | 35d35e8 | 2016-02-04 12:13:44 +0200 | [diff] [blame] | 18 | ifeq ($(ARCH),mips) |
Stanislav Galabov | 10c7a57 | 2016-02-17 15:23:31 +0200 | [diff] [blame] | 19 | ifdef CONFIG_64BIT |
| 20 | LOAD_ADDR = 0xffffffff80200000 |
| 21 | else |
Stanislav Galabov | 35d35e8 | 2016-02-04 12:13:44 +0200 | [diff] [blame] | 22 | LOAD_ADDR = 0x80200000 |
| 23 | endif |
Stanislav Galabov | 10c7a57 | 2016-02-17 15:23:31 +0200 | [diff] [blame] | 24 | endif |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 25 | |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 26 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 27 | extra-y = demo |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 28 | |
Peter Tyser | acce4eb | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 29 | # Source files located in the examples/api directory |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 30 | OBJ-y += crt0.o |
| 31 | OBJ-y += demo.o |
| 32 | OBJ-y += glue.o |
| 33 | OBJ-y += libgenwrap.o |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 34 | |
Peter Tyser | acce4eb | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 35 | # Source files which exist outside the examples/api directory |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 36 | EXT_COBJ-y += lib/crc32.o |
| 37 | EXT_COBJ-y += lib/ctype.o |
| 38 | EXT_COBJ-y += lib/div64.o |
Alexey Brodkin | 2d2fa49 | 2018-06-05 17:17:57 +0300 | [diff] [blame] | 39 | EXT_COBJ-y += lib/hexdump.o |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 40 | EXT_COBJ-y += lib/string.o |
| 41 | EXT_COBJ-y += lib/time.o |
| 42 | EXT_COBJ-y += lib/vsprintf.o |
Rob Clark | 8adf37f | 2017-09-09 06:47:41 -0400 | [diff] [blame] | 43 | EXT_COBJ-y += lib/charset.o |
Rob Clark | c82342f | 2017-09-09 06:47:42 -0400 | [diff] [blame] | 44 | EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 45 | EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o |
Tom Rini | 443b516 | 2017-01-12 13:16:02 -0500 | [diff] [blame] | 46 | ifeq ($(ARCH),arm) |
| 47 | EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o |
| 48 | endif |
Peter Tyser | 2dcb4e1 | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 49 | |
Peter Tyser | bdb925e | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 50 | # Create a list of object files to be compiled |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 51 | OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y)) |
| 52 | targets += $(OBJS) |
| 53 | OBJS := $(addprefix $(obj)/,$(OBJS)) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 54 | |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 55 | ######################################################################### |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 56 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 57 | quiet_cmd_link_demo = LD $@ |
| 58 | cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS) |
| 59 | |
| 60 | $(obj)/demo: $(OBJS) FORCE |
| 61 | $(call if_changed,link_demo) |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 62 | |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 63 | # demo.bin is never genrated. Is this necessary? |
| 64 | OBJCOPYFLAGS_demo.bin := -O binary |
| 65 | $(obj)/demo.bin: $(obj)/demo FORCE |
| 66 | $(call if_changed,objcopy) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 67 | |
Peter Tyser | bdb925e | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 68 | # Rule to build generic library C files |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 69 | $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 70 | $(call cmd,force_checksrc) |
| 71 | $(call if_changed_rule,cc_o_c) |
Rafal Jaworowski | a19be78 | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 72 | |
Peter Tyser | bdb925e | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 73 | # Rule to build architecture-specific library assembly files |
Tom Rini | 443b516 | 2017-01-12 13:16:02 -0500 | [diff] [blame] | 74 | $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 75 | $(call if_changed_dep,as_o_S) |