]> git.ipfire.org Git - people/ms/u-boot.git/blame - examples/standalone/Makefile
Makefile: Select objects by CONFIG_ rather than $(ARCH) or $(CPU)
[people/ms/u-boot.git] / examples / standalone / Makefile
CommitLineData
717b5aad 1#
f9328639 2# (C) Copyright 2000-2006
717b5aad
WD
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
1a459660 5# SPDX-License-Identifier: GPL-2.0+
717b5aad
WD
6#
7
717b5aad
WD
8include $(TOPDIR)/config.mk
9
557555fe
MF
10ELF-y := hello_world
11
12ELF-$(CONFIG_SMC91111) += smc91111_eeprom
13ELF-$(CONFIG_SMC911X) += smc911x_eeprom
14ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
e8a8b824
MY
15# TODO:
16# - Fix the warning of 82559_eeprom.c and uncomment the following
17# or
18# - Delete 82559_eeprom.c and the following line
19#ELF-$(CONFIG_X86) += 82559_eeprom
20ELF-$(CONFIG_MPC5xxx) += interrupt
21ELF-$(CONFIG_8xx) += test_burst timer
22ELF-$(CONFIG_8260) += mem_to_mem_idma2intr
23ELF-$(CONFIG_PPC) += sched
557555fe 24
604f7ce5
SP
25#
26# Some versions of make do not handle trailing white spaces properly;
27# leading to build failures. The problem was found with GNU Make 3.80.
28# Using 'strip' as a workaround for the problem.
29#
e8a8b824 30ELF := $(strip $(ELF-y))
604f7ce5 31
0da43893
CC
32SREC := $(addsuffix .srec,$(ELF))
33BIN := $(addsuffix .bin,$(ELF))
557555fe
MF
34
35COBJS := $(ELF:=.o)
717b5aad 36
6d8962e8 37LIB = $(obj)libstubs.o
557555fe 38
e8a8b824
MY
39LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
40LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
41LIBAOBJS := $(LIBAOBJS-y)
557555fe
MF
42
43LIBCOBJS = stubs.o
f9328639
MB
44
45LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
46
557555fe 47SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
f9328639 48OBJS := $(addprefix $(obj),$(COBJS))
96582987 49ELF := $(addprefix $(obj),$(ELF))
f9328639
MB
50BIN := $(addprefix $(obj),$(BIN))
51SREC := $(addprefix $(obj),$(SREC))
717b5aad 52
8386ca8b 53gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
c29fdfc1 54
620bbba5
PT
55# For PowerPC there's no need to compile standalone applications as a
56# relocatable executable. The relocation data is not needed, and
57# also causes the entry point of the standalone application to be
58# inconsistent.
59ifeq ($(ARCH),powerpc)
60AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
61CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
62CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
63endif
64
c91d456c
PT
65# We don't want gcc reordering functions if possible. This ensures that an
66# application's entry point will be the first function in the application's
67# source file.
cca4e4ae
WD
68CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
69CFLAGS += $(CFLAGS_NTR)
c91d456c 70
96582987 71all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
717b5aad
WD
72
73#########################################################################
f9328639 74$(LIB): $(obj).depend $(LIBOBJS)
6d8962e8 75 $(call cmd_link_o_target, $(LIBOBJS))
717b5aad 76
96582987 77$(ELF):
f9328639 78$(obj)%: $(obj)%.o $(LIB)
e0e7f3b2 79 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
0858b835 80 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
8386ca8b 81 -L$(gcclibdir) -lgcc
96582987
WD
82
83$(SREC):
f9328639
MB
84$(obj)%.srec: $(obj)%
85 $(OBJCOPY) -O srec $< $@ 2>/dev/null
717b5aad 86
96582987 87$(BIN):
f9328639
MB
88$(obj)%.bin: $(obj)%
89 $(OBJCOPY) -O binary $< $@ 2>/dev/null
dc7c9a1a 90
717b5aad
WD
91#########################################################################
92
f9328639
MB
93# defines $(obj).depend target
94include $(SRCTREE)/rules.mk
717b5aad 95
f9328639 96sinclude $(obj).depend
717b5aad
WD
97
98#########################################################################