Makefile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #
  2. # Copyright (c) 2024, Arm Limited. All rights reserved.
  3. # Copyright (c) 2019-2022, Linaro Limited. All rights reserved.
  4. #
  5. # SPDX-License-Identifier: BSD-3-Clause
  6. #
  7. BUILD_INFO ?= 1
  8. DEBUG := 0
  9. ENCTOOL ?= encrypt_fw${BIN_EXT}
  10. BINARY := $(notdir ${ENCTOOL})
  11. OPENSSL_DIR := /usr
  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}common.mk
  16. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  17. include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
  18. OBJECTS := src/encrypt.o \
  19. src/cmd_opt.o \
  20. src/main.o
  21. HOSTCCFLAGS := -Wall -std=c99
  22. # Select OpenSSL version flag according to the OpenSSL build selected
  23. # from setting the OPENSSL_DIR path.
  24. $(eval $(call SELECT_OPENSSL_API_VERSION))
  25. ifeq (${DEBUG},1)
  26. HOSTCCFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
  27. else
  28. ifeq (${BUILD_INFO},1)
  29. HOSTCCFLAGS += -O2 -DLOG_LEVEL=20
  30. else
  31. HOSTCCFLAGS += -O2 -DLOG_LEVEL=10
  32. endif
  33. endif
  34. HOSTCCFLAGS += ${DEFINES}
  35. # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
  36. # computed value.
  37. HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
  38. # Make soft links and include from local directory otherwise wrong headers
  39. # could get pulled in from firmware tree.
  40. INC_DIR := -I ./include -I ../../include/tools_share -I ${OPENSSL_DIR}/include
  41. # Include library directories where OpenSSL library files are located.
  42. # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
  43. # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
  44. # directory. However, for a local build of OpenSSL, the built binaries are
  45. # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
  46. # ${OPENSSL_DIR}/lib/).
  47. LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
  48. LIB := -lssl -lcrypto
  49. .PHONY: all clean realclean --openssl
  50. all: --openssl ${BINARY}
  51. ${BINARY}: ${OBJECTS} Makefile
  52. $(s)echo " HOSTLD $@"
  53. $(q)$(host-cc) ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
  54. %.o: %.c
  55. $(s)echo " HOSTCC $<"
  56. $(q)$(host-cc) -c ${HOSTCCFLAGS} ${INC_DIR} $< -o $@
  57. --openssl:
  58. ifeq ($(DEBUG),1)
  59. $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
  60. endif
  61. clean:
  62. $(call SHELL_DELETE_ALL,${OBJECTS})
  63. realclean: clean
  64. $(call SHELL_DELETE,${BINARY})