-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
83 lines (63 loc) · 2.98 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
# Copyright 2023 University of Adelaide
#
# 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.
#
ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NODE_DIR := $(ROOT)/bins/node
NODE := $(ROOT)/bins/node/bin/node
NODE_VERSION := 20.5.1
PATH := $(NODE_DIR)/bin:$(PATH)
BUILT_CRYPTOPT := $(ROOT)/dist/CryptOpt.js
.PHONY: all build check clean deepclean jasmin
all: clean $(BUILT_CRYPTOPT)
build: $(BUILT_CRYPTOPT)
$(NODE):
mkdir -p ./bins
curl -L https://nodejs.org/dist/v$(NODE_VERSION)/node-v$(NODE_VERSION)-linux-x64.tar.xz | tar --extract --xz --directory ./bins
mv -f ./bins/node-v$(NODE_VERSION)-linux-x64 "$(NODE_DIR)"
node_modules:
@echo "Installing dependencies"
@CFLAGS="-I$(NODE_DIR)/include" PATH=$(PATH) npm $$(test -e ./package-lock.json && echo 'clean-install' || echo "install")
FIAT_DATA_DIR=src/bridge/fiat-bridge/data
FIAT_CHECKSUMS=$(FIAT_DATA_DIR)/sha256sums
FIAT_BINARIES=unsaturated_solinas word_by_word_montgomery dettman_multiplication solinas_reduction
$(FIAT_CHECKSUMS): $(addprefix $(FIAT_DATA_DIR)/, $(FIAT_BINARIES))
cd $(FIAT_DATA_DIR) && sha256sum $(FIAT_BINARIES) > $(notdir $(FIAT_CHECKSUMS))
$(BUILT_CRYPTOPT): $(NODE) node_modules $(shell find ./src -type f -name '*ts') $(FIAT_CHECKSUMS)
@echo "Building CryptOpt"
@PATH=$(PATH) npm run bundle
@test -e "$(@)" && touch $(@) && echo "Successfully built CryptOpt. :)"
check: $(BUILT_CRYPTOPT)
PATH=$(PATH) npm run test-no-watch
clean:
@rm -rf ./dist ./coverage ./bundle.tar.gz ./bundle.zip
deepclean: clean
rm -rf ./bins ./node_modules package-lock.json
install-zsh:
install -v $(ROOT)/completion/_cryptopt /usr/local/share/zsh/site-functions && echo -e "Installed successfully\nRestart your shell to enjoy\n"
BUNDLE_FILES:=$(shell find . -type f ! -path './bundle*' -a ! -path '*node_modules*' -a ! -path '*results*' -a ! -path '*.git*' -a ! -path './bins/*' -a ! -path '*dist*')
dist: bundle.tar.gz bundle.zip
bundle.tar.gz: $(BUNDLE_FILES)
tar czvf ${@} $(^)
bundle.zip: $(BUNDLE_FILES)
zip ${@} $(^)
jasmin: $(BUILT_CRYPTOPT)
clear
./CryptOpt --bridge jasmin --verbose --seed 123456
watch: $(NODE) node_modules
@PATH=$(PATH) DEBUG=1 npm run bundle-w
update-copyright: FILES=$(shell grep -e 'Copyright 2022' --files-with-matches --no-messages --recursive --exclude=results* --exclude=node_modules/* --exclude=.git/* --exclude=modules/*)
update-copyright: deepclean
@printf "Before: %d\n" $(words $(FILES))
@echo $(FILES)
sed -e '1,20{s/Copyright 2022/Copyright 2023/}' -i $(FILES)