blob: c1dfdce581d8f1823754ab8089ac1b304c52eb58 [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#
5# See file CREDITS for list of people who contributed to this
6# project.
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 2 of
11# the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21# MA 02111-1307 USA
22#
23
wdenk717b5aa2002-04-27 11:09:31 +000024include $(TOPDIR)/config.mk
25
Mike Frysinger659c60d2009-09-04 19:54:45 -040026ELF-$(ARCH) :=
27ELF-$(BOARD) :=
28ELF-$(CPU) :=
29ELF-y := hello_world
wdenk717b5aa2002-04-27 11:09:31 +000030
Mike Frysinger659c60d2009-09-04 19:54:45 -040031ELF-$(CONFIG_SMC91111) += smc91111_eeprom
32ELF-$(CONFIG_SMC911X) += smc911x_eeprom
33ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
34ELF-i386 += 82559_eeprom
35ELF-mpc5xxx += interrupt
36ELF-mpc8xx += test_burst timer
37ELF-mpc8260 += mem_to_mem_idma2intr
38ELF-ppc += sched
39ELF-oxc += eepro100_eeprom
Mike Frysinger0f4964a2009-07-23 16:37:03 -040040
Sanjeev Premi68db2352009-11-09 22:43:00 +053041#
42# Some versions of make do not handle trailing white spaces properly;
43# leading to build failures. The problem was found with GNU Make 3.80.
44# Using 'strip' as a workaround for the problem.
45#
46ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU)))
47
Mike Frysinger659c60d2009-09-04 19:54:45 -040048SREC = $(addsuffix .srec,$(ELF))
49BIN = $(addsuffix .bin,$(ELF))
wdenke339a7a2005-05-07 19:06:32 +000050
Mike Frysinger659c60d2009-09-04 19:54:45 -040051COBJS := $(ELF:=.o)
wdenkabda5ca2003-05-31 18:35:21 +000052
Sebastien Carliera8d426f2010-11-05 15:48:07 +010053LIB = $(obj)libstubs.o
wdenkbd1575f2003-10-14 19:43:55 +000054
Mike Frysinger659c60d2009-09-04 19:54:45 -040055LIBAOBJS-$(ARCH) :=
56LIBAOBJS-$(CPU) :=
57LIBAOBJS-ppc += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
58LIBAOBJS-mpc8xx += test_burst_lib.o
59LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
wdenk717b5aa2002-04-27 11:09:31 +000060
Mike Frysinger659c60d2009-09-04 19:54:45 -040061LIBCOBJS = stubs.o
Marian Balakowiczd62379d2006-09-01 19:49:50 +020062
63LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
64
Mike Frysinger659c60d2009-09-04 19:54:45 -040065SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
Marian Balakowiczd62379d2006-09-01 19:49:50 +020066OBJS := $(addprefix $(obj),$(COBJS))
Wolfgang Denk29be6222006-10-24 13:55:18 +020067ELF := $(addprefix $(obj),$(ELF))
Marian Balakowiczd62379d2006-09-01 19:49:50 +020068BIN := $(addprefix $(obj),$(BIN))
69SREC := $(addprefix $(obj),$(SREC))
wdenk717b5aa2002-04-27 11:09:31 +000070
wdenk710e3502003-08-29 20:57:53 +000071gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
72
wdenk717b5aa2002-04-27 11:09:31 +000073CPPFLAGS += -I..
74
Peter Tyser29764ee2010-06-15 21:48:25 +020075# For PowerPC there's no need to compile standalone applications as a
76# relocatable executable. The relocation data is not needed, and
77# also causes the entry point of the standalone application to be
78# inconsistent.
79ifeq ($(ARCH),powerpc)
80AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
81CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
82CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
83endif
84
Peter Tyser4bbc0822010-09-12 17:38:49 -050085# We don't want gcc reordering functions if possible. This ensures that an
86# application's entry point will be the first function in the application's
87# source file.
88CFLAGS += $(call cc-option,-fno-toplevel-reorder)
89
Wolfgang Denk29be6222006-10-24 13:55:18 +020090all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
wdenk717b5aa2002-04-27 11:09:31 +000091
92#########################################################################
Marian Balakowiczd62379d2006-09-01 19:49:50 +020093$(LIB): $(obj).depend $(LIBOBJS)
Sebastien Carliera8d426f2010-11-05 15:48:07 +010094 $(call cmd_link_o_target, $(LIBOBJS))
wdenk717b5aa2002-04-27 11:09:31 +000095
Wolfgang Denk29be6222006-10-24 13:55:18 +020096$(ELF):
Marian Balakowiczd62379d2006-09-01 19:49:50 +020097$(obj)%: $(obj)%.o $(LIB)
Mike Frysinger5b660442009-09-03 23:12:47 -040098 $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
Mike Frysingera13ad8e2008-02-04 19:26:55 -050099 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200100 -L$(gcclibdir) -lgcc
Wolfgang Denk29be6222006-10-24 13:55:18 +0200101
102$(SREC):
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200103$(obj)%.srec: $(obj)%
104 $(OBJCOPY) -O srec $< $@ 2>/dev/null
wdenk717b5aa2002-04-27 11:09:31 +0000105
Wolfgang Denk29be6222006-10-24 13:55:18 +0200106$(BIN):
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200107$(obj)%.bin: $(obj)%
108 $(OBJCOPY) -O binary $< $@ 2>/dev/null
wdenkc8434db2003-03-26 06:55:25 +0000109
wdenk717b5aa2002-04-27 11:09:31 +0000110#########################################################################
111
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200112# defines $(obj).depend target
113include $(SRCTREE)/rules.mk
wdenk717b5aa2002-04-27 11:09:31 +0000114
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200115sinclude $(obj).depend
wdenk717b5aa2002-04-27 11:09:31 +0000116
117#########################################################################