Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #
  2. # Copyright (c) 2014-2023, 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}defaults.mk
  10. FIPTOOL ?= fiptool${BIN_EXT}
  11. PROJECT := $(notdir ${FIPTOOL})
  12. OBJECTS := fiptool.o tbbr_config.o
  13. V ?= 0
  14. OPENSSL_DIR := /usr
  15. override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
  16. HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
  17. ifeq (${DEBUG},1)
  18. HOSTCCFLAGS += -g -O0 -DDEBUG
  19. else
  20. HOSTCCFLAGS += -O2
  21. endif
  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. HOSTCCFLAGS += ${DEFINES}
  26. # USING_OPENSSL3 flag will be added to the HOSTCCFLAGS variable with the proper
  27. # computed value.
  28. HOSTCCFLAGS += -DUSING_OPENSSL3=$(USING_OPENSSL3)
  29. # Include library directories where OpenSSL library files are located.
  30. # For a normal installation (i.e.: when ${OPENSSL_DIR} = /usr or
  31. # /usr/local), binaries are located under the ${OPENSSL_DIR}/lib/
  32. # directory. However, for a local build of OpenSSL, the built binaries are
  33. # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
  34. # ${OPENSSL_DIR}/lib/).
  35. LDLIBS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
  36. ifeq (${V},0)
  37. Q := @
  38. else
  39. Q :=
  40. endif
  41. INCLUDE_PATHS := -I../../include/tools_share -I${OPENSSL_DIR}/include
  42. HOSTCC ?= gcc
  43. ifneq (${PLAT},)
  44. TF_PLATFORM_ROOT := ../../plat/
  45. include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
  46. COMBINED_PATH_FRAG := plat_fiptool/
  47. PLAT_FIPTOOL_HELPER_MK := $(foreach path_frag,$(subst /, ,$(patsubst ../../plat/%/,%,${PLAT_DIR})),\
  48. $(eval COMBINED_PATH_FRAG := ${COMBINED_PATH_FRAG}/${path_frag})\
  49. $(wildcard ${COMBINED_PATH_FRAG}/plat_fiptool.mk))
  50. endif
  51. ifneq (,$(wildcard $(lastword ${PLAT_FIPTOOL_HELPER_MK})))
  52. include ${PLAT_FIPTOOL_HELPER_MK}
  53. endif
  54. DEPS := $(patsubst %.o,%.d,$(OBJECTS))
  55. .PHONY: all clean distclean --openssl
  56. all: --openssl ${PROJECT}
  57. ${PROJECT}: ${OBJECTS} Makefile
  58. @echo " HOSTLD $@"
  59. ${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
  60. @${ECHO_BLANK_LINE}
  61. @echo "Built $@ successfully"
  62. @${ECHO_BLANK_LINE}
  63. %.o: %.c Makefile
  64. @echo " HOSTCC $<"
  65. ${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} -MD -MP $< -o $@
  66. -include $(DEPS)
  67. --openssl:
  68. ifeq ($(DEBUG),1)
  69. @echo "Selected OpenSSL version: ${OPENSSL_CURRENT_VER}"
  70. endif
  71. clean:
  72. $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} $(DEPS))