blob: 4d152eee9c09eececc70309ea25aa48393d8438a [file] [log] [blame]
Simon Glass151ba362017-11-12 21:52:07 -07001#
Simon Glass93a806f2019-08-24 07:22:59 -06002# Builds test programs. This is launched from elf_test.BuildElfTestFiles()
Simon Glass151ba362017-11-12 21:52:07 -07003#
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 Yasake475c5c2020-09-06 14:46:04 +030010HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ )
11ifeq ($(findstring $(HOSTARCH),"x86" "x86_64"),)
12ifeq ($(findstring $(MAKECMDGOALS),"help" "clean"),)
13ifndef 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)
16endif
17endif
18endif
19
20CC = $(CROSS_COMPILE)gcc
21OBJCOPY = $(CROSS_COMPILE)objcopy
22
Simon Glassf6290892019-08-24 07:22:53 -060023VPATH := $(SRC)
Alper Nebi Yasakd6d2c9b2022-06-18 15:13:09 +030024CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include -I $(SRC) \
Simon Glass5d0c0262019-08-24 07:22:56 -060025 -Wl,--no-dynamic-linker
Simon Glass151ba362017-11-12 21:52:07 -070026
Simon Glass4affd4b2019-08-24 07:22:54 -060027LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
Simon Glass5d0c0262019-08-24 07:22:56 -060028LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
Simon Glass46ea6912019-08-24 07:22:58 -060029LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
Simon Glass72555fa2019-11-06 17:22:44 -070030LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
Simon Glassadfb8492021-11-03 21:09:18 -060031LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds
Simon Glass167070a2022-02-08 11:49:59 -070032LDS_EFL_SECTIONS := -T $(SRC)elf_sections.lds
Simon Glasse0035c92023-01-11 16:10:17 -070033LDS_BLOB := -T $(SRC)blob_syms.lds
Simon Glass151ba362017-11-12 21:52:07 -070034
Simon Glass83b8bfe2023-07-18 07:24:01 -060035TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data bss_data_zero \
Simon Glassff339252017-11-13 18:54:58 -070036 u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
Simon Glassadfb8492021-11-03 21:09:18 -060037 u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \
Simon Glasse0035c92023-01-11 16:10:17 -070038 u_boot_binman_embed u_boot_binman_embed_sm elf_sections blob_syms.bin
Simon Glass151ba362017-11-12 21:52:07 -070039
40all: $(TARGETS)
41
42u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
43u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
44
45u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
46u_boot_ucode_ptr: u_boot_ucode_ptr.c
47
Simon Glassf6290892019-08-24 07:22:53 -060048bss_data: CFLAGS += $(SRC)bss_data.lds
Simon Glass7f94e832017-11-12 21:52:25 -070049bss_data: bss_data.c
50
Simon Glass83b8bfe2023-07-18 07:24:01 -060051bss_data_zero: CFLAGS += $(SRC)bss_data_zero.lds
52bss_data_zero: bss_data_zero.c
53
Simon Glassa4e259e2021-11-03 21:09:16 -060054embed_data: CFLAGS += $(SRC)embed_data.lds
55embed_data: embed_data.c
56
Simon Glassff339252017-11-13 18:54:58 -070057u_boot_binman_syms.bin: u_boot_binman_syms
Alper Nebi Yasake475c5c2020-09-06 14:46:04 +030058 $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
Simon Glassff339252017-11-13 18:54:58 -070059
60u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
61u_boot_binman_syms: u_boot_binman_syms.c
62
Simon Glass72555fa2019-11-06 17:22:44 -070063u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
64u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
65
Simon Glassff339252017-11-13 18:54:58 -070066u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
67u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
68
69u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
70u_boot_binman_syms_size: u_boot_binman_syms_size.c
71
Simon Glassadfb8492021-11-03 21:09:18 -060072u_boot_binman_embed: CFLAGS += $(LDS_BINMAN_EMBED)
73u_boot_binman_embed: u_boot_binman_embed.c
74
75u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED)
76u_boot_binman_embed_sm: u_boot_binman_embed_sm.c
77
Simon Glasse0035c92023-01-11 16:10:17 -070078blob_syms.bin: blob_syms
79 $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
80
81blob_syms: CFLAGS += $(LDS_BLOB)
82blob_syms: blob_syms.c
83
Simon Glass167070a2022-02-08 11:49:59 -070084elf_sections: CFLAGS += $(LDS_EFL_SECTIONS)
85elf_sections: elf_sections.c
86
Simon Glass151ba362017-11-12 21:52:07 -070087clean:
88 rm -f $(TARGETS)
89
90help:
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"