~kt/udprelay

udprelay/Makefile -rw-r--r-- 1.2 KiB
7ef0adeaKatie Wolfe Add note about -timeout parsing specifics 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
GO = go

VERSION := $(shell git describe --dirty --broken --match 'v*' 2>/dev/null)

LDFLAGS = '$(if $(VERSION),-X main.Version=$(VERSION))'

# 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 $(LDFLAGS) \
		-o '$@' \
		.

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

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

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

%.txt: %
	groff -Tutf8 -man < $< | col -bx > $@

%: %.scd
ifdef VERSION
	sed '1 s/v\([0-9]\+\.\)\{2\}[0-9]\+/$(VERSION)/' $< | scdoc > $@
else
	scdoc < $< > $@
endif

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

.PHONY: docs-text
docs-text: udprelay.1.txt udprelay.7.txt

.PHONY: deps
deps:
	@echo 'no dependencies :)'

.PHONY: clean
clean:
	rm -f udprelay.1 udprelay.1.txt udprelay.7 udprelay.7.txt udprelay $(PLATFORMS)