Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. DEBUG := 0
  8. CRTTOOL ?= cert_create${BIN_EXT}
  9. BINARY := $(notdir ${CRTTOOL})
  10. COT := tbbr
  11. MAKE_HELPERS_DIRECTORY := ../../make_helpers/
  12. include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
  13. include ${MAKE_HELPERS_DIRECTORY}build_env.mk
  14. include ${MAKE_HELPERS_DIRECTORY}common.mk
  15. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  16. include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
  17. include ${MAKE_HELPERS_DIRECTORY}utilities.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. HOSTCCFLAGS += ${DEFINES} -DPLAT_MSG=$(call escape-shell,"$(PLAT_MSG)")
  53. # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
  54. # computed value.
  55. HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
  56. # Make soft links and include from local directory otherwise wrong headers
  57. # could get pulled in from firmware tree.
  58. INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
  59. # Include library directories where OpenSSL library files are located.
  60. # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
  61. # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
  62. # directory. However, for a local build of OpenSSL, the built binaries are
  63. # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
  64. # ${OPENSSL_DIR}/lib/).
  65. LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
  66. LIB := -lssl -lcrypto
  67. .PHONY: all clean realclean --openssl
  68. all: --openssl ${BINARY}
  69. ${BINARY}: ${OBJECTS} Makefile
  70. $(s)echo " HOSTLD $@"
  71. $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
  72. %.o: %.c
  73. $(s)echo " HOSTCC $<"
  74. $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
  75. --openssl:
  76. ifeq ($(DEBUG),1)
  77. $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
  78. endif
  79. clean:
  80. $(call SHELL_DELETE_ALL,${OBJECTS})
  81. realclean: clean
  82. $(call SHELL_DELETE,${BINARY})