blob: a6819f7792989db39692deec247ee32bcbea47c9 [file] [log] [blame]
wdenk717b5aa2002-04-27 11:09:31 +00001#
Marian Balakowiczf9328632006-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 Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk717b5aa2002-04-27 11:09:31 +00006#
7
Masahiro Yamadad9580022014-02-04 17:24:23 +09008ifdef FTRACE
9CFLAGS += -finstrument-functions -DFTRACE
10endif
11
Masahiro Yamada4a20df32014-02-04 17:24:12 +090012extra-y := hello_world
13extra-$(CONFIG_SMC91111) += smc91111_eeprom
14extra-$(CONFIG_SMC911X) += smc911x_eeprom
15extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
16extra-$(CONFIG_MPC5xxx) += interrupt
17extra-$(CONFIG_8xx) += test_burst timer
18extra-$(CONFIG_8260) += mem_to_mem_idma2intr
19extra-$(CONFIG_PPC) += sched
Mike Frysinger65f6f072009-07-23 16:37:03 -040020
Sanjeev Premi604f7ce2009-11-09 22:43:00 +053021#
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#
Masahiro Yamada4a20df32014-02-04 17:24:12 +090026ELF := $(strip $(extra-y))
Sanjeev Premi604f7ce2009-11-09 22:43:00 +053027
Masahiro Yamada4a20df32014-02-04 17:24:12 +090028extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
29clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
30
wdenk931da932005-05-07 19:06:32 +000031
Mike Frysinger557555f2009-09-04 19:54:45 -040032COBJS := $(ELF:=.o)
wdenk717b5aa2002-04-27 11:09:31 +000033
Masahiro Yamada9e414032014-02-04 17:24:24 +090034LIB = $(obj)/libstubs.o
Mike Frysinger557555f2009-09-04 19:54:45 -040035
Masahiro Yamadae8a8b822013-11-28 12:09:59 +090036LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
37LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
38LIBAOBJS := $(LIBAOBJS-y)
Mike Frysinger557555f2009-09-04 19:54:45 -040039
40LIBCOBJS = stubs.o
Marian Balakowiczf9328632006-09-01 19:49:50 +020041
Masahiro Yamada9e414032014-02-04 17:24:24 +090042LIBOBJS = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
Marian Balakowiczf9328632006-09-01 19:49:50 +020043
Mike Frysinger557555f2009-09-04 19:54:45 -040044SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
Masahiro Yamada9e414032014-02-04 17:24:24 +090045OBJS := $(addprefix $(obj)/,$(COBJS))
46ELF := $(addprefix $(obj)/,$(ELF))
wdenk717b5aa2002-04-27 11:09:31 +000047
Tom Rini8386ca82013-09-10 09:51:44 -040048gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
wdenkc29fdfc2003-08-29 20:57:53 +000049
Peter Tyser620bbba2010-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 Tyserc91d4562010-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.
Masahiro Yamada4a20df32014-02-04 17:24:12 +090063CFLAGS += $(call cc-option,-fno-toplevel-reorder)
wdenk717b5aa2002-04-27 11:09:31 +000064
65#########################################################################
Masahiro Yamada4a20df32014-02-04 17:24:12 +090066$(LIB): $(LIBOBJS)
Sebastien Carlier6d8962e2010-11-05 15:48:07 +010067 $(call cmd_link_o_target, $(LIBOBJS))
wdenk717b5aa2002-04-27 11:09:31 +000068
Wolfgang Denk96582982006-10-24 13:55:18 +020069$(ELF):
Masahiro Yamada9e414032014-02-04 17:24:24 +090070$(obj)/%: $(obj)/%.o $(LIB)
Marek Vasute0e7f3b2012-03-06 00:44:22 +010071 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
Mike Frysinger0858b832008-02-04 19:26:55 -050072 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
Tom Rini8386ca82013-09-10 09:51:44 -040073 -L$(gcclibdir) -lgcc
Wolfgang Denk96582982006-10-24 13:55:18 +020074
Masahiro Yamada9e414032014-02-04 17:24:24 +090075$(obj)/%.srec: $(obj)/%
Marian Balakowiczf9328632006-09-01 19:49:50 +020076 $(OBJCOPY) -O srec $< $@ 2>/dev/null
wdenk717b5aa2002-04-27 11:09:31 +000077
Masahiro Yamada9e414032014-02-04 17:24:24 +090078$(obj)/%.bin: $(obj)/%
Marian Balakowiczf9328632006-09-01 19:49:50 +020079 $(OBJCOPY) -O binary $< $@ 2>/dev/null