2008-01-09 18:39:36 +00:00
|
|
|
#
|
|
|
|
# (C) Copyright 2007 Semihalf
|
|
|
|
#
|
2013-07-08 07:37:19 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2008-01-09 18:39:36 +00:00
|
|
|
#
|
|
|
|
|
2014-02-04 08:24:23 +00:00
|
|
|
ifdef FTRACE
|
|
|
|
CFLAGS += -finstrument-functions -DFTRACE
|
|
|
|
endif
|
|
|
|
|
2010-04-15 14:07:28 +00:00
|
|
|
ifeq ($(ARCH),powerpc)
|
2008-01-09 18:39:36 +00:00
|
|
|
LOAD_ADDR = 0x40000
|
|
|
|
endif
|
2009-01-23 12:27:16 +00:00
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
LOAD_ADDR = 0x1000000
|
|
|
|
endif
|
2008-01-09 18:39:36 +00:00
|
|
|
|
2009-06-22 23:01:39 +00:00
|
|
|
# Resulting ELF and binary exectuables will be named demo and demo.bin
|
2014-02-04 08:24:12 +00:00
|
|
|
extra-y = demo
|
2009-06-22 23:01:41 +00:00
|
|
|
|
2009-07-21 00:02:21 +00:00
|
|
|
# Source files located in the examples/api directory
|
2013-11-18 02:08:35 +00:00
|
|
|
SOBJ_FILES-y += crt0.o
|
|
|
|
COBJ_FILES-y += demo.o
|
|
|
|
COBJ_FILES-y += glue.o
|
|
|
|
COBJ_FILES-y += libgenwrap.o
|
2009-06-22 23:01:41 +00:00
|
|
|
|
2009-07-21 00:02:21 +00:00
|
|
|
# Source files which exist outside the examples/api directory
|
2013-11-18 02:08:35 +00:00
|
|
|
EXT_COBJ_FILES-y += lib/crc32.o
|
|
|
|
EXT_COBJ_FILES-y += lib/ctype.o
|
|
|
|
EXT_COBJ_FILES-y += lib/div64.o
|
|
|
|
EXT_COBJ_FILES-y += lib/string.o
|
|
|
|
EXT_COBJ_FILES-y += lib/time.o
|
|
|
|
EXT_COBJ_FILES-y += lib/vsprintf.o
|
|
|
|
EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
|
2009-06-22 23:01:39 +00:00
|
|
|
|
2009-06-22 23:01:41 +00:00
|
|
|
# Create a list of source files so their dependencies can be auto-generated
|
|
|
|
SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
|
|
|
|
SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
|
2009-07-21 00:02:21 +00:00
|
|
|
SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
|
|
|
|
SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
|
2008-01-09 18:39:36 +00:00
|
|
|
|
2009-06-22 23:01:41 +00:00
|
|
|
# Create a list of object files to be compiled
|
2014-02-04 08:24:24 +00:00
|
|
|
OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y))
|
|
|
|
OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y))
|
|
|
|
OBJS += $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y)))
|
|
|
|
OBJS += $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y)))
|
2008-01-09 18:39:36 +00:00
|
|
|
|
|
|
|
#########################################################################
|
2009-06-22 23:01:40 +00:00
|
|
|
|
2014-02-04 08:24:24 +00:00
|
|
|
$(obj)/demo: $(OBJS)
|
2013-10-04 15:22:40 +00:00
|
|
|
$(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
|
2014-02-04 08:24:12 +00:00
|
|
|
|
2014-02-04 08:24:24 +00:00
|
|
|
$(obj)/demo.bin: $(obj)/demo
|
2014-02-04 08:24:12 +00:00
|
|
|
$(OBJCOPY) -O binary $< $@ 2>/dev/null
|
2008-01-09 18:39:36 +00:00
|
|
|
|
2009-06-22 23:01:41 +00:00
|
|
|
# Rule to build generic library C files
|
2014-02-04 08:24:24 +00:00
|
|
|
$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
|
2009-06-22 23:01:41 +00:00
|
|
|
$(CC) -g $(CFLAGS) -c -o $@ $<
|
2008-01-09 18:39:36 +00:00
|
|
|
|
2009-06-22 23:01:41 +00:00
|
|
|
# Rule to build architecture-specific library assembly files
|
2014-02-04 08:24:24 +00:00
|
|
|
$(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
|
2009-06-22 23:01:41 +00:00
|
|
|
$(CC) -g $(CFLAGS) -c -o $@ $<
|