Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (147 loc) · 8.26 KB
/
Copy pathMakefile
File metadata and controls
167 lines (147 loc) · 8.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
SHELL = /bin/sh
.SUFFIXES: .tar.bz2
ROOT_PATH := .
TOOLS_PATH := ../tools
CORE_PATH := ../packages
DOWNLOAD_PATH := download
OS ?=$(shell uname -s)
# -----------------------------------------------------------------------------
ifeq (postpackaging_core,$(findstring $(MAKECMDGOALS),postpackaging_core))
PACKAGE_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2
PACKAGE_CHKSUM := $(firstword $(shell shasum -a 256 "$(PACKAGE_FILENAME)"))
PACKAGE_SIZE := $(firstword $(shell wc -c "$(PACKAGE_FILENAME)"))
endif
ifeq (postpackaging_tools,$(findstring $(MAKECMDGOALS),postpackaging_tools))
PACKAGE_WIN_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION)-windows.tar.bz2
PACKAGE_LINUX_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION)-linux.tar.bz2
PACKAGE_MAC_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION)-mac.tar.bz2
PACKAGE_WIN_CHKSUM := $(firstword $(shell shasum -a 256 "$(PACKAGE_WIN_FILENAME)"))
PACKAGE_LINUX_CHKSUM := $(firstword $(shell shasum -a 256 "$(PACKAGE_LINUX_FILENAME)"))
PACKAGE_MAC_CHKSUM := $(firstword $(shell shasum -a 256 "$(PACKAGE_MAC_FILENAME)"))
PACKAGE_WIN_SIZE := $(firstword $(shell wc -c "$(PACKAGE_WIN_FILENAME)"))
PACKAGE_LINUX_SIZE := $(firstword $(shell wc -c "$(PACKAGE_LINUX_FILENAME)"))
PACKAGE_MAC_SIZE := $(firstword $(shell wc -c "$(PACKAGE_MAC_FILENAME)"))
endif
ifeq (postpackaging_svd,$(findstring $(MAKECMDGOALS),postpackaging_svd))
PACKAGE_FILENAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2
PACKAGE_CHKSUM := $(firstword $(shell shasum -a 256 "$(PACKAGE_FILENAME)"))
PACKAGE_SIZE := $(firstword $(shell wc -c "$(PACKAGE_FILENAME)"))
endif
# -----------------------------------------------------------------------------
.PHONY: all clean core tools stm32_svd print_info postpackaging_core postpackaging_svd postpackaging_tools
all: core tools stm32_svd
core: PACKAGE_NAME := STM32
core: PACKAGE_FOLDER := Arduino_Core_STM32
core: PACKAGE_VERSION := $(shell git --git-dir=$(PACKAGE_FOLDER)/.git describe --tags)
core: PACKAGE_DATE := $(firstword $(shell git --git-dir=$(PACKAGE_FOLDER)/.git log -1 --pretty=format:%ci))
core: clean print_info
@echo ----------------------------------------------------------
@echo "Packaging $@..."
@git --git-dir=$(PACKAGE_FOLDER)/.git show HEAD --pretty=short --no-patch > $(PACKAGE_FOLDER)/package_version.txt
@tar --mtime='$(PACKAGE_DATE)' \
--exclude=.git \
--exclude=.gitattributes \
--exclude=.github \
--exclude=.gitignore \
--transform "s|$(PACKAGE_FOLDER)|$(PACKAGE_NAME)|" \
-cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2" "$(PACKAGE_FOLDER)"
@-$(RM) $(PACKAGE_FOLDER)/package_version.txt
@git --git-dir=$(PACKAGE_FOLDER)/.git checkout .
$(MAKE) PACKAGE_NAME=$(PACKAGE_NAME) PACKAGE_VERSION=$(PACKAGE_VERSION) PACKAGE_FOLDER=$(PACKAGE_FOLDER) --no-builtin-rules postpackaging_core -C .
@echo ----------------------------------------------------------
tools: PACKAGE_NAME := STM32Tools
tools: PACKAGE_FOLDER := Arduino_Tools
tools: PACKAGE_VERSION := $(shell git --git-dir=$(PACKAGE_FOLDER)/.git describe --tags)
tools: PACKAGE_DATE := $(firstword $(shell git --git-dir=$(PACKAGE_FOLDER)/.git log -1 --pretty=format:%ci))
tools: clean print_info
@echo ----------------------------------------------------------
@echo "Packaging $@..."
@git --git-dir=$(PACKAGE_FOLDER)/.git show HEAD --pretty=short --no-patch > $(PACKAGE_FOLDER)/package_version.txt
@tar --mtime='$(PACKAGE_DATE)' \
--exclude=.git \
--exclude=.gitattributes \
--exclude=.github \
--exclude=.gitignore \
--exclude=linux \
--exclude=linux64 \
--exclude=macosx \
--transform "s|$(PACKAGE_FOLDER)|$(PACKAGE_NAME)|" \
-cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION)-windows.tar.bz2" "$(PACKAGE_FOLDER)"
@tar --mtime='$(PACKAGE_DATE)' \
--exclude=.git \
--exclude=.gitattributes \
--exclude=.github \
--exclude=.gitignore \
--exclude=macosx \
--exclude=win \
--transform "s|$(PACKAGE_FOLDER)|$(PACKAGE_NAME)|" \
-cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION)-linux.tar.bz2" "$(PACKAGE_FOLDER)"
@tar --mtime='$(PACKAGE_DATE)' \
--exclude=.git \
--exclude=.gitattributes \
--exclude=.github \
--exclude=.gitignore \
--exclude=linux \
--exclude=linux64 \
--exclude=win \
--transform "s|$(PACKAGE_FOLDER)|$(PACKAGE_NAME)|" \
-cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION)-mac.tar.bz2" "$(PACKAGE_FOLDER)"
@-$(RM) $(PACKAGE_FOLDER)/package_version.txt
$(MAKE) PACKAGE_NAME=$(PACKAGE_NAME) PACKAGE_VERSION=$(PACKAGE_VERSION) --no-builtin-rules postpackaging_tools -C .
@echo ----------------------------------------------------------
stm32_svd: PACKAGE_NAME := STM32_SVD
stm32_svd: PACKAGE_FOLDER := stm32_svd
stm32_svd: PACKAGE_VERSION := $(shell git --git-dir=$(PACKAGE_FOLDER)/.git describe --tags)
stm32_svd: PACKAGE_DATE := $(firstword $(shell git --git-dir=$(PACKAGE_FOLDER)/.git log -1 --pretty=format:%ci))
stm32_svd: clean print_info
@echo ----------------------------------------------------------
@echo "Packaging module."
@tar --mtime='$(PACKAGE_DATE)' \
--exclude=.git \
--absolute-names \
-cjf "$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.bz2" "$(PACKAGE_FOLDER)"
$(MAKE) PACKAGE_NAME=$(PACKAGE_NAME) PACKAGE_VERSION=$(PACKAGE_VERSION) --no-builtin-rules postpackaging_svd -C .
@echo ----------------------------------------------------------
clean:
@echo ----------------------------------------------------------
@echo Cleanup
-$(RM) *.tar.bz2 package_*.json
-$(RM) -r $(DOWNLOAD_PATH)
@echo ----------------------------------------------------------
print_info:
@echo ----------------------------------------------------------
@echo Building $(PACKAGE_NAME) using
@echo "CURDIR = $(CURDIR)"
@echo "OS = $(OS)"
@echo "SHELL = $(SHELL)"
@echo "PACKAGE_NAME = $(PACKAGE_NAME)"
@echo "PACKAGE_FOLDER = $(PACKAGE_FOLDER)"
@echo "PACKAGE_VERSION = $(PACKAGE_VERSION)"
postpackaging_core:
@echo "PACKAGE_CHKSUM = $(PACKAGE_CHKSUM)"
@echo "PACKAGE_SIZE = $(PACKAGE_SIZE)"
@echo "PACKAGE_FILENAME = $(PACKAGE_FILENAME)"
@BOARDS_LIST=`grep -E "^[^\.]+\.name=" $(PACKAGE_FOLDER)/boards.txt | cut -d'=' -f2 | awk '{print " {\"name\": \""$$0"\"},"}'`; \
BOARDS_LIST=$${BOARDS_LIST::-1}; \
cat templates/package_core_index.json | sed s/%%VERSION%%/$(PACKAGE_VERSION)/ | sed s/%%FILENAME%%/$(PACKAGE_FILENAME)/ | sed s/%%CHECKSUM%%/$(PACKAGE_CHKSUM)/ | sed s/%%SIZE%%/$(PACKAGE_SIZE)/ | sed -e "s/%%BOARDSLIST%%/$${BOARDS_LIST//$$'\n'/\\n}/" > package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json
@mv $(PACKAGE_FILENAME) $(CORE_PATH)/
@echo "package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json created"
postpackaging_tools:
@echo "PACKAGE_WIN_FILENAME = $(PACKAGE_WIN_FILENAME)"
@echo "PACKAGE_WIN_SIZE = $(PACKAGE_WIN_SIZE)"
@echo "PACKAGE_WIN_CHKSUM = $(PACKAGE_WIN_CHKSUM)"
@echo "PACKAGE_LINUX_FILENAME = $(PACKAGE_LINUX_FILENAME)"
@echo "PACKAGE_LINUX_SIZE = $(PACKAGE_LINUX_SIZE)"
@echo "PACKAGE_LINUX_CHKSUM = $(PACKAGE_LINUX_CHKSUM)"
@echo "PACKAGE_MAC_FILENAME = $(PACKAGE_MAC_FILENAME)"
@echo "PACKAGE_MAC_SIZE = $(PACKAGE_MAC_SIZE)"
@echo "PACKAGE_MAC_CHKSUM = $(PACKAGE_MAC_CHKSUM)"
@cat templates/package_tools_index.json | sed s/%%PACKAGENAME%%/$(PACKAGE_NAME)/ | sed s/%%VERSION%%/$(PACKAGE_VERSION)/ | sed s/%%FILENAMEWIN%%/$(PACKAGE_WIN_FILENAME)/ | sed s/%%CHECKSUMWIN%%/$(PACKAGE_WIN_CHKSUM)/ | sed s/%%SIZEWIN%%/$(PACKAGE_WIN_SIZE)/ | sed s/%%FILENAMEMAC%%/$(PACKAGE_MAC_FILENAME)/ | sed s/%%CHECKSUMMAC%%/$(PACKAGE_MAC_CHKSUM)/ | sed s/%%SIZEMAC%%/$(PACKAGE_MAC_SIZE)/ | sed s/%%FILENAMELINUX%%/$(PACKAGE_LINUX_FILENAME)/ | sed s/%%CHECKSUMLINUX%%/$(PACKAGE_LINUX_CHKSUM)/ | sed s/%%SIZELINUX%%/$(PACKAGE_LINUX_SIZE)/ > package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json
@mv $(PACKAGE_WIN_FILENAME) $(PACKAGE_LINUX_FILENAME) $(PACKAGE_MAC_FILENAME) $(TOOLS_PATH)/
@echo "package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json created"
postpackaging_svd:
@echo "PACKAGE_CHKSUM = $(PACKAGE_CHKSUM)"
@echo "PACKAGE_SIZE = $(PACKAGE_SIZE)"
@echo "PACKAGE_FILENAME = $(PACKAGE_FILENAME)"
@cat templates/package_svd_index.json | 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
@echo "package_$(PACKAGE_NAME)_$(PACKAGE_VERSION)_index.json created"