1#!/bin/sh
2# This file is in the public domain
3
4set -e
5
6sh reduce.sh
7
8OPLIST=`sh listallopts.sh`
9
10ODIR=/usr/obj/`pwd`
11RDIR=${ODIR}/_.result
12export ODIR RDIR
13
14table_td () (
15
16	awk -v R=$1 -v T=$2 -v M=$4 '
17	BEGIN	{
18		t= R "-" T
19	}
20	$1 == t {
21		if ($3 == 0 && $5 == 0 && $7 == 0) {
22			printf "<TD align=center COLSPAN=5>no effect</TD>"
23		} else {
24			if ($3 == 0) {
25				printf "<TD align=right>+%d</TD>", $3
26			} else {
27				printf "<TD align=right>"
28				printf "<A HREF=\"%s/%s.mtree.add.txt\">+%d</A>", M, t, $3
29				printf "</TD>"
30			}
31			if ($5 == 0) {
32				printf "<TD align=right>-%d</TD>", $5
33			} else {
34				printf "<TD align=right>"
35				printf "<A HREF=\"%s/%s.mtree.sub.txt\">-%d</A>", M, t, $5
36				printf "</TD>"
37			}
38			if ($7 == 0) {
39				printf "<TD align=right>*%d</TD>", $7
40			} else {
41				printf "<TD align=right>"
42				printf "<A HREF=\"%s/%s.mtree.chg.txt\">*%d</A>", M, t, $7
43				printf "</TD>"
44			}
45			printf "<TD align=right>%d</TD>", $9
46			printf "<TD align=right>%d</TD>", -$11
47		}
48		printf "\n"
49		d = 1
50		}
51	END	{
52		if (d != 1) {
53			printf "<TD COLSPAN=5></TD>"
54		}
55	}
56	' $3/stats
57	mkdir -p $HDIR/$4
58	cp $3/r*.txt $HDIR/$4 || true
59)
60
61HDIR=${ODIR}/HTML
62rm -rf ${HDIR}
63mkdir -p ${HDIR}
64H=${HDIR}/index.html
65
66echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
67<HTML>' > $H
68
69echo '<HEAD>
70<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
71<TITLE>FreeBSD Build Options Survey</TITLE>
72</HEAD>
73<BODY bgcolor="#FFFFFF">
74' >> $H
75
76echo '
77<H2>The table is explained at the bottom</H2>
78<HR>
79' >> $H
80
81echo '<TABLE  border="1" cellspacing="0">' >> $H
82
83echo "<TR>" >> $H
84echo "<TH ROWSPAN=2>src.conf</TH>" >> $H
85echo "<TH ROWSPAN=2>MK_FOO</TH>" >> $H
86echo "<TH ROWSPAN=2></TH>" >> $H
87echo "<TH COLSPAN=5>BuildWorld</TH>" >> $H
88echo "<TH ROWSPAN=2></TH>" >> $H
89echo "<TH COLSPAN=5>InstallWorld</TH>" >> $H
90echo "<TH ROWSPAN=2></TH>" >> $H
91echo "<TH COLSPAN=5>World</TH>" >> $H
92echo "</TR>" >> $H
93
94echo "<TR>" >> $H
95for i in bw iw w
96do
97	echo "<TH>A</TH>" >> $H
98	echo "<TH>D</TH>" >> $H
99	echo "<TH>C</TH>" >> $H
100	echo "<TH>KB</TH>" >> $H
101	echo "<TH>Delta</TH>" >> $H
102done
103echo "</TR>" >> $H
104
105majcol ( ) (
106	echo "<TD></TD>" >> $H
107	if [ ! -f $3/$1/done ] ; then
108		echo "<TD align=center COLSPAN=5>no data yet</TD>" >> $H
109	elif [ -f $3/$1/_.success ] ; then
110		table_td $2 $1 $3 $4 >> $H
111	else
112		echo "<TD align=center COLSPAN=5>failed</TD>" >> $H
113	fi
114)
115
116
117for o in $OPLIST
118do
119	md=`echo "${o}=foo" | md5`
120	m=${RDIR}/$md
121	if [ ! -d $m ] ; then
122		continue
123	fi
124	if [ ! -f $m/stats ] ; then
125		continue
126	fi
127	echo "=== mkhtml ${d}_${o}"
128
129	echo "<TR>" >> $H
130	echo "<TD><PRE>" >> $H
131	cat $m/src.conf >> $H
132	echo "</PRE></TD>" >> $H
133	echo "<TD><PRE>" >> $H
134	if [ -f $m/bw/_.sc ] ; then
135		comm -13 ${RDIR}/Ref/_.sc $m/bw/_.sc >> $H
136	fi
137	echo "</PRE></TD>" >> $H
138
139	majcol bw r $m $md
140	majcol iw r $m $md
141	majcol w  r $m $md
142	echo "</TR>" >> $H
143done
144echo "</TABLE>" >> $H
145echo '
146<HR>
147<H2>How to read this table</H2>
148<P>
149The table has five major columns.
150
151<OL>
152<LI><P><B>src.conf</B></P>
153<P>The name of the option being tested</P>
154<P>
155All options are tested both in their WITH_FOO and WITHOUT_FOO variants
156but if the option has no effect (ie: is the default) it will not appear
157in the table
158</P>
159</LI>
160
161<LI><P><B>MK_FOO</B></P>
162<P>Internal build flags affected by this option </P>
163</LI>
164
165<LI><P><B>Buildworld</B></P>
166<P>What happens when the option is given to buildworld but not installworld</P>
167<PRE>Ie:
168	make buildworld WITH_FOO=yes
169	make installworld
170</PRE>
171</LI>
172
173<LI><P><B>Installworld</B></P>
174<P>What happens when the option is given to installworld but not buildworld</P>
175<PRE>Ie:
176	make buildworld
177	make installworld WITH_FOO=yes
178</PRE>
179</LI>
180
181<LI><P><B>World</B></P>
182<P>What happens when the option is given to both buildworld and installworld</P>
183<PRE>Ie:
184	make buildworld WITH_FOO=yes
185	make installworld WITH_FOO=yes
186</PRE>
187</LI>
188</OL>
189
190<P>Inside each of the last three major columns there are five subcolumns</P>
191<OL>
192<LI><P><B>A</B></P>
193<P>Number of added files/directories (relative to the option not be given</P>
194<P>If non-zero, the number links to a list of the added files/directories</P>
195</LI>
196<LI><P><B>D</B></P>
197<P>Number of deleted files/directories (relative to the option not be given</P>
198<P>If non-zero, the number links to a list of the files not installed files/directories</P>
199</LI>
200<LI><P><B>C</B></P>
201<P>Number of changed files/directories (relative to the option not be given</P>
202<P>If non-zero, the number links to a list of the files/directories which are differnet (two lines each)</P>
203</LI>
204<LI><P><B>KB</B></P>
205<P>Size of installed operating system in kilobytes</P>
206<LI><P><B>Delta</B></P>
207<P>Size change in kilobytes relative to the option not be given</P>
208</LI>
209</OL>
210
211<HR>' >> $H
212echo '
213<p>
214    <a href="http://validator.w3.org/check?uri=referer"><img
215        src="http://www.w3.org/Icons/valid-html401"
216        alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
217</p>
218
219' >> $H
220echo "</HTML>" >> $H
221