-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
50 lines (43 loc) · 1.65 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
.PHONY: clean
libpkcs11_exported.a: pkcs11_exported.o
ar cru libpkcs11_exported.a pkcs11_exported.o
pkcs11_exported.o: spec2
${CC} ${CFLAGS} ${PACKED_CFLAGS} -c pkcs11_exported.c
spec_modules_off:
mkdir -p spec/
cp $(shell go env GOPATH)/src/github.com/miekg/pkcs11/*.h spec/
cp $(shell go env GOPATH)/src/github.com/miekg/pkcs11/vendor.go spec/vendor.go_
spec_modules_on:
mkdir -p spec/
go mod vendor
cp ./vendor/github.com/miekg/pkcs11/*.h spec/
cp ./vendor/github.com/miekg/pkcs11/vendor.go spec/vendor.go_
rm -rf ./vendor/
ifeq ($(shell go env GO111MODULE),off)
spec: spec_modules_off
else
spec: spec_modules_on
endif
spec2: spec
echo 'package pkcs11mod' > strings.go
echo '' >> strings.go
echo 'import "github.com/miekg/pkcs11"' >> strings.go
echo '' >> strings.go
echo 'var strCKA = map[uint]string{' >> strings.go
awk '/#define CKA_/{ print "pkcs11."$$2":\""$$2"\"," }' spec/pkcs11t.h | grep -v CKA_SUB_PRIME_BITS | grep -v CKA_EC_PARAMS >> strings.go
awk '/CKA_/{ print "pkcs11."$$1":\""$$1"\"," }' spec/vendor.go_ >> strings.go
echo '}' >> strings.go
echo '' >> strings.go
echo 'var strCKO = map[uint]string{' >> strings.go
awk '/#define CKO_/{ print "pkcs11."$$2":\""$$2"\"," }' spec/pkcs11t.h >> strings.go
awk '/CKO_/{ print "pkcs11."$$1":\""$$1"\"," }' spec/vendor.go_ >> strings.go
echo '}' >> strings.go
echo '' >> strings.go
echo 'var strCKT = map[uint]string{' >> strings.go
awk '/CKT_/{ print "pkcs11."$$1":\""$$1"\"," }' spec/vendor.go_ >> strings.go
echo '}' >> strings.go
gofmt -s -w strings.go
clean:
rm -vf libpkcs11_exported.a pkcs11_exported.o spec/*.h spec/*.go_ strings.go
rmdir spec || true
all: clean libpkcs11_exported.a