aboutsummaryrefslogtreecommitdiffgithub
path: root/Makefile
blob: 144783ae3bbd4ad0692e00f93462b2d8a7c9be38 (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
30
31
32
33
34
CFLAGS ?= -Wall -O2
# if you're building a system package, you should probably set these to
# /usr, /usr/share/bash-completion/completions, and your package dir
PREFIX ?= /usr/local
BASH_COMPLETION_DIR ?= /etc/bash_completion.d
DESTDIR ?=

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 -Dm4755 $< $(DESTDIR)$(PREFIX)/bin/$<
	install -Dm644 $(word 2,$^) $(DESTDIR)$(PREFIX)/share/man/man$(MANSECTION)/$(word 2,$^)
	install -Dm644 bash_completion/$(PROG) $(DESTDIR)$(BASH_COMPLETION_DIR)/$(PROG)

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

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

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