-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
127 lines (98 loc) · 3.34 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
116
117
118
119
120
121
122
123
124
125
126
127
# 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.
#
UNAME:=$(shell uname)
# Containers tags
TOOLCHAIN_TAG ?= devel
KERNEL_TAG ?= devel
KERNEL_TOOLCHAIN_TAG := $(TOOLCHAIN_TAG)
# Install settings
PREFIX?= /usr
SHARE_INSTALL_PATH= $(PREFIX)/share/cartesi-machine
IMAGES_INSTALL_PATH= $(SHARE_INSTALL_PATH)/images
INSTALL= install -p
INSTALL_EXEC= $(INSTALL) -m 0755
INSTALL_DATA= $(INSTALL) -m 0644
TOOLS_TO_IMAGES= rootfs-tools-v0.16.1.ext2
KERNEL_TO_IMAGES= linux-6.5.13-ctsi-1-v0.20.0.bin
SRCDIRS := emulator
SRCCLEAN := $(addsuffix .clean,$(SRCDIRS))
SRCDISTC := $(addsuffix .distclean,$(SRCDIRS))
CONTAINER_BASE := /opt/cartesi/machine-emulator-sdk
CONTAINER_MAKE := /usr/bin/make
UPPER = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
export PREFIX
all:
@echo "Usage: make [option]\n"
@echo "Options: toolchain, kernel, tools, emulator and solidity-step.\n"
@echo "eg.: make emulator"
clean: $(SRCCLEAN)
distclean: $(SRCDISTC)
$(BUILDDIR) $(IMAGES_INSTALL_PATH):
mkdir -p $@
submodules:
git submodule update --init --recursive emulator kernel toolchain solidity-step tools
emulator:
$(MAKE) -C $@
$(SRCCLEAN): %.clean:
$(MAKE) -C $* clean
$(SRCDISTC): %.distclean:
$(MAKE) -C $* distclean
run-tests:
$(MAKE) -C emulator build-tests-all
$(MAKE) -C emulator test
kernel-env:
@docker run --hostname $@ -it --rm \
-v `pwd`:$(CONTAINER_BASE) \
-w $(CONTAINER_BASE) \
cartesi/image-kernel:$(KERNEL_TAG) $(CONTAINER_COMMAND)
toolchain-env:
docker run --hostname $@ -it --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:$(CONTAINER_BASE) \
-w $(CONTAINER_BASE) \
cartesi/toolchain:$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND)
toolchain-exec:
docker run --hostname $@ --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:$(CONTAINER_BASE) \
-w $(CONTAINER_BASE) \
cartesi/toolchain:$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND)
kernel:
$(MAKE) -C $@ \
TAG=$($(call UPPER,$@)_TAG) \
TOOLCHAIN_TAG=$($(call UPPER,$@)_TOOLCHAIN_TAG)
tools:
$(MAKE) -C $@
toolchain:
$(MAKE) -C $@ TOOLCHAIN_TAG=$(TOOLCHAIN_TAG)
solidity-step:
$(MAKE) -C $@ build
create-symlinks:
@ln -svf ../../tools/$(TOOLS_TO_IMAGES) emulator/src/rootfs.ext2
@ln -svf ../../kernel/artifacts/$(KERNEL_TO_IMAGES) emulator/src/linux.bin
install: $(IMAGES_INSTALL_PATH)
$(MAKE) -C emulator install
cd kernel/artifacts && $(INSTALL_DATA) $(KERNEL_TO_IMAGES) $(IMAGES_INSTALL_PATH)
cd tools && $(INSTALL_DATA) $(TOOLS_TO_IMAGES) $(IMAGES_INSTALL_PATH)
cd $(IMAGES_INSTALL_PATH) && ln -s $(KERNEL_TO_IMAGES) linux.bin
cd $(IMAGES_INSTALL_PATH) && ln -s $(TOOLS_TO_IMAGES) rootfs.ext2
.PHONY: all submodules clean kernel toolchain tools solidity-step kernel-env toolchain-env $(SRCDIRS) $(SRCCLEAN)