Makefile 2.1 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')
M
Mislav Marohnić 已提交
4
HUB_VERSION = $(shell hub version | tail -1)
5 6 7
export LDFLAGS := -extldflags=$(LDFLAGS)
export GCFLAGS := all=-trimpath=$(PWD)
export ASMFLAGS := all=-trimpath=$(PWD)
M
Mislav Marohnić 已提交
8

9
MIN_COVERAGE = 89.4
M
Mislav Marohnić 已提交
10

M
Mislav Marohnić 已提交
11
HELP_CMD = \
12 13 14 15 16
	share/man/man1/hub-alias.1 \
	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 \
17
	share/man/man1/hub-delete.1 \
18
	share/man/man1/hub-fork.1 \
J
Johan Walles 已提交
19
	share/man/man1/hub-pr.1 \
20 21
	share/man/man1/hub-pull-request.1 \
	share/man/man1/hub-release.1 \
22
	share/man/man1/hub-issue.1 \
23
	share/man/man1/hub-sync.1 \
M
Mislav Marohnić 已提交
24 25

HELP_EXT = \
26 27 28 29 30 31 32 33 34 35 36 37 38 39
	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ć 已提交
40 41 42 43 44 45 46

TEXT_WIDTH = 87

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

test:
M
Mislav Marohnić 已提交
47
	go test ./...
M
Mislav Marohnić 已提交
48 49

test-all: bin/cucumber
M
Mislav Marohnić 已提交
50 51 52
ifdef CI
	script/test --coverage $(MIN_COVERAGE)
else
M
Mislav Marohnić 已提交
53
	script/test
M
Mislav Marohnić 已提交
54
endif
M
Mislav Marohnić 已提交
55

56
bin/cucumber:
M
Mislav Marohnić 已提交
57 58
	script/bootstrap

M
Mislav Marohnić 已提交
59
fmt:
M
Mislav Marohnić 已提交
60
	go fmt ./...
M
Mislav Marohnić 已提交
61

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

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

67
$(HELP_ALL): share/man/.man-pages.stamp
M
Mislav Marohnić 已提交
68 69
share/man/.man-pages.stamp: $(HELP_ALL:=.md) ./man-template.html
	go run md2roff-bin/cmd.go --manual="hub manual" \
70
		--date="$(BUILD_DATE)" --version="$(HUB_VERSION)" \
M
Mislav Marohnić 已提交
71 72
		--template=./man-template.html \
		share/man/man1/*.md
73
	touch $@
M
Mislav Marohnić 已提交
74

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

78
share/man/man1/hub.1.md:
M
Mislav Marohnić 已提交
79 80
	true

M
Mislav Marohnić 已提交
81 82 83
install: bin/hub man-pages
	bash < script/install.sh

M
Mislav Marohnić 已提交
84
clean:
M
Mislav Marohnić 已提交
85
	git clean -fdx bin share/man
M
Mislav Marohnić 已提交
86 87

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