-
Notifications
You must be signed in to change notification settings - Fork 8
/
GNUmakefile
122 lines (100 loc) · 4.14 KB
/
GNUmakefile
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
.DEFAULT_GOAL := help
DESTDIR ?= /usr/local
GPL2 ?= false
NO_QUIC ?= false
ifeq (${GPL2},true)
GOFLAGS += -modfile=go-gpl2.mod -tags=stdsha256
export GOFLAGS
endif
ifeq (${NO_QUIC},true)
GOFLAGS += -tags=noquic
export GOFLAGS
endif
GO111MODULE=on
export GO111MODULE
.PHONY: help
help:
@echo "Usage: make [target]"
@cat Makefile | awk -F ":.*##" '/##/ { printf " %-17s %s\n", $$1, $$2 }' | grep -v grep
.PHONY: format-c
format-c: ## formats all the C code
find . -type f -iname \*.h -o -iname \*.c | xargs clang-format --style=file -i
.PHONY: format-c-check
format-c-check: ## checks C code formatting
./scripts/format-c-check
.PHONY: build
build: ## builds the Linux dynamic libraries and leave them and a copy of the definitions in .build directory
ifeq (${GPL2},true)
cp go.mod go-gpl2.mod
cp go.sum go-gpl2.sum
go mod edit -replace github.com/spacemonkeygo/monkit/v3=./internal/replacements/monkit
./scripts/check-licenses-gpl2
endif
go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink.so .
go build -ldflags="-s -w" -buildmode c-archive -o .build/uplink.a .
mv .build/uplink.so .build/libuplink.so
mv .build/uplink.a .build/libuplink.a
mkdir -p .build/uplink
mv .build/*.h .build/uplink
cp uplink_definitions.h .build/uplink
cp uplink_compat.h .build/uplink
./scripts/gen-pkg-config > .build/libuplink.pc
.PHONY: bump-dependencies
bump-dependencies: ## bumps the dependencies
go get storj.io/common@main storj.io/uplink@main
go mod tidy
cd testsuite;\
go get storj.io/common@main storj.io/storj@main storj.io/uplink@main;\
go mod tidy
.PHONY: test
test: ## run test suite
cd testsuite && go test
.PHONY: test-install
test-install: ## test install process
./scripts/test-install
.PHONY: test-namespace
test-namespace: ## test namespacing
./scripts/test-namespace
.PHONY: install
install: build ## install library and headers
install -d \
${DESTDIR}/include/uplink \
${DESTDIR}/lib \
${DESTDIR}/lib/pkgconfig
install .build/libuplink.so ${DESTDIR}/lib
install .build/libuplink.a ${DESTDIR}/lib
install -m 644 .build/uplink/* ${DESTDIR}/include/uplink
install -m 644 .build/libuplink.pc ${DESTDIR}/lib/pkgconfig
OS ?= $(shell uname)
ZIG ?= $(shell which zig)
TAG ?= $(shell git tag -l | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1)
.PHONY: release-files
release-files: ## builds and copies release files to Github
## MacOS is required by license to build MacOS libraries
## Forcing it here just prevents things from being half-done
ifneq ($(OS),Darwin)
echo This tool must be run from MacOS
exit 1
endif
ifndef GITHUB_TOKEN
echo GITHUB_TOKEN is undefined
exit 1
endif
echo "Uploading binaries to release draft"
git checkout $(TAG)
## linux_amd64
CGO_ENABLED=1 CC="${ZIG} cc -target x86_64-linux-gnu" GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink_linux_amd64.so .
github-release upload --user storj --repo uplink-c --tag "$(TAG)" --name "uplink_linux_amd64.so" --file ".build/uplink_linux_amd64.so"
## linux_arm64
CGO_ENABLED=1 CC="${ZIG} cc -target aarch64-linux-gnu" GOOS=linux go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink_linux_arm64.so .
github-release upload --user storj --repo uplink-c --tag "$(TAG)" --name "uplink_linux_arm64.so" --file ".build/uplink_linux_arm64.so"
## windows_amd64
CGO_ENABLED=1 CC="${ZIG} cc -target x86_64-windows" GOARCH=amd64 GOOS=windows go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink_windows_amd64.dll .
github-release upload --user storj --repo uplink-c --tag "$(TAG)" --name "uplink_windows_amd64.dll" --file ".build/uplink_windows_amd64.dll"
## darwin_amd64
CGO_ENABLED=1 GOARCH=amd64 go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink_darwin_amd64.dylib .
github-release upload --user storj --repo uplink-c --tag "$(TAG)" --name "uplink_darwin_amd64.dylib" --file ".build/uplink_darwin_amd64.dylib"
## darwin_arm64
CGO_ENABLED=1 GOARCH=arm64 go build -ldflags="-s -w" -buildmode c-shared -o .build/uplink_darwin_arm64.dylib .
github-release upload --user storj --repo uplink-c --tag "$(TAG)" --name "uplink_darwin_arm64.dylib" --file ".build/uplink_darwin_arm64.dylib"
echo "Uploading release binaries done"