Makefile 2.8 KB

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