Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 2 | # |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 3 | # (C) Copyright 2000-2006 |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 4 | # Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 5 | |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 6 | extra-y := hello_world |
| 7 | extra-$(CONFIG_SMC91111) += smc91111_eeprom |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 8 | extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 9 | extra-$(CONFIG_PPC) += sched |
Mike Frysinger | 65f6f07 | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 10 | |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 11 | # |
| 12 | # Some versions of make do not handle trailing white spaces properly; |
| 13 | # leading to build failures. The problem was found with GNU Make 3.80. |
| 14 | # Using 'strip' as a workaround for the problem. |
| 15 | # |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 16 | ELF := $(strip $(extra-y)) |
Sanjeev Premi | 604f7ce | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 17 | |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 18 | extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y)) |
Masahiro Yamada | 8e71443 | 2014-09-05 01:56:52 +0900 | [diff] [blame] | 19 | clean-files := *.srec *.bin |
Masahiro Yamada | 4a20df3 | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 20 | |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 21 | COBJS := $(ELF:=.o) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 22 | |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 23 | LIB = $(obj)/libstubs.o |
Mike Frysinger | 557555f | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 24 | |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 25 | LIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 26 | LIBOBJS-y += stubs.o |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 27 | |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 28 | targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y) |
Masahiro Yamada | 6825a95 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 29 | |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 30 | LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y)) |
Masahiro Yamada | 9e41403 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 31 | ELF := $(addprefix $(obj)/,$(ELF)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 32 | |
Peter Tyser | 620bbba | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 33 | # For PowerPC there's no need to compile standalone applications as a |
| 34 | # relocatable executable. The relocation data is not needed, and |
| 35 | # also causes the entry point of the standalone application to be |
| 36 | # inconsistent. |
Masahiro Yamada | 026f9cf | 2014-03-05 16:59:40 +0900 | [diff] [blame] | 37 | ifeq ($(CONFIG_PPC),y) |
| 38 | PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS)) |
Peter Tyser | 620bbba | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 39 | endif |
| 40 | |
Peter Tyser | c91d456 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 41 | # We don't want gcc reordering functions if possible. This ensures that an |
| 42 | # application's entry point will be the first function in the application's |
| 43 | # source file. |
Masahiro Yamada | 6825a95 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 44 | ccflags-y += $(call cc-option,-fno-toplevel-reorder) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 45 | |
Daniel Schwierzeck | 1d3b97c | 2018-09-23 19:15:15 +0200 | [diff] [blame] | 46 | LDFLAGS_STANDALONE += -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) |
| 47 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 48 | ######################################################################### |
Masahiro Yamada | 6825a95 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 49 | |
| 50 | quiet_cmd_link_lib = LD $@ |
| 51 | cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^) |
| 52 | |
| 53 | $(LIB): $(LIBOBJS) FORCE |
| 54 | $(call if_changed,link_lib) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 55 | |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 56 | quiet_cmd_link_elf = LD $@ |
Tom Rini | 587e4a4 | 2020-03-27 11:46:27 -0400 | [diff] [blame] | 57 | cmd_link_elf = $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_STANDALONE) -g \ |
Alexey Brodkin | e75e73d | 2014-05-16 12:54:17 +0400 | [diff] [blame] | 58 | -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC) |
Masahiro Yamada | 04a34c9 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 59 | |
| 60 | $(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE |
| 61 | $(call if_changed,link_elf) |
Wolfgang Denk | 9658298 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 62 | |
Daniel Schwierzeck | d3a9ba7 | 2018-09-23 19:15:16 +0200 | [diff] [blame] | 63 | $(obj)/%.srec: OBJCOPYFLAGS += -O srec |
Masahiro Yamada | f9c235f | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 64 | $(obj)/%.srec: $(obj)/% FORCE |
| 65 | $(call if_changed,objcopy) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 66 | |
Daniel Schwierzeck | d3a9ba7 | 2018-09-23 19:15:16 +0200 | [diff] [blame] | 67 | $(obj)/%.bin: OBJCOPYFLAGS += -O binary |
Masahiro Yamada | f9c235f | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 68 | $(obj)/%.bin: $(obj)/% FORCE |
| 69 | $(call if_changed,objcopy) |
Albert ARIBAUD | 62e9207 | 2015-10-23 18:06:40 +0200 | [diff] [blame] | 70 | |
| 71 | # some files can only build in ARM or THUMB2, not THUMB1 |
| 72 | |
| 73 | ifdef CONFIG_SYS_THUMB_BUILD |
| 74 | ifndef CONFIG_HAS_THUMB2 |
| 75 | |
| 76 | CFLAGS_stubs.o := -marm |
| 77 | |
| 78 | endif |
| 79 | endif |