-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (33 loc) · 1.29 KB
/
Copy pathMakefile
File metadata and controls
43 lines (33 loc) · 1.29 KB
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
# Build, test and package. Everything here is also one plain command if you
# would rather not use make — see the README.
# Debian versions must start with a digit, so this cannot fall back to a bare
# commit hash. Tag as vX.Y.Z and it is picked up; otherwise override:
# make deb VERSION=1.2.3
VERSION ?= $(shell git describe --tags --match 'v[0-9]*' --dirty 2>/dev/null | sed 's/^v//' || true)
ifeq ($(strip $(VERSION)),)
VERSION := 0.1.0
endif
ARCH ?= amd64
# Pinned rather than @latest so a build is reproducible, and run via `go run` so
# packaging needs nothing installed beyond the Go toolchain already required.
NFPM := go run github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.38.0
.PHONY: all build test linux deb clean
all: test build
build:
go build -o randomimageviewer .
test:
go test ./...
node --test
# Statically linked: nothing in the dependency tree uses cgo, so the result runs
# on any Linux of this architecture with no libc to match.
linux:
mkdir -p dist
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -trimpath -ldflags='-s -w' \
-o dist/randomimageviewer .
deb: linux
mkdir -p dist
VERSION=$(VERSION) ARCH=$(ARCH) $(NFPM) package \
--config nfpm.yaml --packager deb --target dist/
@echo "built dist/randomimageviewer_$(VERSION)_$(ARCH).deb"
clean:
rm -rf dist randomimageviewer