blob: 0841c758ff9660e33123ef00ab234bf85d32de65 [file] [log] [blame]
wdenk717b5aa2002-04-27 11:09:31 +00001#
Marian Balakowiczd62379d2006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenk717b5aa2002-04-27 11:09:31 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk717b5aa2002-04-27 11:09:31 +00006#
7
wdenk717b5aa2002-04-27 11:09:31 +00008include $(TOPDIR)/config.mk
9
Mike Frysinger659c60d2009-09-04 19:54:45 -040010ELF-y := hello_world
wdenk717b5aa2002-04-27 11:09:31 +000011
Mike Frysinger659c60d2009-09-04 19:54:45 -040012ELF-$(CONFIG_SMC91111) += smc91111_eeprom
13ELF-$(CONFIG_SMC911X) += smc911x_eeprom
14ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
Masahiro Yamada71db7542013-11-28 12:09:59 +090015ELF-$(CONFIG_MPC5xxx) += interrupt
16ELF-$(CONFIG_8xx) += test_burst timer
17ELF-$(CONFIG_8260) += mem_to_mem_idma2intr
18ELF-$(CONFIG_PPC) += sched
Mike Frysinger0f4964a2009-07-23 16:37:03 -040019
Sanjeev Premi68db2352009-11-09 22:43:00 +053020#
21# Some versions of make do not handle trailing white spaces properly;
22# leading to build failures. The problem was found with GNU Make 3.80.
23# Using 'strip' as a workaround for the problem.
24#
Masahiro Yamada71db7542013-11-28 12:09:59 +090025ELF := $(strip $(ELF-y))
Sanjeev Premi68db2352009-11-09 22:43:00 +053026
Che-liang Chiou4234bf32011-02-21 21:07:00 +000027SREC := $(addsuffix .srec,$(ELF))
28BIN := $(addsuffix .bin,$(ELF))
wdenke339a7a2005-05-07 19:06:32 +000029
Mike Frysinger659c60d2009-09-04 19:54:45 -040030COBJS := $(ELF:=.o)
wdenkabda5ca2003-05-31 18:35:21 +000031
Sebastien Carliera8d426f2010-11-05 15:48:07 +010032LIB = $(obj)libstubs.o
wdenkbd1575f2003-10-14 19:43:55 +000033
Masahiro Yamada71db7542013-11-28 12:09:59 +090034LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
35LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
36LIBAOBJS := $(LIBAOBJS-y)
wdenk717b5aa2002-04-27 11:09:31 +000037
Mike Frysinger659c60d2009-09-04 19:54:45 -040038LIBCOBJS = stubs.o
Marian Balakowiczd62379d2006-09-01 19:49:50 +020039
40LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
41
Mike Frysinger659c60d2009-09-04 19:54:45 -040042SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
Marian Balakowiczd62379d2006-09-01 19:49:50 +020043OBJS := $(addprefix $(obj),$(COBJS))
Wolfgang Denk29be6222006-10-24 13:55:18 +020044ELF := $(addprefix $(obj),$(ELF))
Marian Balakowiczd62379d2006-09-01 19:49:50 +020045BIN := $(addprefix $(obj),$(BIN))
46SREC := $(addprefix $(obj),$(SREC))
wdenk717b5aa2002-04-27 11:09:31 +000047
Tom Rinic98feda2013-09-10 09:51:44 -040048gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
wdenk710e3502003-08-29 20:57:53 +000049
Peter Tyser29764ee2010-06-15 21:48:25 +020050# 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
Peter Tyser4bbc0822010-09-12 17:38:49 -050060# 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.
Wolfgang Denk9209ed52011-11-01 20:54:02 +000063CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
64CFLAGS += $(CFLAGS_NTR)
Peter Tyser4bbc0822010-09-12 17:38:49 -050065
Wolfgang Denk29be6222006-10-24 13:55:18 +020066all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
wdenk717b5aa2002-04-27 11:09:31 +000067
68#########################################################################
Marian Balakowiczd62379d2006-09-01 19:49:50 +020069$(LIB): $(obj).depend $(LIBOBJS)
Sebastien Carliera8d426f2010-11-05 15:48:07 +010070 $(call cmd_link_o_target, $(LIBOBJS))
wdenk717b5aa2002-04-27 11:09:31 +000071
Wolfgang Denk29be6222006-10-24 13:55:18 +020072$(ELF):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020073$(obj)%: $(obj)%.o $(LIB)
Marek Vasut3ee93d32012-03-06 00:44:22 +010074 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
Mike Frysingera13ad8e2008-02-04 19:26:55 -050075 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
Tom Rinic98feda2013-09-10 09:51:44 -040076 -L$(gcclibdir) -lgcc
Wolfgang Denk29be6222006-10-24 13:55:18 +020077
78$(SREC):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020079$(obj)%.srec: $(obj)%
80 $(OBJCOPY) -O srec $< $@ 2>/dev/null
wdenk717b5aa2002-04-27 11:09:31 +000081
Wolfgang Denk29be6222006-10-24 13:55:18 +020082$(BIN):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020083$(obj)%.bin: $(obj)%
84 $(OBJCOPY) -O binary $< $@ 2>/dev/null
wdenkc8434db2003-03-26 06:55:25 +000085
wdenk717b5aa2002-04-27 11:09:31 +000086#########################################################################
87
Marian Balakowiczd62379d2006-09-01 19:49:50 +020088# defines $(obj).depend target
89include $(SRCTREE)/rules.mk
wdenk717b5aa2002-04-27 11:09:31 +000090
Marian Balakowiczd62379d2006-09-01 19:49:50 +020091sinclude $(obj).depend
wdenk717b5aa2002-04-27 11:09:31 +000092
93#########################################################################