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