wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 1 | # |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 2 | # (C) Copyright 2000-2006 |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 3 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | # |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0+ |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 6 | # |
| 7 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 8 | include $(TOPDIR)/config.mk |
| 9 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 10 | ELF-y := hello_world |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 11 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 12 | ELF-$(CONFIG_SMC91111) += smc91111_eeprom |
| 13 | ELF-$(CONFIG_SMC911X) += smc911x_eeprom |
| 14 | ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
Masahiro Yamada | 71db754 | 2013-11-28 12:09:59 +0900 | [diff] [blame] | 15 | ELF-$(CONFIG_MPC5xxx) += interrupt |
| 16 | ELF-$(CONFIG_8xx) += test_burst timer |
| 17 | ELF-$(CONFIG_8260) += mem_to_mem_idma2intr |
| 18 | ELF-$(CONFIG_PPC) += sched |
Mike Frysinger | 0f4964a | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 19 | |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 20 | # |
| 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 Yamada | 71db754 | 2013-11-28 12:09:59 +0900 | [diff] [blame] | 25 | ELF := $(strip $(ELF-y)) |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 26 | |
Che-liang Chiou | 4234bf3 | 2011-02-21 21:07:00 +0000 | [diff] [blame] | 27 | SREC := $(addsuffix .srec,$(ELF)) |
| 28 | BIN := $(addsuffix .bin,$(ELF)) |
wdenk | e339a7a | 2005-05-07 19:06:32 +0000 | [diff] [blame] | 29 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 30 | COBJS := $(ELF:=.o) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 31 | |
Sebastien Carlier | a8d426f | 2010-11-05 15:48:07 +0100 | [diff] [blame] | 32 | LIB = $(obj)libstubs.o |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 33 | |
Masahiro Yamada | 71db754 | 2013-11-28 12:09:59 +0900 | [diff] [blame] | 34 | LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o |
| 35 | LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o |
| 36 | LIBAOBJS := $(LIBAOBJS-y) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 37 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 38 | LIBCOBJS = stubs.o |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 39 | |
| 40 | LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS)) |
| 41 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 42 | SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 43 | OBJS := $(addprefix $(obj),$(COBJS)) |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 44 | ELF := $(addprefix $(obj),$(ELF)) |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 45 | BIN := $(addprefix $(obj),$(BIN)) |
| 46 | SREC := $(addprefix $(obj),$(SREC)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 47 | |
Tom Rini | c98feda | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 48 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 49 | |
Peter Tyser | 29764ee | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 50 | # 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. |
| 54 | ifeq ($(ARCH),powerpc) |
| 55 | AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS)) |
| 56 | CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS)) |
| 57 | CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS)) |
| 58 | endif |
| 59 | |
Peter Tyser | 4bbc082 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 60 | # 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 Denk | 9209ed5 | 2011-11-01 20:54:02 +0000 | [diff] [blame] | 63 | CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder) |
| 64 | CFLAGS += $(CFLAGS_NTR) |
Peter Tyser | 4bbc082 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 65 | |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 66 | all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 67 | |
| 68 | ######################################################################### |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 69 | $(LIB): $(obj).depend $(LIBOBJS) |
Sebastien Carlier | a8d426f | 2010-11-05 15:48:07 +0100 | [diff] [blame] | 70 | $(call cmd_link_o_target, $(LIBOBJS)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 71 | |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 72 | $(ELF): |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 73 | $(obj)%: $(obj)%.o $(LIB) |
Marek Vasut | 3ee93d3 | 2012-03-06 00:44:22 +0100 | [diff] [blame] | 74 | $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \ |
Mike Frysinger | a13ad8e | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 75 | -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \ |
Tom Rini | c98feda | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 76 | -L$(gcclibdir) -lgcc |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 77 | |
| 78 | $(SREC): |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 79 | $(obj)%.srec: $(obj)% |
| 80 | $(OBJCOPY) -O srec $< $@ 2>/dev/null |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 81 | |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 82 | $(BIN): |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 83 | $(obj)%.bin: $(obj)% |
| 84 | $(OBJCOPY) -O binary $< $@ 2>/dev/null |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 85 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 86 | ######################################################################### |
| 87 | |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 88 | # defines $(obj).depend target |
| 89 | include $(SRCTREE)/rules.mk |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 90 | |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 91 | sinclude $(obj).depend |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 92 | |
| 93 | ######################################################################### |