blob: 6cffee74652f944d9d9bc9ed812b4177432f98af [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
Stanislav Galabov7c604232016-02-04 12:13:44 +020013ifeq ($(ARCH),mips)
Stanislav Galabov78757d52016-02-17 15:23:31 +020014ifdef CONFIG_64BIT
15LOAD_ADDR = 0xffffffff80200000
16else
Stanislav Galabov7c604232016-02-04 12:13:44 +020017LOAD_ADDR = 0x80200000
18endif
Stanislav Galabov78757d52016-02-17 15:23:31 +020019endif
Rafal Jaworowski500856e2008-01-09 19:39:36 +010020
Peter Tyser117d0ab2009-06-22 18:01:39 -050021# Resulting ELF and binary exectuables will be named demo and demo.bin
Masahiro Yamada4a20df32014-02-04 17:24:12 +090022extra-y = demo
Rafal Jaworowski500856e2008-01-09 19:39:36 +010023
Peter Tyserd4abc752009-07-20 19:02:21 -050024# Source files located in the examples/api directory
Masahiro Yamada04a34c92014-02-24 11:12:19 +090025OBJ-y += crt0.o
26OBJ-y += demo.o
27OBJ-y += glue.o
28OBJ-y += libgenwrap.o
Rafal Jaworowski500856e2008-01-09 19:39:36 +010029
Peter Tyserd4abc752009-07-20 19:02:21 -050030# Source files which exist outside the examples/api directory
Masahiro Yamada04a34c92014-02-24 11:12:19 +090031EXT_COBJ-y += lib/crc32.o
32EXT_COBJ-y += lib/ctype.o
33EXT_COBJ-y += lib/div64.o
34EXT_COBJ-y += lib/string.o
35EXT_COBJ-y += lib/time.o
36EXT_COBJ-y += lib/vsprintf.o
37EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
Peter Tyser117d0ab2009-06-22 18:01:39 -050038
Peter Tyser876b3ce2009-06-22 18:01:41 -050039# Create a list of object files to be compiled
Masahiro Yamada04a34c92014-02-24 11:12:19 +090040OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
41targets += $(OBJS)
42OBJS := $(addprefix $(obj)/,$(OBJS))
Rafal Jaworowski500856e2008-01-09 19:39:36 +010043
Rafal Jaworowski500856e2008-01-09 19:39:36 +010044#########################################################################
Rafal Jaworowski500856e2008-01-09 19:39:36 +010045
Masahiro Yamada04a34c92014-02-24 11:12:19 +090046quiet_cmd_link_demo = LD $@
47cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
48
49$(obj)/demo: $(OBJS) FORCE
50 $(call if_changed,link_demo)
Masahiro Yamada4a20df32014-02-04 17:24:12 +090051
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090052# demo.bin is never genrated. Is this necessary?
53OBJCOPYFLAGS_demo.bin := -O binary
54$(obj)/demo.bin: $(obj)/demo FORCE
55 $(call if_changed,objcopy)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010056
Peter Tyser876b3ce2009-06-22 18:01:41 -050057# Rule to build generic library C files
Masahiro Yamada04a34c92014-02-24 11:12:19 +090058$(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090059 $(call cmd,force_checksrc)
60 $(call if_changed_rule,cc_o_c)
Rafal Jaworowski500856e2008-01-09 19:39:36 +010061
Peter Tyser876b3ce2009-06-22 18:01:41 -050062# Rule to build architecture-specific library assembly files
Masahiro Yamada04a34c92014-02-24 11:12:19 +090063$(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
Masahiro Yamada6825a952014-02-04 17:24:28 +090064 $(call if_changed_dep,as_o_S)