blob: 6e7500dc75db870b02628de5802311488e8bce1b [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
wdenk717b5aa2002-04-27 11:09:31 +00008include $(TOPDIR)/config.mk
9
Mike Frysinger557555f2009-09-04 19:54:45 -040010ELF-y := hello_world
wdenk717b5aa2002-04-27 11:09:31 +000011
Mike Frysinger557555f2009-09-04 19:54:45 -040012ELF-$(CONFIG_SMC91111) += smc91111_eeprom
13ELF-$(CONFIG_SMC911X) += smc911x_eeprom
14ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
Masahiro Yamadae8a8b822013-11-28 12:09:59 +090015# TODO:
16# - Fix the warning of 82559_eeprom.c and uncomment the following
17# or
18# - Delete 82559_eeprom.c and the following line
19#ELF-$(CONFIG_X86) += 82559_eeprom
20ELF-$(CONFIG_MPC5xxx) += interrupt
21ELF-$(CONFIG_8xx) += test_burst timer
22ELF-$(CONFIG_8260) += mem_to_mem_idma2intr
23ELF-$(CONFIG_PPC) += sched
Mike Frysinger65f6f072009-07-23 16:37:03 -040024
Sanjeev Premi604f7ce2009-11-09 22:43:00 +053025#
26# Some versions of make do not handle trailing white spaces properly;
27# leading to build failures. The problem was found with GNU Make 3.80.
28# Using 'strip' as a workaround for the problem.
29#
Masahiro Yamadae8a8b822013-11-28 12:09:59 +090030ELF := $(strip $(ELF-y))
Sanjeev Premi604f7ce2009-11-09 22:43:00 +053031
Che-liang Chiou0da43892011-02-21 21:07:00 +000032SREC := $(addsuffix .srec,$(ELF))
33BIN := $(addsuffix .bin,$(ELF))
wdenk931da932005-05-07 19:06:32 +000034
Mike Frysinger557555f2009-09-04 19:54:45 -040035COBJS := $(ELF:=.o)
wdenk717b5aa2002-04-27 11:09:31 +000036
Sebastien Carlier6d8962e2010-11-05 15:48:07 +010037LIB = $(obj)libstubs.o
Mike Frysinger557555f2009-09-04 19:54:45 -040038
Masahiro Yamadae8a8b822013-11-28 12:09:59 +090039LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
40LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
41LIBAOBJS := $(LIBAOBJS-y)
Mike Frysinger557555f2009-09-04 19:54:45 -040042
43LIBCOBJS = stubs.o
Marian Balakowiczf9328632006-09-01 19:49:50 +020044
45LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
46
Mike Frysinger557555f2009-09-04 19:54:45 -040047SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
Marian Balakowiczf9328632006-09-01 19:49:50 +020048OBJS := $(addprefix $(obj),$(COBJS))
Wolfgang Denk96582982006-10-24 13:55:18 +020049ELF := $(addprefix $(obj),$(ELF))
Marian Balakowiczf9328632006-09-01 19:49:50 +020050BIN := $(addprefix $(obj),$(BIN))
51SREC := $(addprefix $(obj),$(SREC))
wdenk717b5aa2002-04-27 11:09:31 +000052
Tom Rini8386ca82013-09-10 09:51:44 -040053gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
wdenkc29fdfc2003-08-29 20:57:53 +000054
Peter Tyser620bbba2010-06-15 21:48:25 +020055# 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.
59ifeq ($(ARCH),powerpc)
60AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
61CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
62CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
63endif
64
Peter Tyserc91d4562010-09-12 17:38:49 -050065# 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.
Wolfgang Denkcca4e4a2011-11-01 20:54:02 +000068CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
69CFLAGS += $(CFLAGS_NTR)
Peter Tyserc91d4562010-09-12 17:38:49 -050070
Wolfgang Denk96582982006-10-24 13:55:18 +020071all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
wdenk717b5aa2002-04-27 11:09:31 +000072
73#########################################################################
Marian Balakowiczf9328632006-09-01 19:49:50 +020074$(LIB): $(obj).depend $(LIBOBJS)
Sebastien Carlier6d8962e2010-11-05 15:48:07 +010075 $(call cmd_link_o_target, $(LIBOBJS))
wdenk717b5aa2002-04-27 11:09:31 +000076
Wolfgang Denk96582982006-10-24 13:55:18 +020077$(ELF):
Marian Balakowiczf9328632006-09-01 19:49:50 +020078$(obj)%: $(obj)%.o $(LIB)
Marek Vasute0e7f3b2012-03-06 00:44:22 +010079 $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
Mike Frysinger0858b832008-02-04 19:26:55 -050080 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
Tom Rini8386ca82013-09-10 09:51:44 -040081 -L$(gcclibdir) -lgcc
Wolfgang Denk96582982006-10-24 13:55:18 +020082
83$(SREC):
Marian Balakowiczf9328632006-09-01 19:49:50 +020084$(obj)%.srec: $(obj)%
85 $(OBJCOPY) -O srec $< $@ 2>/dev/null
wdenk717b5aa2002-04-27 11:09:31 +000086
Wolfgang Denk96582982006-10-24 13:55:18 +020087$(BIN):
Marian Balakowiczf9328632006-09-01 19:49:50 +020088$(obj)%.bin: $(obj)%
89 $(OBJCOPY) -O binary $< $@ 2>/dev/null
wdenkdc7c9a12003-03-26 06:55:25 +000090
wdenk717b5aa2002-04-27 11:09:31 +000091#########################################################################
92
Marian Balakowiczf9328632006-09-01 19:49:50 +020093# defines $(obj).depend target
94include $(SRCTREE)/rules.mk
wdenk717b5aa2002-04-27 11:09:31 +000095
Marian Balakowiczf9328632006-09-01 19:49:50 +020096sinclude $(obj).depend
wdenk717b5aa2002-04-27 11:09:31 +000097
98#########################################################################