Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 1 | # |
Simon Glass | 93a806f | 2019-08-24 07:22:59 -0600 | [diff] [blame] | 2 | # Builds test programs. This is launched from elf_test.BuildElfTestFiles() |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 3 | # |
| 4 | # Copyright (C) 2017 Google, Inc |
| 5 | # Written by Simon Glass <sjg@chromium.org> |
| 6 | # |
| 7 | # SPDX-License-Identifier: GPL-2.0+ |
| 8 | # |
| 9 | |
Alper Nebi Yasak | e475c5c | 2020-09-06 14:46:04 +0300 | [diff] [blame] | 10 | HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ ) |
| 11 | ifeq ($(findstring $(HOSTARCH),"x86" "x86_64"),) |
| 12 | ifeq ($(findstring $(MAKECMDGOALS),"help" "clean"),) |
| 13 | ifndef CROSS_COMPILE |
| 14 | $(error Binman tests need to compile to x86, but the CPU arch of your \ |
| 15 | machine is $(HOSTARCH). Set CROSS_COMPILE to a suitable cross compiler) |
| 16 | endif |
| 17 | endif |
| 18 | endif |
| 19 | |
| 20 | CC = $(CROSS_COMPILE)gcc |
| 21 | OBJCOPY = $(CROSS_COMPILE)objcopy |
| 22 | |
Simon Glass | f629089 | 2019-08-24 07:22:53 -0600 | [diff] [blame] | 23 | VPATH := $(SRC) |
Alper Nebi Yasak | d6d2c9b | 2022-06-18 15:13:09 +0300 | [diff] [blame] | 24 | CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include -I $(SRC) \ |
Simon Glass | 5d0c026 | 2019-08-24 07:22:56 -0600 | [diff] [blame] | 25 | -Wl,--no-dynamic-linker |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 26 | |
Simon Glass | 4affd4b | 2019-08-24 07:22:54 -0600 | [diff] [blame] | 27 | LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds |
Simon Glass | 5d0c026 | 2019-08-24 07:22:56 -0600 | [diff] [blame] | 28 | LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds |
Simon Glass | 46ea691 | 2019-08-24 07:22:58 -0600 | [diff] [blame] | 29 | LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds |
Simon Glass | 72555fa | 2019-11-06 17:22:44 -0700 | [diff] [blame] | 30 | LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds |
Simon Glass | adfb849 | 2021-11-03 21:09:18 -0600 | [diff] [blame] | 31 | LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds |
Simon Glass | 167070a | 2022-02-08 11:49:59 -0700 | [diff] [blame] | 32 | LDS_EFL_SECTIONS := -T $(SRC)elf_sections.lds |
Simon Glass | e0035c9 | 2023-01-11 16:10:17 -0700 | [diff] [blame] | 33 | LDS_BLOB := -T $(SRC)blob_syms.lds |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 34 | |
Simon Glass | 83b8bfe | 2023-07-18 07:24:01 -0600 | [diff] [blame^] | 35 | TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data bss_data_zero \ |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 36 | u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \ |
Simon Glass | adfb849 | 2021-11-03 21:09:18 -0600 | [diff] [blame] | 37 | u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \ |
Simon Glass | e0035c9 | 2023-01-11 16:10:17 -0700 | [diff] [blame] | 38 | u_boot_binman_embed u_boot_binman_embed_sm elf_sections blob_syms.bin |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 39 | |
| 40 | all: $(TARGETS) |
| 41 | |
| 42 | u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE) |
| 43 | u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c |
| 44 | |
| 45 | u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE) |
| 46 | u_boot_ucode_ptr: u_boot_ucode_ptr.c |
| 47 | |
Simon Glass | f629089 | 2019-08-24 07:22:53 -0600 | [diff] [blame] | 48 | bss_data: CFLAGS += $(SRC)bss_data.lds |
Simon Glass | 7f94e83 | 2017-11-12 21:52:25 -0700 | [diff] [blame] | 49 | bss_data: bss_data.c |
| 50 | |
Simon Glass | 83b8bfe | 2023-07-18 07:24:01 -0600 | [diff] [blame^] | 51 | bss_data_zero: CFLAGS += $(SRC)bss_data_zero.lds |
| 52 | bss_data_zero: bss_data_zero.c |
| 53 | |
Simon Glass | a4e259e | 2021-11-03 21:09:16 -0600 | [diff] [blame] | 54 | embed_data: CFLAGS += $(SRC)embed_data.lds |
| 55 | embed_data: embed_data.c |
| 56 | |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 57 | u_boot_binman_syms.bin: u_boot_binman_syms |
Alper Nebi Yasak | e475c5c | 2020-09-06 14:46:04 +0300 | [diff] [blame] | 58 | $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@ |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 59 | |
| 60 | u_boot_binman_syms: CFLAGS += $(LDS_BINMAN) |
| 61 | u_boot_binman_syms: u_boot_binman_syms.c |
| 62 | |
Simon Glass | 72555fa | 2019-11-06 17:22:44 -0700 | [diff] [blame] | 63 | u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86) |
| 64 | u_boot_binman_syms_x86: u_boot_binman_syms_x86.c |
| 65 | |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 66 | u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD) |
| 67 | u_boot_binman_syms_bad: u_boot_binman_syms_bad.c |
| 68 | |
| 69 | u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN) |
| 70 | u_boot_binman_syms_size: u_boot_binman_syms_size.c |
| 71 | |
Simon Glass | adfb849 | 2021-11-03 21:09:18 -0600 | [diff] [blame] | 72 | u_boot_binman_embed: CFLAGS += $(LDS_BINMAN_EMBED) |
| 73 | u_boot_binman_embed: u_boot_binman_embed.c |
| 74 | |
| 75 | u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED) |
| 76 | u_boot_binman_embed_sm: u_boot_binman_embed_sm.c |
| 77 | |
Simon Glass | e0035c9 | 2023-01-11 16:10:17 -0700 | [diff] [blame] | 78 | blob_syms.bin: blob_syms |
| 79 | $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@ |
| 80 | |
| 81 | blob_syms: CFLAGS += $(LDS_BLOB) |
| 82 | blob_syms: blob_syms.c |
| 83 | |
Simon Glass | 167070a | 2022-02-08 11:49:59 -0700 | [diff] [blame] | 84 | elf_sections: CFLAGS += $(LDS_EFL_SECTIONS) |
| 85 | elf_sections: elf_sections.c |
| 86 | |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 87 | clean: |
| 88 | rm -f $(TARGETS) |
| 89 | |
| 90 | help: |
| 91 | @echo "Makefile for binman test programs" |
| 92 | @echo |
| 93 | @echo "Intended for use on x86 hosts" |
| 94 | @echo |
| 95 | @echo "Targets:" |
| 96 | @echo |
| 97 | @echo -e "\thelp - Print help (this is it!)" |
| 98 | @echo -e "\tall - Builds test programs (default targget)" |
| 99 | @echo -e "\tclean - Delete output files" |