blob: 3bc372a281b47289dbaea89ff9768ca01ef4270c [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#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# Redistributions of source code must retain the above copyright notice, this
8# list of conditions and the following disclaimer.
9#
10# Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# Neither the name of ARM nor the names of its contributors may be used
15# to endorse or promote products derived from this software without specific
16# prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30
Evan Lloyd26c6cb42015-12-02 18:33:55 +000031MAKE_HELPERS_DIRECTORY := ../../make_helpers/
32include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
Evan Lloyda71d2592015-12-02 18:56:06 +000033include ${MAKE_HELPERS_DIRECTORY}build_env.mk
Evan Lloyd26c6cb42015-12-02 18:33:55 +000034
dp-arm4972ec52016-05-25 16:20:20 +010035PROJECT := fiptool${BIN_EXT}
36OBJECTS := fiptool.o tbbr_config.o
37V := 0
Evan Lloyd93a76402015-12-02 20:30:13 +000038COPIED_H_FILES := uuid.h firmware_image_package.h
Harry Liebelf58ad362014-01-10 18:00:33 +000039
dp-arm4972ec52016-05-25 16:20:20 +010040override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000041CFLAGS := -Wall -Werror -pedantic -std=c99
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000042ifeq (${DEBUG},1)
Harry Liebelf58ad362014-01-10 18:00:33 +000043 CFLAGS += -g -O0 -DDEBUG
44else
45 CFLAGS += -O2
46endif
47
dp-arm4972ec52016-05-25 16:20:20 +010048ifeq (${V},0)
49 Q := @
50else
51 Q :=
52endif
53
Evan Lloyd93a76402015-12-02 20:30:13 +000054# Only include from local directory (see comment below).
Evan Lloydf4ba5ca2015-12-03 09:47:51 +000055INCLUDE_PATHS := -I.
Harry Liebelf58ad362014-01-10 18:00:33 +000056
57CC := gcc
Harry Liebelf58ad362014-01-10 18:00:33 +000058
Evan Lloyd93a76402015-12-02 20:30:13 +000059.PHONY: all clean distclean
Harry Liebelf58ad362014-01-10 18:00:33 +000060
dp-arm4972ec52016-05-25 16:20:20 +010061all: ${PROJECT} fip_create
Harry Liebelf58ad362014-01-10 18:00:33 +000062
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000063${PROJECT}: ${OBJECTS} Makefile
64 @echo " LD $@"
65 ${Q}${CC} ${OBJECTS} -o $@
Evan Lloyd26c6cb42015-12-02 18:33:55 +000066 @${ECHO_BLANK_LINE}
Sandrine Bailleux152c17f2014-10-27 17:10:46 +000067 @echo "Built $@ successfully"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000068 @${ECHO_BLANK_LINE}
Harry Liebelf58ad362014-01-10 18:00:33 +000069
dp-arm4972ec52016-05-25 16:20:20 +010070fip_create: fip_create.sh
dp-arm65dfe4c2016-08-10 13:39:42 +010071 ${Q}mkdir -p ../fip_create
72 ${Q}install -m 755 fip_create.sh ../fip_create/fip_create
dp-arm4972ec52016-05-25 16:20:20 +010073
Evan Lloyd93a76402015-12-02 20:30:13 +000074%.o: %.c %.h ${COPIED_H_FILES} Makefile
Jeenu Viswambharan2f2cef42014-02-19 09:38:18 +000075 @echo " CC $<"
dp-arm4972ec52016-05-25 16:20:20 +010076 ${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@
Harry Liebelf58ad362014-01-10 18:00:33 +000077
Evan Lloyd93a76402015-12-02 20:30:13 +000078#
79# Copy required library headers to a local directory so they can be included
80# by this project without adding the library directories to the system include
81# path. This avoids conflicts with definitions in the compiler standard
82# include path.
83#
Dan Handleyd7b59e42016-06-02 17:15:13 +010084uuid.h : ../../include/lib/stdlib/sys/uuid.h
Evan Lloyd93a76402015-12-02 20:30:13 +000085 $(call SHELL_COPY,$<,$@)
86
87firmware_image_package.h : ../../include/common/firmware_image_package.h
88 $(call SHELL_COPY,$<,$@)
89
Harry Liebelf58ad362014-01-10 18:00:33 +000090clean:
dp-arm4972ec52016-05-25 16:20:20 +010091 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create)
Evan Lloyd26c6cb42015-12-02 18:33:55 +000092
Evan Lloyd93a76402015-12-02 20:30:13 +000093distclean: clean
94 $(call SHELL_DELETE_ALL, ${COPIED_H_FILES})