]> git.ipfire.org Git - thirdparty/u-boot.git/blame - examples/standalone/Makefile
Merge branch 'next'
[thirdparty/u-boot.git] / examples / standalone / Makefile
CommitLineData
83d290c5 1# SPDX-License-Identifier: GPL-2.0+
717b5aad 2#
f9328639 3# (C) Copyright 2000-2006
717b5aad 4# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
717b5aad 5
4a20df39 6extra-y := hello_world
4a20df39 7extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
4a20df39 8extra-$(CONFIG_PPC) += sched
557555fe 9
604f7ce5
SP
10#
11# Some versions of make do not handle trailing white spaces properly;
12# leading to build failures. The problem was found with GNU Make 3.80.
13# Using 'strip' as a workaround for the problem.
14#
4a20df39
MY
15ELF := $(strip $(extra-y))
16
17extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
8e714432 18clean-files := *.srec *.bin
604f7ce5 19
557555fe 20COBJS := $(ELF:=.o)
717b5aad 21
9e414032 22LIB = $(obj)/libstubs.o
557555fe 23
04a34c96 24LIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
04a34c96 25LIBOBJS-y += stubs.o
f9328639 26
04a34c96 27targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
f9328639 28
04a34c96 29LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y))
9e414032 30ELF := $(addprefix $(obj)/,$(ELF))
717b5aad 31
332f4802
TR
32# Disable LTO for these builds
33CFLAGS_REMOVE_hello_world.o := $(LTO_CFLAGS)
34CFLAGS_REMOVE_stubs.o := $(LTO_CFLAGS)
35
620bbba5
PT
36# For PowerPC there's no need to compile standalone applications as a
37# relocatable executable. The relocation data is not needed, and
38# also causes the entry point of the standalone application to be
39# inconsistent.
026f9cf2
MY
40ifeq ($(CONFIG_PPC),y)
41PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
620bbba5
PT
42endif
43
c91d456c
PT
44# We don't want gcc reordering functions if possible. This ensures that an
45# application's entry point will be the first function in the application's
46# source file.
6825a95b 47ccflags-y += $(call cc-option,-fno-toplevel-reorder)
717b5aad 48
1d3b97c9
DS
49LDFLAGS_STANDALONE += -Ttext $(CONFIG_STANDALONE_LOAD_ADDR)
50
717b5aad 51#########################################################################
6825a95b
MY
52
53quiet_cmd_link_lib = LD $@
54 cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
55
56$(LIB): $(LIBOBJS) FORCE
57 $(call if_changed,link_lib)
717b5aad 58
04a34c96 59quiet_cmd_link_elf = LD $@
587e4a42 60 cmd_link_elf = $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_STANDALONE) -g \
e75e73dd 61 -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC)
04a34c96
MY
62
63$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
64 $(call if_changed,link_elf)
96582987 65
d3a9ba7f 66$(obj)/%.srec: OBJCOPYFLAGS += -O srec
f9c235fd
MY
67$(obj)/%.srec: $(obj)/% FORCE
68 $(call if_changed,objcopy)
717b5aad 69
d3a9ba7f 70$(obj)/%.bin: OBJCOPYFLAGS += -O binary
f9c235fd
MY
71$(obj)/%.bin: $(obj)/% FORCE
72 $(call if_changed,objcopy)
62e92077
AA
73
74# some files can only build in ARM or THUMB2, not THUMB1
75
76ifdef CONFIG_SYS_THUMB_BUILD
77ifndef CONFIG_HAS_THUMB2
78
79CFLAGS_stubs.o := -marm
80
81endif
82endif