1# SPDX-License-Identifier: GPL-2.0+ 2# 3# (C) Copyright 2007 Semihalf 4 5# Provide symbol API_BUILD to signal that the API example is being built. 6KBUILD_CPPFLAGS += -DAPI_BUILD 7 8# Environment variable loadaddr is set from CONFIG_SYS_LOAD_ADDR. 9# Run the examples 4 MiB above this address. 10LOAD_ADDR:=${shell printf 0x%X $$(( $(CONFIG_SYS_LOAD_ADDR) + 0x400000 ))} 11 12# Resulting ELF and binary exectuables will be named demo and demo.bin 13extra-y = demo 14 15# Source files located in the examples/api directory 16OBJ-y += crt0.o 17OBJ-y += demo.o 18OBJ-y += glue.o 19OBJ-y += libgenwrap.o 20 21# Source files which exist outside the examples/api directory 22EXT_COBJ-y += lib/crc32.o 23EXT_COBJ-y += lib/ctype.o 24EXT_COBJ-y += lib/div64.o 25EXT_COBJ-y += lib/hexdump.o 26EXT_COBJ-y += lib/string.o 27EXT_COBJ-y += lib/time.o 28EXT_COBJ-y += lib/vsprintf.o 29EXT_COBJ-y += lib/charset.o 30EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o 31EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o 32ifneq ($(CONFIG_ARM)$(CONFIG_RISCV),) 33EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/$(ARCH)/lib/memset.o 34endif 35 36# Create a list of object files to be compiled 37OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y)) 38targets += $(OBJS) 39OBJS := $(addprefix $(obj)/,$(OBJS)) 40 41######################################################################### 42 43quiet_cmd_link_demo = LD $@ 44cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS) 45 46$(obj)/demo: $(OBJS) FORCE 47 $(call if_changed,link_demo) 48 49# demo.bin is never genrated. Is this necessary? 50OBJCOPYFLAGS_demo.bin := -O binary 51$(obj)/demo.bin: $(obj)/demo FORCE 52 $(call if_changed,objcopy) 53 54# Rule to build generic library C files 55$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE 56 $(call cmd,force_checksrc) 57 $(call if_changed_rule,cc_o_c) 58 59# Rule to build architecture-specific library assembly files 60$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE 61 $(call if_changed_dep,as_o_S) 62