-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
68 lines (49 loc) · 1.37 KB
/
GNUmakefile
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
56
57
58
59
60
61
62
63
64
65
66
67
# vim: ft=make ts=8 sts=2 sw=2 noet
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
MAN1DIR ?= $(MANDIR)/man1
GZIPCMD ?= gzip
INSTALL_DATA ?= install -m 644
INSTALL_DIR ?= install -m 755 -d
INSTALL_SCRIPT ?= install -m 755
RST2HTML ?= $(call first_in_path,rst2html.py rst2html)
name = bs-update
artifacts = $(installed) $(htmlfiles)
installed = $(name).1.gz $(name)
htmlfiles = README.html
ALL_INCLUSIVE ?= 0
.DEFAULT_GOAL := $(if $(subst 0,,$(ALL_INCLUSIVE)),all,most)
all: $(artifacts)
most: $(installed)
.PHONY: all most
all most:
@touch .built
.PHONY: clean
clean:
$(RM) .built $(artifacts)
.PHONY: check
check: $(.DEFAULT_GOAL)
SHELL=$(SHELL) $(SHELL) rnt/run-tests.sh tests $$PWD/$(name)
$(name): $(name).in
$(INSTALL_SCRIPT) $< $@
.PHONY: html
html: $(htmlfiles)
%.html: %.rest
$(RST2HTML) $< $@
%.1.gz: %.1
$(GZIPCMD) < $< > $@
.PHONY: install
install: .built
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
$(INSTALL_SCRIPT) $(name).in $(DESTDIR)$(BINDIR)/$(name)
$(INSTALL_DATA) $(name).1.gz $(DESTDIR)$(MAN1DIR)/$(name).1.gz
.built:
@printf "%s\n" '' "ERROR: run '$(MAKE) $(.DEFAULT_GOAL)' first." '' >&2
@false
define first_in_path
$(firstword $(wildcard \
$(foreach p,$(1),$(addsuffix /$(p),$(subst :, ,$(PATH)))) \
))
endef