forked from kryptco/kr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (111 loc) · 3.59 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
OS ?= $(shell ./install/os.sh)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PREFIX ?= /usr
SUDO ?= sudo
endif
ifeq ($(UNAME_S),Darwin)
PREFIX ?= /usr/local
OSXRELEASE := $(shell uname -r | sed 's/\..*//')
ifeq ($(OSXRELEASE), 17)
OSXVER = "High Sierra"
endif
ifeq ($(OSXRELEASE), 16)
OSXVER = "Sierra"
endif
ifeq ($(OSXRELEASE), 15)
OSXVER = "El Capitan"
endif
ifeq ($(OSXRELEASE), 14)
OSXVER = "Yosemite"
endif
ifeq ($(OSXRELEASE), 13)
OSXVER = "Maverick"
endif
ifeq ($(OSXRELEASE), 12)
OSXVER = "Mountain Lion"
endif
ifeq ($(OSXRELEASE), 11)
OSXVER = "Lion"
endif
ifeq ($(shell expr $(OSXRELEASE) \>= 16), 1)
CGO_TEST_LDFLAGS += -F${PWD}/Frameworks -Wl,-rpath,${PWD}/Frameworks -framework krbtle
CGO_LDFLAGS += -F${PWD}/Frameworks -Wl,-rpath,@executable_path/../Frameworks -framework krbtle
else
GO_TAGS = -tags nobluetooth
endif
endif
ifeq ($(UNAME_S),FreeBSD)
PREFIX ?= /usr/local
endif
SRCBIN = $(PWD)/bin
DSTBIN = $(DESTDIR)$(PREFIX)/bin
SRCLIB = $(PWD)/lib
DSTLIB = $(DESTDIR)$(PREFIX)/lib
SRCFRAMEWORK = $(PWD)/Frameworks
DSTFRAMEWORK = $(PREFIX)/Frameworks
CONFIGURATION ?= Release
ifeq ($(CONFIGURATION), Release)
CARGO_RELEASE = --release
CARGO_TARGET_SCHEME = release
else ifeq ($(CONFIGURATION), Debug)
CARGO_TARGET_SCHEME = debug
else
$(error Invalid $$CONFIGURATION)
endif
LINK_LIBSIGCHAIN_LDFLAGS = -L ${PWD}/sigchain/target/${CARGO_TARGET_SCHEME}
all:
-rm -rf bin lib Frameworks
-mkdir -p bin
-mkdir -p lib
-mkdir -p Frameworks
go clean -cache || true
ifeq ($(UNAME_S),Darwin)
ifeq ($(shell expr $(OSXRELEASE) \>= 16), 1)
cd krbtle && xcodebuild -configuration $(CONFIGURATION) -archivePath $(SRCFRAMEWORK) -scheme krbtle-Package
-rm -rf $(SRCFRAMEWORK)/krbtle.framework
cp -R krbtle/build/$(CONFIGURATION)/krbtle.framework $(SRCFRAMEWORK)/krbtle.framework
endif
endif
cd sigchain && CARGO_RELEASE=$(CARGO_RELEASE) make libsigchain-with-dashboard
cd kr; CGO_LDFLAGS="$(LINK_LIBSIGCHAIN_LDFLAGS)" go build -ldflags="-s -w" $(GO_TAGS) -o ../bin/kr
cd krd/main; CGO_LDFLAGS="$(CGO_LDFLAGS) $(LINK_LIBSIGCHAIN_LDFLAGS)" go build -ldflags="-s -w" $(GO_TAGS) -o ../../bin/krd
cd pkcs11shim; make; cp target/release/kr-pkcs11.so ../lib/
cd krssh; CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -ldflags="-s -w" $(GO_TAGS) -o ../bin/krssh
cd krgpg; go build $(GO_TAGS) -ldflags="-s -w" -o ../bin/krgpg
clean:
rm -rf bin/
check:
go clean -cache || true
CGO_LDFLAGS="$(CGO_TEST_LDFLAGS) $(LINK_LIBSIGCHAIN_LDFLAGS)" go test $(GO_TAGS) github.com/kryptco/kr github.com/kryptco/kr/krd github.com/kryptco/kr/krd/main github.com/kryptco/kr/krdclient github.com/kryptco/kr/kr github.com/kryptco/kr/krssh github.com/kryptco/kr/krgpg
cd pkcs11shim; cargo test
cd sigchain; CARGO_RELEASE=$(CARGO_RELEASE) make check-libsigchain-with-dashboard
install: all
mkdir -p $(DSTBIN)
mkdir -p $(DSTLIB)
ifeq ($(UNAME_S),Darwin)
ifeq ($(shell expr $(OSXRELEASE) \>= 16), 1)
mkdir -p $(DSTFRAMEWORK)
-rm -rf $(DSTFRAMEWORK)/krbtle.framework
cp -R $(SRCFRAMEWORK)/krbtle.framework $(DSTFRAMEWORK)/krbtle.framework
endif
endif
$(SUDO) install $(SRCBIN)/kr $(DSTBIN)
$(SUDO) install $(SRCBIN)/krd $(DSTBIN)
$(SUDO) install $(SRCBIN)/krssh $(DSTBIN)
$(SUDO) install $(SRCBIN)/krgpg $(DSTBIN)
$(SUDO) install $(SRCLIB)/kr-pkcs11.so $(DSTLIB)
start:
ifeq ($(UNAME_S),Darwin)
mkdir -p ~/Library/LaunchAgents
cp share/co.krypt.krd.plist ~/Library/LaunchAgents/co.krypt.krd.plist
endif
kr restart
uninstall:
pkill -U $(USER) -x krd
kr uninstall
$(SUDO) rm -f $(DSTBIN)/kr
$(SUDO) rm -f $(DSTBIN)/krd
$(SUDO) rm -f $(DSTBIN)/krssh
$(SUDO) rm -f $(DSTBIN)/krgpg
$(SUDO) rm -f $(DSTLIB)/kr-pkcs11.so