sets.subr revision 1.120
11.120Splunky#	$NetBSD: sets.subr,v 1.120 2010/02/04 13:07:55 plunky 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.11Slukem#	TOOLCHAIN_MISSING
231.11Slukem#	OBJECT_FMT
241.22Slukem# as well as:
251.22Slukem#
261.95Suebayasi
271.42Sapb#
281.42Sapb# The following variables refer to tools that are used when building sets:
291.42Sapb#
301.43Sapb: ${AWK:=awk}
311.42Sapb: ${CKSUM:=cksum}
321.43Sapb: ${COMM:=comm}
331.44Sapb: ${DATE:=date}
341.43Sapb: ${DB:=db}
351.43Sapb: ${EGREP:=egrep}
361.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
371.44Sapb: ${FGREP:=fgrep}
381.43Sapb: ${FIND:=find}
391.44Sapb: ${GREP:=grep}
401.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
411.99Sapb: ${HOSTNAME_CMD:=hostname}	# ${HOSTNAME} is special to bash(1)
421.42Sapb: ${HOST_SH:=sh}
431.43Sapb: ${IDENT:=ident}
441.43Sapb: ${JOIN:=join}
451.43Sapb: ${LS:=ls}
461.43Sapb: ${MAKE:=make}
471.42Sapb: ${MKTEMP:=mktemp}
481.43Sapb: ${MTREE:=mtree}
491.43Sapb: ${PASTE:=paste}
501.42Sapb: ${PAX:=pax}
511.43Sapb: ${PRINTF:=printf}
521.43Sapb: ${SED:=sed}
531.43Sapb: ${SORT:=sort}
541.44Sapb: ${STAT:=stat}
551.44Sapb: ${TSORT:=tsort}
561.43Sapb: ${UNAME:=uname}
571.43Sapb: ${WC:=wc}
581.118Suebayasi: ${XARGS:=xargs}
591.43Sapb
601.45Sapb#
611.45Sapb# If printf is a shell builtin command, then we can
621.45Sapb# implement cheaper versions of basename and dirname
631.45Sapb# that do not involve any fork/exec overhead.
641.45Sapb# If printf is not builtin, approximate it using echo,
651.45Sapb# and hope there are no weird file names that cause
661.45Sapb# some versions of echo to do the wrong thing.
671.45Sapb# (Converting to this version of dirname speeded up the
681.45Sapb# syspkgdeps script by an order of magnitude, from 68
691.45Sapb# seconds to 6.3 seconds on one particular host.)
701.45Sapb#
711.45Sapb# Note that naive approximations for dirname
721.45Sapb# using ${foo%/*} do not do the right thing in cases
731.45Sapb# where the result should be "/" or ".".
741.45Sapb#
751.45Sapbcase "$(type printf)" in
761.45Sapb*builtin*)
771.45Sapb	basename ()
781.45Sapb	{
791.45Sapb		local bn
801.45Sapb		bn="${1##*/}"
811.45Sapb		bn="${bn%$2}"
821.45Sapb		printf "%s\n" "$bn"
831.45Sapb	}
841.45Sapb	dirname ()
851.45Sapb	{
861.45Sapb		local dn
871.45Sapb		case "$1" in
881.45Sapb		?*/*)	dn="${1%/*}" ;;
891.45Sapb		/*)	dn=/ ;;
901.45Sapb		*)	dn=. ;;
911.45Sapb		esac
921.45Sapb		printf "%s\n" "$dn"
931.45Sapb	}
941.45Sapb	;;
951.45Sapb*)
961.45Sapb	basename ()
971.45Sapb	{
981.45Sapb		local bn
991.45Sapb		bn="${1##*/}"
1001.45Sapb		bn="${bn%$2}"
1011.45Sapb		echo "$bn"
1021.45Sapb	}
1031.45Sapb	dirname ()
1041.45Sapb	{
1051.45Sapb		local dn
1061.45Sapb		case "$1" in
1071.45Sapb		?*/*)	dn="${1%/*}" ;;
1081.45Sapb		/*)	dn=/ ;;
1091.45Sapb		*)	dn=. ;;
1101.45Sapb		esac
1111.45Sapb		echo "$dn"
1121.45Sapb	}
1131.45Sapb	;;
1141.45Sapbesac
1151.45Sapb
1161.108Suebayasi#####
1171.108Suebayasi
1181.9SlukemoIFS=$IFS
1191.9SlukemIFS="
1201.9Slukem"
1211.100Suebayasi
1221.109Shefor x in $( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do
1231.108Suebayasi	eval export $x
1241.9Slukemdone
1251.100Suebayasi
1261.9SlukemIFS=$oIFS
1271.9Slukem
1281.118SuebayasiMKVARS="$( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )"
1291.100Suebayasi
1301.105Suebayasi#####
1311.105Suebayasi
1321.117Suebayasisetsdir=${rundir}
1331.9Slukemobsolete=0
1341.76Stsutsuimodule=yes
1351.91Sdyoungif [ "${MKKMOD}" = "no" ]; then
1361.91Sdyoung	module=no			# MODULEs are off.
1371.119She	kmod=no
1381.9Slukemfi
1391.31Sjmc# Determine lib type. Do this first so stlib also gets set.
1401.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
1411.9Slukem	shlib=elf
1421.9Slukemelse
1431.9Slukem	shlib=aout
1441.9Slukemfi
1451.9Slukemstlib=$shlib
1461.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
1471.31Sjmcif [ "${MKPIC}" = "no" ]; then
1481.31Sjmc	shlib=no
1491.31Sjmcfi
1501.86Sjnemethif [ "$module" != "no" ]; then
1511.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
1521.86Sjnemethelse
1531.86Sjnemeth	nlists="base comp etc games man misc tests text"
1541.86Sjnemethfi
1551.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
1561.92Suebayasiextlists="extbase extcomp extetc"
1571.9Slukem
1581.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
1591.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
1601.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
1611.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
1621.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
1631.60Sad
1641.9Slukem#
1651.9Slukem# list_set_files setfile [...]
1661.1Sdyoung# 
1671.9Slukem# Produce a packing list for setfile(s).
1681.9Slukem# In each file, a record consists of a path and a System Package name,
1691.9Slukem# separated by whitespace. E.g.,
1701.9Slukem#
1711.120Splunky# 	# $NetBSD: sets.subr,v 1.120 2010/02/04 13:07:55 plunky Exp $
1721.9Slukem# 	.			base-sys-root	[keyword[,...]]
1731.9Slukem# 	./altroot		base-sys-root
1741.9Slukem# 	./bin			base-sys-root
1751.9Slukem# 	./bin/[			base-util-root
1761.9Slukem# 	./bin/cat		base-util-root
1771.9Slukem#		[...]
1781.9Slukem#
1791.9Slukem# A # in the first column marks a comment.
1801.9Slukem#
1811.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
1821.52Slukem# be printed.  All other keywords must be present.
1831.9Slukem#
1841.9Slukem# The third field is an optional comma separated list of keywords to
1851.9Slukem# control if a record is printed; every keyword listed must be enabled
1861.9Slukem# for the record to be printed.  The following keywords are available:
1871.9Slukem#	dummy			dummy entry (ignored)
1881.13Slukem#	obsolete		file is obsolete, and only printed if 
1891.13Slukem#				${obsolete} != 0
1901.13Slukem#
1911.87Sskrll#	bfd			obsolete, use binutils.
1921.87Sskrll#	binutils		${MKBINUTILS} != no
1931.22Slukem#	catpages		${MKCATPAGES} != no
1941.71Smrg#	compat			${MKCOMPAT} != no
1951.22Slukem#	crypto			${MKCRYPTO} != no
1961.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
1971.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
1981.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
1991.22Slukem#	cvs			${MKCVS} != no
2001.53Slukem#	debug			${MKDEBUG} != no
2011.69Slukem#	debuglib		${MKDEBUGLIB} != no
2021.23Slukem#	doc			${MKDOC} != no
2031.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2041.92Suebayasi#	extsrc			${MKEXTSRC} != no
2051.52Slukem#	gcc			${MKGCC} != no
2061.36Smatt#	gcccmds			${MKGCCCMDS} != no
2071.32Sscw#	gdb			${MKGDB} != no
2081.22Slukem#	hesiod			${MKHESIOD} != no
2091.68Slukem#	html			${MKHTML} != no
2101.67Slukem#	inet6			${MKINET6} != no
2111.23Slukem#	info			${MKINFO} != no
2121.39Speter#	ipfilter		${MKIPFILTER} != no
2131.51Smrg#	iscsi			${MKISCSI} != no
2141.22Slukem#	kerberos		${MKKERBEROS} != no
2151.85Sdyoung#	kmod			${MKKMOD} != no
2161.67Slukem#	ldap			${MKLDAP} != no
2171.22Slukem#	lint			${MKLINT} != no
2181.78Sagc#	lvm			${MKLVM} != no
2191.22Slukem#	man			${MKMAN} != no
2201.67Slukem#	manpages		${MKMANPAGES} != no
2211.22Slukem#	manz			${MKMANZ} != no
2221.88Stsarna#	mdns			${MKMDNS} != no
2231.23Slukem#	nls			${MKNLS} != no
2241.66Sdyoung#	nvi			${MKNVI} != no
2251.37She#	pam			${MKPAM} != no
2261.120Splunky#	pcc			${MKPCC} != no
2271.120Splunky#	pcccmds			${MKPCCCMDS} != no
2281.39Speter#	pf			${MKPF} != no
2291.67Slukem#	pic			${MKPIC} != no
2301.22Slukem#	postfix			${MKPOSTFIX} != no
2311.22Slukem#	profile			${MKPROFILE} != no
2321.24Slukem#	share			${MKSHARE} != no
2331.22Slukem#	skey			${MKSKEY} != no
2341.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2351.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2361.22Slukem#	yp			${MKYP} != no
2371.89Shaad#	zfs			${MKZFS} != no
2381.22Slukem#
2391.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
2401.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2411.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2421.52Slukem#
2431.41Slukem#	use_inet6		${USE_INET6} != no
2441.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2451.41Slukem#	use_yp			${USE_YP} != no
2461.41Slukem#
2471.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
2481.22Slukem#				  automatically append ".gz" to the filename
2491.22Slukem#
2501.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
2511.22Slukem#				  automatically append ".gz" to the filename
2521.1Sdyoung#
2531.8Slukemlist_set_files()
2541.8Slukem{
2551.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
2561.65She		verbose=false
2571.65She	else
2581.65She		verbose=true
2591.65She	fi
2601.116Suebayasi	print_set_lists "$@" | \
2611.43Sapb	${AWK} -v obsolete=${obsolete} '
2621.9Slukem		BEGIN {
2631.52Slukem			if (obsolete)
2641.52Slukem				wanted["obsolete"] = 1
2651.52Slukem		
2661.100Suebayasi			split("'"${MKVARS}"'", needvars)
2671.52Slukem			for (vi in needvars) {
2681.52Slukem				nv = needvars[vi]
2691.52Slukem				kw = tolower(nv)
2701.52Slukem				sub(/^mk/, "", kw)
2711.52Slukem				if (ENVIRON[nv] != "no")
2721.52Slukem					wanted[kw] = 1 
2731.52Slukem			}
2741.52Slukem
2751.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
2761.90Sdyoung				if ("binutils" in wanted)
2771.90Sdyoung					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
2781.90Sdyoung				if ("gcc" in wanted)
2791.90Sdyoung					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
2801.90Sdyoung				if ("gdb" in wanted)
2811.90Sdyoung					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
2821.9Slukem			}
2831.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
2841.52Slukem				wanted[".cat"] = 1
2851.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
2861.52Slukem				wanted[".man"] = 1
2871.9Slukem		}
2881.9Slukem
2891.9Slukem		/^#/ {
2901.9Slukem			next;
2911.9Slukem		}
2921.9Slukem
2931.9Slukem		NF > 2 && $3 != "-" {
2941.9Slukem			split($3, keywords, ",")
2951.9Slukem			show = 1
2961.52Slukem			haveobs = 0
2971.9Slukem			for (ki in keywords) {
2981.9Slukem				kw = keywords[ki]
2991.22Slukem				if (("manz" in wanted) &&
3001.22Slukem				    (kw == ".cat" || kw == ".man"))
3011.22Slukem					$1 = $1 ".gz"
3021.59Sjmmv				negated = match(kw, "! *")
3031.59Sjmmv				if (negated > 0) {
3041.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3051.59Sjmmv					if (kw in wanted)
3061.59Sjmmv						show = 0
3071.59Sjmmv				} else {
3081.59Sjmmv					if (! (kw in wanted))
3091.59Sjmmv						show = 0
3101.59Sjmmv				}
3111.52Slukem				if (kw == "obsolete")
3121.52Slukem					haveobs = 1
3131.9Slukem			}
3141.52Slukem			if (obsolete && ! haveobs)
3151.52Slukem				next
3161.9Slukem			if (show)
3171.9Slukem				print
3181.9Slukem			next
3191.9Slukem		}
3201.9Slukem
3211.9Slukem		{
3221.9Slukem			if (! obsolete)
3231.9Slukem				print
3241.9Slukem		}'
3251.9Slukem
3261.1Sdyoung}
3271.1Sdyoung
3281.1Sdyoung#
3291.1Sdyoung# list_set_lists setname
3301.1Sdyoung# 
3311.1Sdyoung# Print to stdout a list of files, one filename per line, which
3321.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3331.1Sdyoung#
3341.1Sdyoung# 	.../lists/base/mi
3351.1Sdyoung# 	.../lists/base/rescue.mi
3361.1Sdyoung# 	.../lists/base/md.i386
3371.9Slukem#		[...]
3381.1Sdyoung#
3391.9Slukem# For a given setname $set, the following files may be selected from
3401.9Slukem# .../list/$set:
3411.9Slukem#	mi
3421.92Suebayasi#	mi.ext.*
3431.11Slukem#	ad.${MACHINE_ARCH}
3441.11Slukem# (or)	ad.${MACHINE_CPU}
3451.11Slukem#	ad.${MACHINE_CPU}.shl
3461.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
3471.11Slukem# (or)	md.${MACHINE}
3481.9Slukem#	stl.mi
3491.92Suebayasi#	stl.${stlib}
3501.9Slukem#	shl.mi
3511.92Suebayasi#	shl.mi.ext.*
3521.92Suebayasi#	shl.${shlib}
3531.92Suebayasi#	shl.${shlib}.ext.*
3541.77Stsutsui#	module.mi			if ${module} != no
3551.77Stsutsui#	module.${MACHINE}		if ${module} != no
3561.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
3571.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
3581.9Slukem#	rescue.shl
3591.11Slukem#	rescue.${MACHINE}
3601.11Slukem#	rescue.ad.${MACHINE_ARCH}
3611.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
3621.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
3631.1Sdyoung#
3641.9Slukem# Environment:
3651.1Sdyoung# 	shlib
3661.1Sdyoung# 	stlib
3671.1Sdyoung#
3681.8Slukemlist_set_lists()
3691.8Slukem{
3701.1Sdyoung	setname=$1
3711.1Sdyoung
3721.111Suebayasi	list_set_lists_mi $setname
3731.113Suebayasi	list_set_lists_ad $setname
3741.111Suebayasi	list_set_lists_md $setname
3751.111Suebayasi	list_set_lists_stl $setname
3761.113Suebayasi	list_set_lists_shl $setname
3771.113Suebayasi	list_set_lists_module $setname
3781.111Suebayasi	list_set_lists_rescue $setname
3791.117Suebayasi	return 0
3801.111Suebayasi}
3811.110Suebayasi
3821.111Suebayasilist_set_lists_mi()
3831.111Suebayasi{
3841.111Suebayasi	setdir=$setsdir/lists/$1
3851.113Suebayasi	# always exist!
3861.9Slukem	echo $setdir/mi
3871.111Suebayasi}
3881.110Suebayasi
3891.111Suebayasilist_set_lists_ad()
3901.111Suebayasi{
3911.111Suebayasi	setdir=$setsdir/lists/$1
3921.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
3931.113Suebayasi	list_set_lists_common_ad $1
3941.111Suebayasi}
3951.110Suebayasi
3961.111Suebayasilist_set_lists_md()
3971.111Suebayasi{
3981.111Suebayasi	setdir=$setsdir/lists/$1
3991.110Suebayasi	echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
4001.110Suebayasi	echo_if_exist $setdir/md.${MACHINE}
4011.111Suebayasi}
4021.110Suebayasi
4031.111Suebayasilist_set_lists_stl()
4041.111Suebayasi{
4051.111Suebayasi	setdir=$setsdir/lists/$1
4061.110Suebayasi	echo_if_exist $setdir/stl.mi
4071.110Suebayasi	echo_if_exist $setdir/stl.${stlib}
4081.111Suebayasi}
4091.110Suebayasi
4101.111Suebayasilist_set_lists_shl()
4111.111Suebayasi{
4121.111Suebayasi	setdir=$setsdir/lists/$1
4131.113Suebayasi	[ "$shlib" != "no" ] || return
4141.112Suebayasi	echo_if_exist $setdir/shl.mi
4151.112Suebayasi	echo_if_exist $setdir/shl.${shlib}
4161.111Suebayasi}
4171.110Suebayasi
4181.111Suebayasilist_set_lists_module()
4191.111Suebayasi{
4201.111Suebayasi	setdir=$setsdir/lists/$1
4211.113Suebayasi	[ "$module" != "no" ] || return
4221.112Suebayasi	echo_if_exist $setdir/module.mi
4231.112Suebayasi	echo_if_exist $setdir/module.${MACHINE}
4241.113Suebayasi	# XXX module never has .shl
4251.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
4261.113Suebayasi	list_set_lists_common_ad $1 module
4271.111Suebayasi}
4281.1Sdyoung
4291.111Suebayasilist_set_lists_rescue()
4301.111Suebayasi{
4311.111Suebayasi	setdir=$setsdir/lists/$1
4321.110Suebayasi	echo_if_exist $setdir/rescue.mi
4331.110Suebayasi	echo_if_exist $setdir/rescue.${MACHINE}
4341.113Suebayasi	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
4351.113Suebayasi	list_set_lists_common_ad $1 rescue
4361.111Suebayasi}
4371.111Suebayasi
4381.113Suebayasilist_set_lists_common_ad()
4391.111Suebayasi{
4401.113Suebayasi	setdir=$setsdir/lists/$1; _prefix=$2
4411.113Suebayasi
4421.113Suebayasi	[ -n "$_prefix" ] && prefix="$_prefix".
4431.113Suebayasi
4441.113Suebayasi	# Prefer a <prefix>.ad.${MACHINE_ARCH} over a
4451.113Suebayasi	# <prefix>.ad.${MACHINE_CPU}, since the arch-
4461.112Suebayasi	# specific one will be more specific than the
4471.112Suebayasi	# cpu-specific one.
4481.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
4491.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
4501.113Suebayasi	[ "$shlib" != "no" ] && \
4511.113Suebayasi	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
4521.5Sdyoung}
4531.5Sdyoung
4541.110Suebayasiecho_if_exist()
4551.110Suebayasi{
4561.110Suebayasi	[ -f $1 ] && echo $1
4571.110Suebayasi	return $?
4581.110Suebayasi}
4591.110Suebayasi
4601.110Suebayasiecho_if_exist_foreach()
4611.110Suebayasi{
4621.110Suebayasi	local _list=$1; shift
4631.110Suebayasi	for _suffix in $@; do
4641.110Suebayasi		echo_if_exist ${_list}.${_suffix}
4651.110Suebayasi	done
4661.110Suebayasi}
4671.110Suebayasi
4681.116Suebayasiprint_set_lists()
4691.116Suebayasi{
4701.116Suebayasi	for setname; do
4711.116Suebayasi		list=`list_set_lists $setname`
4721.116Suebayasi		for l in $list; do
4731.116Suebayasi			echo $l
4741.116Suebayasi			if $verbose; then
4751.116Suebayasi				echo >&2 "DEBUG: list_set_files: $l"
4761.116Suebayasi			fi
4771.116Suebayasi		done
4781.118Suebayasi	done | ${XARGS} ${SED} ${SUBST}
4791.116Suebayasi}
4801.116Suebayasi
4811.9Slukem# arch_to_cpu mach
4821.9Slukem#
4831.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
4841.9Slukem# as determined by <bsd.own.mk>.
4851.9Slukem#
4861.8Slukemarch_to_cpu()
4871.8Slukem{
4881.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
4891.5Sdyoung.include <bsd.own.mk>
4901.5Sdyoungall:
4911.5Sdyoung	@echo \${MACHINE_CPU}
4921.12SlukemEOMAKE
4931.1Sdyoung}
4941.46Sapb
4951.46Sapb# arch_to_endian mach
4961.46Sapb#
4971.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
4981.46Sapb# as determined by <bsd.endian.mk>.
4991.46Sapb#
5001.46Sapbarch_to_endian()
5011.46Sapb{
5021.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5031.46Sapb.include <bsd.endian.mk>
5041.46Sapball:
5051.46Sapb	@echo \${TARGET_ENDIANNESS}
5061.46SapbEOMAKE
5071.46Sapb}
5081.117Suebayasi
5091.117Suebayasi#####
5101.117Suebayasi
5111.117Suebayasi# print_mkvars
5121.117Suebayasiprint_mkvars()
5131.117Suebayasi{
5141.117Suebayasi	for v in $MKVARS; do
5151.117Suebayasi		eval echo $v=\$$v
5161.117Suebayasi	done
5171.117Suebayasi}
5181.117Suebayasi
5191.117Suebayasi# print_set_lists_{base,x,ext}
5201.117Suebayasi# list_set_lists_{base,x,ext}
5211.117Suebayasi# list_set_files_{base,x,ext}
5221.117Suebayasifor func in print_set_lists list_set_lists list_set_files; do
5231.117Suebayasi	for x in base x ext; do
5241.117Suebayasi		if [ $x = base ]; then
5251.117Suebayasi			list=nlists
5261.117Suebayasi		else
5271.117Suebayasi			list=${x}lists
5281.117Suebayasi		fi
5291.117Suebayasi		eval ${func}_${x} \(\) \{ $func \$$list \; \}
5301.117Suebayasi	done
5311.117Suebayasidone
532