sets.subr revision 1.126
11.126She#	$NetBSD: sets.subr,v 1.126 2010/12/28 09:15:24 he Exp $
21.1Sdyoung#
31.9Slukem
41.9Slukem#
51.11Slukem# The following variables contain defaults for sets.subr functions and callers:
61.9Slukem#	setsdir			path to src/distrib/sets
71.9Slukem#	nlists			list of base sets
81.9Slukem#	xlists			list of x11 sets
91.92Suebayasi#	extlists		list of extsrc sets
101.9Slukem#	obsolete		controls if obsolete files are selected instead
111.76Stsutsui#	module			if != "no", enable MODULE sets
121.9Slukem#	shlib			shared library format (a.out, elf, or "")
131.9Slukem#	stlib			static library format (a.out, elf)
141.11Slukem#
151.11Slukem# The following <bsd.own.mk> variables are exported to the environment:
161.11Slukem#	MACHINE	
171.11Slukem#	MACHINE_ARCH
181.11Slukem#	MACHINE_CPU
191.87Sskrll#	HAVE_BINUTILS
201.48Smrg#	HAVE_GCC
211.52Slukem#	HAVE_GDB
221.126She#	HAS_SSP
231.11Slukem#	TOOLCHAIN_MISSING
241.11Slukem#	OBJECT_FMT
251.22Slukem# as well as:
261.22Slukem#
271.95Suebayasi
281.42Sapb#
291.42Sapb# The following variables refer to tools that are used when building sets:
301.42Sapb#
311.43Sapb: ${AWK:=awk}
321.42Sapb: ${CKSUM:=cksum}
331.43Sapb: ${COMM:=comm}
341.44Sapb: ${DATE:=date}
351.43Sapb: ${DB:=db}
361.43Sapb: ${EGREP:=egrep}
371.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
381.44Sapb: ${FGREP:=fgrep}
391.43Sapb: ${FIND:=find}
401.44Sapb: ${GREP:=grep}
411.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
421.99Sapb: ${HOSTNAME_CMD:=hostname}	# ${HOSTNAME} is special to bash(1)
431.42Sapb: ${HOST_SH:=sh}
441.43Sapb: ${IDENT:=ident}
451.43Sapb: ${JOIN:=join}
461.43Sapb: ${LS:=ls}
471.43Sapb: ${MAKE:=make}
481.42Sapb: ${MKTEMP:=mktemp}
491.43Sapb: ${MTREE:=mtree}
501.43Sapb: ${PASTE:=paste}
511.42Sapb: ${PAX:=pax}
521.43Sapb: ${PRINTF:=printf}
531.43Sapb: ${SED:=sed}
541.43Sapb: ${SORT:=sort}
551.44Sapb: ${STAT:=stat}
561.44Sapb: ${TSORT:=tsort}
571.43Sapb: ${UNAME:=uname}
581.43Sapb: ${WC:=wc}
591.118Suebayasi: ${XARGS:=xargs}
601.43Sapb
611.45Sapb#
621.45Sapb# If printf is a shell builtin command, then we can
631.45Sapb# implement cheaper versions of basename and dirname
641.45Sapb# that do not involve any fork/exec overhead.
651.45Sapb# If printf is not builtin, approximate it using echo,
661.45Sapb# and hope there are no weird file names that cause
671.45Sapb# some versions of echo to do the wrong thing.
681.45Sapb# (Converting to this version of dirname speeded up the
691.45Sapb# syspkgdeps script by an order of magnitude, from 68
701.45Sapb# seconds to 6.3 seconds on one particular host.)
711.45Sapb#
721.45Sapb# Note that naive approximations for dirname
731.45Sapb# using ${foo%/*} do not do the right thing in cases
741.45Sapb# where the result should be "/" or ".".
751.45Sapb#
761.45Sapbcase "$(type printf)" in
771.45Sapb*builtin*)
781.45Sapb	basename ()
791.45Sapb	{
801.45Sapb		local bn
811.45Sapb		bn="${1##*/}"
821.45Sapb		bn="${bn%$2}"
831.45Sapb		printf "%s\n" "$bn"
841.45Sapb	}
851.45Sapb	dirname ()
861.45Sapb	{
871.45Sapb		local dn
881.45Sapb		case "$1" in
891.45Sapb		?*/*)	dn="${1%/*}" ;;
901.45Sapb		/*)	dn=/ ;;
911.45Sapb		*)	dn=. ;;
921.45Sapb		esac
931.45Sapb		printf "%s\n" "$dn"
941.45Sapb	}
951.45Sapb	;;
961.45Sapb*)
971.45Sapb	basename ()
981.45Sapb	{
991.45Sapb		local bn
1001.45Sapb		bn="${1##*/}"
1011.45Sapb		bn="${bn%$2}"
1021.45Sapb		echo "$bn"
1031.45Sapb	}
1041.45Sapb	dirname ()
1051.45Sapb	{
1061.45Sapb		local dn
1071.45Sapb		case "$1" in
1081.45Sapb		?*/*)	dn="${1%/*}" ;;
1091.45Sapb		/*)	dn=/ ;;
1101.45Sapb		*)	dn=. ;;
1111.45Sapb		esac
1121.45Sapb		echo "$dn"
1131.45Sapb	}
1141.45Sapb	;;
1151.45Sapbesac
1161.45Sapb
1171.108Suebayasi#####
1181.108Suebayasi
1191.9SlukemoIFS=$IFS
1201.9SlukemIFS="
1211.9Slukem"
1221.100Suebayasi
1231.109Shefor x in $( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do
1241.108Suebayasi	eval export $x
1251.9Slukemdone
1261.100Suebayasi
1271.9SlukemIFS=$oIFS
1281.9Slukem
1291.118SuebayasiMKVARS="$( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )"
1301.100Suebayasi
1311.105Suebayasi#####
1321.105Suebayasi
1331.117Suebayasisetsdir=${rundir}
1341.9Slukemobsolete=0
1351.91Sdyoungif [ "${MKKMOD}" = "no" ]; then
1361.91Sdyoung	module=no			# MODULEs are off.
1371.125Snjoly	modset=""
1381.125Snjolyelse
1391.125Snjoly	module=yes
1401.125Snjoly	modset="modules"
1411.125Snjolyfi
1421.125Snjolyif [ "${MKATF}" = "no" ]; then
1431.125Snjoly	testset=""
1441.125Snjolyelse
1451.125Snjoly	testset="tests"
1461.9Slukemfi
1471.31Sjmc# Determine lib type. Do this first so stlib also gets set.
1481.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
1491.9Slukem	shlib=elf
1501.9Slukemelse
1511.9Slukem	shlib=aout
1521.9Slukemfi
1531.9Slukemstlib=$shlib
1541.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
1551.31Sjmcif [ "${MKPIC}" = "no" ]; then
1561.31Sjmc	shlib=no
1571.31Sjmcfi
1581.125Snjolynlists="base comp etc games man misc $modset $testset text"
1591.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
1601.92Suebayasiextlists="extbase extcomp extetc"
1611.9Slukem
1621.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
1631.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
1641.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
1651.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
1661.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
1671.60Sad
1681.9Slukem#
1691.9Slukem# list_set_files setfile [...]
1701.1Sdyoung# 
1711.9Slukem# Produce a packing list for setfile(s).
1721.9Slukem# In each file, a record consists of a path and a System Package name,
1731.9Slukem# separated by whitespace. E.g.,
1741.9Slukem#
1751.126She# 	# $NetBSD: sets.subr,v 1.126 2010/12/28 09:15:24 he Exp $
1761.9Slukem# 	.			base-sys-root	[keyword[,...]]
1771.9Slukem# 	./altroot		base-sys-root
1781.9Slukem# 	./bin			base-sys-root
1791.9Slukem# 	./bin/[			base-util-root
1801.9Slukem# 	./bin/cat		base-util-root
1811.9Slukem#		[...]
1821.9Slukem#
1831.9Slukem# A # in the first column marks a comment.
1841.9Slukem#
1851.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
1861.52Slukem# be printed.  All other keywords must be present.
1871.9Slukem#
1881.9Slukem# The third field is an optional comma separated list of keywords to
1891.9Slukem# control if a record is printed; every keyword listed must be enabled
1901.9Slukem# for the record to be printed.  The following keywords are available:
1911.9Slukem#	dummy			dummy entry (ignored)
1921.13Slukem#	obsolete		file is obsolete, and only printed if 
1931.13Slukem#				${obsolete} != 0
1941.13Slukem#
1951.125Snjoly#	atf			${MKATF} != no
1961.87Sskrll#	bfd			obsolete, use binutils.
1971.87Sskrll#	binutils		${MKBINUTILS} != no
1981.22Slukem#	catpages		${MKCATPAGES} != no
1991.71Smrg#	compat			${MKCOMPAT} != no
2001.22Slukem#	crypto			${MKCRYPTO} != no
2011.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2021.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2031.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2041.22Slukem#	cvs			${MKCVS} != no
2051.53Slukem#	debug			${MKDEBUG} != no
2061.69Slukem#	debuglib		${MKDEBUGLIB} != no
2071.23Slukem#	doc			${MKDOC} != no
2081.121Sdarran#	dtrace			${MKDTRACE} != no
2091.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2101.92Suebayasi#	extsrc			${MKEXTSRC} != no
2111.52Slukem#	gcc			${MKGCC} != no
2121.36Smatt#	gcccmds			${MKGCCCMDS} != no
2131.32Sscw#	gdb			${MKGDB} != no
2141.22Slukem#	hesiod			${MKHESIOD} != no
2151.68Slukem#	html			${MKHTML} != no
2161.67Slukem#	inet6			${MKINET6} != no
2171.23Slukem#	info			${MKINFO} != no
2181.39Speter#	ipfilter		${MKIPFILTER} != no
2191.51Smrg#	iscsi			${MKISCSI} != no
2201.22Slukem#	kerberos		${MKKERBEROS} != no
2211.85Sdyoung#	kmod			${MKKMOD} != no
2221.67Slukem#	ldap			${MKLDAP} != no
2231.22Slukem#	lint			${MKLINT} != no
2241.78Sagc#	lvm			${MKLVM} != no
2251.22Slukem#	man			${MKMAN} != no
2261.67Slukem#	manpages		${MKMANPAGES} != no
2271.22Slukem#	manz			${MKMANZ} != no
2281.88Stsarna#	mdns			${MKMDNS} != no
2291.23Slukem#	nls			${MKNLS} != no
2301.66Sdyoung#	nvi			${MKNVI} != no
2311.37She#	pam			${MKPAM} != no
2321.120Splunky#	pcc			${MKPCC} != no
2331.120Splunky#	pcccmds			${MKPCCCMDS} != no
2341.39Speter#	pf			${MKPF} != no
2351.67Slukem#	pic			${MKPIC} != no
2361.22Slukem#	postfix			${MKPOSTFIX} != no
2371.22Slukem#	profile			${MKPROFILE} != no
2381.24Slukem#	share			${MKSHARE} != no
2391.22Slukem#	skey			${MKSKEY} != no
2401.122Stron#	solaris			${MKDTRACE} != no or ${MKZFS} != no
2411.126She#	ssp			${HAS_SSP} != no
2421.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2431.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2441.22Slukem#	yp			${MKYP} != no
2451.89Shaad#	zfs			${MKZFS} != no
2461.22Slukem#
2471.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
2481.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2491.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2501.52Slukem#
2511.41Slukem#	use_inet6		${USE_INET6} != no
2521.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2531.41Slukem#	use_yp			${USE_YP} != no
2541.41Slukem#
2551.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
2561.22Slukem#				  automatically append ".gz" to the filename
2571.22Slukem#
2581.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
2591.22Slukem#				  automatically append ".gz" to the filename
2601.1Sdyoung#
2611.8Slukemlist_set_files()
2621.8Slukem{
2631.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
2641.65She		verbose=false
2651.65She	else
2661.65She		verbose=true
2671.65She	fi
2681.116Suebayasi	print_set_lists "$@" | \
2691.43Sapb	${AWK} -v obsolete=${obsolete} '
2701.9Slukem		BEGIN {
2711.52Slukem			if (obsolete)
2721.52Slukem				wanted["obsolete"] = 1
2731.52Slukem		
2741.100Suebayasi			split("'"${MKVARS}"'", needvars)
2751.52Slukem			for (vi in needvars) {
2761.52Slukem				nv = needvars[vi]
2771.52Slukem				kw = tolower(nv)
2781.52Slukem				sub(/^mk/, "", kw)
2791.126She				sub(/^has_/, "", kw)
2801.52Slukem				if (ENVIRON[nv] != "no")
2811.52Slukem					wanted[kw] = 1 
2821.52Slukem			}
2831.52Slukem
2841.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
2851.90Sdyoung				if ("binutils" in wanted)
2861.90Sdyoung					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
2871.90Sdyoung				if ("gcc" in wanted)
2881.90Sdyoung					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
2891.90Sdyoung				if ("gdb" in wanted)
2901.90Sdyoung					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
2911.9Slukem			}
2921.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
2931.52Slukem				wanted[".cat"] = 1
2941.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
2951.52Slukem				wanted[".man"] = 1
2961.9Slukem		}
2971.9Slukem
2981.9Slukem		/^#/ {
2991.9Slukem			next;
3001.9Slukem		}
3011.9Slukem
3021.9Slukem		NF > 2 && $3 != "-" {
3031.9Slukem			split($3, keywords, ",")
3041.9Slukem			show = 1
3051.52Slukem			haveobs = 0
3061.9Slukem			for (ki in keywords) {
3071.9Slukem				kw = keywords[ki]
3081.22Slukem				if (("manz" in wanted) &&
3091.22Slukem				    (kw == ".cat" || kw == ".man"))
3101.22Slukem					$1 = $1 ".gz"
3111.59Sjmmv				negated = match(kw, "! *")
3121.59Sjmmv				if (negated > 0) {
3131.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3141.59Sjmmv					if (kw in wanted)
3151.59Sjmmv						show = 0
3161.59Sjmmv				} else {
3171.59Sjmmv					if (! (kw in wanted))
3181.59Sjmmv						show = 0
3191.59Sjmmv				}
3201.52Slukem				if (kw == "obsolete")
3211.52Slukem					haveobs = 1
3221.9Slukem			}
3231.52Slukem			if (obsolete && ! haveobs)
3241.52Slukem				next
3251.9Slukem			if (show)
3261.9Slukem				print
3271.9Slukem			next
3281.9Slukem		}
3291.9Slukem
3301.9Slukem		{
3311.9Slukem			if (! obsolete)
3321.9Slukem				print
3331.9Slukem		}'
3341.9Slukem
3351.1Sdyoung}
3361.1Sdyoung
3371.1Sdyoung#
3381.1Sdyoung# list_set_lists setname
3391.1Sdyoung# 
3401.1Sdyoung# Print to stdout a list of files, one filename per line, which
3411.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3421.1Sdyoung#
3431.1Sdyoung# 	.../lists/base/mi
3441.1Sdyoung# 	.../lists/base/rescue.mi
3451.1Sdyoung# 	.../lists/base/md.i386
3461.9Slukem#		[...]
3471.1Sdyoung#
3481.9Slukem# For a given setname $set, the following files may be selected from
3491.9Slukem# .../list/$set:
3501.9Slukem#	mi
3511.92Suebayasi#	mi.ext.*
3521.11Slukem#	ad.${MACHINE_ARCH}
3531.11Slukem# (or)	ad.${MACHINE_CPU}
3541.11Slukem#	ad.${MACHINE_CPU}.shl
3551.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
3561.11Slukem# (or)	md.${MACHINE}
3571.9Slukem#	stl.mi
3581.92Suebayasi#	stl.${stlib}
3591.9Slukem#	shl.mi
3601.92Suebayasi#	shl.mi.ext.*
3611.92Suebayasi#	shl.${shlib}
3621.92Suebayasi#	shl.${shlib}.ext.*
3631.77Stsutsui#	module.mi			if ${module} != no
3641.77Stsutsui#	module.${MACHINE}		if ${module} != no
3651.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
3661.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
3671.9Slukem#	rescue.shl
3681.11Slukem#	rescue.${MACHINE}
3691.11Slukem#	rescue.ad.${MACHINE_ARCH}
3701.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
3711.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
3721.1Sdyoung#
3731.9Slukem# Environment:
3741.1Sdyoung# 	shlib
3751.1Sdyoung# 	stlib
3761.1Sdyoung#
3771.8Slukemlist_set_lists()
3781.8Slukem{
3791.1Sdyoung	setname=$1
3801.1Sdyoung
3811.111Suebayasi	list_set_lists_mi $setname
3821.113Suebayasi	list_set_lists_ad $setname
3831.111Suebayasi	list_set_lists_md $setname
3841.111Suebayasi	list_set_lists_stl $setname
3851.113Suebayasi	list_set_lists_shl $setname
3861.113Suebayasi	list_set_lists_module $setname
3871.111Suebayasi	list_set_lists_rescue $setname
3881.117Suebayasi	return 0
3891.111Suebayasi}
3901.110Suebayasi
3911.111Suebayasilist_set_lists_mi()
3921.111Suebayasi{
3931.111Suebayasi	setdir=$setsdir/lists/$1
3941.113Suebayasi	# always exist!
3951.9Slukem	echo $setdir/mi
3961.111Suebayasi}
3971.110Suebayasi
3981.111Suebayasilist_set_lists_ad()
3991.111Suebayasi{
4001.111Suebayasi	setdir=$setsdir/lists/$1
4011.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
4021.113Suebayasi	list_set_lists_common_ad $1
4031.111Suebayasi}
4041.110Suebayasi
4051.111Suebayasilist_set_lists_md()
4061.111Suebayasi{
4071.111Suebayasi	setdir=$setsdir/lists/$1
4081.110Suebayasi	echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
4091.110Suebayasi	echo_if_exist $setdir/md.${MACHINE}
4101.111Suebayasi}
4111.110Suebayasi
4121.111Suebayasilist_set_lists_stl()
4131.111Suebayasi{
4141.111Suebayasi	setdir=$setsdir/lists/$1
4151.110Suebayasi	echo_if_exist $setdir/stl.mi
4161.110Suebayasi	echo_if_exist $setdir/stl.${stlib}
4171.111Suebayasi}
4181.110Suebayasi
4191.111Suebayasilist_set_lists_shl()
4201.111Suebayasi{
4211.111Suebayasi	setdir=$setsdir/lists/$1
4221.113Suebayasi	[ "$shlib" != "no" ] || return
4231.112Suebayasi	echo_if_exist $setdir/shl.mi
4241.112Suebayasi	echo_if_exist $setdir/shl.${shlib}
4251.111Suebayasi}
4261.110Suebayasi
4271.111Suebayasilist_set_lists_module()
4281.111Suebayasi{
4291.111Suebayasi	setdir=$setsdir/lists/$1
4301.113Suebayasi	[ "$module" != "no" ] || return
4311.112Suebayasi	echo_if_exist $setdir/module.mi
4321.112Suebayasi	echo_if_exist $setdir/module.${MACHINE}
4331.113Suebayasi	# XXX module never has .shl
4341.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
4351.113Suebayasi	list_set_lists_common_ad $1 module
4361.111Suebayasi}
4371.1Sdyoung
4381.111Suebayasilist_set_lists_rescue()
4391.111Suebayasi{
4401.111Suebayasi	setdir=$setsdir/lists/$1
4411.110Suebayasi	echo_if_exist $setdir/rescue.mi
4421.110Suebayasi	echo_if_exist $setdir/rescue.${MACHINE}
4431.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
4441.113Suebayasi	list_set_lists_common_ad $1 rescue
4451.111Suebayasi}
4461.111Suebayasi
4471.113Suebayasilist_set_lists_common_ad()
4481.111Suebayasi{
4491.113Suebayasi	setdir=$setsdir/lists/$1; _prefix=$2
4501.113Suebayasi
4511.113Suebayasi	[ -n "$_prefix" ] && prefix="$_prefix".
4521.113Suebayasi
4531.113Suebayasi	# Prefer a <prefix>.ad.${MACHINE_ARCH} over a
4541.113Suebayasi	# <prefix>.ad.${MACHINE_CPU}, since the arch-
4551.112Suebayasi	# specific one will be more specific than the
4561.112Suebayasi	# cpu-specific one.
4571.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
4581.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
4591.113Suebayasi	[ "$shlib" != "no" ] && \
4601.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
4611.5Sdyoung}
4621.5Sdyoung
4631.110Suebayasiecho_if_exist()
4641.110Suebayasi{
4651.110Suebayasi	[ -f $1 ] && echo $1
4661.110Suebayasi	return $?
4671.110Suebayasi}
4681.110Suebayasi
4691.110Suebayasiecho_if_exist_foreach()
4701.110Suebayasi{
4711.110Suebayasi	local _list=$1; shift
4721.110Suebayasi	for _suffix in $@; do
4731.110Suebayasi		echo_if_exist ${_list}.${_suffix}
4741.110Suebayasi	done
4751.110Suebayasi}
4761.110Suebayasi
4771.116Suebayasiprint_set_lists()
4781.116Suebayasi{
4791.116Suebayasi	for setname; do
4801.116Suebayasi		list=`list_set_lists $setname`
4811.116Suebayasi		for l in $list; do
4821.116Suebayasi			echo $l
4831.116Suebayasi			if $verbose; then
4841.116Suebayasi				echo >&2 "DEBUG: list_set_files: $l"
4851.116Suebayasi			fi
4861.116Suebayasi		done
4871.118Suebayasi	done | ${XARGS} ${SED} ${SUBST}
4881.116Suebayasi}
4891.116Suebayasi
4901.9Slukem# arch_to_cpu mach
4911.9Slukem#
4921.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
4931.9Slukem# as determined by <bsd.own.mk>.
4941.9Slukem#
4951.8Slukemarch_to_cpu()
4961.8Slukem{
4971.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
4981.5Sdyoung.include <bsd.own.mk>
4991.5Sdyoungall:
5001.5Sdyoung	@echo \${MACHINE_CPU}
5011.12SlukemEOMAKE
5021.1Sdyoung}
5031.46Sapb
5041.46Sapb# arch_to_endian mach
5051.46Sapb#
5061.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5071.46Sapb# as determined by <bsd.endian.mk>.
5081.46Sapb#
5091.46Sapbarch_to_endian()
5101.46Sapb{
5111.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5121.46Sapb.include <bsd.endian.mk>
5131.46Sapball:
5141.46Sapb	@echo \${TARGET_ENDIANNESS}
5151.46SapbEOMAKE
5161.46Sapb}
5171.117Suebayasi
5181.117Suebayasi#####
5191.117Suebayasi
5201.117Suebayasi# print_mkvars
5211.117Suebayasiprint_mkvars()
5221.117Suebayasi{
5231.117Suebayasi	for v in $MKVARS; do
5241.117Suebayasi		eval echo $v=\$$v
5251.117Suebayasi	done
5261.117Suebayasi}
5271.117Suebayasi
5281.117Suebayasi# print_set_lists_{base,x,ext}
5291.117Suebayasi# list_set_lists_{base,x,ext}
5301.117Suebayasi# list_set_files_{base,x,ext}
5311.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do
5321.117Suebayasi	for x in base x ext; do
5331.117Suebayasi		if [ $x = base ]; then
5341.117Suebayasi			list=nlists
5351.117Suebayasi		else
5361.117Suebayasi			list=${x}lists
5371.117Suebayasi		fi
5381.117Suebayasi		eval ${func}_${x} \(\) \{ $func \$$list \; \}
5391.117Suebayasi	done
5401.117Suebayasidone
541