Tom Rini | 10e4779 | 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 | d62379d | 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 | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 6 | extra-y := hello_world |
| 7 | extra-$(CONFIG_SMC91111) += smc91111_eeprom |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 8 | extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2 |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 9 | extra-$(CONFIG_PPC) += sched |
Mike Frysinger | 0f4964a | 2009-07-23 16:37:03 -0400 | [diff] [blame] | 10 | |
Marek Vasut | 5539944 | 2020-03-15 17:39:01 +0100 | [diff] [blame^] | 11 | ifndef CONFIG_DM_ETH |
| 12 | extra-$(CONFIG_SMC911X) += smc911x_eeprom |
| 13 | endif |
| 14 | |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 15 | # |
| 16 | # Some versions of make do not handle trailing white spaces properly; |
| 17 | # leading to build failures. The problem was found with GNU Make 3.80. |
| 18 | # Using 'strip' as a workaround for the problem. |
| 19 | # |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 20 | ELF := $(strip $(extra-y)) |
Sanjeev Premi | 68db235 | 2009-11-09 22:43:00 +0530 | [diff] [blame] | 21 | |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 22 | extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y)) |
Masahiro Yamada | 580a5f1 | 2014-09-05 01:56:52 +0900 | [diff] [blame] | 23 | clean-files := *.srec *.bin |
Masahiro Yamada | 6b05dae | 2014-02-04 17:24:12 +0900 | [diff] [blame] | 24 | |
Mike Frysinger | 659c60d | 2009-09-04 19:54:45 -0400 | [diff] [blame] | 25 | COBJS := $(ELF:=.o) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 26 | |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 27 | LIB = $(obj)/libstubs.o |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 28 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 29 | LIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 30 | LIBOBJS-y += stubs.o |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 31 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 32 | targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y) |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 33 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 34 | LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y)) |
Masahiro Yamada | 59f15f2 | 2014-02-04 17:24:24 +0900 | [diff] [blame] | 35 | ELF := $(addprefix $(obj)/,$(ELF)) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 36 | |
Peter Tyser | 29764ee | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 37 | # For PowerPC there's no need to compile standalone applications as a |
| 38 | # relocatable executable. The relocation data is not needed, and |
| 39 | # also causes the entry point of the standalone application to be |
| 40 | # inconsistent. |
Masahiro Yamada | 958fe8f | 2014-03-05 16:59:40 +0900 | [diff] [blame] | 41 | ifeq ($(CONFIG_PPC),y) |
| 42 | PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS)) |
Peter Tyser | 29764ee | 2010-06-15 21:48:25 +0200 | [diff] [blame] | 43 | endif |
| 44 | |
Peter Tyser | 4bbc082 | 2010-09-12 17:38:49 -0500 | [diff] [blame] | 45 | # We don't want gcc reordering functions if possible. This ensures that an |
| 46 | # application's entry point will be the first function in the application's |
| 47 | # source file. |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 48 | ccflags-y += $(call cc-option,-fno-toplevel-reorder) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 49 | |
Daniel Schwierzeck | 9dc13da | 2018-09-23 19:15:15 +0200 | [diff] [blame] | 50 | LDFLAGS_STANDALONE += -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) |
| 51 | |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 52 | ######################################################################### |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 53 | |
| 54 | quiet_cmd_link_lib = LD $@ |
| 55 | cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^) |
| 56 | |
| 57 | $(LIB): $(LIBOBJS) FORCE |
| 58 | $(call if_changed,link_lib) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 59 | |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 60 | quiet_cmd_link_elf = LD $@ |
Tom Rini | 5d4ecf2 | 2020-03-27 11:46:27 -0400 | [diff] [blame] | 61 | cmd_link_elf = $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_STANDALONE) -g \ |
Alexey Brodkin | 80bf416 | 2014-05-16 12:54:17 +0400 | [diff] [blame] | 62 | -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC) |
Masahiro Yamada | 020a1f2 | 2014-02-24 11:12:19 +0900 | [diff] [blame] | 63 | |
| 64 | $(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE |
| 65 | $(call if_changed,link_elf) |
Wolfgang Denk | 29be622 | 2006-10-24 13:55:18 +0200 | [diff] [blame] | 66 | |
Daniel Schwierzeck | 81a0644 | 2018-09-23 19:15:16 +0200 | [diff] [blame] | 67 | $(obj)/%.srec: OBJCOPYFLAGS += -O srec |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 68 | $(obj)/%.srec: $(obj)/% FORCE |
| 69 | $(call if_changed,objcopy) |
wdenk | 717b5aa | 2002-04-27 11:09:31 +0000 | [diff] [blame] | 70 | |
Daniel Schwierzeck | 81a0644 | 2018-09-23 19:15:16 +0200 | [diff] [blame] | 71 | $(obj)/%.bin: OBJCOPYFLAGS += -O binary |
Masahiro Yamada | 734c3ef | 2014-02-24 11:12:14 +0900 | [diff] [blame] | 72 | $(obj)/%.bin: $(obj)/% FORCE |
| 73 | $(call if_changed,objcopy) |
Albert ARIBAUD | a382322 | 2015-10-23 18:06:40 +0200 | [diff] [blame] | 74 | |
| 75 | # some files can only build in ARM or THUMB2, not THUMB1 |
| 76 | |
| 77 | ifdef CONFIG_SYS_THUMB_BUILD |
| 78 | ifndef CONFIG_HAS_THUMB2 |
| 79 | |
| 80 | CFLAGS_stubs.o := -marm |
| 81 | |
| 82 | endif |
| 83 | endif |