1#
2# Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7MAKE_HELPERS_DIRECTORY := ../../make_helpers/
8include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
9include ${MAKE_HELPERS_DIRECTORY}build_env.mk
10
11FIPTOOL ?= fiptool${BIN_EXT}
12PROJECT := $(notdir ${FIPTOOL})
13OBJECTS := fiptool.o tbbr_config.o
14V ?= 0
15
16override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
17HOSTCCFLAGS := -Wall -Werror -pedantic -std=c99
18ifeq (${DEBUG},1)
19  HOSTCCFLAGS += -g -O0 -DDEBUG
20else
21  HOSTCCFLAGS += -O2
22endif
23LDLIBS := -lcrypto
24
25ifeq (${V},0)
26  Q := @
27else
28  Q :=
29endif
30
31INCLUDE_PATHS := -I../../include/tools_share
32
33HOSTCC ?= gcc
34
35.PHONY: all clean distclean
36
37all: ${PROJECT}
38
39${PROJECT}: ${OBJECTS} Makefile
40	@echo "  HOSTLD  $@"
41	${Q}${HOSTCC} ${OBJECTS} -o $@ ${LDLIBS}
42	@${ECHO_BLANK_LINE}
43	@echo "Built $@ successfully"
44	@${ECHO_BLANK_LINE}
45
46%.o: %.c %.h Makefile
47	@echo "  HOSTCC  $<"
48	${Q}${HOSTCC} -c ${CPPFLAGS} ${HOSTCCFLAGS} ${INCLUDE_PATHS} $< -o $@
49
50clean:
51	$(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS})
52