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