blob: 0a46ad7c66710fead6467ec09ae6f5ca0f2077e5 [file] [log] [blame]
Harry Liebelf58ad362014-01-10 18:00:33 +00001#
Evan Lloyd26c6cb42015-12-02 18:33:55 +00002# Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
Harry Liebelf58ad362014-01-10 18:00:33 +00003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Harry Liebelf58ad362014-01-10 18:00:33 +00005#
6
Evan Lloyd26c6cb42015-12-02 18:33:55 +00007MAKE_HELPERS_DIRECTORY := ../../make_helpers/
8include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +00009include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000010
dp-arm4972ec52016-05-25 16:20:20 +010011PROJECT := fiptool${BIN_EXT}
12OBJECTS := fiptool.o tbbr_config.o
13V := 0
Evan Lloyd93a76402015-12-02 20:30:13 +000014COPIED_H_FILES := uuid.h firmware_image_package.h
Harry Liebelf58ad362014-01-10 18:00:33 +000015
dp-arm4972ec52016-05-25 16:20:20 +010016override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000017CFLAGS := -Wall -Werror -pedantic -std=c99
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000018ifeq (${DEBUG},1)
Harry Liebelf58ad362014-01-10 18:00:33 +000019 CFLAGS += -g -O0 -DDEBUG
20else
21 CFLAGS += -O2
22endif
dp-arm12e893b2016-08-24 13:21:08 +010023LDLIBS := -lcrypto
Harry Liebelf58ad362014-01-10 18:00:33 +000024
dp-arm4972ec52016-05-25 16:20:20 +010025ifeq (${V},0)
26 Q := @
27else
28 Q :=
29endif
30
Evan Lloyd93a76402015-12-02 20:30:13 +000031# Only include from local directory (see comment below).
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000032INCLUDE_PATHS := -I.
Harry Liebelf58ad362014-01-10 18:00:33 +000033
34CC := gcc
Harry Liebelf58ad362014-01-10 18:00:33 +000035
Evan Lloyd93a76402015-12-02 20:30:13 +000036.PHONY: all clean distclean
Harry Liebelf58ad362014-01-10 18:00:33 +000037
dp-arm4972ec52016-05-25 16:20:20 +010038all: ${PROJECT} fip_create
Harry Liebelf58ad362014-01-10 18:00:33 +000039
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000040${PROJECT}: ${OBJECTS} Makefile
41 @echo " LD $@"
dp-arm12e893b2016-08-24 13:21:08 +010042 ${Q}${CC} ${OBJECTS} -o $@ ${LDLIBS}
Evan Lloyd26c6cb42015-12-02 18:33:55 +000043 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000044 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000045 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000046
dp-arm4972ec52016-05-25 16:20:20 +010047fip_create: fip_create.sh
dp-arm65dfe4c2016-08-10 13:39:42 +010048 ${Q}mkdir -p ../fip_create
49 ${Q}install -m 755 fip_create.sh ../fip_create/fip_create
dp-arm4972ec52016-05-25 16:20:20 +010050
Evan Lloyd93a76402015-12-02 20:30:13 +000051%.o: %.c %.h ${COPIED_H_FILES} Makefile
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000052 @echo " CC $<"
dp-arm4972ec52016-05-25 16:20:20 +010053 ${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
Harry Liebelf58ad362014-01-10 18:00:33 +000054
Evan Lloyd93a76402015-12-02 20:30:13 +000055#
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#
Dan Handleyd7b59e42016-06-02 17:15:13 +010061uuid.h : ../../include/lib/stdlib/sys/uuid.h
Evan Lloyd93a76402015-12-02 20:30:13 +000062 $(call SHELL_COPY,$<,$@)
63
64firmware_image_package.h : ../../include/common/firmware_image_package.h
65 $(call SHELL_COPY,$<,$@)
66
Harry Liebelf58ad362014-01-10 18:00:33 +000067clean:
dp-arm4972ec52016-05-25 16:20:20 +010068 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create)
Evan Lloyd26c6cb42015-12-02 18:33:55 +000069
Evan Lloyd93a76402015-12-02 20:30:13 +000070distclean: clean
71 $(call SHELL_DELETE_ALL, ${COPIED_H_FILES})