Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #
  2. # Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. PLAT := none
  7. V ?= 0
  8. DEBUG := 0
  9. CRTTOOL ?= cert_create${BIN_EXT}
  10. BINARY := $(notdir ${CRTTOOL})
  11. COT := tbbr
  12. toolchains := host
  13. MAKE_HELPERS_DIRECTORY := ../../make_helpers/
  14. include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
  15. include ${MAKE_HELPERS_DIRECTORY}build_env.mk
  16. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  17. include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
  18. ifneq (${PLAT},none)
  19. TF_PLATFORM_ROOT := ../../plat/
  20. include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
  21. PLAT_CERT_CREATE_HELPER_MK := ${PLAT_DIR}/cert_create_tbbr.mk
  22. endif
  23. # Common source files.
  24. OBJECTS := src/cert.o \
  25. src/cmd_opt.o \
  26. src/ext.o \
  27. src/key.o \
  28. src/main.o \
  29. src/sha.o
  30. # Chain of trust.
  31. ifeq (${COT},tbbr)
  32. include src/tbbr/tbbr.mk
  33. else ifeq (${COT},dualroot)
  34. include src/dualroot/cot.mk
  35. else ifeq (${COT},cca)
  36. include src/cca/cot.mk
  37. else
  38. $(error Unknown chain of trust ${COT})
  39. endif
  40. ifneq (,$(wildcard ${PLAT_CERT_CREATE_HELPER_MK}))
  41. include ${PLAT_CERT_CREATE_HELPER_MK}
  42. endif
  43. # Select OpenSSL version flag according to the OpenSSL build selected
  44. # from setting the OPENSSL_DIR path.
  45. $(eval $(call SELECT_OPENSSL_API_VERSION))
  46. HOSTCCFLAGS := -Wall -std=c99
  47. ifeq (${DEBUG},1)
  48. HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
  49. else
  50. HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
  51. endif
  52. ifeq (${V},0)
  53. Q := @
  54. else
  55. Q :=
  56. endif
  57. HOSTCCFLAGS += ${DEFINES}
  58. # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
  59. # computed value.
  60. HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
  61. # Make soft links and include from local directory otherwise wrong headers
  62. # could get pulled in from firmware tree.
  63. INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
  64. # Include library directories where OpenSSL library files are located.
  65. # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
  66. # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
  67. # directory. However, for a local build of OpenSSL, the built binaries are
  68. # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
  69. # ${OPENSSL_DIR}/lib/).
  70. LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
  71. LIB := -lssl -lcrypto
  72. .PHONY: all clean realclean --openssl
  73. all: --openssl ${BINARY}
  74. ${BINARY}: ${OBJECTS} Makefile
  75. @echo " HOSTLD $@"
  76. @echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
  77. const char platform_msg[] = "${PLAT_MSG}";' | \
  78. $(host-cc) -c ${HOSTCCFLAGS} -xc - -o src/build_msg.o
  79. ${Q}$(host-cc) src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
  80. %.o: %.c
  81. @echo " HOSTCC $<"
  82. ${Q}$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
  83. --openssl:
  84. ifeq ($(DEBUG),1)
  85. @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
  86. endif
  87. clean:
  88. $(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
  89. realclean: clean
  90. $(call SHELL_DELETE,${BINARY})