Makefile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ )
  10. ifeq ($(findstring $(HOSTARCH),"x86" "x86_64"),)
  11. ifeq ($(findstring $(MAKECMDGOALS),"help" "clean"),)
  12. ifndef CROSS_COMPILE
  13. $(error Binman tests need to compile to x86, but the CPU arch of your \
  14. machine is $(HOSTARCH). Set CROSS_COMPILE to a suitable cross compiler)
  15. endif
  16. endif
  17. endif
  18. CC = $(CROSS_COMPILE)gcc
  19. OBJCOPY = $(CROSS_COMPILE)objcopy
  20. VPATH := $(SRC)
  21. CFLAGS := -march=i386 -m32 -nostdlib -I $(SRC)../../../include \
  22. -Wl,--no-dynamic-linker
  23. LDS_UCODE := -T $(SRC)u_boot_ucode_ptr.lds
  24. LDS_BINMAN := -T $(SRC)u_boot_binman_syms.lds
  25. LDS_BINMAN_BAD := -T $(SRC)u_boot_binman_syms_bad.lds
  26. LDS_BINMAN_X86 := -T $(SRC)u_boot_binman_syms_x86.lds
  27. TARGETS = u_boot_ucode_ptr u_boot_no_ucode_ptr bss_data \
  28. u_boot_binman_syms u_boot_binman_syms.bin u_boot_binman_syms_bad \
  29. u_boot_binman_syms_size u_boot_binman_syms_x86
  30. all: $(TARGETS)
  31. u_boot_no_ucode_ptr: CFLAGS += $(LDS_UCODE)
  32. u_boot_no_ucode_ptr: u_boot_no_ucode_ptr.c
  33. u_boot_ucode_ptr: CFLAGS += $(LDS_UCODE)
  34. u_boot_ucode_ptr: u_boot_ucode_ptr.c
  35. bss_data: CFLAGS += $(SRC)bss_data.lds
  36. bss_data: bss_data.c
  37. u_boot_binman_syms.bin: u_boot_binman_syms
  38. $(OBJCOPY) -O binary $< -R .note.gnu.build-id $@
  39. u_boot_binman_syms: CFLAGS += $(LDS_BINMAN)
  40. u_boot_binman_syms: u_boot_binman_syms.c
  41. u_boot_binman_syms_x86: CFLAGS += $(LDS_BINMAN_X86)
  42. u_boot_binman_syms_x86: u_boot_binman_syms_x86.c
  43. u_boot_binman_syms_bad: CFLAGS += $(LDS_BINMAN_BAD)
  44. u_boot_binman_syms_bad: u_boot_binman_syms_bad.c
  45. u_boot_binman_syms_size: CFLAGS += $(LDS_BINMAN)
  46. u_boot_binman_syms_size: u_boot_binman_syms_size.c
  47. clean:
  48. rm -f $(TARGETS)
  49. help:
  50. @echo "Makefile for binman test programs"
  51. @echo
  52. @echo "Intended for use on x86 hosts"
  53. @echo
  54. @echo "Targets:"
  55. @echo
  56. @echo -e "\thelp - Print help (this is it!)"
  57. @echo -e "\tall - Builds test programs (default targget)"
  58. @echo -e "\tclean - Delete output files"