xref: /rk3399_ARM-atf/tools/fiptool/Makefile (revision 0e14a7fbeb3014e719302c9b7f6a24c4030dfaf0)
1#
2# Copyright (c) 2014-2016, 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
11PROJECT := fiptool${BIN_EXT}
12OBJECTS := fiptool.o tbbr_config.o
13V := 0
14COPIED_H_FILES := uuid.h firmware_image_package.h
15
16override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
17CFLAGS := -Wall -Werror -pedantic -std=c99
18ifeq (${DEBUG},1)
19  CFLAGS += -g -O0 -DDEBUG
20else
21  CFLAGS += -O2
22endif
23LDLIBS := -lcrypto
24
25ifeq (${V},0)
26  Q := @
27else
28  Q :=
29endif
30
31# Only include from local directory (see comment below).
32INCLUDE_PATHS := -I.
33
34CC := gcc
35
36.PHONY: all clean distclean
37
38all: ${PROJECT} fip_create
39
40${PROJECT}: ${OBJECTS} Makefile
41	@echo "  LD      $@"
42	${Q}${CC} ${OBJECTS} -o $@ ${LDLIBS}
43	@${ECHO_BLANK_LINE}
44	@echo "Built $@ successfully"
45	@${ECHO_BLANK_LINE}
46
47fip_create: fip_create.sh
48	${Q}mkdir -p ../fip_create
49	${Q}install -m 755 fip_create.sh ../fip_create/fip_create
50
51%.o: %.c %.h ${COPIED_H_FILES} Makefile
52	@echo "  CC      $<"
53	${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
54
55#
56# Copy required library headers to a local directory so they can be included
57# by this project without adding the library directories to the system include
58# path. This avoids conflicts with definitions in the compiler standard
59# include path.
60#
61uuid.h : ../../include/lib/stdlib/sys/uuid.h
62	$(call SHELL_COPY,$<,$@)
63
64firmware_image_package.h : ../../include/common/firmware_image_package.h
65	$(call SHELL_COPY,$<,$@)
66
67clean:
68	$(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create)
69
70distclean: clean
71	$(call SHELL_DELETE_ALL, ${COPIED_H_FILES})
72