blob: 7e0e5b71b60885fc85e896f635ebb51a151e2a82 [file] [log] [blame]
wdenk717b5aa2002-04-27 11:09:31 +00001#
Marian Balakowiczd62379d2006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenk717b5aa2002-04-27 11:09:31 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk717b5aa2002-04-27 11:09:31 +00006#
7
Masahiro Yamada6b05dae2014-02-04 17:24:12 +09008extra-y := hello_world
9extra-$(CONFIG_SMC91111) += smc91111_eeprom
10extra-$(CONFIG_SMC911X) += smc911x_eeprom
11extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
12extra-$(CONFIG_MPC5xxx) += interrupt
13extra-$(CONFIG_8xx) += test_burst timer
14extra-$(CONFIG_8260) += mem_to_mem_idma2intr
15extra-$(CONFIG_PPC) += sched
Mike Frysinger0f4964a2009-07-23 16:37:03 -040016
Sanjeev Premi68db2352009-11-09 22:43:00 +053017#
18# Some versions of make do not handle trailing white spaces properly;
19# leading to build failures. The problem was found with GNU Make 3.80.
20# Using 'strip' as a workaround for the problem.
21#
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090022ELF := $(strip $(extra-y))
Sanjeev Premi68db2352009-11-09 22:43:00 +053023
Masahiro Yamada6b05dae2014-02-04 17:24:12 +090024extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
25clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
26
Mike Frysinger659c60d2009-09-04 19:54:45 -040027COBJS := $(ELF:=.o)
wdenkabda5ca2003-05-31 18:35:21 +000028
Masahiro Yamada59f15f22014-02-04 17:24:24 +090029LIB = $(obj)/libstubs.o
wdenkbd1575f2003-10-14 19:43:55 +000030
Masahiro Yamada020a1f22014-02-24 11:12:19 +090031LIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
32LIBOBJS-$(CONFIG_8xx) += test_burst_lib.o
33LIBOBJS-y += stubs.o
Marian Balakowiczd62379d2006-09-01 19:49:50 +020034
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090035.SECONDARY: $(call objectify,$(COBJS))
Masahiro Yamada020a1f22014-02-24 11:12:19 +090036targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090037
Masahiro Yamada020a1f22014-02-24 11:12:19 +090038LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y))
Masahiro Yamada59f15f22014-02-04 17:24:24 +090039ELF := $(addprefix $(obj)/,$(ELF))
wdenk717b5aa2002-04-27 11:09:31 +000040
Tom Rinic98feda2013-09-10 09:51:44 -040041gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
wdenk710e3502003-08-29 20:57:53 +000042
Peter Tyser29764ee2010-06-15 21:48:25 +020043# For PowerPC there's no need to compile standalone applications as a
44# relocatable executable. The relocation data is not needed, and
45# also causes the entry point of the standalone application to be
46# inconsistent.
Masahiro Yamada958fe8f2014-03-05 16:59:40 +090047ifeq ($(CONFIG_PPC),y)
48PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
Peter Tyser29764ee2010-06-15 21:48:25 +020049endif
50
Peter Tyser4bbc0822010-09-12 17:38:49 -050051# We don't want gcc reordering functions if possible. This ensures that an
52# application's entry point will be the first function in the application's
53# source file.
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090054ccflags-y += $(call cc-option,-fno-toplevel-reorder)
wdenk717b5aa2002-04-27 11:09:31 +000055
56#########################################################################
Masahiro Yamada0d68fb12014-02-04 17:24:28 +090057
58quiet_cmd_link_lib = LD $@
59 cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
60
61$(LIB): $(LIBOBJS) FORCE
62 $(call if_changed,link_lib)
wdenk717b5aa2002-04-27 11:09:31 +000063
Masahiro Yamada020a1f22014-02-24 11:12:19 +090064quiet_cmd_link_elf = LD $@
65 cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
66 -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) -L$(gcclibdir) -lgcc
67
68$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
69 $(call if_changed,link_elf)
Wolfgang Denk29be6222006-10-24 13:55:18 +020070
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090071$(obj)/%.srec: OBJCOPYFLAGS := -O srec
72$(obj)/%.srec: $(obj)/% FORCE
73 $(call if_changed,objcopy)
wdenk717b5aa2002-04-27 11:09:31 +000074
Masahiro Yamada734c3ef2014-02-24 11:12:14 +090075$(obj)/%.bin: OBJCOPYFLAGS := -O binary
76$(obj)/%.bin: $(obj)/% FORCE
77 $(call if_changed,objcopy)