387ba1633536f52a40783a6ebc26886ed8ca8943
[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 LDS_BINMAN_EMBED := -T $(SRC)u_boot_binman_embed.lds
32
33 TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
34         u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
35         u_boot_binman_syms_size u_boot_binman_syms_x86 embed_data \
36         u_boot_binman_embed u_boot_binman_embed_sm
37
38 all: $(TARGETS)
39
40 u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
41 u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
42
43 u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
44 u_boot_ucode_ptr: u_boot_ucode_ptr.c
45
46 bss_data: CFLAGS += $(SRC)bss_data.lds
47 bss_data: bss_data.c
48
49 embed_data: CFLAGS += $(SRC)embed_data.lds
50 embed_data: embed_data.c
51
52 u_boot_binman_syms.bin: u_boot_binman_syms
53         $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
54
55 u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
56 u_boot_binman_syms: u_boot_binman_syms.c
57
58 u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
59 u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
60
61 u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
62 u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
63
64 u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
65 u_boot_binman_syms_size: u_boot_binman_syms_size.c
66
67 u_boot_binman_embed: CFLAGS += $(LDS_BINMAN_EMBED)
68 u_boot_binman_embed: u_boot_binman_embed.c
69
70 u_boot_binman_embed_sm: CFLAGS += $(LDS_BINMAN_EMBED)
71 u_boot_binman_embed_sm: u_boot_binman_embed_sm.c
72
73 clean:
74         rm -f $(TARGETS)
75
76 help:
77         @echo "Makefile for binman test programs"
78         @echo
79         @echo "Intended for use on x86 hosts"
80         @echo
81         @echo "Targets:"
82         @echo
83         @echo -e "\thelp        - Print help (this is it!)"
84         @echo -e "\tall - Builds test programs (default targget)"
85         @echo -e "\tclean       - Delete output files"