|
| 1 | +# |
| 2 | +# ARM CMSIS Arduino IDE Module makefile. |
| 3 | +# |
| 4 | +# Copyright (c) 2015 Atmel Corp./Thibaut VIARD. All right reserved. |
| 5 | +# |
| 6 | +# This library is free software; you can redistribute it and/or |
| 7 | +# modify it under the terms of the GNU Lesser General Public |
| 8 | +# License as published by the Free Software Foundation; either |
| 9 | +# version 2.1 of the License, or (at your option) any later version. |
| 10 | +# |
| 11 | +# This library is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 | +# See the GNU Lesser General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU Lesser General Public |
| 17 | +# License along with this library; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | +# |
| 20 | + |
| 21 | +SHELL = /bin/sh |
| 22 | + |
| 23 | +.SUFFIXES: .tar.bz2 |
| 24 | + |
| 25 | +ROOT_PATH := . |
| 26 | + |
| 27 | +PACKAGE_NAME := $(basename $(notdir $(CURDIR))) |
| 28 | +PACKAGE_VERSION := 4.5.0 |
| 29 | + |
| 30 | +# ----------------------------------------------------------------------------- |
| 31 | +# packaging specific |
| 32 | +PACKAGE_FOLDER := module |
| 33 | + |
| 34 | +ifeq (postpackaging,$(findstring $(MAKECMDGOALS),postpackaging)) |
| 35 | + PACKAGE_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2 |
| 36 | + PACKAGE_CHKSUM := $(firstword $(shell sha256sum "$(PACKAGE_FILENAME)")) |
| 37 | + PACKAGE_SIZE := $(firstword $(shell wc -c "$(PACKAGE_FILENAME)")) |
| 38 | +endif |
| 39 | + |
| 40 | +# end of packaging specific |
| 41 | +# ----------------------------------------------------------------------------- |
| 42 | + |
| 43 | +.PHONY: all clean print_info postpackaging |
| 44 | + |
| 45 | +# Arduino module packaging: |
| 46 | +# - exclude version control system files, here git files and folders .git, .gitattributes and .gitignore |
| 47 | +# - exclude 'extras' folder |
| 48 | +all: clean print_info |
| 49 | + @echo ---------------------------------------------------------- |
| 50 | + @echo "Packaging module." |
| 51 | + tar --transform "s|module|$(PACKAGE_NAME)-$(PACKAGE_VERSION)|g" --exclude=.gitattributes --exclude=.travis.yml --exclude-vcs -cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2" "$(PACKAGE_FOLDER)" |
| 52 | + $(MAKE) --no-builtin-rules postpackaging -C . |
| 53 | + @echo ---------------------------------------------------------- |
| 54 | + |
| 55 | +clean: |
| 56 | + @echo ---------------------------------------------------------- |
| 57 | + @echo Cleanup |
| 58 | + -$(RM) $(PACKAGE_NAME)-*.tar.bz2 package_$(PACKAGE_NAME)_*.json test_package_$(PACKAGE_NAME)_*.json |
| 59 | + @echo ---------------------------------------------------------- |
| 60 | + |
| 61 | +print_info: |
| 62 | + @echo ---------------------------------------------------------- |
| 63 | + @echo Building $(PACKAGE_NAME) using |
| 64 | + @echo "CURDIR = $(CURDIR)" |
| 65 | + @echo "OS = $(OS)" |
| 66 | + @echo "SHELL = $(SHELL)" |
| 67 | + @echo "PACKAGE_VERSION = $(PACKAGE_VERSION)" |
| 68 | + @echo "PACKAGE_NAME = $(PACKAGE_NAME)" |
| 69 | + |
| 70 | +postpackaging: |
| 71 | + @echo "PACKAGE_CHKSUM = $(PACKAGE_CHKSUM)" |
| 72 | + @echo "PACKAGE_SIZE = $(PACKAGE_SIZE)" |
| 73 | + @echo "PACKAGE_FILENAME = $(PACKAGE_FILENAME)" |
| 74 | + cat extras/package_index.json.template | sed s/%%VERSION%%/$(PACKAGE_VERSION)/ | sed s/%%FILENAME%%/$(PACKAGE_FILENAME)/ | sed s/%%CHECKSUM%%/$(PACKAGE_CHKSUM)/ | sed s/%%SIZE%%/$(PACKAGE_SIZE)/ > package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json |
| 75 | + cp package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json test_package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json |
| 76 | + @echo "package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json created" |
0 commit comments