Merge branch 'sandbox1' of http://git.denx.de/u-boot-x86
[oweals/u-boot.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 include $(TOPDIR)/config.mk
9
10 ELF-$(ARCH)  :=
11 ELF-$(CPU)   :=
12 ELF-y        := hello_world
13
14 ELF-$(CONFIG_SMC91111)           += smc91111_eeprom
15 ELF-$(CONFIG_SMC911X)            += smc911x_eeprom
16 ELF-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
17 ELF-i386                         += 82559_eeprom
18 ELF-mpc5xxx                      += interrupt
19 ELF-mpc8xx                       += test_burst timer
20 ELF-mpc8260                      += mem_to_mem_idma2intr
21 ELF-ppc                          += sched
22
23 #
24 # Some versions of make do not handle trailing white spaces properly;
25 # leading to build failures. The problem was found with GNU Make 3.80.
26 # Using 'strip' as a workaround for the problem.
27 #
28 ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(CPU)))
29
30 SREC := $(addsuffix .srec,$(ELF))
31 BIN  := $(addsuffix .bin,$(ELF))
32
33 COBJS   := $(ELF:=.o)
34
35 LIB     = $(obj)libstubs.o
36
37 LIBAOBJS-$(ARCH)     :=
38 LIBAOBJS-$(CPU)      :=
39 LIBAOBJS-ppc         += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
40 LIBAOBJS-mpc8xx      += test_burst_lib.o
41 LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
42
43 LIBCOBJS = stubs.o
44
45 LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
46
47 SRCS    := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
48 OBJS    := $(addprefix $(obj),$(COBJS))
49 ELF     := $(addprefix $(obj),$(ELF))
50 BIN     := $(addprefix $(obj),$(BIN))
51 SREC    := $(addprefix $(obj),$(SREC))
52
53 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
54
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.
59 ifeq ($(ARCH),powerpc)
60 AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
61 CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
62 CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
63 endif
64
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.
68 CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
69 CFLAGS += $(CFLAGS_NTR)
70
71 all:    $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
72
73 #########################################################################
74 $(LIB): $(obj).depend $(LIBOBJS)
75         $(call cmd_link_o_target, $(LIBOBJS))
76
77 $(ELF):
78 $(obj)%:        $(obj)%.o $(LIB)
79                 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
80                         -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
81                         -L$(gcclibdir) -lgcc
82
83 $(SREC):
84 $(obj)%.srec:   $(obj)%
85                 $(OBJCOPY) -O srec $< $@ 2>/dev/null
86
87 $(BIN):
88 $(obj)%.bin:    $(obj)%
89                 $(OBJCOPY) -O binary $< $@ 2>/dev/null
90
91 #########################################################################
92
93 # defines $(obj).depend target
94 include $(SRCTREE)/rules.mk
95
96 sinclude $(obj).depend
97
98 #########################################################################