1# 2# (C) Copyright 2007 Semihalf 3# 4# SPDX-License-Identifier: GPL-2.0+ 5# 6 7ifeq ($(ARCH),powerpc) 8LOAD_ADDR = 0x40000 9endif 10ifeq ($(ARCH),arm) 11LOAD_ADDR = 0x1000000 12endif 13 14include $(TOPDIR)/config.mk 15 16# Resulting ELF and binary exectuables will be named demo and demo.bin 17OUTPUT = $(obj)demo 18 19# Source files located in the examples/api directory 20SOBJ_FILES-y += crt0.o 21COBJ_FILES-y += demo.o 22COBJ_FILES-y += glue.o 23COBJ_FILES-y += libgenwrap.o 24 25# Source files which exist outside the examples/api directory 26EXT_COBJ_FILES-y += lib/crc32.o 27EXT_COBJ_FILES-y += lib/ctype.o 28EXT_COBJ_FILES-y += lib/div64.o 29EXT_COBJ_FILES-y += lib/string.o 30EXT_COBJ_FILES-y += lib/time.o 31EXT_COBJ_FILES-y += lib/vsprintf.o 32EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o 33 34# Create a list of source files so their dependencies can be auto-generated 35SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c)) 36SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S)) 37SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c)) 38SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S)) 39 40# Create a list of object files to be compiled 41OBJS += $(addprefix $(obj),$(SOBJ_FILES-y)) 42OBJS += $(addprefix $(obj),$(COBJ_FILES-y)) 43OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y))) 44OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y))) 45 46all: $(obj).depend $(OUTPUT) 47 48######################################################################### 49 50$(OUTPUT): $(OBJS) 51 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS) 52 $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null 53 54# Rule to build generic library C files 55$(obj)%.o: $(SRCTREE)/lib/%.c 56 $(CC) -g $(CFLAGS) -c -o $@ $< 57 58# Rule to build architecture-specific library assembly files 59$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S 60 $(CC) -g $(CFLAGS) -c -o $@ $< 61 62######################################################################### 63 64# defines $(obj).depend target 65include $(SRCTREE)/rules.mk 66 67sinclude $(obj).depend 68 69######################################################################### 70