Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support cross compiling libcartesi as a static library #156

Merged
merged 15 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
*.d
*.clang-tidy
*.deb
*.a
*.wasm

build
pkg
third-party/downloads
third-party/mongoose-*
src/remote-cartesi-machine
Expand All @@ -22,6 +25,7 @@ doc/xml/
.vscode
.ycm_extra_conf.py

*.tar.gz
*.raw
*.so
*.dylib
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
build-essential vim wget git clang-tidy-15 clang-format-15 lcov \
libboost1.81-dev libssl-dev \
ca-certificates automake libtool patchelf pkg-config lua5.4 liblua5.4-dev \
ca-certificates pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 120 && \
Expand Down Expand Up @@ -48,7 +48,7 @@ ARG MACHINE_EMULATOR_VERSION=0.0.0
ARG TARGETARCH

RUN make install-tests
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt install -y \
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
./cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -62,7 +62,7 @@ ARG TARGETARCH
COPY --from=installer \
/usr/src/emulator/cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \
cartesi-machine.deb
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt install -y \
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \
./cartesi-machine.deb \
&& rm -rf /var/lib/apt/lists/* \
&& rm cartesi-machine.deb
Expand Down
215 changes: 114 additions & 101 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,81 @@
# with this program (see COPYING). If not, see <https://www.gnu.org/licenses/>.
#

UNAME:=$(shell uname)
TARGET_OS?=$(shell uname)
export TARGET_OS

# Install settings
ARCH:= $(shell dpkg --print-architecture 2>/dev/null || echo amd64)
DEB_ARCH= $(shell dpkg --print-architecture 2>/dev/null || echo amd64)
PREFIX= /usr
MACHINE_EMULATOR_VERSION:= $(shell make -sC src version)
MACHINE_EMULATOR_SO_VERSION:= $(shell make -sC src so-version)
DEB_FILENAME= cartesi-machine-v$(MACHINE_EMULATOR_VERSION)_$(ARCH).deb
MACHINE_EMULATOR_VERSION= $(shell make -sC src version)
MACHINE_EMULATOR_SO_VERSION= $(shell make -sC src so-version)
DEB_FILENAME= cartesi-machine-v$(MACHINE_EMULATOR_VERSION)_$(DEB_ARCH).deb
BIN_RUNTIME_PATH= $(PREFIX)/bin
LIB_RUNTIME_PATH= $(PREFIX)/lib
DOC_RUNTIME_PATH= $(PREFIX)/doc/cartesi-machine
SHARE_RUNTIME_PATH= $(PREFIX)/share/cartesi-machine
IMAGES_RUNTIME_PATH= $(SHARE_RUNTIME_PATH)/images
LUA_RUNTIME_CPATH= $(PREFIX)/lib/lua/5.4
LUA_RUNTIME_PATH= $(PREFIX)/share/lua/5.4
INSTALL_PLAT = install-$(UNAME)

LIBCARTESI_Darwin=libcartesi.dylib
LIBCARTESI_Linux=libcartesi.so
LIBCARTESI_GRPC_Darwin=libcartesi_grpc.dylib
LIBCARTESI_GRPC_Linux=libcartesi_grpc.so

LIBCARTESI_SO_Darwin:=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).dylib
LIBCARTESI_SO_Linux:=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).so
LIBCARTESI_SO_GRPC_Darwin:=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).dylib
LIBCARTESI_SO_GRPC_Linux:=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).so

BIN_INSTALL_PATH:= $(DESTDIR)$(BIN_RUNTIME_PATH)
LIB_INSTALL_PATH:= $(DESTDIR)$(LIB_RUNTIME_PATH)
DOC_INSTALL_PATH:= $(DESTDIR)$(DOC_RUNTIME_PATH)
SHARE_INSTALL_PATH:= $(DESTDIR)$(SHARE_RUNTIME_PATH)
IMAGES_INSTALL_PATH:= $(DESTDIR)$(IMAGES_RUNTIME_PATH)
UARCH_INSTALL_PATH:= $(SHARE_INSTALL_PATH)/uarch
LUA_INSTALL_CPATH:= $(DESTDIR)$(LUA_RUNTIME_CPATH)
LUA_INSTALL_PATH:= $(DESTDIR)$(LUA_RUNTIME_PATH)
INC_INSTALL_PATH:= $(DESTDIR)$(PREFIX)/include/cartesi-machine

INSTALL= cp -RP

ifeq ($(TARGET_OS),Darwin)
LIBCARTESI=libcartesi.dylib
LIBCARTESI_GRPC=libcartesi_grpc.dylib
LIBCARTESI_JSONRPC=libcartesi_jsonrpc.dylib
LIBCARTESI_SO=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).dylib
LIBCARTESI_SO_GRPC=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).dylib
LIBCARTESI_SO_JSONRPC=libcartesi_jsonrpc-$(MACHINE_EMULATOR_SO_VERSION).dylib
else
LIBCARTESI=libcartesi.so
LIBCARTESI_GRPC=libcartesi_grpc.so
LIBCARTESI_JSONRPC=libcartesi_jsonrpc.so
LIBCARTESI_SO=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).so
LIBCARTESI_SO_GRPC=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).so
LIBCARTESI_SO_JSONRPC=libcartesi_jsonrpc-$(MACHINE_EMULATOR_SO_VERSION).so
endif

BIN_INSTALL_PATH= $(abspath $(DESTDIR)$(BIN_RUNTIME_PATH))
LIB_INSTALL_PATH= $(abspath $(DESTDIR)$(LIB_RUNTIME_PATH))
DOC_INSTALL_PATH= $(abspath $(DESTDIR)$(DOC_RUNTIME_PATH))
SHARE_INSTALL_PATH= $(abspath $(DESTDIR)$(SHARE_RUNTIME_PATH))
IMAGES_INSTALL_PATH= $(abspath $(DESTDIR)$(IMAGES_RUNTIME_PATH))
UARCH_INSTALL_PATH= $(abspath $(SHARE_INSTALL_PATH)/uarch)
LUA_INSTALL_CPATH= $(abspath $(DESTDIR)$(LUA_RUNTIME_CPATH))
LUA_INSTALL_PATH= $(abspath $(DESTDIR)$(LUA_RUNTIME_PATH))
INC_INSTALL_PATH= $(abspath $(DESTDIR)$(PREFIX)/include/cartesi-machine)

INSTALL_FILE= install -m0644
INSTALL_EXEC= install -m0755
INSTALL_DIR= cp -RP
SYMLINK= ln -sf
CHMOD_EXEC= chmod 0755
CHMOD_DATA= chmod 0644
STRIP_EXEC= strip -x

EMU_TO_BIN= jsonrpc-remote-cartesi-machine remote-cartesi-machine merkle-tree-hash
EMU_TO_LIB= $(LIBCARTESI_SO_$(UNAME)) $(LIBCARTESI_SO_GRPC_$(UNAME))
EMU_LUA_TO_BIN= cartesi-machine.lua cartesi-machine-stored-hash.lua rollup-memory-range.lua
EMU_LUA_TEST_TO_BIN= cartesi-machine-tests.lua uarch-riscv-tests.lua
EMU_TO_LUA_PATH= cartesi/util.lua cartesi/proof.lua cartesi/gdbstub.lua
EMU_TO_LUA_CPATH= cartesi.so
EMU_TO_LUA_CARTESI_CPATH= cartesi/grpc.so cartesi/jsonrpc.so
STRIP= strip
STRIP_BINARY= $(STRIP)
STRIP_SHARED= $(STRIP) -S -x
STRIP_STATIC= $(STRIP) -S

EMU_TO_BIN= src/jsonrpc-remote-cartesi-machine src/remote-cartesi-machine src/merkle-tree-hash
EMU_TEST_TO_BIN= src/tests/test-merkle-tree-hash src/tests/test-machine-c-api
EMU_TO_LIB= src/$(LIBCARTESI_SO) src/$(LIBCARTESI_SO_GRPC) src/$(LIBCARTESI_SO_JSONRPC)
EMU_TO_LIB_A= src/libcartesi.a src/libcartesi_jsonrpc.a
EMU_LUA_TO_BIN= src/cartesi-machine.lua src/cartesi-machine-stored-hash.lua src/rollup-memory-range.lua
EMU_LUA_TEST_TO_BIN= src/cartesi-machine-tests.lua src/uarch-riscv-tests.lua
EMU_TO_LUA_PATH= src/cartesi/util.lua src/cartesi/proof.lua src/cartesi/gdbstub.lua
EMU_TO_LUA_CPATH= src/cartesi.so
EMU_TO_LUA_CARTESI_CPATH= src/cartesi/grpc.so src/cartesi/jsonrpc.so
EMU_TO_INC= $(addprefix src/,jsonrpc-machine-c-api.h grpc-machine-c-api.h machine-c-api.h \
machine-c-defines.h machine-c-version.h pma-defines.h rtc-defines.h htif-defines.h uarch-defines.h)
UARCH_TO_SHARE= uarch-ram.bin

MONGOOSE_VERSION=7.12

# Build settings
DEPDIR := third-party
SRCDIR := $(abspath src)
DOWNLOADDIR := $(DEPDIR)/downloads
DEPDIRS := third-party/mongoose-$(MONGOOSE_VERSION)
SUBCLEAN := $(addsuffix .clean,$(SRCDIR) uarch third-party/riscv-arch-tests)
COREPROTO := lib/grpc-interfaces/core.proto
DEPDIR = third-party
diegonehab marked this conversation as resolved.
Show resolved Hide resolved
SRCDIR = $(abspath src)
DOWNLOADDIR = $(DEPDIR)/downloads
DEPDIRS = third-party/mongoose-$(MONGOOSE_VERSION)
SUBCLEAN = $(addsuffix .clean,$(SRCDIR) uarch third-party/riscv-arch-tests)
COREPROTO = lib/grpc-interfaces/core.proto

# Docker image tag
TAG ?= devel
Expand All @@ -97,22 +110,25 @@ export release
export coverage

# Mac OS X specific settings
ifeq ($(UNAME),Darwin)
LUA_PLAT ?= macosx
ifeq ($(TARGET_OS),Darwin)
export CC = clang
export CXX = clang++
LUACC = "CC=$(CXX)"
LIBRARY_PATH := "export DYLD_LIBRARY_PATH="
LIBRARY_PATH = "export DYLD_LIBRARY_PATH="
SHA1SUM=shasum

# Linux specific settings
else ifeq ($(UNAME),Linux)
LUA_PLAT ?= linux
LIBRARY_PATH := "export LD_LIBRARY_PATH=$(SRCDIR)"
LUACC = "CC=g++"
# Unknown platform
else ifeq ($(TARGET_OS),Linux)
export CC=gcc
export CXX=g++
LIBRARY_PATH = "export LD_LIBRARY_PATH=$(SRCDIR)"
SHA1SUM=sha1sum

# Other system
else
LUA_PLAT ?= none
INSTALL_PLAT=
export CC=gcc
export CXX=g++
SHA1SUM=sha1sum

endif

all: source-default
Expand Down Expand Up @@ -157,7 +173,7 @@ help:
@echo ' uarch-tests-with-linux-env - build and run microarchitecture rv64i instruction tests using the linux-env docker image'

checksum:
@cd $(DEPDIR) && shasum -c shasumfile
@cd $(DEPDIR) && $(SHA1SUM) -c shasumfile

$(DOWNLOADDIR):
@mkdir -p $(DOWNLOADDIR)
Expand All @@ -170,6 +186,13 @@ third-party/downloads/$(MONGOOSE_VERSION).tar.gz: | downloads
third-party/mongoose-$(MONGOOSE_VERSION): third-party/downloads/$(MONGOOSE_VERSION).tar.gz
tar -C third-party -xzf $< mongoose-$(MONGOOSE_VERSION)/mongoose.c mongoose-$(MONGOOSE_VERSION)/mongoose.h

bundle-boost: third-party/downloads/boost
third-party/downloads/boost: | downloads
wget -O third-party/downloads/boost_1_81_0.tar.gz https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz
tar -C third-party/downloads -xzf third-party/downloads/boost_1_81_0.tar.gz boost_1_81_0/boost
mv third-party/downloads/boost_1_81_0/boost third-party/downloads/boost
rm -rf third-party/downloads/boost_1_81_0.tar.gz third-party/downloads/boost_1_81_0

dep: $(DEPDIRS)

submodules:
Expand All @@ -184,6 +207,9 @@ grpc: | $(COREPROTO)
hash luacartesi grpc test lint coverage-report check-format format check-format-lua check-lua format-lua:
@eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C $(SRCDIR) $@

libcartesi libcartesi_grpc libcartesi_jsonrpc libcartesi.a libcartesi_jsonrpc.a libcartesi.so libcartesi_grpc.so libcartesi_jsonrpc.so:
@eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C $(SRCDIR) $@

version:
@eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -sC $(SRCDIR) $@

Expand Down Expand Up @@ -257,61 +283,48 @@ uarch-with-linux-env:
uarch-tests-with-linux-env:
@$(MAKE) linux-env-exec CONTAINER_COMMAND="make uarch-tests"

install-Darwin:
install_name_tool -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi.so
install_name_tool -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi/grpc.so
install_name_tool -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi/jsonrpc.so
cd $(BIN_INSTALL_PATH) && \
for x in $(EMU_TO_BIN); do \
install_name_tool -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $$x ;\
done
install-headers: $(INC_INSTALL_PATH)
$(INSTALL_FILE) $(EMU_TO_INC) $(INC_INSTALL_PATH)

install-emulator: $(BIN_INSTALL_PATH) $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi $(LUA_INSTALL_PATH)/cartesi $(IMAGES_INSTALL_PATH)
$(INSTALL_EXEC) $(EMU_TO_BIN) $(BIN_INSTALL_PATH)
$(INSTALL_EXEC) $(EMU_TO_LIB) $(LIB_INSTALL_PATH)
$(INSTALL_FILE) $(EMU_TO_LIB_A) $(LIB_INSTALL_PATH)
$(INSTALL_FILE) $(EMU_LUA_TO_BIN) $(LUA_INSTALL_PATH)
$(INSTALL_EXEC) $(EMU_TO_LUA_CPATH) $(LUA_INSTALL_CPATH)
$(INSTALL_EXEC) $(EMU_TO_LUA_CARTESI_CPATH) $(LUA_INSTALL_CPATH)/cartesi
$(INSTALL_FILE) $(EMU_TO_LUA_PATH) $(LUA_INSTALL_PATH)/cartesi
cat tools/template/cartesi-machine.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_INSTALL_PATH|$(IMAGES_RUNTIME_PATH)|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine
cat tools/template/cartesi-machine-stored-hash.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine-stored-hash
cat tools/template/rollup-memory-range.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/rollup-memory-range
$(CHMOD_EXEC) $(BIN_INSTALL_PATH)/cartesi-machine $(BIN_INSTALL_PATH)/cartesi-machine-stored-hash $(BIN_INSTALL_PATH)/rollup-memory-range
$(SYMLINK) $(LIBCARTESI_SO) $(LIB_INSTALL_PATH)/$(LIBCARTESI)
$(SYMLINK) $(LIBCARTESI_SO_GRPC) $(LIB_INSTALL_PATH)/$(LIBCARTESI_GRPC)
$(SYMLINK) $(LIBCARTESI_SO_JSONRPC) $(LIB_INSTALL_PATH)/$(LIBCARTESI_JSONRPC)
$(INSTALL_DIR) tools/gdb $(SHARE_INSTALL_PATH)/gdb

install-Linux:
cd $(BIN_INSTALL_PATH) && for x in $(EMU_TO_BIN); do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x ; done
cd $(LIB_INSTALL_PATH) && for x in $(EMU_TO_LIB); do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x; done
cd $(LUA_INSTALL_CPATH) && for x in $(EMU_TO_LUA_CPATH) $(EMU_TO_LUA_CARTESI_CPATH); do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x ; done
install-strip: install-emulator
$(STRIP_BINARY) $(subst src/,$(BIN_INSTALL_PATH)/,$(EMU_TO_BIN))
$(STRIP_SHARED) $(subst src/,$(LUA_INSTALL_CPATH)/,$(EMU_TO_LUA_CPATH))
$(STRIP_SHARED) $(subst src/,$(LIB_INSTALL_PATH)/,$(EMU_TO_LIB))
$(STRIP_STATIC) $(subst src/,$(LIB_INSTALL_PATH)/,$(EMU_TO_LIB_A))

install: install-strip install-headers

install-tests: install
cd src && $(INSTALL) $(EMU_LUA_TEST_TO_BIN) $(LUA_INSTALL_PATH)
cd src && $(INSTALL) tests/test-merkle-tree-hash tests/test-machine-c-api $(BIN_INSTALL_PATH)
$(INSTALL_FILE) $(EMU_LUA_TEST_TO_BIN) $(LUA_INSTALL_PATH)
$(INSTALL_EXEC) $(EMU_TEST_TO_BIN) $(BIN_INSTALL_PATH)
cat tools/template/cartesi-machine-tests.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine-tests
cat tools/template/uarch-riscv-tests.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/uarch-riscv-tests
cd $(LUA_INSTALL_PATH) && $(CHMOD_DATA) $(EMU_LUA_TEST_TO_BIN)
cd $(BIN_INSTALL_PATH) && $(CHMOD_EXEC) cartesi-machine-tests uarch-riscv-tests
patchelf --set-rpath $(LIB_RUNTIME_PATH) src/tests/test-merkle-tree-hash
patchelf --set-rpath $(LIB_RUNTIME_PATH) src/tests/test-machine-c-api

install-emulator: $(BIN_INSTALL_PATH) $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi $(LUA_INSTALL_PATH)/cartesi $(INC_INSTALL_PATH) $(IMAGES_INSTALL_PATH)
cd src && $(INSTALL) $(EMU_TO_BIN) $(BIN_INSTALL_PATH)
cd src && $(INSTALL) $(EMU_TO_LIB) $(LIB_INSTALL_PATH)
cd src && $(INSTALL) $(EMU_LUA_TO_BIN) $(LUA_INSTALL_PATH)
cd src && $(INSTALL) $(EMU_TO_LUA_CPATH) $(LUA_INSTALL_CPATH)
cd src && $(INSTALL) $(EMU_TO_LUA_CARTESI_CPATH) $(LUA_INSTALL_CPATH)/cartesi
cd src && $(INSTALL) $(EMU_TO_LUA_PATH) $(LUA_INSTALL_PATH)/cartesi
cat tools/template/cartesi-machine.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_INSTALL_PATH|$(IMAGES_RUNTIME_PATH)|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine
cat tools/template/cartesi-machine-stored-hash.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine-stored-hash
cat tools/template/rollup-memory-range.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/rollup-memory-range
cd $(BIN_INSTALL_PATH) && $(CHMOD_EXEC) $(EMU_TO_BIN) cartesi-machine cartesi-machine-stored-hash rollup-memory-range
cd $(LIB_INSTALL_PATH) && ln -sf $(LIBCARTESI_SO_$(UNAME)) $(LIBCARTESI_$(UNAME))
cd $(LIB_INSTALL_PATH) && ln -sf $(LIBCARTESI_SO_GRPC_$(UNAME)) $(LIBCARTESI_GRPC_$(UNAME))
cd $(LUA_INSTALL_PATH) && $(CHMOD_DATA) $(EMU_LUA_TO_BIN)
$(INSTALL) $(EMU_TO_INC) $(INC_INSTALL_PATH)
$(INSTALL) tools/gdb $(SHARE_INSTALL_PATH)/gdb
cd $(LUA_INSTALL_CPATH) && $(CHMOD_EXEC) $(EMU_TO_LUA_CPATH)
$(CHMOD_EXEC) $(BIN_INSTALL_PATH)/cartesi-machine-tests $(BIN_INSTALL_PATH)/uarch-riscv-tests

install-uarch: install $(UARCH_INSTALL_PATH)
$(INSTALL) uarch/$(UARCH_TO_SHARE) $(UARCH_INSTALL_PATH)

install-strip: install-emulator
cd $(BIN_INSTALL_PATH) && $(STRIP_EXEC) $(EMU_TO_BIN)
cd $(LIB_INSTALL_PATH) && $(STRIP_EXEC) $(EMU_TO_LIB)
cd $(LUA_INSTALL_CPATH) && $(STRIP_EXEC) $(EMU_TO_LUA_CPATH)
$(INSTALL_FILE) uarch/$(UARCH_TO_SHARE) $(UARCH_INSTALL_PATH)

install: install-emulator install-strip $(INSTALL_PLAT)
debian-package: install
mkdir -p $(DESTDIR)/DEBIAN $(DOC_INSTALL_PATH)
$(INSTALL) COPYING $(DOC_INSTALL_PATH)/copyright
cat tools/template/control.template | sed 's|ARG_VERSION|$(MACHINE_EMULATOR_VERSION)|g;s|ARG_ARCH|$(ARCH)|g' > $(DESTDIR)/DEBIAN/control
$(INSTALL_FILE) COPYING $(DOC_INSTALL_PATH)/copyright
cat tools/template/control.template | sed 's|ARG_VERSION|$(MACHINE_EMULATOR_VERSION)|g;s|ARG_ARCH|$(DEB_ARCH)|g' > $(DESTDIR)/DEBIAN/control
dpkg-deb -Zxz --root-owner-group --build $(DESTDIR) $(DEB_FILENAME)

.SECONDARY: $(DOWNLOADDIR) $(DEPDIRS) $(COREPROTO)
Expand Down
Loading