blob: 0b19b7d99358569351358963008c6e8a37feda74 [file] [log] [blame]
Simon Glass00ebd1f2017-11-12 21:52:07 -07001#
Simon Glassc9a0b272019-08-24 07:22:59 -06002# Builds test programs. This is launched from elf_test.BuildElfTestFiles()
Simon Glass00ebd1f2017-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 Yasak5ac76872020-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 Glass53e22bf2019-08-24 07:22:53 -060023VPATH := $(SRC)
Simon Glass1542c8b2019-08-24 07:22:56 -060024CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include \
25 -Wl,--no-dynamic-linker
Simon Glass00ebd1f2017-11-12 21:52:07 -070026
Simon Glassf514d8f2019-08-24 07:22:54 -060027LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
Simon Glass1542c8b2019-08-24 07:22:56 -060028LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
Simon Glass8dc60f92019-08-24 07:22:58 -060029LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
Simon Glass7c150132019-11-06 17:22:44 -070030LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
Simon Glass00ebd1f2017-11-12 21:52:07 -070031
Simon Glass5cfcf7e2017-11-13 18:54:58 -070032TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
33 u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
Simon Glass7c150132019-11-06 17:22:44 -070034 u_boot_binman_syms_size u_boot_binman_syms_x86
Simon Glass00ebd1f2017-11-12 21:52:07 -070035
36all: $(TARGETS)
37
38u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
39u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
40
41u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
42u_boot_ucode_ptr: u_boot_ucode_ptr.c
43
Simon Glass53e22bf2019-08-24 07:22:53 -060044bss_data: CFLAGS += $(SRC)bss_data.lds
Simon Glass56509842017-11-12 21:52:25 -070045bss_data: bss_data.c
46
Simon Glass5cfcf7e2017-11-13 18:54:58 -070047u_boot_binman_syms.bin: u_boot_binman_syms
Alper Nebi Yasak5ac76872020-09-06 14:46:04 +030048 $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
Simon Glass5cfcf7e2017-11-13 18:54:58 -070049
50u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
51u_boot_binman_syms: u_boot_binman_syms.c
52
Simon Glass7c150132019-11-06 17:22:44 -070053u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
54u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
55
Simon Glass5cfcf7e2017-11-13 18:54:58 -070056u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
57u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
58
59u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
60u_boot_binman_syms_size: u_boot_binman_syms_size.c
61
Simon Glass00ebd1f2017-11-12 21:52:07 -070062clean:
63 rm -f $(TARGETS)
64
65help:
66 @echo "Makefile for binman test programs"
67 @echo
68 @echo "Intended for use on x86 hosts"
69 @echo
70 @echo "Targets:"
71 @echo
72 @echo -e "\thelp - Print help (this is it!)"
73 @echo -e "\tall - Builds test programs (default targget)"
74 @echo -e "\tclean - Delete output files"