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