105 lines
4.1 KiB
Makefile
105 lines
4.1 KiB
Makefile
.PHONY: all submodule githooks src test tools install format format-check clean
|
|
|
|
all: src
|
|
|
|
githooks:
|
|
@find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
|
|
@echo "Add Git hooks that check Rust code format issues before commits and pushes"
|
|
|
|
OCCLUM_GIT_OPTIONS ?=
|
|
GIT_MIN_VERSION := 2.11.0
|
|
GIT_CURRENT_VERSION := $(shell git --version | sed 's/[^0-9.]*//g')
|
|
GIT_NEED_PROGRESS := $(shell /bin/echo -e "$(GIT_MIN_VERSION)\n$(GIT_CURRENT_VERSION)" \
|
|
| sort -V | head -n1 | grep -q $(GIT_MIN_VERSION) && echo "true" || echo "false")
|
|
# If git version >= min_version, append the `--progress` option to show progress status
|
|
ifeq ($(GIT_NEED_PROGRESS), true)
|
|
OCCLUM_GIT_OPTIONS += --progress
|
|
else
|
|
OCCLUM_GIT_OPTIONS +=
|
|
endif
|
|
|
|
# Enclaves using by tools are running in simulation mode by default to run faster.
|
|
# If a user really wants to run the tools in SGX hardware mode, please use command
|
|
# `OCCLUM_TOOLS_SIM_MODE_ONLY=N make submodule`.
|
|
OCCLUM_TOOLS_SIM_MODE_ONLY ?= Y
|
|
|
|
submodule: githooks
|
|
git submodule init
|
|
git submodule update $(OCCLUM_GIT_OPTIONS)
|
|
@# Try to apply the patches. If failed, check if the patches are already applied
|
|
cd deps/rust-sgx-sdk && git apply ../rust-sgx-sdk.patch >/dev/null 2>&1 || git apply ../rust-sgx-sdk.patch -R --check
|
|
cd deps/serde-json-sgx && git apply ../serde-json-sgx.patch >/dev/null 2>&1 || git apply ../serde-json-sgx.patch -R --check
|
|
|
|
ifeq ($(OCCLUM_TOOLS_SIM_MODE_ONLY), Y)
|
|
@# Tools and sefs-fuse are used in SIM mode by default
|
|
@rm -rf build build_sim
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C tools
|
|
@$(MAKE) --no-print-directory -C deps/sefs/sefs-fuse clean
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C deps/sefs/sefs-fuse
|
|
@cp deps/sefs/sefs-fuse/bin/sefs-fuse build_sim/bin
|
|
@cp deps/sefs/sefs-fuse/lib/libsefs-fuse.signed.so build_sim/lib
|
|
@cp -r build_sim build
|
|
else
|
|
@# Tools and sefs-fuse are built for both HW mode and SIM mode
|
|
@rm -rf build build_sim
|
|
@$(MAKE) SGX_MODE=HW --no-print-directory -C tools
|
|
@$(MAKE) --no-print-directory -C deps/sefs/sefs-fuse clean
|
|
@$(MAKE) SGX_MODE=HW --no-print-directory -C deps/sefs/sefs-fuse
|
|
@cp deps/sefs/sefs-fuse/bin/sefs-fuse build/bin
|
|
@cp deps/sefs/sefs-fuse/lib/libsefs-fuse.signed.so build/lib
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C tools
|
|
@$(MAKE) --no-print-directory -C deps/sefs/sefs-fuse clean
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C deps/sefs/sefs-fuse
|
|
@cp deps/sefs/sefs-fuse/bin/sefs-fuse build_sim/bin
|
|
@cp deps/sefs/sefs-fuse/lib/libsefs-fuse.signed.so build_sim/lib
|
|
endif
|
|
|
|
src:
|
|
@$(MAKE) --no-print-directory -C src
|
|
|
|
test:
|
|
@$(MAKE) --no-print-directory -C test test
|
|
|
|
OCCLUM_PREFIX ?= /opt/occlum
|
|
install:
|
|
@# Install both libraries for HW mode and SIM mode
|
|
@$(MAKE) SGX_MODE=HW --no-print-directory -C src
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C src
|
|
|
|
@echo "Install libraries for SGX hardware mode ..."
|
|
@mkdir -p $(OCCLUM_PREFIX)/build/bin/
|
|
@cp build/bin/* $(OCCLUM_PREFIX)/build/bin
|
|
@mkdir -p $(OCCLUM_PREFIX)/build/lib/
|
|
@cp --no-dereference build/lib/* $(OCCLUM_PREFIX)/build/lib/
|
|
|
|
@echo "Install libraries for SGX simulation mode ..."
|
|
@mkdir -p $(OCCLUM_PREFIX)/build_sim/bin/
|
|
@cp build_sim/bin/* $(OCCLUM_PREFIX)/build_sim/bin
|
|
@mkdir -p $(OCCLUM_PREFIX)/build_sim/lib/
|
|
@cp --no-dereference build_sim/lib/* $(OCCLUM_PREFIX)/build_sim/lib/
|
|
|
|
@echo "Install headers and miscs ..."
|
|
@mkdir -p $(OCCLUM_PREFIX)/include/
|
|
@cp -r src/pal/include/*.h $(OCCLUM_PREFIX)/include
|
|
@chmod 444 $(OCCLUM_PREFIX)/include/*.h
|
|
@mkdir -p $(OCCLUM_PREFIX)/etc/template/
|
|
@cp etc/template/* $(OCCLUM_PREFIX)/etc/template
|
|
@chmod 444 $(OCCLUM_PREFIX)/etc/template/*
|
|
@echo "Installation is done."
|
|
|
|
format:
|
|
@$(MAKE) --no-print-directory -C test format
|
|
@$(MAKE) --no-print-directory -C tools format
|
|
@$(MAKE) --no-print-directory -C src format
|
|
|
|
format-check:
|
|
@$(MAKE) --no-print-directory -C test format-check
|
|
@$(MAKE) --no-print-directory -C tools format-check
|
|
@$(MAKE) --no-print-directory -C src format-check
|
|
|
|
clean:
|
|
@$(MAKE) --no-print-directory -C src clean
|
|
@$(MAKE) --no-print-directory -C test clean
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C src clean
|
|
@$(MAKE) SGX_MODE=SIM --no-print-directory -C test clean
|