|
| 1 | +########################################################################### |
| 2 | +# |
| 3 | +# Copyright (c) 2016, ARM Limited, All Rights Reserved |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | +# not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | +########################################################################### |
| 19 | + |
| 20 | +# |
| 21 | +# Use this file to import an Mbed Crypto release into Mbed OS as follows: |
| 22 | +# |
| 23 | +# 1) Set the CRYPTO_RELEASE variable to the required Mbed Crypto release |
| 24 | +# tag |
| 25 | +# 2) make update |
| 26 | +# 3) make |
| 27 | +# 4) commit and push changes via git |
| 28 | +# |
| 29 | + |
| 30 | +# Set the Mbed Crypto release to import (this can/should be edited before |
| 31 | +# import) |
| 32 | +CRYPTO_RELEASE ?= mbedcrypto-0.1.0b2 |
| 33 | +CRYPTO_REPO_URL ?= [email protected]:ARMmbed/mbed-crypto.git |
| 34 | + |
| 35 | +# Translate between Mbed Crypto namespace and Mbed OS namespace |
| 36 | +TARGET_PREFIX:=.. |
| 37 | +TARGET_INC:=$(TARGET_PREFIX)/inc |
| 38 | + |
| 39 | +# A folder structure is introduced here for targets that have both a Secure |
| 40 | +# Processing Environment (SPE) targets and Non-secure Processing Environment |
| 41 | +# (NSPE). Documentation for each folder as follows: |
| 42 | +# COMPONENT_PSA_SRV_IMPL - Include secure service implementation code. For |
| 43 | +# example PSA Crypto or PSA Secure Time implementations |
| 44 | +TARGET_SRV_IMPL:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL |
| 45 | +# COMPONENT_SPE - Include code that compiles ONLY to the SPE image and never |
| 46 | +# compiles to the NSPE image |
| 47 | +TARGET_SPE:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_SPE |
| 48 | +# COMPONENT_NSPE - Include code that compiles ONLY to the NSPE image and never |
| 49 | +# compiles to the SPE image |
| 50 | +TARGET_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE |
| 51 | + |
| 52 | +# Mbed Crypto source directory - hidden from mbed via TARGET_IGNORE |
| 53 | +CRYPTO_DIR:=TARGET_IGNORE/mbed-crypto |
| 54 | +CRYPTO_API:=$(CRYPTO_DIR)/include/psa |
| 55 | +CRYPTO_GIT_CFG=$(CRYPTO_DIR)/.git/config |
| 56 | + |
| 57 | + |
| 58 | +.PHONY: all rsync clean update |
| 59 | + |
| 60 | +all: rsync |
| 61 | + |
| 62 | +rsync: |
| 63 | + # |
| 64 | + # Copying Mbed Crypto headers to includes... |
| 65 | + rm -rf $(TARGET_INC) |
| 66 | + mkdir -p $(TARGET_INC) |
| 67 | + rsync -a --delete --exclude='crypto_struct.h' $(CRYPTO_API) $(TARGET_INC)/ |
| 68 | + # |
| 69 | + # Copying licenses |
| 70 | + cp $(CRYPTO_DIR)/LICENSE $(TARGET_PREFIX)/ |
| 71 | + cp $(CRYPTO_DIR)/apache-2.0.txt $(TARGET_PREFIX)/ |
| 72 | + # |
| 73 | + # Copying Mbed Crypto into Mbed OS... |
| 74 | + rm -rf $(TARGET_SRV_IMPL) |
| 75 | + rm -rf $(TARGET_SPE) |
| 76 | + |
| 77 | + mkdir -p $(TARGET_SRV_IMPL) |
| 78 | + mkdir -p $(TARGET_SPE) |
| 79 | + mkdir -p $(TARGET_NSPE) |
| 80 | + |
| 81 | + rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_NSPE)/ |
| 82 | + rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h |
| 83 | + rsync -a --delete $(CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)/ |
| 84 | + rsync -a --delete $(CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)/ |
| 85 | + |
| 86 | +update: $(CRYPTO_GIT_CFG) |
| 87 | + # |
| 88 | + # Updating to the specified Mbed Crypto library version |
| 89 | + # (If it is not an initial checkout we will start with the repository |
| 90 | + # being in a detached head state) |
| 91 | + git -C $(CRYPTO_DIR) checkout development |
| 92 | + git -C $(CRYPTO_DIR) pull --rebase origin development |
| 93 | + # |
| 94 | + # Checking out the required release |
| 95 | + git -C $(CRYPTO_DIR) checkout $(CRYPTO_RELEASE) |
| 96 | + # |
| 97 | + # Update and checkout git submodules |
| 98 | + git -C $(CRYPTO_DIR) submodule update --init --recursive |
| 99 | + # |
| 100 | + # Updating Mbed Crypto checked out version tag |
| 101 | + git -C $(CRYPTO_DIR) describe --tags --abbrev=12 --dirty --always > $(TARGET_PREFIX)/VERSION.txt |
| 102 | + |
| 103 | +$(CRYPTO_GIT_CFG): |
| 104 | + rm -rf $(CRYPTO_DIR) |
| 105 | + git clone $(CRYPTO_REPO_URL) $(CRYPTO_DIR) |
| 106 | + |
| 107 | +clean: |
| 108 | + rm -f $(TARGET_PREFIX)/LICENSE |
| 109 | + rm -f $(TARGET_PREFIX)/apache-2.0.txt |
| 110 | + rm -f $(TARGET_PREFIX)/VERSION.txt |
| 111 | + rm -f $(TARGET_PREFIX)/AUTHORS.txt |
| 112 | + rm -rf $(TARGET_INC) |
| 113 | + rm -rf $(CRYPTO_DIR) |
| 114 | + rm -rf $(TARGET_SRV_IMPL) |
| 115 | + rm -rf $(TARGET_SPE) |
0 commit comments