|
| 1 | +########################################################################### |
| 2 | +# |
| 3 | +# Copyright (c) 2013-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 | +# Toolchain |
| 21 | +PREFIX:=arm-none-eabi- |
| 22 | +GDB:=$(PREFIX)gdb |
| 23 | +OBJDUMP:=$(PREFIX)objdump |
| 24 | + |
| 25 | +# Translate between uVisor namespace and mbed namespace |
| 26 | +TARGET_TRANSLATION:=MCU_K64F.kinetis EFM32.efm32 STM32F4.stm32 |
| 27 | +TARGET_PREFIX:=../ |
| 28 | +TARGET_SUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_SUPPORTED |
| 29 | +TARGET_UNSUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_UNSUPPORTED |
| 30 | +TARGET_INC:=$(TARGET_PREFIX)includes/uvisor/api |
| 31 | + |
| 32 | +# uVisor source directory - hidden from mbed via TARGET_IGNORE |
| 33 | +UVISOR_GIT_URL:=https://github.com/ARMmbed/uvisor |
| 34 | +UVISOR_GIT_BRANCH:=dev |
| 35 | +UVISOR_DIR:=TARGET_IGNORE/uvisor |
| 36 | +UVISOR_API:=$(UVISOR_DIR)/api |
| 37 | +UVISOR_GIT_CFG=$(UVISOR_DIR)/.git/config |
| 38 | + |
| 39 | +# Derive variables from user configuration |
| 40 | +TARGET_LIST:=$(subst .,,$(suffix $(TARGET_TRANSLATION))) |
| 41 | +TARGET_LIST_DIR_SRC:=$(addprefix $(UVISOR_API)/lib/,$(TARGET_LIST)) |
| 42 | +TARGET_LIST_DIR_DST:=$(addprefix $(TARGET_SUPPORTED)/,$(TARGET_LIST)) |
| 43 | +TARGET_LIST_RELEASE:=$(addsuffix /release,$(TARGET_LIST_DIR_DST)) |
| 44 | +TARGET_LIST_DEBUG:=$(addsuffix /debug,$(TARGET_LIST_DIR_DST)) |
| 45 | + |
| 46 | +.PHONY: all deploy rsync publish uvisor uvisor-compile clean cache update |
| 47 | + |
| 48 | +all: uvisor |
| 49 | + |
| 50 | +uvisor: uvisor-compile publish |
| 51 | + |
| 52 | +rsync: |
| 53 | + # |
| 54 | + # Copying uVisor into mbed library... |
| 55 | + rm -rf $(TARGET_SUPPORTED) |
| 56 | + mkdir -p $(TARGET_SUPPORTED) |
| 57 | + rsync -a --exclude='*.txt' $(TARGET_LIST_DIR_SRC) $(TARGET_SUPPORTED) |
| 58 | + # |
| 59 | + # Copying uVisor headers to mbed includes... |
| 60 | + rm -rf $(TARGET_INC) |
| 61 | + mkdir -p $(TARGET_INC) |
| 62 | + rsync -a --delete $(UVISOR_API)/inc $(TARGET_INC) |
| 63 | + # |
| 64 | + # Copying uVisor unsupported sources to unsupported target source... |
| 65 | + mkdir -p $(TARGET_UNSUPPORTED) |
| 66 | + cp $(UVISOR_API)/src/unsupported.c $(TARGET_UNSUPPORTED)/ |
| 67 | + # |
| 68 | + # Copying licenses |
| 69 | + cp $(UVISOR_DIR)/LICENSE* $(TARGET_SUPPORTED) |
| 70 | + |
| 71 | +TARGET_M%: $(TARGET_SUPPORTED)/*/*/*_m%_*.a |
| 72 | + @printf "#\n# Copying $@ files...\n" |
| 73 | + mkdir $(foreach file,$^,$(dir $(file))$@) |
| 74 | + $(foreach file,$^,mv $(file) $(dir $(file))$@/lib$(notdir $(file));) |
| 75 | + |
| 76 | +publish: rsync TARGET_M3 TARGET_M4 |
| 77 | + # |
| 78 | + # Rename release directorires to TARGET_RELEASE filters... |
| 79 | + $(foreach dir, $(TARGET_LIST_RELEASE),mv $(dir) $(dir $(dir))TARGET_RELEASE;) |
| 80 | + # |
| 81 | + # Rename debug directorires to TARGET_DEBUG filters... |
| 82 | + $(foreach dir, $(TARGET_LIST_DEBUG),mv $(dir) $(dir $(dir))TARGET_DEBUG;) |
| 83 | + # |
| 84 | + # Rename target directorires to TARGET_* filters... |
| 85 | + $(foreach target, $(TARGET_TRANSLATION),mv $(TARGET_SUPPORTED)/$(subst .,,$(suffix $(target))) $(TARGET_SUPPORTED)/TARGET_$(basename $(target));) |
| 86 | + |
| 87 | +uvisor-compile: $(UVISOR_GIT_CFG) |
| 88 | + make -C $(UVISOR_DIR) |
| 89 | + |
| 90 | +update: $(UVISOR_GIT_CFG) |
| 91 | + # |
| 92 | + # Updating to latest uVisor library version |
| 93 | + git -C $(UVISOR_DIR) pull --rebase |
| 94 | + # |
| 95 | + # Updating checked out version tag |
| 96 | + git -C $(UVISOR_DIR) describe --tags --abbrev=40 --dirty > $(TARGET_PREFIX)VERSION.txt |
| 97 | + # |
| 98 | + # Updated list of authors, sorted by contributions |
| 99 | + git -C $(UVISOR_DIR) shortlog -s -n > $(TARGET_PREFIX)AUTHORS.txt |
| 100 | + |
| 101 | +$(UVISOR_GIT_CFG): |
| 102 | + rm -rf $(UVISOR_DIR) |
| 103 | + git clone -b $(UVISOR_GIT_BRANCH) $(UVISOR_GIT_URL) $(UVISOR_DIR) |
| 104 | + |
| 105 | +clean: $(UVISOR_GIT_CFG) |
| 106 | + make -C $(UVISOR_DIR) clean |
0 commit comments