blob: 93469217ef8ad8442bdbaefaf0f8099ea9993607 [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-$(ARCH) :=
Mike Frysinger659c60d2009-09-04 19:54:45 -040011ELF-$(CPU) :=
12ELF-y := hello_world
wdenk717b5aa2002-04-27 11:09:31 +000013
Mike Frysinger659c60d2009-09-04 19:54:45 -040014ELF-$(CONFIG_SMC91111) += smc91111_eeprom
15ELF-$(CONFIG_SMC911X) += smc911x_eeprom
16ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
17ELF-i386 += 82559_eeprom
18ELF-mpc5xxx += interrupt
19ELF-mpc8xx += test_burst timer
20ELF-mpc8260 += mem_to_mem_idma2intr
21ELF-ppc += sched
Mike Frysinger0f4964a2009-07-23 16:37:03 -040022
Sanjeev Premi68db2352009-11-09 22:43:00 +053023#
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#
Masahiro Yamada7e9a74e2013-11-11 12:45:40 +090028ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(CPU)))
Sanjeev Premi68db2352009-11-09 22:43:00 +053029
Che-liang Chiou4234bf32011-02-21 21:07:00 +000030SREC := $(addsuffix .srec,$(ELF))
31BIN := $(addsuffix .bin,$(ELF))
wdenke339a7a2005-05-07 19:06:32 +000032
Mike Frysinger659c60d2009-09-04 19:54:45 -040033COBJS := $(ELF:=.o)
wdenkabda5ca2003-05-31 18:35:21 +000034
Sebastien Carliera8d426f2010-11-05 15:48:07 +010035LIB = $(obj)libstubs.o
wdenkbd1575f2003-10-14 19:43:55 +000036
Mike Frysinger659c60d2009-09-04 19:54:45 -040037LIBAOBJS-$(ARCH) :=
38LIBAOBJS-$(CPU) :=
39LIBAOBJS-ppc += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
40LIBAOBJS-mpc8xx += test_burst_lib.o
41LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
wdenk717b5aa2002-04-27 11:09:31 +000042
Mike Frysinger659c60d2009-09-04 19:54:45 -040043LIBCOBJS = stubs.o
Marian Balakowiczd62379d2006-09-01 19:49:50 +020044
45LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
46
Mike Frysinger659c60d2009-09-04 19:54:45 -040047SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
Marian Balakowiczd62379d2006-09-01 19:49:50 +020048OBJS := $(addprefix $(obj),$(COBJS))
Wolfgang Denk29be6222006-10-24 13:55:18 +020049ELF := $(addprefix $(obj),$(ELF))
Marian Balakowiczd62379d2006-09-01 19:49:50 +020050BIN := $(addprefix $(obj),$(BIN))
51SREC := $(addprefix $(obj),$(SREC))
wdenk717b5aa2002-04-27 11:09:31 +000052
Tom Rinic98feda2013-09-10 09:51:44 -040053gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
wdenk710e3502003-08-29 20:57:53 +000054
wdenk717b5aa2002-04-27 11:09:31 +000055CPPFLAGS += -I..
56
Peter Tyser29764ee2010-06-15 21:48:25 +020057# For PowerPC there's no need to compile standalone applications as a
58# relocatable executable. The relocation data is not needed, and
59# also causes the entry point of the standalone application to be
60# inconsistent.
61ifeq ($(ARCH),powerpc)
62AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
63CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
64CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
65endif
66
Peter Tyser4bbc0822010-09-12 17:38:49 -050067# We don't want gcc reordering functions if possible. This ensures that an
68# application's entry point will be the first function in the application's
69# source file.
Wolfgang Denk9209ed52011-11-01 20:54:02 +000070CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
71CFLAGS += $(CFLAGS_NTR)
Peter Tyser4bbc0822010-09-12 17:38:49 -050072
Wolfgang Denk29be6222006-10-24 13:55:18 +020073all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
wdenk717b5aa2002-04-27 11:09:31 +000074
75#########################################################################
Marian Balakowiczd62379d2006-09-01 19:49:50 +020076$(LIB): $(obj).depend $(LIBOBJS)
Sebastien Carliera8d426f2010-11-05 15:48:07 +010077 $(call cmd_link_o_target, $(LIBOBJS))
wdenk717b5aa2002-04-27 11:09:31 +000078
Wolfgang Denk29be6222006-10-24 13:55:18 +020079$(ELF):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020080$(obj)%: $(obj)%.o $(LIB)
Marek Vasut3ee93d32012-03-06 00:44:22 +010081 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
Mike Frysingera13ad8e2008-02-04 19:26:55 -050082 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
Tom Rinic98feda2013-09-10 09:51:44 -040083 -L$(gcclibdir) -lgcc
Wolfgang Denk29be6222006-10-24 13:55:18 +020084
85$(SREC):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020086$(obj)%.srec: $(obj)%
87 $(OBJCOPY) -O srec $< $@ 2>/dev/null
wdenk717b5aa2002-04-27 11:09:31 +000088
Wolfgang Denk29be6222006-10-24 13:55:18 +020089$(BIN):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020090$(obj)%.bin: $(obj)%
91 $(OBJCOPY) -O binary $< $@ 2>/dev/null
wdenkc8434db2003-03-26 06:55:25 +000092
wdenk717b5aa2002-04-27 11:09:31 +000093#########################################################################
94
Marian Balakowiczd62379d2006-09-01 19:49:50 +020095# defines $(obj).depend target
96include $(SRCTREE)/rules.mk
wdenk717b5aa2002-04-27 11:09:31 +000097
Marian Balakowiczd62379d2006-09-01 19:49:50 +020098sinclude $(obj).depend
wdenk717b5aa2002-04-27 11:09:31 +000099
100#########################################################################