xref: /OK3568_Linux_fs/u-boot/examples/standalone/Makefile (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# (C) Copyright 2000-2006
3*4882a593Smuzhiyun# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun# SPDX-License-Identifier:	GPL-2.0+
6*4882a593Smuzhiyun#
7*4882a593Smuzhiyun
8*4882a593Smuzhiyunextra-y        := hello_world
9*4882a593Smuzhiyunextra-$(CONFIG_SMC91111)           += smc91111_eeprom
10*4882a593Smuzhiyunextra-$(CONFIG_SMC911X)            += smc911x_eeprom
11*4882a593Smuzhiyunextra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
12*4882a593Smuzhiyunextra-$(CONFIG_PPC)                += sched
13*4882a593Smuzhiyunextra-$(CONFIG_ROCKCHIP_SPI)       += rkspi
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun#
16*4882a593Smuzhiyun# Some versions of make do not handle trailing white spaces properly;
17*4882a593Smuzhiyun# leading to build failures. The problem was found with GNU Make 3.80.
18*4882a593Smuzhiyun# Using 'strip' as a workaround for the problem.
19*4882a593Smuzhiyun#
20*4882a593SmuzhiyunELF := $(strip $(extra-y))
21*4882a593Smuzhiyun
22*4882a593Smuzhiyunextra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
23*4882a593Smuzhiyunclean-files  := *.srec *.bin
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunCOBJS	:= $(ELF:=.o)
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunLIB	= $(obj)/libstubs.o
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunLIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
30*4882a593SmuzhiyunLIBOBJS-y += stubs.o
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun.SECONDARY: $(call objectify,$(COBJS))
33*4882a593Smuzhiyuntargets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunLIBOBJS	:= $(addprefix $(obj)/,$(LIBOBJS-y))
36*4882a593SmuzhiyunELF	:= $(addprefix $(obj)/,$(ELF))
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun# For PowerPC there's no need to compile standalone applications as a
39*4882a593Smuzhiyun# relocatable executable.  The relocation data is not needed, and
40*4882a593Smuzhiyun# also causes the entry point of the standalone application to be
41*4882a593Smuzhiyun# inconsistent.
42*4882a593Smuzhiyunifeq ($(CONFIG_PPC),y)
43*4882a593SmuzhiyunPLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
44*4882a593Smuzhiyunendif
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun# We don't want gcc reordering functions if possible.  This ensures that an
47*4882a593Smuzhiyun# application's entry point will be the first function in the application's
48*4882a593Smuzhiyun# source file.
49*4882a593Smuzhiyunccflags-y += $(call cc-option,-fno-toplevel-reorder)
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun#########################################################################
52*4882a593Smuzhiyun
53*4882a593Smuzhiyunquiet_cmd_link_lib = LD      $@
54*4882a593Smuzhiyun      cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun$(LIB):	$(LIBOBJS) FORCE
57*4882a593Smuzhiyun	$(call if_changed,link_lib)
58*4882a593Smuzhiyun
59*4882a593Smuzhiyunquiet_cmd_link_elf = LD      $@
60*4882a593Smuzhiyun      cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
61*4882a593Smuzhiyun		     -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC)
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
64*4882a593Smuzhiyun	$(call if_changed,link_elf)
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun$(obj)/%.srec: OBJCOPYFLAGS := -O srec
67*4882a593Smuzhiyun$(obj)/%.srec: $(obj)/% FORCE
68*4882a593Smuzhiyun	$(call if_changed,objcopy)
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun$(obj)/%.bin: OBJCOPYFLAGS := -O binary
71*4882a593Smuzhiyun$(obj)/%.bin: $(obj)/% FORCE
72*4882a593Smuzhiyun	$(call if_changed,objcopy)
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun# some files can only build in ARM or THUMB2, not THUMB1
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunifdef CONFIG_SYS_THUMB_BUILD
77*4882a593Smuzhiyunifndef CONFIG_HAS_THUMB2
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunCFLAGS_stubs.o := -marm
80*4882a593Smuzhiyun
81*4882a593Smuzhiyunendif
82*4882a593Smuzhiyunendif
83