1+ AWK = awk
2+ MAKEWHATIS = /usr/libexec/makewhatis
3+ MANDOC = mandoc
4+ MKDIR_P = mkdir -p
5+ FIND = find
6+ SED = sed
7+
18BASE_URL = https://manp.gs/posix/
9+ REDIRECT = 1
210
311base_url = https://pubs.opengroup.org/onlinepubs/9799919799
412
513dirs = 1 3
614
7- MANDOC =mandoc
8- FLAGS=-Oman=../%S/%N,style =../style.css
9- FILTER =sed '/<pre>/,/<\/pre>/{/^<br\/>$$/d;}'
10- CMD =$(MANDOC ) $(FLAGS ) -Thtml "$< " | $(FILTER )
11- BUILD =$(CMD ) > "$@ "
12-
13- REDIRECT = 1
15+ filter = $(SED ) '/<pre>/,/<\/pre>/{/^<br\/>$$/d;}'
1416
1517ifeq ($(REDIRECT ) ,1)
16- FILTER=sed \
18+ filter = $(SED) \
1719 -e "$$(printf '%s\n' '/<body>/,/<\/body>/c\' '<body>Redirecting…</body>')"\
1820 -e '/<title>.*(1P)<\/title>/{ s|<title>.*</title>|<title>$*(1)</title>|; h; s|.*| <meta http-equiv="refresh" content="0;url=$(base_url)/utilities/$*.html">|; H; x; }' \
1921 -e '/<title>.*\.H(3P)<\/title>/{ s|<title>.*</title>|<title>$*(3)</title>|; h; s|.*| <meta http-equiv="refresh" content="0;url=$(base_url)/basedefs/$*.html">|; H; x; }' \
2022 -e '/<title>.*(3P)<\/title>/{ s|<title>.*</title>|<title>$*(3)</title>|; h; s|.*| <meta http-equiv="refresh" content="0;url=$(base_url)/functions/$*.html">|; H; x; }'
2123endif
2224
25+ man2html = $(MANDOC ) -Oman=../%S/%N,style=../style.css -Thtml "$< " | $(filter )
26+
27+ convert = $(man2html ) > "$@ "
28+
2329template = <!doctype html>\n<html lang="en">\n\
2430\40<head>\n\
2531\40\40\40<meta charset="utf-8">\n\
@@ -41,26 +47,26 @@ case $$1 in \
4147esac; \
4248};
4349
44- html = $(shell find man-posix/man?? -type f \
50+ html = $(shell $( FIND ) man-posix/man?? -type f \
4551 ! -name * .7p \
4652 ! -name intro.1p \
4753 ! -name shell.1p \
4854 ! -name intro.3p \
4955 ! -name info.3p \
50- | sed 's|^.* /\([^/]* \) \.\([0-9]\)p$$|\2/\1.html|')
56+ | $( SED ) 's|^.* /\([^/]* \) \.\([0-9]\)p$$|\2/\1.html|')
5157
5258all : $(dirs ) index.html
5359 cd man-posix && $(MAKE )
5460 $(MAKE ) $(html )
5561 $(MAKE ) sitemap.xml
5662
5763$(dirs ) :
58- mkdir -p " $@ "
64+ $( MKDIR_P ) " $@ "
5965
6066whatis :
61- /usr/libexec/makewhatis man-posix
62- sed -e ' s/(\([0-9]\)p)/(\1)/g' -e " s/\[aq]/'/g" man-posix/whatis > whatis
63- rm man-posix/whatis
67+ $( MAKEWHATIS ) man-posix
68+ $( SED ) -e ' s/(\([0-9]\)p)/(\1)/g' -e " s/\[aq]/'/g" man-posix/whatis > whatis
69+ $( RM ) man-posix/whatis
6470
6571clean :
6672 $(RM ) -r index.html sitemap.xml whatis $(dirs )
@@ -79,7 +85,7 @@ sitemap.xml:
7985 (echo " " && printf ' %s/\n' $( dirs) ) | while read dir; do \
8086 printf " <url><loc>%s%s</loc></url>\n" " $( BASE_URL) " " $$ dir" ; \
8187 done ; \
82- find $(dirs ) -type f ! -name index.html | sort | awk ' { \
88+ $( FIND ) $(dirs ) -type f ! -name index.html | sort | $( AWK ) ' { \
8389 sub(/\. [^.]+$$ /, " " ); \
8490 gsub(/ /, " %20" ); \
8591 gsub(/\[ /, " %5B" ); \
@@ -93,15 +99,13 @@ sitemap.xml:
9399 printf ' $(template)' " man$$ sect — POSIX Manpages" " ../style.css" \
94100 " <a href=\" ../\" >POSIX</a> — $$ (desc " $$ sect" )" " $$ (\
95101 printf ' <ul class="whatis">\n' ; \
96- sed -n -e ' \
102+ $( SED ) -n -e ' \
97103 h; \
98104 s/ - /\n /; \
99105 s| .* \n || ; \
100106 x; \
101107 s| - .* || ; \
102- ' -e ' t clear' -e :clear -e ' \
103- s| (' "$$sect"' )| & | ; \
104- ' -e ' t link' -e b -e :link -e ' \
108+ ' -e "/($$sect)/!b" -e ' \
105109 s| \( [^, ][^(]* \) ([0-9n][^)]* )| < a href=" ./\1" > & < /a> | g; \
106110 s| \( < a href=" \./[^" ]* \) /| \1 _| g; \
107111 s| ^| < li> | ; \
@@ -113,7 +117,7 @@ sitemap.xml:
113117 )" > " $@ "
114118
1151191/% .html : man-posix/man1p/% .1p
116- $(BUILD )
120+ $(convert )
117121
1181223/% .html : man-posix/man3p/% .3p
119- $(BUILD )
123+ $(convert )
0 commit comments