Makefile 2.4 KB
Newer Older
M
Mislav Marohnić 已提交
1
SOURCES = $(shell script/build files)
2 3
SOURCE_DATE_EPOCH ?= $(shell date +%s)
BUILD_DATE = $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" '+%d %b %Y' 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" '+%d %b %Y')
4
HUB_VERSION = $(shell bin/hub version | tail -1)
5
FLAGS_ALL = $(shell go version | grep -q 'go1.[89]' || echo 'all=')
6
export MOD_VENDOR_ARG := $(shell go version | grep -q 'go1.1[^01]' && echo '-mod=vendor')
7 8 9
export LDFLAGS := -extldflags '$(LDFLAGS)'
export GCFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'
export ASMFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'
M
Mislav Marohnić 已提交
10

11
ifneq ($(MOD_VENDOR_ARG),)
12
	export GO111MODULE=on
13 14 15
	unexport GOPATH
endif

16
MIN_COVERAGE = 89.4
M
Mislav Marohnić 已提交
17

M
Mislav Marohnić 已提交
18
HELP_CMD = \
19
	share/man/man1/hub-alias.1 \
20
	share/man/man1/hub-api.1 \
21 22 23 24
	share/man/man1/hub-browse.1 \
	share/man/man1/hub-ci-status.1 \
	share/man/man1/hub-compare.1 \
	share/man/man1/hub-create.1 \
25
	share/man/man1/hub-delete.1 \
26
	share/man/man1/hub-fork.1 \
J
Johan Walles 已提交
27
	share/man/man1/hub-pr.1 \
28 29
	share/man/man1/hub-pull-request.1 \
	share/man/man1/hub-release.1 \
30
	share/man/man1/hub-issue.1 \
31
	share/man/man1/hub-sync.1 \
M
Mislav Marohnić 已提交
32 33

HELP_EXT = \
34 35 36 37 38 39 40 41 42 43 44 45 46 47
	share/man/man1/hub-am.1 \
	share/man/man1/hub-apply.1 \
	share/man/man1/hub-checkout.1 \
	share/man/man1/hub-cherry-pick.1 \
	share/man/man1/hub-clone.1 \
	share/man/man1/hub-fetch.1 \
	share/man/man1/hub-help.1 \
	share/man/man1/hub-init.1 \
	share/man/man1/hub-merge.1 \
	share/man/man1/hub-push.1 \
	share/man/man1/hub-remote.1 \
	share/man/man1/hub-submodule.1 \

HELP_ALL = share/man/man1/hub.1 $(HELP_CMD) $(HELP_EXT)
M
Mislav Marohnić 已提交
48 49 50 51 52 53

TEXT_WIDTH = 87

bin/hub: $(SOURCES)
	script/build -o $@

54
bin/md2roff: $(SOURCES)
55
	go build $(MOD_VENDOR_ARG) -o $@ github.com/github/hub/md2roff-bin
56

M
Mislav Marohnić 已提交
57
test:
M
Mislav Marohnić 已提交
58
	go test ./...
M
Mislav Marohnić 已提交
59 60

test-all: bin/cucumber
M
Mislav Marohnić 已提交
61 62 63
ifdef CI
	script/test --coverage $(MIN_COVERAGE)
else
M
Mislav Marohnić 已提交
64
	script/test
M
Mislav Marohnić 已提交
65
endif
M
Mislav Marohnić 已提交
66

67
bin/cucumber:
M
Mislav Marohnić 已提交
68 69
	script/bootstrap

M
Mislav Marohnić 已提交
70
fmt:
M
Mislav Marohnić 已提交
71
	go fmt ./...
M
Mislav Marohnić 已提交
72

73
man-pages: $(HELP_ALL:=.md) $(HELP_ALL) $(HELP_ALL:=.txt)
M
Mislav Marohnić 已提交
74

75
%.txt: %
M
Mislav Marohnić 已提交
76 77
	groff -Wall -mtty-char -mandoc -Tutf8 -rLL=$(TEXT_WIDTH)n $< | col -b >$@

78
$(HELP_ALL): share/man/.man-pages.stamp
79 80
share/man/.man-pages.stamp: $(HELP_ALL:=.md) ./man-template.html bin/md2roff
	bin/md2roff --manual="hub manual" \
81
		--date="$(BUILD_DATE)" --version="$(HUB_VERSION)" \
M
Mislav Marohnić 已提交
82 83
		--template=./man-template.html \
		share/man/man1/*.md
84
	touch $@
M
Mislav Marohnić 已提交
85

86 87
%.1.md: bin/hub
	bin/hub help $(*F) --plain-text >$@
M
Mislav Marohnić 已提交
88

89
share/man/man1/hub.1.md:
M
Mislav Marohnić 已提交
90 91
	true

M
Mislav Marohnić 已提交
92 93 94
install: bin/hub man-pages
	bash < script/install.sh

M
Mislav Marohnić 已提交
95
clean:
M
Mislav Marohnić 已提交
96
	git clean -fdx bin share/man
M
Mislav Marohnić 已提交
97 98

.PHONY: clean test test-all man-pages fmt install