blob: db0bb34afeb6eeb9fe618af8ad148701bfaf6984 [file] [log] [blame]
Rafal Jaworowski500856e2008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
Wolfgang Denk1a459662013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski500856e2008-01-09 19:39:36 +01005#
6
Masahiro Yamadad9580022014-02-04 17:24:23 +09007ifdef FTRACE
8CFLAGS += -finstrument-functions -DFTRACE
9endif
10
Stefan Roesea47a12b2010-04-15 16:07:28 +020011ifeq ($(ARCH),powerpc)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010012LOAD_ADDR = 0x40000
13endif
Rafal Jaworowski7fb6c4f2009-01-23 13:27:16 +010014ifeq ($(ARCH),arm)
15LOAD_ADDR = 0x1000000
16endif
Rafal Jaworowski500856e2008-01-09 19:39:36 +010017
Peter Tyser117d0ab2009-06-22 18:01:39 -050018# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada4a20df32014-02-04 17:24:12 +090019extra-y = demo
Rafal Jaworowski500856e2008-01-09 19:39:36 +010020
Peter Tyserd4abc752009-07-20 19:02:21 -050021# Source files located in the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090022SOBJ_FILES-y += crt0.o
23COBJ_FILES-y += demo.o
24COBJ_FILES-y += glue.o
25COBJ_FILES-y += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010026
Peter Tyserd4abc752009-07-20 19:02:21 -050027# Source files which exist outside the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090028EXT_COBJ_FILES-y += lib/crc32.o
29EXT_COBJ_FILES-y += lib/ctype.o
30EXT_COBJ_FILES-y += lib/div64.o
31EXT_COBJ_FILES-y += lib/string.o
32EXT_COBJ_FILES-y += lib/time.o
33EXT_COBJ_FILES-y += lib/vsprintf.o
34EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Peter Tyser117d0ab2009-06-22 18:01:39 -050035
Peter Tyser876b3ce2009-06-22 18:01:41 -050036# Create a list of source files so their dependencies can be auto-generated
37SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
38SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
Peter Tyserd4abc752009-07-20 19:02:21 -050039SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
40SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010041
Peter Tyser876b3ce2009-06-22 18:01:41 -050042# Create a list of object files to be compiled
Masahiro Yamada9e414032014-02-04 17:24:24 +090043OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y))
44OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y))
45OBJS += $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y)))
46OBJS += $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y)))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010047
Rafal Jaworowski500856e2008-01-09 19:39:36 +010048#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010049
Masahiro Yamada9e414032014-02-04 17:24:24 +090050$(obj)/demo: $(OBJS)
Rob Herringe32a2682013-10-04 10:22:40 -050051 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Masahiro Yamada4a20df32014-02-04 17:24:12 +090052
Masahiro Yamada9e414032014-02-04 17:24:24 +090053$(obj)/demo.bin: $(obj)/demo
Masahiro Yamada4a20df32014-02-04 17:24:12 +090054 $(OBJCOPY) -O binary $< $@ 2>/dev/null
Rafal Jaworowski500856e2008-01-09 19:39:36 +010055
Peter Tyser876b3ce2009-06-22 18:01:41 -050056# Rule to build generic library C files
Masahiro Yamada9e414032014-02-04 17:24:24 +090057$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
Peter Tyser876b3ce2009-06-22 18:01:41 -050058 $(CC) -g $(CFLAGS) -c -o $@ $<
Rafal Jaworowski500856e2008-01-09 19:39:36 +010059
Peter Tyser876b3ce2009-06-22 18:01:41 -050060# Rule to build architecture-specific library assembly files
Masahiro Yamada9e414032014-02-04 17:24:24 +090061$(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Peter Tyser876b3ce2009-06-22 18:01:41 -050062 $(CC) -g $(CFLAGS) -c -o $@ $<