Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 2 | # |
| 3 | # (C) Copyright 2007 Semihalf |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 4 | |
Heinrich Schuchardt | 256060e | 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 | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 8 | ifeq ($(ARCH),powerpc) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 9 | LOAD_ADDR = 0x40000 |
| 10 | endif |
Rafal Jaworowski | 7fb6c4f | 2009-01-23 13:27:16 +0100 | [diff] [blame] | 11 | ifeq ($(ARCH),arm) |
| 12 | LOAD_ADDR = 0x1000000 |
| 13 | endif |
Stanislav Galabov | 7c60423 | 2016-02-04 12:13:44 +0200 | [diff] [blame] | 14 | ifeq ($(ARCH),mips) |
Stanislav Galabov | 78757d5 | 2016-02-17 15:23:31 +0200 | [diff] [blame] | 15 | ifdef CONFIG_64BIT |
| 16 | LOAD_ADDR = 0xffffffff80200000 |
| 17 | else |
Stanislav Galabov | 7c60423 | 2016-02-04 12:13:44 +0200 | [diff] [blame] | 18 | LOAD_ADDR = 0x80200000 |
| 19 | endif |
Stanislav Galabov | 78757d5 | 2016-02-17 15:23:31 +0200 | [diff] [blame] | 20 | endif |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 21 | |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 22 | # Resulting ELF and binary exectuables will be named demo and demo.bin |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 23 | extra-y = demo |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 24 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 25 | # Source files located in the examples/api directory |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 26 | OBJ-y += crt0.o |
| 27 | OBJ-y += demo.o |
| 28 | OBJ-y += glue.o |
| 29 | OBJ-y += libgenwrap.o |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 30 | |
Peter Tyser | d4abc75 | 2009-07-20 19:02:21 -0500 | [diff] [blame] | 31 | # Source files which exist outside the examples/api directory |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 32 | EXT_COBJ-y += lib/crc32.o |
| 33 | EXT_COBJ-y += lib/ctype.o |
| 34 | EXT_COBJ-y += lib/div64.o |
Alexey Brodkin | f8c987f | 2018-06-05 17:17:57 +0300 | [diff] [blame^] | 35 | EXT_COBJ-y += lib/hexdump.o |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 36 | EXT_COBJ-y += lib/string.o |
| 37 | EXT_COBJ-y += lib/time.o |
| 38 | EXT_COBJ-y += lib/vsprintf.o |
Rob Clark | 274325c | 2017-09-09 06:47:41 -0400 | [diff] [blame] | 39 | EXT_COBJ-y += lib/charset.o |
Rob Clark | 22ada0c | 2017-09-09 06:47:42 -0400 | [diff] [blame] | 40 | EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 41 | EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o |
Tom Rini | 40d5534 | 2017-01-12 13:16:02 -0500 | [diff] [blame] | 42 | ifeq ($(ARCH),arm) |
| 43 | EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o |
| 44 | endif |
Peter Tyser | 117d0ab | 2009-06-22 18:01:39 -0500 | [diff] [blame] | 45 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 46 | # Create a list of object files to be compiled |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 47 | OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y)) |
| 48 | targets += $(OBJS) |
| 49 | OBJS := $(addprefix $(obj)/,$(OBJS)) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 50 | |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 51 | ######################################################################### |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 52 | |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 53 | quiet_cmd_link_demo = LD $@ |
| 54 | cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS) |
| 55 | |
| 56 | $(obj)/demo: $(OBJS) FORCE |
| 57 | $(call if_changed,link_demo) |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 58 | |
Masahiro Yamada | f9c235f | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 59 | # demo.bin is never genrated. Is this necessary? |
| 60 | OBJCOPYFLAGS_demo.bin := -O binary |
| 61 | $(obj)/demo.bin: $(obj)/demo FORCE |
| 62 | $(call if_changed,objcopy) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 63 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 64 | # Rule to build generic library C files |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 65 | $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE |
Masahiro Yamada | 6825a95 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 66 | $(call cmd,force_checksrc) |
| 67 | $(call if_changed_rule,cc_o_c) |
Rafal Jaworowski | 500856e | 2008-01-09 19:39:36 +0100 | [diff] [blame] | 68 | |
Peter Tyser | 876b3ce | 2009-06-22 18:01:41 -0500 | [diff] [blame] | 69 | # Rule to build architecture-specific library assembly files |
Tom Rini | 40d5534 | 2017-01-12 13:16:02 -0500 | [diff] [blame] | 70 | $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE |
Masahiro Yamada | 6825a95 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 71 | $(call if_changed_dep,as_o_S) |