forked from cartesi/machine-emulator-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
115 lines (95 loc) · 4.36 KB
/
Makefile
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
# Copyright Cartesi and individual authors (see AUTHORS)
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
MAJOR := 0
MINOR := 13
PATCH := 0
LABEL :=
VERSION := $(MAJOR).$(MINOR).$(PATCH)$(LABEL)
MACHINE_EMULATOR_TOOLS_VERSION ?= v$(VERSION)
MACHINE_EMULATOR_TOOLS_TAR_GZ := machine-emulator-tools-$(MACHINE_EMULATOR_TOOLS_VERSION).tar.gz
MACHINE_EMULATOR_TOOLS_DEB := machine-emulator-tools-$(MACHINE_EMULATOR_TOOLS_VERSION).deb
MACHINE_EMULATOR_TOOLS_IMAGE := cartesi/machine-emulator-tools:$(MACHINE_EMULATOR_TOOLS_VERSION)
LINUX_SOURCES_VERSION ?= 5.15.63-ctsi-2
LINUX_SOURCES_FILEPATH := dep/linux-$(LINUX_SOURCES_VERSION).tar.gz
LINUX_SOURCES_URLPATH := https://github.com/cartesi/linux/archive/refs/tags/v$(LINUX_SOURCES_VERSION).tar.gz
RNDADDENTROPY_VERSION ?= 3.0.0
RNDADDENTROPY_FILEPATH := dep/twuewand-$(RNDADDENTROPY_VERSION).tar.gz
RNDADDENTROPY_URLPATH := https://www.finnie.org/software/twuewand/twuewand-$(RNDADDENTROPY_VERSION).tar.gz
SHASUMFILES := $(LINUX_SOURCES_FILEPATH) $(RNDADDENTROPY_FILEPATH)
all: build copy
build: Dockerfile checksum
docker buildx build --platform=linux/riscv64 --load \
--build-arg MACHINE_EMULATOR_TOOLS_TAR_GZ=$(MACHINE_EMULATOR_TOOLS_TAR_GZ) \
--build-arg MACHINE_EMULATOR_TOOLS_DEB=$(MACHINE_EMULATOR_TOOLS_DEB) \
--build-arg LINUX_SOURCES_VERSION=$(LINUX_SOURCES_VERSION) \
--build-arg LINUX_SOURCES_FILEPATH=$(LINUX_SOURCES_FILEPATH) \
--build-arg RNDADDENTROPY_VERSION=$(RNDADDENTROPY_VERSION) \
--build-arg RNDADDENTROPY_FILEPATH=$(RNDADDENTROPY_FILEPATH) \
-t $(MACHINE_EMULATOR_TOOLS_IMAGE) \
-f $< \
.
copy:
ID=`docker create --platform=linux/riscv64 $(MACHINE_EMULATOR_TOOLS_IMAGE)` && \
docker cp $$ID:/opt/cartesi/$(MACHINE_EMULATOR_TOOLS_TAR_GZ) . && \
docker cp $$ID:/opt/cartesi/$(MACHINE_EMULATOR_TOOLS_DEB) . && \
docker rm $$ID
deb:
mkdir -p $(DESTDIR)/DEBIAN
cat tools/template/control.template | sed 's|ARG_VERSION|$(VERSION)|g' > $(DESTDIR)/DEBIAN/control
cp -R $(STAGING_BASE)* $(DESTDIR)$(PREFIX)
dpkg-deb -Zxz --root-owner-group --build $(DESTDIR) $(MACHINE_EMULATOR_TOOLS_DEB)
$(LINUX_SOURCES_FILEPATH):
T=`mktemp` && \
mkdir -p `dirname $@` && \
wget $(LINUX_SOURCES_URLPATH) -O $$T && \
mv $$T $@ || (rm $$T && false)
$(RNDADDENTROPY_FILEPATH):
T=`mktemp` && \
mkdir -p `dirname $@` && \
wget $(RNDADDENTROPY_URLPATH) -O $$T && \
mv $$T $@ || (rm $$T && false)
shasumfile: $(SHASUMFILES)
shasum -a 256 $^ > $@
checksum: $(SHASUMFILES)
@shasum -ca 256 shasumfile
env:
@echo MACHINE_EMULATOR_TOOLS_TAR_GZ=$(MACHINE_EMULATOR_TOOLS_TAR_GZ)
@echo MACHINE_EMULATOR_TOOLS_DEB=$(MACHINE_EMULATOR_TOOLS_DEB)
@echo MACHINE_EMULATOR_TOOLS_VERSION=$(MACHINE_EMULATOR_TOOLS_VERSION)
@echo LINUX_SOURCES_VERSION=$(LINUX_SOURCES_VERSION)
@echo LINUX_SOURCES_FILEPATH=$(LINUX_SOURCES_FILEPATH)
@echo RNDADDENTROPY_VERSION=$(RNDADDENTROPY_VERSION)
@echo RNDADDENTROPY_FILEPATH=$(RNDADDENTROPY_FILEPATH)
setup:
docker run --privileged --rm linuxkit/binfmt:bebbae0c1100ebf7bf2ad4dfb9dfd719cf0ef132
setup-required:
@echo 'riscv64 buildx setup required:' `docker buildx ls | grep -q riscv64 && echo no || echo yes`
help:
@echo 'available commands:'
@echo ' setup - setup riscv64 buildx'
@echo ' setup-required - check if riscv64 buildx setup is required'
@echo '+ tgz - create "$(MACHINE_EMULATOR_TOOLS_TAR_GZ)" (default)'
@echo ' help - list makefile commands'
@echo ' checksum - verify downloaded files'
@echo ' shasumfile - recreate shasumfile of downloaded files'
@echo ' env - print useful Makefile variables as a KEY=VALUE list'
@echo ' clean - remove the generated artifacts'
@echo ' distclean - clean and remove dependencies'
clean:
rm -f $(MACHINE_EMULATOR_TOOLS_TAR_GZ) $(MACHINE_EMULATOR_TOOLS_DEB)
distclean: clean
rm -rf dep
.PHONY: checksum env setup help