aboutsummaryrefslogtreecommitdiffgithub
path: root/Makefile
blob: 390723a8c5830f6d0f2362a2f61f649664fb95a2 (plain)
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
CFLAGS ?= -Wall -Werror -O3
PREFIX ?= /usr/local

PROG = nsdo
MANSECTION = 1
MANPAGE = $(PROG).$(MANSECTION)
MANPAGEGZ = $(MANPAGE).gz
README = README.md

.PHONY: all install clean

all: $(PROG) $(MANPAGEGZ) $(README)

install: $(PROG) $(MANPAGEGZ)
	install -Dm6755 $< $(PREFIX)/bin/$<
	install -Dm644 $(word 2,$^) $(PREFIX)/share/man/man$(MANSECTION)/$(word 2,$^)

clean:
	rm -fv $(PROG) $(MANPAGEGZ) $(README)

$(MANPAGEGZ): $(MANPAGE)
	gzip --best -k $<

$(README): readme.head $(MANPAGE)
	{ \
	  cat $<; \
	  echo; \
	  MANWIDTH=68 man -l $(word 2,$^) | sed 's/^/    /'; \
	} >$@