summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2f9ba8f035b44f3286b52ab6a3edcb89cd61a775 (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
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
68
69
70
71
72
# Do "make screen" first, if you want to protect already installed,
# more up-to-date manual pages than the ones included in this package.
# Do "make install" to copy the pages to their destination.
# Do "make gz" or "make bz2" first if you use compressed source pages.

DESTDIR=
prefix?=/usr
MANDIR=$(prefix)/share/man

GZIP=gzip -9
BZIP2=bzip2 -9

all: screen remove install

allgz: gz all

allbz: bz2 all

screen:
	mkdir -p not_installed
	for i in man?/*; do \
		if [ $(MANDIR)/"$$i" -nt "$$i" ]; then \
			cmp -s $(MANDIR)/"$$i" "$$i" > /dev/null 2>&1; \
			if [ "$$?" != 0 ]; then mv "$$i" not_installed; fi; \
		fi; \
	done

uninstall remove:
	for i in man?/*; do \
		rm -f $(MANDIR)/"$$i" $(MANDIR)/"$$i".gz $(MANDIR)/"$$i".bz2; \
	done

gz:
	for i in man?; do $(GZIP) "$$i"/*; done

bz2:
	for i in man?; do $(BZIP2) "$$i"/*; done

# Use with
#  make HTDIR=/some/dir HTOPTS=whatever html
# The sed removes the lines "Content-type: text/html\n\n"
html:
	@if [ x$(HTDIR) = x ]; then echo "You must set HTDIR."; else \
	for i in man?; do \
		[ -d $(HTDIR)/"$$i" ] || mkdir -p $(HTDIR)/"$$i"; \
		find "$$i/" -type f | while read f; do \
			(cd "$$i"; man2html $(HTOPTS) `basename $$f`) | \
			sed -e '1,2d' > $(HTDIR)/"$$i"/`basename $$f`.html; \
		done; \
	done; fi

install:
	for i in man?; do \
		install -d -m 755 $(DESTDIR)$(MANDIR)/"$$i" || exit $$?; \
		install -m 644 "$$i"/* $(DESTDIR)$(MANDIR)/"$$i" || exit $$?; \
	done; \

# Check if groff reports warnings (may be words of sentances not displayed)
# from http://lintian.debian.org/tags/manpage-has-errors-from-man.html 
GROFF_LOG := $(shell mktemp /tmp/manpages-checksXXXX)
check-groff-warnings:
	for i in man?/*.[1-9]; \
	do \
		if grep -q 'SH.*NAME' $$i; then \
			LC_ALL=en_US.UTF-8 MANWIDTH=80 man --warnings -E UTF-8 -l $$i > /dev/null 2>$(GROFF_LOG); \
			[ -s $(GROFF_LOG) ] && ( echo "$$i: " ; cat $(GROFF_LOG) ; echo "" ); \
			rm $(GROFF_LOG) 2>/dev/null; \
		fi \
	done

# someone might also want to look at /var/catman/cat2 or so ...
# a problem is that the location of cat pages varies a lot