~kt/udprelay

ref: v1.0.0 udprelay/Makefile -rw-r--r-- 842 bytes
44327e2bKatie Wolfe v1.0.0 11 months ago
                                                                                
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
GO = go

VERSION = $(shell git describe --dirty --broken --match 'v*')

# list of binary names for every os/arch combination returned from `go tool dist list`
PLATFORMS := $(foreach plat,$(shell go tool dist list),udprelay-$(subst /,-,$(plat))$(if $(findstring windows,$(plat)),.exe))

platform = $(subst -, ,$(patsubst udprelay-%,%,$(basename $@)))
os = $(word 1, $(platform))
arch = $(word 2, $(platform))

udprelay: *.go
	$(GO) build \
		-ldflags '-X main.Version=$(VERSION)' \
		-o '$@' \
		.

.PHONY: all-platforms
all-platforms: $(PLATFORMS)

$(PLATFORMS): *.go
	GOOS=$(os) GOARCH=$(arch) $(GO) build \
		-ldflags '-X main.Version=$(VERSION)' \
		-o '$@' \
		.

.PHONY: list-binary-targets
list-binary-targets:
	@echo $(PLATFORMS)

%: %.scd
	scdoc < $< > $@

.PHONY: docs
docs: udprelay.1 udprelay.7

.PHONY: deps
deps:
	$(GO) get -v .