xref: /openbmc/u-boot/examples/standalone/Makefile (revision 9e414032)
1#
2# (C) Copyright 2000-2006
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
5# SPDX-License-Identifier:	GPL-2.0+
6#
7
8ifdef FTRACE
9CFLAGS += -finstrument-functions -DFTRACE
10endif
11
12extra-y        := hello_world
13extra-$(CONFIG_SMC91111)           += smc91111_eeprom
14extra-$(CONFIG_SMC911X)            += smc911x_eeprom
15extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
16extra-$(CONFIG_MPC5xxx)            += interrupt
17extra-$(CONFIG_8xx)                += test_burst timer
18extra-$(CONFIG_8260)               += mem_to_mem_idma2intr
19extra-$(CONFIG_PPC)                += sched
20
21#
22# Some versions of make do not handle trailing white spaces properly;
23# leading to build failures. The problem was found with GNU Make 3.80.
24# Using 'strip' as a workaround for the problem.
25#
26ELF := $(strip $(extra-y))
27
28extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
29clean-files  := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
30
31
32COBJS	:= $(ELF:=.o)
33
34LIB	= $(obj)/libstubs.o
35
36LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
37LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
38LIBAOBJS := $(LIBAOBJS-y)
39
40LIBCOBJS = stubs.o
41
42LIBOBJS	= $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
43
44SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
45OBJS	:= $(addprefix $(obj)/,$(COBJS))
46ELF	:= $(addprefix $(obj)/,$(ELF))
47
48gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
49
50# For PowerPC there's no need to compile standalone applications as a
51# relocatable executable.  The relocation data is not needed, and
52# also causes the entry point of the standalone application to be
53# inconsistent.
54ifeq ($(ARCH),powerpc)
55AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
56CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
57CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
58endif
59
60# We don't want gcc reordering functions if possible.  This ensures that an
61# application's entry point will be the first function in the application's
62# source file.
63CFLAGS += $(call cc-option,-fno-toplevel-reorder)
64
65#########################################################################
66$(LIB):	$(LIBOBJS)
67	$(call cmd_link_o_target, $(LIBOBJS))
68
69$(ELF):
70$(obj)/%:	$(obj)/%.o $(LIB)
71		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
72			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
73			-L$(gcclibdir) -lgcc
74
75$(obj)/%.srec:	$(obj)/%
76		$(OBJCOPY) -O srec $< $@ 2>/dev/null
77
78$(obj)/%.bin:	$(obj)/%
79		$(OBJCOPY) -O binary $< $@ 2>/dev/null
80