xref: /freebsd/tools/tools/build_option_survey/option_survey.sh (revision 22aec2a31537deea151b92438ed9051e677f6062)
168d71fe7SPoul-Henning Kamp#!/bin/sh
268d71fe7SPoul-Henning Kamp# This file is in the public domain
368d71fe7SPoul-Henning Kamp# $FreeBSD$
468d71fe7SPoul-Henning Kamp
522aec2a3SPoul-Henning Kampif [ "x$1" != "x" ] ; then
622aec2a3SPoul-Henning Kamp	OPLIST=$1
722aec2a3SPoul-Henning Kampelse
822aec2a3SPoul-Henning Kamp	OPLIST=no_list
922aec2a3SPoul-Henning Kampfi
1022aec2a3SPoul-Henning Kamp
1122aec2a3SPoul-Henning KampOPLIST=_.options
1222aec2a3SPoul-Henning Kamp
1368d71fe7SPoul-Henning Kampset -e
1468d71fe7SPoul-Henning Kamp
1568d71fe7SPoul-Henning Kampbw ( ) (
1668d71fe7SPoul-Henning Kamp	cd ../../..
1768d71fe7SPoul-Henning Kamp	make -j 4 buildworld \
1868d71fe7SPoul-Henning Kamp		__MAKE_CONF=${ODIR}/make.conf \
1968d71fe7SPoul-Henning Kamp		> ${ODIR}/_.bw 2>&1
2068d71fe7SPoul-Henning Kamp	make -j 4 buildkernel \
2168d71fe7SPoul-Henning Kamp		KERNCONF=GENERIC \
2268d71fe7SPoul-Henning Kamp		__MAKE_CONF=${ODIR}/make.conf \
2368d71fe7SPoul-Henning Kamp		> ${ODIR}/_.bk 2>&1
2468d71fe7SPoul-Henning Kamp)
2568d71fe7SPoul-Henning Kamp
2668d71fe7SPoul-Henning Kampiw ( ) (
2768d71fe7SPoul-Henning Kamp	dd if=/dev/zero of=${ODIR}/_.i bs=1m count=200
2868d71fe7SPoul-Henning Kamp	mkdir -p ${MNT}
2968d71fe7SPoul-Henning Kamp	MD=`mdconfig -a -t vnode -f ${ODIR}/_.i`
3068d71fe7SPoul-Henning Kamp	trap "umount ${MNT} || true ; mdconfig -d -u $MD" 1 2 15 EXIT
3168d71fe7SPoul-Henning Kamp	newfs -O1 -U -b 4096 -f 512 /dev/$MD
3268d71fe7SPoul-Henning Kamp	mount /dev/${MD} ${MNT}
3368d71fe7SPoul-Henning Kamp
3468d71fe7SPoul-Henning Kamp	cd ../../..
3568d71fe7SPoul-Henning Kamp	make installworld \
3668d71fe7SPoul-Henning Kamp		__MAKE_CONF=${ODIR}/make.conf \
3768d71fe7SPoul-Henning Kamp		DESTDIR=${MNT} \
3868d71fe7SPoul-Henning Kamp		> ${ODIR}/_.iw 2>&1
3968d71fe7SPoul-Henning Kamp	cd etc
4068d71fe7SPoul-Henning Kamp	make distribution \
4168d71fe7SPoul-Henning Kamp		__MAKE_CONF=${ODIR}/make.conf \
4268d71fe7SPoul-Henning Kamp		DESTDIR=${MNT} \
4368d71fe7SPoul-Henning Kamp		> ${ODIR}/_.etc 2>&1
4468d71fe7SPoul-Henning Kamp	cd ..
4568d71fe7SPoul-Henning Kamp	make installkernel \
4668d71fe7SPoul-Henning Kamp		KERNCONF=GENERIC \
4768d71fe7SPoul-Henning Kamp		DESTDIR=${MNT} \
4868d71fe7SPoul-Henning Kamp		__MAKE_CONF=${ODIR}/make.conf \
4968d71fe7SPoul-Henning Kamp		> ${ODIR}/_.ik 2>&1
5068d71fe7SPoul-Henning Kamp
5168d71fe7SPoul-Henning Kamp	sync ${MNT}
5268d71fe7SPoul-Henning Kamp	( cd ${MNT} && mtree -c ) > ${ODIR}/_.mtree
5368d71fe7SPoul-Henning Kamp	( cd ${MNT} && du ) > ${ODIR}/_.du
5468d71fe7SPoul-Henning Kamp	( df -i ${MNT} ) > ${ODIR}/_.df
5568d71fe7SPoul-Henning Kamp)
5668d71fe7SPoul-Henning Kamp
5768d71fe7SPoul-Henning KampODIR=/usr/obj/`pwd`
5868d71fe7SPoul-Henning KampMNT=${ODIR}/_.mnt
5922aec2a3SPoul-Henning KampRDIR=${ODIR}/_.result
6022aec2a3SPoul-Henning Kampexport ODIR MNT RDIR
6122aec2a3SPoul-Henning Kamp
6222aec2a3SPoul-Henning Kamp
6322aec2a3SPoul-Henning Kamp# Clean and recrate the ODIR
6468d71fe7SPoul-Henning Kamp
6568d71fe7SPoul-Henning Kampif false ; then
6668d71fe7SPoul-Henning Kamp	if rm -rf ${ODIR} ; then
6768d71fe7SPoul-Henning Kamp		true
6868d71fe7SPoul-Henning Kamp	else
6968d71fe7SPoul-Henning Kamp		chflags -R noschg ${ODIR}
7068d71fe7SPoul-Henning Kamp		rm -rf ${ODIR}
7168d71fe7SPoul-Henning Kamp	fi
7268d71fe7SPoul-Henning Kamp	mkdir -p ${ODIR}
7368d71fe7SPoul-Henning Kamp
7422aec2a3SPoul-Henning Kampfi
7568d71fe7SPoul-Henning Kamp
7622aec2a3SPoul-Henning Kamp# Build the reference world
7722aec2a3SPoul-Henning Kamp
7822aec2a3SPoul-Henning Kampif false ; then
7922aec2a3SPoul-Henning Kamp	echo '' > ${ODIR}/make.conf
8022aec2a3SPoul-Henning Kamp	MAKEOBJDIRPREFIX=$ODIR/_.ref
8122aec2a3SPoul-Henning Kamp	export MAKEOBJDIRPREFIX
8268d71fe7SPoul-Henning Kamp	bw
8368d71fe7SPoul-Henning Kampfi
8468d71fe7SPoul-Henning Kamp
8522aec2a3SPoul-Henning Kamp# Parse option list into subdirectories with make.conf files.
8622aec2a3SPoul-Henning Kamp
8768d71fe7SPoul-Henning Kampif false ; then
8822aec2a3SPoul-Henning Kamp	rm -rf ${RDIR}
8922aec2a3SPoul-Henning Kamp	grep -v '^[ 	]*#' $OPLIST | while read o
9068d71fe7SPoul-Henning Kamp	do
9122aec2a3SPoul-Henning Kamp		echo "$o=/dev/YES" > ${ODIR}/_make.conf
9222aec2a3SPoul-Henning Kamp		m=`md5 < ${ODIR}/_make.conf`
9322aec2a3SPoul-Henning Kamp		mkdir -p ${RDIR}/$m
9422aec2a3SPoul-Henning Kamp		mv ${ODIR}/_make.conf ${RDIR}/$m/make.conf
9568d71fe7SPoul-Henning Kamp	done
9668d71fe7SPoul-Henning Kampfi
9768d71fe7SPoul-Henning Kamp
9822aec2a3SPoul-Henning Kamp# Do the reference installworld
9922aec2a3SPoul-Henning Kamp
10022aec2a3SPoul-Henning Kampif false ; then
10122aec2a3SPoul-Henning Kamp	echo '' > ${ODIR}/make.conf
10222aec2a3SPoul-Henning Kamp	MAKEOBJDIRPREFIX=$ODIR/_.ref
10322aec2a3SPoul-Henning Kamp	export MAKEOBJDIRPREFIX
10422aec2a3SPoul-Henning Kamp	mkdir -p ${RDIR}/Ref
10522aec2a3SPoul-Henning Kamp	iw
10622aec2a3SPoul-Henning Kamp	cp ${ODIR}/_.df ${RDIR}/Ref
10722aec2a3SPoul-Henning Kamp	cp ${ODIR}/_.mtree ${RDIR}/Ref
10822aec2a3SPoul-Henning Kamp	cp ${ODIR}/_.du ${RDIR}/Ref
10922aec2a3SPoul-Henning Kampfi
11022aec2a3SPoul-Henning Kamp
11122aec2a3SPoul-Henning Kamp# Run through each testtarget in turn
11222aec2a3SPoul-Henning Kamp
11368d71fe7SPoul-Henning Kampif true ; then
11422aec2a3SPoul-Henning Kamp	for d in ${RDIR}/[0-9a-z]*
11568d71fe7SPoul-Henning Kamp	do
11622aec2a3SPoul-Henning Kamp		if [ ! -d $d ] ; then
11722aec2a3SPoul-Henning Kamp			continue;
11868d71fe7SPoul-Henning Kamp		fi
11922aec2a3SPoul-Henning Kamp		echo '------------------------------------------------'
12022aec2a3SPoul-Henning Kamp		cat $d/make.conf
12122aec2a3SPoul-Henning Kamp		echo '------------------------------------------------'
12222aec2a3SPoul-Henning Kamp		cp $d/make.conf ${ODIR}/make.conf
12322aec2a3SPoul-Henning Kamp
12422aec2a3SPoul-Henning Kamp		if [ ! -f $d/iw/done ] ; then
12522aec2a3SPoul-Henning Kamp			echo "# Trying IW"
12622aec2a3SPoul-Henning Kamp			rm -rf $d/iw
12722aec2a3SPoul-Henning Kamp			mkdir -p $d/iw
12822aec2a3SPoul-Henning Kamp			MAKEOBJDIRPREFIX=$ODIR/_.ref
12922aec2a3SPoul-Henning Kamp			export MAKEOBJDIRPREFIX
13068d71fe7SPoul-Henning Kamp			if iw ; then
13122aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.df $d/iw
13222aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.mtree $d/iw
13322aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.du $d/iw
13468d71fe7SPoul-Henning Kamp			else
13522aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.iw $d/iw || true
13622aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.ik $d/iw || true
13768d71fe7SPoul-Henning Kamp			fi
13822aec2a3SPoul-Henning Kamp			touch $d/iw/done
13922aec2a3SPoul-Henning Kamp		fi
14022aec2a3SPoul-Henning Kamp		if [ ! -f $d/bw/done ] ; then
14122aec2a3SPoul-Henning Kamp			echo "# Trying BW"
14222aec2a3SPoul-Henning Kamp			MAKEOBJDIRPREFIX=$ODIR/_.tst
14322aec2a3SPoul-Henning Kamp			export MAKEOBJDIRPREFIX
14422aec2a3SPoul-Henning Kamp			if bw ; then
14522aec2a3SPoul-Henning Kamp				mkdir -p $d/w
14622aec2a3SPoul-Henning Kamp				if iw ; then
14722aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.df $d/w
14822aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.mtree $d/w
14922aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.du $d/w
15022aec2a3SPoul-Henning Kamp				else
15122aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.iw $d/w || true
15222aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.ik $d/w || true
15322aec2a3SPoul-Henning Kamp				fi
15422aec2a3SPoul-Henning Kamp				touch $d/w/done
15522aec2a3SPoul-Henning Kamp				echo "# Trying W"
15622aec2a3SPoul-Henning Kamp				mkdir -p $d/bw
15768d71fe7SPoul-Henning Kamp				echo '' > ${ODIR}/make.conf
15868d71fe7SPoul-Henning Kamp				if iw ; then
15922aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.df $d/bw
16022aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.mtree $d/bw
16122aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.du $d/bw
16268d71fe7SPoul-Henning Kamp				else
16322aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.iw $d/bw || true
16422aec2a3SPoul-Henning Kamp					cp ${ODIR}/_.ik $d/bw || true
16568d71fe7SPoul-Henning Kamp				fi
16622aec2a3SPoul-Henning Kamp				touch $d/bw/done
16722aec2a3SPoul-Henning Kamp			else
16822aec2a3SPoul-Henning Kamp				mkdir -p $d/bw
16922aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.bw $d/bw || true
17022aec2a3SPoul-Henning Kamp				cp ${ODIR}/_.bk $d/bw || true
17122aec2a3SPoul-Henning Kamp				touch $d/bw/done
17222aec2a3SPoul-Henning Kamp			fi
17322aec2a3SPoul-Henning Kamp		fi
17468d71fe7SPoul-Henning Kamp	done
17568d71fe7SPoul-Henning Kampfi
176