]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - examples/standalone/Makefile
kbuild: use Linux Kernel build scripts
[karo-tx-uboot.git] / examples / standalone / Makefile
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
8 ifdef FTRACE
9 ccflags-y += -finstrument-functions -DFTRACE
10 endif
11
12 extra-y        := hello_world
13 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
14 extra-$(CONFIG_SMC911X)            += smc911x_eeprom
15 extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
16 extra-$(CONFIG_MPC5xxx)            += interrupt
17 extra-$(CONFIG_8xx)                += test_burst timer
18 extra-$(CONFIG_8260)               += mem_to_mem_idma2intr
19 extra-$(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 #
26 ELF := $(strip $(extra-y))
27
28 extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
29 clean-files  := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
30
31
32 COBJS   := $(ELF:=.o)
33
34 LIB     = $(obj)/libstubs.o
35
36 LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
37 LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
38 LIBAOBJS := $(LIBAOBJS-y)
39
40 LIBCOBJS = stubs.o
41
42 .SECONDARY: $(call objectify,$(COBJS))
43 targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBAOBJS) $(LIBCOBJS)
44
45 LIBOBJS = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
46
47 ELF     := $(addprefix $(obj)/,$(ELF))
48
49 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
50
51 # For PowerPC there's no need to compile standalone applications as a
52 # relocatable executable.  The relocation data is not needed, and
53 # also causes the entry point of the standalone application to be
54 # inconsistent.
55 ifeq ($(ARCH),powerpc)
56 # FIX ME
57 CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS))
58 endif
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.
63 ccflags-y += $(call cc-option,-fno-toplevel-reorder)
64
65 #########################################################################
66
67 quiet_cmd_link_lib = LD      $@
68       cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
69
70 $(LIB): $(LIBOBJS) FORCE
71         $(call if_changed,link_lib)
72
73 $(ELF):
74 $(obj)/%:       $(obj)/%.o $(LIB)
75                 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
76                         -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
77                         -L$(gcclibdir) -lgcc
78
79 $(obj)/%.srec:  $(obj)/%
80                 $(OBJCOPY) -O srec $< $@ 2>/dev/null
81
82 $(obj)/%.bin:   $(obj)/%
83                 $(OBJCOPY) -O binary $< $@ 2>/dev/null