blob: 0863a8cda205b14d54584d73f22cf3ee8de15e72 [file] [log] [blame]
wdenk717b5aa2002-04-27 11:09:31 +00001#
Marian Balakowiczf9328632006-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 Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk717b5aa2002-04-27 11:09:31 +00006#
7
Masahiro Yamada4a20df32014-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
Masahiro Yamada58dac322014-03-05 17:40:10 +090014extra-$(CONFIG_MPC8260) += mem_to_mem_idma2intr
Masahiro Yamada4a20df32014-02-04 17:24:12 +090015extra-$(CONFIG_PPC) += sched
Mike Frysinger65f6f072009-07-23 16:37:03 -040016
Sanjeev Premi604f7ce2009-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 Yamada4a20df32014-02-04 17:24:12 +090022ELF := $(strip $(extra-y))
Sanjeev Premi604f7ce2009-11-09 22:43:00 +053023
Masahiro Yamada4a20df32014-02-04 17:24:12 +090024extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
Masahiro Yamada8e714432014-09-05 01:56:52 +090025clean-files := *.srec *.bin
Masahiro Yamada4a20df32014-02-04 17:24:12 +090026
Mike Frysinger557555f2009-09-04 19:54:45 -040027COBJS := $(ELF:=.o)
wdenk717b5aa2002-04-27 11:09:31 +000028
Masahiro Yamada9e414032014-02-04 17:24:24 +090029LIB = $(obj)/libstubs.o
Mike Frysinger557555f2009-09-04 19:54:45 -040030
Masahiro Yamada04a34c92014-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 Balakowiczf9328632006-09-01 19:49:50 +020034
Masahiro Yamada6825a952014-02-04 17:24:28 +090035.SECONDARY: $(call objectify,$(COBJS))
Masahiro Yamada04a34c92014-02-24 11:12:19 +090036targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
Masahiro Yamada6825a952014-02-04 17:24:28 +090037
Masahiro Yamada04a34c92014-02-24 11:12:19 +090038LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y))
Masahiro Yamada9e414032014-02-04 17:24:24 +090039ELF := $(addprefix $(obj)/,$(ELF))
wdenk717b5aa2002-04-27 11:09:31 +000040
Peter Tyser620bbba2010-06-15 21:48:25 +020041# For PowerPC there's no need to compile standalone applications as a
42# relocatable executable. The relocation data is not needed, and
43# also causes the entry point of the standalone application to be
44# inconsistent.
Masahiro Yamada026f9cf2014-03-05 16:59:40 +090045ifeq ($(CONFIG_PPC),y)
46PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
Peter Tyser620bbba2010-06-15 21:48:25 +020047endif
48
Peter Tyserc91d4562010-09-12 17:38:49 -050049# We don't want gcc reordering functions if possible. This ensures that an
50# application's entry point will be the first function in the application's
51# source file.
Masahiro Yamada6825a952014-02-04 17:24:28 +090052ccflags-y += $(call cc-option,-fno-toplevel-reorder)
wdenk717b5aa2002-04-27 11:09:31 +000053
54#########################################################################
Masahiro Yamada6825a952014-02-04 17:24:28 +090055
56quiet_cmd_link_lib = LD $@
57 cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
58
59$(LIB): $(LIBOBJS) FORCE
60 $(call if_changed,link_lib)
wdenk717b5aa2002-04-27 11:09:31 +000061
Masahiro Yamada04a34c92014-02-24 11:12:19 +090062quiet_cmd_link_elf = LD $@
63 cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
Alexey Brodkine75e73d2014-05-16 12:54:17 +040064 -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC)
Masahiro Yamada04a34c92014-02-24 11:12:19 +090065
66$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
67 $(call if_changed,link_elf)
Wolfgang Denk96582982006-10-24 13:55:18 +020068
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090069$(obj)/%.srec: OBJCOPYFLAGS := -O srec
70$(obj)/%.srec: $(obj)/% FORCE
71 $(call if_changed,objcopy)
wdenk717b5aa2002-04-27 11:09:31 +000072
Masahiro Yamadaf9c235f2014-02-24 11:12:14 +090073$(obj)/%.bin: OBJCOPYFLAGS := -O binary
74$(obj)/%.bin: $(obj)/% FORCE
75 $(call if_changed,objcopy)