blob: 4e9b8ea17dcc6ffd49c34de6ec6a0febd2e36028 [file] [log] [blame]
Rafal Jaworowskia19be782008-01-09 19:39:36 +01001#
2# (C) Copyright 2007 Semihalf
3#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004# SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowskia19be782008-01-09 19:39:36 +01005#
6
Stefan Roese88fbf932010-04-15 16:07:28 +02007ifeq ($(ARCH),powerpc)
Rafal Jaworowskia19be782008-01-09 19:39:36 +01008LOAD_ADDR = 0x40000
9endif
Rafal Jaworowski9d9689f2009-01-23 13:27:16 +010010ifeq ($(ARCH),arm)
11LOAD_ADDR = 0x1000000
12endif
Stanislav Galabov35d35e82016-02-04 12:13:44 +020013ifeq ($(ARCH),mips)
14LOAD_ADDR = 0x80200000
15endif
Rafal Jaworowskia19be782008-01-09 19:39:36 +010016
Peter Tyser2dcb4e12009-06-22 18:01:39 -050017# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090018extra-y = demo
Rafal Jaworowskia19be782008-01-09 19:39:36 +010019
Peter Tyseracce4eb2009-07-20 19:02:21 -050020# Source files located in the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090021OBJ-y += crt0.o
22OBJ-y += demo.o
23OBJ-y += glue.o
24OBJ-y += libgenwrap.o
Rafal Jaworowskia19be782008-01-09 19:39:36 +010025
Peter Tyseracce4eb2009-07-20 19:02:21 -050026# Source files which exist outside the examples/api directory
Masahiro Yamada020a1f22014-02-24 11:12:19 +090027EXT_COBJ-y += lib/crc32.o
28EXT_COBJ-y += lib/ctype.o
29EXT_COBJ-y += lib/div64.o
30EXT_COBJ-y += lib/string.o
31EXT_COBJ-y += lib/time.o
32EXT_COBJ-y += lib/vsprintf.o
33EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Peter Tyser2dcb4e12009-06-22 18:01:39 -050034
Peter Tyserbdb925e2009-06-22 18:01:41 -050035# Create a list of object files to be compiled
Masahiro Yamada020a1f22014-02-24 11:12:19 +090036OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
37targets += $(OBJS)
38OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowskia19be782008-01-09 19:39:36 +010039
Rafal Jaworowskia19be782008-01-09 19:39:36 +010040#########################################################################
Rafal Jaworowskia19be782008-01-09 19:39:36 +010041
Masahiro Yamada020a1f22014-02-24 11:12:19 +090042quiet_cmd_link_demo = LD $@
43cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
44
45$(obj)/demo: $(OBJS) FORCE
46 $(call if_changed,link_demo)
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090047
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090048# demo.bin is never genrated. Is this necessary?
49OBJCOPYFLAGS_demo.bin := -O binary
50$(obj)/demo.bin: $(obj)/demo FORCE
51 $(call if_changed,objcopy)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010052
Peter Tyserbdb925e2009-06-22 18:01:41 -050053# Rule to build generic library C files
Masahiro Yamada020a1f22014-02-24 11:12:19 +090054$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090055 $(call cmd,force_checksrc)
56 $(call if_changed_rule,cc_o_c)
Rafal Jaworowskia19be782008-01-09 19:39:36 +010057
Peter Tyserbdb925e2009-06-22 18:01:41 -050058# Rule to build architecture-specific library assembly files
Masahiro Yamada020a1f22014-02-24 11:12:19 +090059$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090060 $(call if_changed_dep,as_o_S)