1
1
# Default target
2
2
build :
3
3
4
- # Project metadata (note: to package, VERSION *must* be set by the caller)
4
+ # Project metadata
5
+ # By default, the project version is automatically determined using
6
+ # 'git describe'. If you would like to set the version manually, set the
7
+ # 'VERSION' variable to the desired version string.
5
8
NAME := git-bundle-server
6
- VERSION :=
7
- PACKAGE_REVISION := 1
8
9
9
10
# Installation information
10
11
INSTALL_ROOT := /
@@ -22,6 +23,7 @@ GOARCH := $(shell go env GOARCH)
22
23
# Packaging information
23
24
SUPPORTED_PACKAGE_GOARCHES := amd64 arm64
24
25
PACKAGE_ARCH := $(GOARCH )
26
+ PACKAGE_REVISION := 1
25
27
26
28
# Guard against environment variables
27
29
APPLE_APP_IDENTITY =
@@ -30,18 +32,39 @@ APPLE_KEYCHAIN_PROFILE =
30
32
E2E_FLAGS =
31
33
INTEGRATION_FLAGS =
32
34
35
+ # General targets
36
+ .PHONY : FORCE
37
+
38
+ ifdef VERSION
39
+ # If the version is set by the user, don't bother with regenerating the version
40
+ # file.
41
+ .PHONY : VERSION-FILE
42
+ else
43
+ # If the version is not set by the user, we need to generate the version file
44
+ # and load it.
45
+ VERSION-FILE : FORCE
46
+ @scripts/generate-version.sh --version-file=" $@ "
47
+ -include VERSION-FILE
48
+ endif
49
+
33
50
# Build targets
51
+ LDFLAGS += -X '$(shell go list -m) /cmd/utils.Version=$(VERSION ) '
52
+
34
53
.PHONY : build
35
54
build :
36
55
$(RM ) -r $(BINDIR )
37
56
@mkdir -p $(BINDIR )
38
- GOOS=" $( GOOS) " GOARCH=" $( GOARCH) " go build -o $(BINDIR ) ./...
57
+ GOOS=" $( GOOS) " GOARCH=" $( GOARCH) " go build -o $(BINDIR ) -ldflags " $( LDFLAGS ) " ./...
39
58
40
59
.PHONY : doc
41
60
doc :
42
61
@scripts/make-docs.sh --docs=" $( CURDIR) /docs/man" \
43
62
--output=" $( DOCDIR) "
44
63
64
+ .PHONY : vet
65
+ vet :
66
+ GOOS=" $( GOOS) " GOARCH=" $( GOARCH) " go vet ./...
67
+
45
68
# Testing targets
46
69
.PHONY : test
47
70
test : build
@@ -193,6 +216,7 @@ endif
193
216
.PHONY : clean
194
217
clean :
195
218
go clean ./...
219
+ $(RM ) -r VERSION-FILE
196
220
$(RM ) -r $(BINDIR )
197
221
$(RM ) -r $(DISTDIR )
198
222
$(RM ) -r $(DOCDIR )
0 commit comments