blob: 6cf23d10acb201c66d0dbe76b3371e56dabba437 [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 Yamada04a34c92014-02-24 11:12:19 +090018OBJ-y += crt0.o
19OBJ-y += demo.o
20OBJ-y += glue.o
21OBJ-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 Yamada04a34c92014-02-24 11:12:19 +090024EXT_COBJ-y += lib/crc32.o
25EXT_COBJ-y += lib/ctype.o
26EXT_COBJ-y += lib/div64.o
27EXT_COBJ-y += lib/string.o
28EXT_COBJ-y += lib/time.o
29EXT_COBJ-y += lib/vsprintf.o
30EXT_SOBJ-$(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 Yamada04a34c92014-02-24 11:12:19 +090033OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
34targets += $(OBJS)
35OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010036
Rafal Jaworowski500856e2008-01-09 19:39:36 +010037#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010038
Masahiro Yamada04a34c92014-02-24 11:12:19 +090039quiet_cmd_link_demo = LD $@
40cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
41
42$(obj)/demo: $(OBJS) FORCE
43 $(call if_changed,link_demo)
Masahiro Yamada4a20df32014-02-04 17:24:12 +090044
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090045# demo.bin is never genrated. Is this necessary?
46OBJCOPYFLAGS_demo.bin := -O binary
47$(obj)/demo.bin: $(obj)/demo FORCE
48 $(call if_changed,objcopy)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010049
Peter Tyser876b3ce2009-06-22 18:01:41 -050050# Rule to build generic library C files
Masahiro Yamada04a34c92014-02-24 11:12:19 +090051$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090052 $(call cmd,force_checksrc)
53 $(call if_changed_rule,cc_o_c)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010054
Peter Tyser876b3ce2009-06-22 18:01:41 -050055# Rule to build architecture-specific library assembly files
Masahiro Yamada04a34c92014-02-24 11:12:19 +090056$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090057 $(call if_changed_dep,as_o_S)