Makefile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. MAKE_HELPERS_DIRECTORY := ../../make_helpers/
  7. include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
  8. include ${MAKE_HELPERS_DIRECTORY}build_env.mk
  9. include ${MAKE_HELPERS_DIRECTORY}common.mk
  10. include ${MAKE_HELPERS_DIRECTORY}defaults.mk
  11. include ${MAKE_HELPERS_DIRECTORY}toolchain.mk
  12. FIPTOOL ?= fiptool${BIN_EXT}
  13. PROJECT := $(notdir ${FIPTOOL})
  14. OBJECTS := fiptool.o tbbr_config.o
  15. STATIC ?= 0
  16. override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
  17. HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
  18. ifeq (${DEBUG},1)
  19. HOSTCCFLAGS += -g -O0 -DDEBUG
  20. else
  21. HOSTCCFLAGS += -O2
  22. endif
  23. INCLUDE_PATHS := -I../../include/tools_share
  24. DEFINES += -DSTATIC=$(STATIC)
  25. ifeq (${STATIC},1)
  26. LDOPTS := -static
  27. else
  28. OPENSSL_DIR := /usr
  29. # Select OpenSSL version flag according to the OpenSSL build selected
  30. # from setting the OPENSSL_DIR path.
  31. $(eval $(call SELECT_OPENSSL_API_VERSION))
  32. # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
  33. # computed value.
  34. DEFINES += -DUSING_OPENSSL3=$(USING_OPENSSL3)
  35. # Include library directories where OpenSSL library files are located.
  36. # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
  37. # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
  38. # directory. However, for a local build of OpenSSL, the built binaries are
  39. # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
  40. # ${OPENSSL_DIR}/lib/).
  41. LDOPTS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
  42. INCLUDE_PATHS += -I${OPENSSL_DIR}/include
  43. endif # STATIC
  44. HOSTCCFLAGS += ${DEFINES}
  45. ifneq (${PLAT},)
  46. TF_PLATFORM_ROOT := ../../plat/
  47. include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
  48. COMBINED_PATH_FRAG := plat_fiptool/
  49. PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
  50. $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
  51. $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
  52. endif
  53. ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
  54. include ${PLAT_FIPTOOL_HELPER_MK}
  55. endif
  56. DEPS := $(patsubst %.o,%.d,$(OBJECTS))
  57. .PHONY: all clean distclean --openssl
  58. all: --openssl ${PROJECT}
  59. ${PROJECT}: ${OBJECTS} Makefile
  60. $(s)echo " HOSTLD $@"
  61. $(q)$(host-cc) ${OBJECTS} -o $@ $(LDOPTS)
  62. $(s)echo
  63. $(s)echo "Built $@ successfully"
  64. $(s)echo
  65. %.o: %.c Makefile
  66. $(s)echo " HOSTCC $<"
  67. $(q)$(host-cc) -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
  68. -include $(DEPS)
  69. --openssl:
  70. ifeq ($(STATIC),0)
  71. ifeq ($(DEBUG),1)
  72. $(s)echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
  73. endif
  74. endif # STATIC
  75. clean:
  76. $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))