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 | |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 8 | extra-y := hello_world |
| 9 | extra-$(CONFIG_SMC91111) += smc91111_eeprom |
| 10 | extra-$(CONFIG_SMC911X) += smc911x_eeprom |
| 11 | extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
| 12 | extra-$(CONFIG_MPC5xxx) += interrupt |
| 13 | extra-$(CONFIG_8xx) += test_burst timer |
| 14 | extra-$(CONFIG_8260) += mem_to_mem_idma2intr |
| 15 | extra-$(CONFIG_PPC) += sched |
Mike Frysinger | 0f4964a | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 16 | |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 17 | # |
| 18 | # Some versions of make do not handle trailing white spaces properly; |
| 19 | # leading to build failures. The problem was found with GNU Make 3.80. |
| 20 | # Using 'strip' as a workaround for the problem. |
| 21 | # |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 22 | ELF := $(strip $(extra-y)) |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 23 | |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 24 | extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y)) |
| 25 | clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-)) |
| 26 | |
wdenk | e339a7a | 2005-05-07 19:06:32 +0000 | [diff] [blame] | 27 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 28 | COBJS := $(ELF:=.o) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 29 | |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 30 | LIB = $(obj)/libstubs.o |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 31 | |
Masahiro Yamada | 71db754 | 2013-11-28 12:09:59 +0900 | [diff] [blame] | 32 | LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o |
| 33 | LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o |
| 34 | LIBAOBJS := $(LIBAOBJS-y) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 35 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 36 | LIBCOBJS = stubs.o |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 37 | |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 38 | .SECONDARY: $(call objectify,$(COBJS)) |
| 39 | targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBAOBJS) $(LIBCOBJS) |
| 40 | |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 41 | LIBOBJS = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS)) |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 42 | |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 43 | ELF := $(addprefix $(obj)/,$(ELF)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 44 | |
Tom Rini | c98feda | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 45 | gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`) |
wdenk | 710e350 | 2003-08-29 20:57:53 +0000 | [diff] [blame] | 46 | |
Peter Tyser | 29764ee | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 47 | # For PowerPC there's no need to compile standalone applications as a |
| 48 | # relocatable executable. The relocation data is not needed, and |
| 49 | # also causes the entry point of the standalone application to be |
| 50 | # inconsistent. |
| 51 | ifeq ($(ARCH),powerpc) |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 52 | # FIX ME |
| 53 | CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS)) |
Peter Tyser | 29764ee | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 54 | endif |
| 55 | |
Peter Tyser | 4bbc082 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 56 | # We don't want gcc reordering functions if possible. This ensures that an |
| 57 | # application's entry point will be the first function in the application's |
| 58 | # source file. |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 59 | ccflags-y += $(call cc-option,-fno-toplevel-reorder) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 60 | |
| 61 | ######################################################################### |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 62 | |
| 63 | quiet_cmd_link_lib = LD $@ |
| 64 | cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^) |
| 65 | |
| 66 | $(LIB): $(LIBOBJS) FORCE |
| 67 | $(call if_changed,link_lib) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 68 | |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 69 | $(ELF): |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 70 | $(obj)/%: $(obj)/%.o $(LIB) |
Marek Vasut | 3ee93d3 | 2012-03-06 00:44:22 +0100 | [diff] [blame] | 71 | $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \ |
Mike Frysinger | a13ad8e | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 72 | -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \ |
Tom Rini | c98feda | 2013-09-10 09:51:44 -0400 | [diff] [blame] | 73 | -L$(gcclibdir) -lgcc |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 74 | |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame^] | 75 | $(obj)/%.srec: OBJCOPYFLAGS := -O srec |
| 76 | $(obj)/%.srec: $(obj)/% FORCE |
| 77 | $(call if_changed,objcopy) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 78 | |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame^] | 79 | $(obj)/%.bin: OBJCOPYFLAGS := -O binary |
| 80 | $(obj)/%.bin: $(obj)/% FORCE |
| 81 | $(call if_changed,objcopy) |