xref: /openbmc/u-boot/examples/standalone/Makefile (revision f9727161)
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
8include $(TOPDIR)/config.mk
9
10ELF-$(ARCH)  :=
11ELF-$(BOARD) :=
12ELF-$(CPU)   :=
13ELF-y        := hello_world
14
15ELF-$(CONFIG_SMC91111)           += smc91111_eeprom
16ELF-$(CONFIG_SMC911X)            += smc911x_eeprom
17ELF-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
18ELF-i386                         += 82559_eeprom
19ELF-mpc5xxx                      += interrupt
20ELF-mpc8xx                       += test_burst timer
21ELF-mpc8260                      += mem_to_mem_idma2intr
22ELF-ppc                          += sched
23ELF-oxc                          += eepro100_eeprom
24
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#
30ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU)))
31
32SREC := $(addsuffix .srec,$(ELF))
33BIN  := $(addsuffix .bin,$(ELF))
34
35COBJS	:= $(ELF:=.o)
36
37LIB	= $(obj)libstubs.o
38
39LIBAOBJS-$(ARCH)     :=
40LIBAOBJS-$(CPU)      :=
41LIBAOBJS-ppc         += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
42LIBAOBJS-mpc8xx      += test_burst_lib.o
43LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
44
45LIBCOBJS = stubs.o
46
47LIBOBJS	= $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
48
49SRCS	:= $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
50OBJS	:= $(addprefix $(obj),$(COBJS))
51ELF	:= $(addprefix $(obj),$(ELF))
52BIN	:= $(addprefix $(obj),$(BIN))
53SREC	:= $(addprefix $(obj),$(SREC))
54
55gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
56
57CPPFLAGS += -I..
58
59# For PowerPC there's no need to compile standalone applications as a
60# relocatable executable.  The relocation data is not needed, and
61# also causes the entry point of the standalone application to be
62# inconsistent.
63ifeq ($(ARCH),powerpc)
64AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
65CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
66CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
67endif
68
69# We don't want gcc reordering functions if possible.  This ensures that an
70# application's entry point will be the first function in the application's
71# source file.
72CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
73CFLAGS += $(CFLAGS_NTR)
74
75all:	$(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
76
77#########################################################################
78$(LIB):	$(obj).depend $(LIBOBJS)
79	$(call cmd_link_o_target, $(LIBOBJS))
80
81$(ELF):
82$(obj)%:	$(obj)%.o $(LIB)
83		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
84			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
85			-L$(gcclibdir) -lgcc
86
87$(SREC):
88$(obj)%.srec:	$(obj)%
89		$(OBJCOPY) -O srec $< $@ 2>/dev/null
90
91$(BIN):
92$(obj)%.bin:	$(obj)%
93		$(OBJCOPY) -O binary $< $@ 2>/dev/null
94
95#########################################################################
96
97# defines $(obj).depend target
98include $(SRCTREE)/rules.mk
99
100sinclude $(obj).depend
101
102#########################################################################
103