Merge tag 'xilinx-for-v2021.01' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / tools / binman / test / Makefile
1 #
2 # Builds test programs. This is launched from elf_test.BuildElfTestFiles()
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
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
23 VPATH := $(SRC)
24 CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include \
25         -Wl,--no-dynamic-linker
26
27 LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
28 LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
29 LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
30 LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
31
32 TARGETS = 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 \
34         u_boot_binman_syms_size u_boot_binman_syms_x86
35
36 all: $(TARGETS)
37
38 u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
39 u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
40
41 u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
42 u_boot_ucode_ptr: u_boot_ucode_ptr.c
43
44 bss_data: CFLAGS += $(SRC)bss_data.lds
45 bss_data: bss_data.c
46
47 u_boot_binman_syms.bin: u_boot_binman_syms
48         $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
49
50 u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
51 u_boot_binman_syms: u_boot_binman_syms.c
52
53 u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
54 u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
55
56 u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
57 u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
58
59 u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
60 u_boot_binman_syms_size: u_boot_binman_syms_size.c
61
62 clean:
63         rm -f $(TARGETS)
64
65 help:
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"