blob: 6c19830d2ccb96d03cfbfe86f534eb9a369842cc [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
Stefan Roesea47a12b2010-04-15 16:07:28 +02007ifeq ($(ARCH),powerpc)
Rafal Jaworowski500856e2008-01-09 19:39:36 +01008LOAD_ADDR = 0x40000
9endif
Rafal Jaworowski7fb6c4f2009-01-23 13:27:16 +010010ifeq ($(ARCH),arm)
11LOAD_ADDR = 0x1000000
12endif
Rafal Jaworowski500856e2008-01-09 19:39:36 +010013
Peter Tyser117d0ab2009-06-22 18:01:39 -050014# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada4a20df32014-02-04 17:24:12 +090015extra-y = demo
Rafal Jaworowski500856e2008-01-09 19:39:36 +010016
Peter Tyserd4abc752009-07-20 19:02:21 -050017# Source files located in the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090018SOBJ_FILES-y += crt0.o
19COBJ_FILES-y += demo.o
20COBJ_FILES-y += glue.o
21COBJ_FILES-y += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010022
Peter Tyserd4abc752009-07-20 19:02:21 -050023# Source files which exist outside the examples/api directory
Masahiro Yamada8a7e7d52013-11-18 11:08:35 +090024EXT_COBJ_FILES-y += lib/crc32.o
25EXT_COBJ_FILES-y += lib/ctype.o
26EXT_COBJ_FILES-y += lib/div64.o
27EXT_COBJ_FILES-y += lib/string.o
28EXT_COBJ_FILES-y += lib/time.o
29EXT_COBJ_FILES-y += lib/vsprintf.o
30EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Peter Tyser117d0ab2009-06-22 18:01:39 -050031
Peter Tyser876b3ce2009-06-22 18:01:41 -050032# Create a list of object files to be compiled
Masahiro Yamada9e414032014-02-04 17:24:24 +090033OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y))
34OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y))
35OBJS += $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y)))
36OBJS += $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y)))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010037
Rafal Jaworowski500856e2008-01-09 19:39:36 +010038#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010039
Masahiro Yamada9e414032014-02-04 17:24:24 +090040$(obj)/demo: $(OBJS)
Rob Herringe32a2682013-10-04 10:22:40 -050041 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
Masahiro Yamada4a20df32014-02-04 17:24:12 +090042
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090043# demo.bin is never genrated. Is this necessary?
44OBJCOPYFLAGS_demo.bin := -O binary
45$(obj)/demo.bin: $(obj)/demo FORCE
46 $(call if_changed,objcopy)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010047
Peter Tyser876b3ce2009-06-22 18:01:41 -050048# Rule to build generic library C files
Masahiro Yamada6825a952014-02-04 17:24:28 +090049$(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c FORCE
50 $(call cmd,force_checksrc)
51 $(call if_changed_rule,cc_o_c)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010052
Peter Tyser876b3ce2009-06-22 18:01:41 -050053# Rule to build architecture-specific library assembly files
Masahiro Yamada9e414032014-02-04 17:24:24 +090054$(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
Masahiro Yamada6825a952014-02-04 17:24:28 +090055 $(call if_changed_dep,as_o_S)