1# 2# Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. 3# 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 31MAKE_HELPERS_DIRECTORY := ../../make_helpers/ 32include ${MAKE_HELPERS_DIRECTORY}build_macros.mk 33include ${MAKE_HELPERS_DIRECTORY}build_env.mk 34 35PROJECT := fiptool${BIN_EXT} 36OBJECTS := fiptool.o tbbr_config.o 37V := 0 38COPIED_H_FILES := uuid.h firmware_image_package.h 39 40override CPPFLAGS += -D_GNU_SOURCE -D_XOPEN_SOURCE=700 41CFLAGS := -Wall -Werror -pedantic -std=c99 42ifeq (${DEBUG},1) 43 CFLAGS += -g -O0 -DDEBUG 44else 45 CFLAGS += -O2 46endif 47LDLIBS := -lcrypto 48 49ifeq (${V},0) 50 Q := @ 51else 52 Q := 53endif 54 55# Only include from local directory (see comment below). 56INCLUDE_PATHS := -I. 57 58CC := gcc 59 60.PHONY: all clean distclean 61 62all: ${PROJECT} fip_create 63 64${PROJECT}: ${OBJECTS} Makefile 65 @echo " LD $@" 66 ${Q}${CC} ${OBJECTS} -o $@ ${LDLIBS} 67 @${ECHO_BLANK_LINE} 68 @echo "Built $@ successfully" 69 @${ECHO_BLANK_LINE} 70 71fip_create: fip_create.sh 72 ${Q}mkdir -p ../fip_create 73 ${Q}install -m 755 fip_create.sh ../fip_create/fip_create 74 75%.o: %.c %.h ${COPIED_H_FILES} Makefile 76 @echo " CC $<" 77 ${Q}${CC} -c ${CPPFLAGS} ${CFLAGS} ${INCLUDE_PATHS} $< -o $@ 78 79# 80# Copy required library headers to a local directory so they can be included 81# by this project without adding the library directories to the system include 82# path. This avoids conflicts with definitions in the compiler standard 83# include path. 84# 85uuid.h : ../../include/lib/stdlib/sys/uuid.h 86 $(call SHELL_COPY,$<,$@) 87 88firmware_image_package.h : ../../include/common/firmware_image_package.h 89 $(call SHELL_COPY,$<,$@) 90 91clean: 92 $(call SHELL_DELETE_ALL, ${PROJECT} ${OBJECTS} fip_create) 93 94distclean: clean 95 $(call SHELL_DELETE_ALL, ${COPIED_H_FILES}) 96