Home | History | Annotate | Download | only in cert_create
      1 #
      2 # Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
      3 #
      4 # SPDX-License-Identifier: BSD-3-Clause
      5 #
      6 
      7 PROJECT		:= cert_create
      8 PLAT		:= none
      9 V		?= 0
     10 DEBUG		:= 0
     11 BINARY		:= ${PROJECT}${BIN_EXT}
     12 OPENSSL_DIR	:= /usr
     13 USE_TBBR_DEFS   := 1
     14 
     15 OBJECTS := src/cert.o \
     16            src/cmd_opt.o \
     17            src/ext.o \
     18            src/key.o \
     19            src/main.o \
     20            src/sha.o \
     21            src/tbbr/tbb_cert.o \
     22            src/tbbr/tbb_ext.o \
     23            src/tbbr/tbb_key.o
     24 
     25 CFLAGS := -Wall -std=c99
     26 
     27 MAKE_HELPERS_DIRECTORY := ../../make_helpers/
     28 include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
     29 include ${MAKE_HELPERS_DIRECTORY}build_env.mk
     30 
     31 ifeq (${USE_TBBR_DEFS},1)
     32 # In this case, cert_tool is platform-independent
     33 PLAT_MSG		:=	TBBR Generic
     34 PLAT_INCLUDE		:=	../../include/tools_share
     35 else
     36 PLAT_MSG		:=	${PLAT}
     37 
     38 PLATFORM_ROOT		:=	../../plat/
     39 include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
     40 
     41 PLAT_INCLUDE		:=	$(wildcard ${PLAT_DIR}include)
     42 
     43 ifeq ($(PLAT_INCLUDE),)
     44   $(error "Error: Invalid platform '${PLAT}' has no include directory.")
     45 endif
     46 endif
     47 
     48 ifeq (${DEBUG},1)
     49   CFLAGS += -g -O0 -DDEBUG -DLOG_LEVEL=40
     50 else
     51   CFLAGS += -O2 -DLOG_LEVEL=20
     52 endif
     53 ifeq (${V},0)
     54   Q := @
     55 else
     56   Q :=
     57 endif
     58 
     59 $(eval $(call add_define,USE_TBBR_DEFS))
     60 CFLAGS += ${DEFINES}
     61 
     62 # Make soft links and include from local directory otherwise wrong headers
     63 # could get pulled in from firmware tree.
     64 INC_DIR := -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
     65 LIB_DIR := -L ${OPENSSL_DIR}/lib
     66 LIB := -lssl -lcrypto
     67 
     68 HOSTCC ?= gcc
     69 
     70 .PHONY: all clean realclean
     71 
     72 all: clean ${BINARY}
     73 
     74 ${BINARY}: ${OBJECTS} Makefile
     75 	@echo "  LD      $@"
     76 	@echo 'const char build_msg[] = "Built : "__TIME__", "__DATE__; \
     77                 const char platform_msg[] = "${PLAT_MSG}";' | \
     78                 ${CC} -c ${CFLAGS} -xc - -o src/build_msg.o
     79 	${Q}${HOSTCC} src/build_msg.o ${OBJECTS} ${LIB_DIR} ${LIB} -o $@
     80 
     81 %.o: %.c
     82 	@echo "  CC      $<"
     83 	${Q}${HOSTCC} -c ${CFLAGS} ${INC_DIR} $< -o $@
     84 
     85 clean:
     86 	$(call SHELL_DELETE_ALL, src/build_msg.o ${OBJECTS})
     87 
     88 realclean: clean
     89 	$(call SHELL_DELETE, ${BINARY})
     90 
     91