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 | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 35 | TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \ |
| 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 | a4e259e | 2021-11-03 21:09:16 -0600 | [diff] [blame] | 51 | embed_data: CFLAGS += $(SRC)embed_data.lds |
| 52 | embed_data: embed_data.c |
| 53 | |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 54 | u_boot_binman_syms.bin: u_boot_binman_syms |
Alper Nebi Yasak | e475c5c | 2020-09-06 14:46:04 +0300 | [diff] [blame] | 55 | $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@ |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 56 | |
| 57 | u_boot_binman_syms: CFLAGS += $(LDS_BINMAN) |
| 58 | u_boot_binman_syms: u_boot_binman_syms.c |
| 59 | |
Simon Glass | 72555fa | 2019-11-06 17:22:44 -0700 | [diff] [blame] | 60 | u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86) |
| 61 | u_boot_binman_syms_x86: u_boot_binman_syms_x86.c |
| 62 | |
Simon Glass | ff33925 | 2017-11-13 18:54:58 -0700 | [diff] [blame] | 63 | u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD) |
| 64 | u_boot_binman_syms_bad: u_boot_binman_syms_bad.c |
| 65 | |
| 66 | u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN) |
| 67 | u_boot_binman_syms_size: u_boot_binman_syms_size.c |
| 68 | |
Simon Glass | adfb849 | 2021-11-03 21:09:18 -0600 | [diff] [blame] | 69 | u_boot_binman_embed: CFLAGS += $(LDS_BINMAN_EMBED) |
| 70 | u_boot_binman_embed: u_boot_binman_embed.c |
| 71 | |
| 72 | u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED) |
| 73 | u_boot_binman_embed_sm: u_boot_binman_embed_sm.c |
| 74 | |
Simon Glass | e0035c9 | 2023-01-11 16:10:17 -0700 | [diff] [blame] | 75 | blob_syms.bin: blob_syms |
| 76 | $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@ |
| 77 | |
| 78 | blob_syms: CFLAGS += $(LDS_BLOB) |
| 79 | blob_syms: blob_syms.c |
| 80 | |
Simon Glass | 167070a | 2022-02-08 11:49:59 -0700 | [diff] [blame] | 81 | elf_sections: CFLAGS += $(LDS_EFL_SECTIONS) |
| 82 | elf_sections: elf_sections.c |
| 83 | |
Simon Glass | 151ba36 | 2017-11-12 21:52:07 -0700 | [diff] [blame] | 84 | clean: |
| 85 | rm -f $(TARGETS) |
| 86 | |
| 87 | help: |
| 88 | @echo "Makefile for binman test programs" |
| 89 | @echo |
| 90 | @echo "Intended for use on x86 hosts" |
| 91 | @echo |
| 92 | @echo "Targets:" |
| 93 | @echo |
| 94 | @echo -e "\thelp - Print help (this is it!)" |
| 95 | @echo -e "\tall - Builds test programs (default targget)" |
| 96 | @echo -e "\tclean - Delete output files" |