code: 9ferno

ref: 0977f294bab0345ba43fbf674449fd8e996c5719
dir: /man/mkfile/

View raw version
<../mkconfig
DOC=$ROOT
<$DOC/man/fonts

LIB=$DOC/man/lib

default:V: check

# Can be called from hosted Inferno
indices.hosted:V:
	for i in `{seq 10} {
		$LIB/secindex.hosted $i > $i/INDEX
	}
	mk lookindex.hosted

# Can only be called from plan9
indices:V:
	rfork n
	for (i in [0-9] 10){
		$LIB/secindex $i > $i/INDEX
	}
	mk lookindex


permind:V:
	test -f $LIB/permind/toc && rm -f $LIB/permind/toc
	{
		echo -n $"FONTS
		echo .am TH
		echo .tm '\\$1' '\\$2' '\\n%'
		echo ..
		for (i in [0-9]){
			builtin cd $i
			for(j in [a-z0-9]*)
				switch($i/$j){
				case 1/tbl
					tbl $j
				case 1/eqn 6/auth
					eqn $j
				case 1/pic
					pic $j
				case 1/grap
					grap $j | pic
				case *
					cat $j
				}
			builtin cd ..
		}
		# section 10 is in a special order
		builtin cd 10
		cat 0intro
		cat `{grep -l '^\.TH.*\.1' *}
		cat `{grep -l '^\.TH.*\.2' *}
		cat `{grep -l '^\.TH.*\.6' *}
		cat `{grep -l '^\.TH.*\.8' *}
		builtin cd ..
	} | troff -$MAN > /dev/null >[2] $LIB/permind/toc
	builtin cd $LIB/permind
	rm -f out
	mk out > /dev/null >[2] /dev/null

check:V: checksource
	awk -f $LIB/checkman.awk [0-9]/* | sed '/\/(cda|av|midi|pub|weather|service\.9net|isdn)(\/|\))/d'

checksource:QV:
	sam -d >[2]/dev/null <<'!'
	f input
	< cat [0-9]/[0-9a-z]*
	B output
	b input
	,x/^\.SH SOURCE/ .,/^\.SH/ x g/^\.B/t "output
	b output
	,x/^\.B.? / d
	,x/ .*/d
	,s/.+/if(! test -f $ROOT& \&\& ! test -d $ROOT&) echo no such SOURCE file '&'/g
	,>rc
	!

# Can be called from hosted Inferno
lookindex.hosted:V:
	builtin cd $LIB/lookman
	mkindex.hosted

# Only works called from plan9
lookindex:V:
	builtin cd $LIB/lookman
	mkindex


print.out:V:
	{
		{echo -n $FONTS; cat $LIB/title} | troff
		{echo -n $FONTS; cat $LIB/trademarks} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/preface} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{
			for (i in [0-9]){
				builtin cd $i
				for(j in [a-z0-9]*)
					switch($i/$j){
					case 1/tbl
						tbl $j
					case 1/eqn 6/auth
						eqn $j
					case 1/pic
						pic $j
					case 1/grap
						grap $j | pic
					case *
						cat $j
					}
				builtin cd ..
			}
			# section 10 is in a special order
			builtin cd 10
			cat 0intro
			cat `{grep -l '^\.TH.*\.1' *}
			cat `{grep -l '^\.TH.*\.2' *}
			cat `{grep -l '^\.TH.*\.6' *}
			cat `{grep -l '^\.TH.*\.8' *}
			builtin cd ..
		} | troff -$MAN
	} > print.out

print.man:V:
	{
		{echo -n $FONTS; cat $LIB/title} | troff
		{echo -n $FONTS; cat $LIB/trademarks} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/preface} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{
			for (i in [0-9]){
				builtin cd $i
				for(j in [a-z0-9]*)
					switch($i/$j){
					case 1/tbl
						tbl $j
					case 1/eqn 6/auth
						eqn $j
					case 1/pic
						pic $j
					case 1/grap
						grap $j | pic
					case *
						cat $j
					}
				builtin cd ..
			}
			# section 10 is in a special order
			builtin cd 10
			cat 0intro
			cat `{grep -l '^\.TH.*\.1' *}
			cat `{grep -l '^\.TH.*\.2' *}
			cat `{grep -l '^\.TH.*\.6' *}
			cat `{grep -l '^\.TH.*\.8' *}
			builtin cd ..
		}
	} > print.man

print10.man:V:
	{
		{echo -n $FONTS; cat $LIB/title} | troff
		{echo -n $FONTS; cat $LIB/trademarks} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/preface} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{
			# section 10 is in a special order
			builtin cd 10
			cat 0intro
			cat `{grep -l '^\.TH.*\.1' *}
			cat `{grep -l '^\.TH.*\.2' *}
			cat `{grep -l '^\.TH.*\.6' *}
			cat `{grep -l '^\.TH.*\.8' *}
			builtin cd ..
		}
	} > print10.man

print10.out:V:
	{
		{echo -n $FONTS; cat $LIB/title} | troff
		{echo -n $FONTS; cat $LIB/trademarks} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/preface} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{
			# section 10 is in a special order
			builtin cd 10
			cat 0intro
			cat `{grep -l '^\.TH.*\.1' *}
			cat `{grep -l '^\.TH.*\.2' *}
			cat `{grep -l '^\.TH.*\.6' *}
			cat `{grep -l '^\.TH.*\.8' *}
			builtin cd ..
		} | troff -$MAN
	} > print10.out

clean:V:
	rm -f man.out


original.print.out:V: permind
	{
		{echo -n $FONTS; cat $LIB/title} | troff
		{echo -n $FONTS; cat $LIB/trademarks} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/preface} | troff -ms
		{echo -n $FONTS; echo ' '} | troff
		{
			for (i in [0-9]){
				builtin cd $i
				for(j in [a-z0-9]*)
					switch($i/$j){
					case 1/tbl
						tbl $j
					case 1/eqn 6/auth
						eqn $j
					case 1/pic
						pic $j
					case 1/grap
						grap $j | pic
					case *
						cat $j
					}
				builtin cd ..
			}
			# section 10 is in a special order
			builtin cd 10
			cat 0intro
			cat `{grep -l '^\.TH.*\.1' *}
			cat `{grep -l '^\.TH.*\.2' *}
			cat `{grep -l '^\.TH.*\.6' *}
			cat `{grep -l '^\.TH.*\.8' *}
			builtin cd ..
		} | troff -$MAN
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; echo ' '} | troff
		cat $LIB/permind/out
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; echo ' '} | troff
		{echo -n $FONTS; cat $LIB/colophon} | troff
	} > print.out