2 # (C) Copyright 2007 Semihalf
4 # SPDX-License-Identifier: GPL-2.0+
14 # Resulting ELF and binary exectuables will be named demo and demo.bin
17 # Source files located in the examples/api directory
18 SOBJ_FILES-y += crt0.o
19 COBJ_FILES-y += demo.o
20 COBJ_FILES-y += glue.o
21 COBJ_FILES-y += libgenwrap.o
23 # Source files which exist outside the examples/api directory
24 EXT_COBJ_FILES-y += lib/crc32.o
25 EXT_COBJ_FILES-y += lib/ctype.o
26 EXT_COBJ_FILES-y += lib/div64.o
27 EXT_COBJ_FILES-y += lib/string.o
28 EXT_COBJ_FILES-y += lib/time.o
29 EXT_COBJ_FILES-y += lib/vsprintf.o
30 EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
32 # Create a list of source files so their dependencies can be auto-generated
33 SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
34 SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
35 SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
36 SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
38 # Create a list of object files to be compiled
39 OBJS += $(addprefix $(obj),$(SOBJ_FILES-y))
40 OBJS += $(addprefix $(obj),$(COBJ_FILES-y))
41 OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
42 OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
44 #########################################################################
47 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
49 $(obj)demo.bin: $(obj)demo
50 $(OBJCOPY) -O binary $< $@ 2>/dev/null
52 # Rule to build generic library C files
53 $(obj)%.o: $(SRCTREE)/lib/%.c
54 $(CC) -g $(CFLAGS) -c -o $@ $<
56 # Rule to build architecture-specific library assembly files
57 $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
58 $(CC) -g $(CFLAGS) -c -o $@ $<