blob: 1f8cb61c8bfb94fb0a438d42c47074c7ba112aa4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass3d750d72011-09-26 14:10:39 +00002# Copyright (c) 2011 The Chromium OS Authors.
Simon Glass3d750d72011-09-26 14:10:39 +00003
Masahiro Yamada4869aee2014-07-30 14:08:23 +09004PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
Masahiro Yamada57a11eb2015-03-19 19:42:52 +09005PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
Andy Shevchenko5077f432018-09-03 12:08:10 +03006PLATFORM_CPPFLAGS += -fPIC
Matthias Weisser0d3dd142011-11-29 12:16:40 +01007PLATFORM_LIBS += -lrt
Simon Glassb6f4c1c2020-02-03 07:36:12 -07008SDL_CONFIG ?= sdl2-config
Simon Glass62cf9122013-04-26 02:53:43 +00009
Simon Glassd8e22922015-02-10 18:52:35 -070010# Define this to avoid linking with SDL, which requires SDL libraries
11# This can solve 'sdl-config: Command not found' errors
12ifneq ($(NO_SDL),)
13PLATFORM_CPPFLAGS += -DSANDBOX_NO_SDL
14else
Simon Glass73585b92019-05-18 11:59:47 -060015PLATFORM_LIBS += $(shell $(SDL_CONFIG) --libs)
16PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
Simon Glass0d10f292014-02-27 13:26:17 -070017endif
18
Simon Glass66cf8f72018-11-23 21:29:30 -070019cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
Marek Behún72434932021-05-20 13:24:07 +020020 $(LTO_FINAL_LDFLAGS) \
Marek Behúnf8726852021-05-20 13:24:02 +020021 -Wl,--whole-archive \
22 $(u-boot-main) \
Marek Behún72434932021-05-20 13:24:07 +020023 $(u-boot-keep-syms-lto) \
Marek Behúnf8726852021-05-20 13:24:02 +020024 -Wl,--no-whole-archive \
Masahiro Yamada9f9a4e92014-02-24 11:12:18 +090025 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map
Simon Glass66c164b2014-02-26 15:59:14 -070026
Simon Glass1a3ba622016-07-04 11:57:46 -060027cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
Marek Behún72434932021-05-20 13:24:07 +020028 $(LTO_FINAL_LDFLAGS) \
Simon Glass66cf8f72018-11-23 21:29:30 -070029 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
Marek Behúnf8726852021-05-20 13:24:02 +020030 -Wl,--whole-archive \
31 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
32 $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
Marek Behún72434932021-05-20 13:24:07 +020033 $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
Marek Behúnf8726852021-05-20 13:24:02 +020034 -Wl,--no-whole-archive \
Simon Glass1a3ba622016-07-04 11:57:46 -060035 $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot-spl.map -Wl,--gc-sections)
36
Simon Glass66c164b2014-02-26 15:59:14 -070037CONFIG_ARCH_DEVICE_TREE := sandbox
Heinrich Schuchardt0f675d92019-11-07 08:05:17 +010038
39ifeq ($(HOST_ARCH),$(HOST_ARCH_X86_64))
40EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_x86_64_efi.lds
41EFI_TARGET := --target=efi-app-x86_64
42else ifeq ($(HOST_ARCH),$(HOST_ARCH_X86))
43EFI_LDS := ${SRCDIR}/../../../arch/x86/lib/elf_ia32_efi.lds
44EFI_TARGET := --target=efi-app-ia32
45else ifeq ($(HOST_ARCH),$(HOST_ARCH_AARCH64))
46EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_aarch64_efi.lds
47OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
48 -j .u_boot_list -j .rela.dyn -j .got -j .got.plt \
49 -j .binman_sym_table -j .text_rest \
50 -j .efi_runtime -j .efi_runtime_rel
51else ifeq ($(HOST_ARCH),$(HOST_ARCH_ARM))
52EFI_LDS := ${SRCDIR}/../../../arch/arm/lib/elf_arm_efi.lds
53OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
54 -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn \
55 -j .binman_sym_table -j .text_rest \
56 -j .efi_runtime -j .efi_runtime_rel
57else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV32))
58EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv32_efi.lds
59else ifeq ($(HOST_ARCH),$(HOST_ARCH_RISCV64))
60EFI_LDS := ${SRCDIR}/../../../arch/riscv/lib/elf_riscv64_efi.lds
61endif
62EFI_CRT0 := crt0_sandbox_efi.o
63EFI_RELOC := reloc_sandbox_efi.o
64AFLAGS_crt0_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"
65CFLAGS_reloc_sandbox_efi.o += -DHOST_ARCH="$(HOST_ARCH)"