Debian Codegraph @

Makefile

raw
1 # Constants
2 MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
3 PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH)))
4 GOPATH_LOCAL = $(PRJ_DIR)/build
5 GOPATH_DIR = github.com/cloudflare/sidh
6 VENDOR_DIR = build/vendor
7 CSHAKE_PKG ?= github.com/henrydcase/nobs/hash/sha3
8 TARGETS = p503 p751 sidh sike
9 GO ?= go
10 GOARCH ?=
11 OPTS_GCCGO ?= -compiler gccgo -O2 -g
12 OPTS ?=
13 OPTS_TAGS ?= -tags=noasm
14 NOASM ?=
15 # -run="NonExistent" is set to make sure tests are not run before benchmarking
16 BENCH_OPTS ?= -bench=. -run="NonExistent"
17 # whether to be verbose
18 V ?= 1
19
20 ifeq ($(NOASM),1)
21 OPTS+=$(OPTS_TAGS)
22 endif
23
24 ifeq ($(V),1)
25 OPTS += -v # Be verbose
26 BENCH_OPTS += -gcflags=-m # Show results from inlining
27 endif
28
29 all: test
30 clean:
31 rm -rf $(GOPATH_LOCAL)
32 rm -rf coverage*.txt
33
34 build_env:
35 GOPATH=$(GOPATH_LOCAL) $(GO) get $(CSHAKE_PKG)
36 mkdir -p $(GOPATH_LOCAL)/src/$(GOPATH_DIR)
37 cp -rf internal $(GOPATH_LOCAL)/src/$(GOPATH_DIR)
38 cp -rf etc $(GOPATH_LOCAL)/src/$(GOPATH_DIR)
39
40 copy-target-%:
41 cp -rf $* $(GOPATH_LOCAL)/src/$(GOPATH_DIR)
42
43 prep_targets: build_env $(addprefix copy-target-, $(TARGETS))
44
45 install-%: prep_targets
46 GOPATH=$(GOPATH_LOCAL) GOARCH=$(GOARCH) $(GO) install $(OPTS) $(GOPATH_DIR)/$*
47
48 test-%: prep_targets
49 GOPATH=$(GOPATH_LOCAL) $(GO) vet $(GOPATH_DIR)/$*
50 GOPATH=$(GOPATH_LOCAL) GOARCH=$(GOARCH) $(GO) test $(OPTS) $(GOPATH_DIR)/$*
51
52 bench-%: prep_targets
53 GOMAXPROCS=1 GOPATH=$(GOPATH_LOCAL) $(GO) test $(OPTS) $(GOPATH_DIR)/$* $(BENCH_OPTS)
54
55 cover-%: prep_targets
56 GOPATH=$(GOPATH_LOCAL) $(GO) test \
57 -race -coverprofile=coverage_$*.txt -covermode=atomic $(OPTS) $(GOPATH_DIR)/$*
58 cat coverage_$*.txt >> coverage.txt
59 rm coverage_$*.txt
60
61 vendor: clean
62 mkdir -p $(VENDOR_DIR)/github_com/cloudflare/sidh/
63 rsync -a . $(VENDOR_DIR)/github_com/cloudflare/sidh/ \
64 --exclude=$(VENDOR_DIR) \
65 --exclude=.git \
66 --exclude=.travis.yml \
67 --exclude=README.md \
68 --exclude=Makefile \
69 --exclude=build
70 # This swaps all imports with github.com to github_com, so that standard library doesn't
71 # try to access external libraries.
72 find $(VENDOR_DIR) -type f -iname "*.go" -print0 | xargs -0 sed -i 's/github\.com/github_com/g'
73
74 bench: $(addprefix bench-, $(TARGETS))
75 cover: $(addprefix cover-, $(TARGETS))
76 install: $(addprefix install-, $(TARGETS))
77 test: $(addprefix test-, $(TARGETS))