sets.subr revision 1.84
11.84Smrg#	$NetBSD: sets.subr,v 1.84 2009/06/18 21:05:35 mrg 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.9Slukem#	obsolete		controls if obsolete files are selected instead
101.76Stsutsui#	module			if != "no", enable MODULE sets
111.9Slukem#	shlib			shared library format (a.out, elf, or "")
121.9Slukem#	stlib			static library format (a.out, elf)
131.11Slukem#
141.11Slukem# The following <bsd.own.mk> variables are exported to the environment:
151.11Slukem#	MACHINE	
161.11Slukem#	MACHINE_ARCH
171.11Slukem#	MACHINE_CPU
181.48Smrg#	HAVE_GCC
191.52Slukem#	HAVE_GDB
201.11Slukem#	TOOLCHAIN_MISSING
211.11Slukem#	OBJECT_FMT
221.22Slukem# as well as:
231.22Slukem#
241.22SlukemMKVARS="\
251.22Slukem	MKBFD		\
261.22Slukem	MKCATPAGES	\
271.71Smrg	MKCOMPAT	\
281.22Slukem	MKCRYPTO	\
291.22Slukem	MKCRYPTO_IDEA	\
301.22Slukem	MKCRYPTO_MDC2	\
311.22Slukem	MKCRYPTO_RC5	\
321.22Slukem	MKCVS		\
331.67Slukem	MKDEBUG		\
341.69Slukem	MKDEBUGLIB	\
351.67Slukem	MKDOC		\
361.67Slukem	MKDYNAMICROOT	\
371.52Slukem	MKGCC		\
381.36Smatt	MKGCCCMDS	\
391.32Sscw	MKGDB		\
401.22Slukem	MKHESIOD	\
411.68Slukem	MKHTML		\
421.67Slukem	MKINET6		\
431.23Slukem	MKINFO		\
441.39Speter	MKIPFILTER	\
451.51Smrg	MKISCSI		\
461.22Slukem	MKKERBEROS	\
471.67Slukem	MKLDAP		\
481.22Slukem	MKLINT		\
491.78Sagc	MKLVM		\
501.22Slukem	MKMAN		\
511.33Sjmc	MKMANPAGES	\
521.22Slukem	MKMANZ		\
531.23Slukem	MKNLS		\
541.66Sdyoung	MKNVI		\
551.37She	MKPAM		\
561.39Speter	MKPF		\
571.30Smatt	MKPIC		\
581.22Slukem	MKPOSTFIX	\
591.22Slukem	MKPROFILE	\
601.24Slukem	MKSHARE		\
611.22Slukem	MKSKEY		\
621.40Stron	MKX11		\
631.84Smrg	MKX11FONTS	\
641.68Slukem	MKXORG		\
651.22Slukem	MKYP		\
661.41Slukem	USE_INET6	\
671.41Slukem	USE_KERBEROS	\
681.63Slukem	USE_LDAP	\
691.41Slukem	USE_YP		\
701.64She	NETBSDSRCDIR	\
711.65She	MAKEVERBOSE	\
721.22Slukem"
731.42Sapb#
741.42Sapb# The following variables refer to tools that are used when building sets:
751.42Sapb#
761.43Sapb: ${AWK:=awk}
771.42Sapb: ${CKSUM:=cksum}
781.43Sapb: ${COMM:=comm}
791.44Sapb: ${DATE:=date}
801.43Sapb: ${DB:=db}
811.43Sapb: ${EGREP:=egrep}
821.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
831.44Sapb: ${FGREP:=fgrep}
841.43Sapb: ${FIND:=find}
851.44Sapb: ${GREP:=grep}
861.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
871.44Sapb: ${HOSTNAME:=hostname}
881.42Sapb: ${HOST_SH:=sh}
891.43Sapb: ${IDENT:=ident}
901.43Sapb: ${JOIN:=join}
911.43Sapb: ${LS:=ls}
921.43Sapb: ${MAKE:=make}
931.42Sapb: ${MKTEMP:=mktemp}
941.43Sapb: ${MTREE:=mtree}
951.43Sapb: ${PASTE:=paste}
961.42Sapb: ${PAX:=pax}
971.43Sapb: ${PKG_CREATE:=pkg_create}
981.43Sapb: ${PRINTF:=printf}
991.43Sapb: ${SED:=sed}
1001.43Sapb: ${SORT:=sort}
1011.44Sapb: ${STAT:=stat}
1021.44Sapb: ${TSORT:=tsort}
1031.43Sapb: ${UNAME:=uname}
1041.43Sapb: ${WC:=wc}
1051.43Sapb
1061.45Sapb#
1071.45Sapb# If printf is a shell builtin command, then we can
1081.45Sapb# implement cheaper versions of basename and dirname
1091.45Sapb# that do not involve any fork/exec overhead.
1101.45Sapb# If printf is not builtin, approximate it using echo,
1111.45Sapb# and hope there are no weird file names that cause
1121.45Sapb# some versions of echo to do the wrong thing.
1131.45Sapb# (Converting to this version of dirname speeded up the
1141.45Sapb# syspkgdeps script by an order of magnitude, from 68
1151.45Sapb# seconds to 6.3 seconds on one particular host.)
1161.45Sapb#
1171.45Sapb# Note that naive approximations for dirname
1181.45Sapb# using ${foo%/*} do not do the right thing in cases
1191.45Sapb# where the result should be "/" or ".".
1201.45Sapb#
1211.45Sapbcase "$(type printf)" in
1221.45Sapb*builtin*)
1231.45Sapb	basename ()
1241.45Sapb	{
1251.45Sapb		local bn
1261.45Sapb		bn="${1##*/}"
1271.45Sapb		bn="${bn%$2}"
1281.45Sapb		printf "%s\n" "$bn"
1291.45Sapb	}
1301.45Sapb	dirname ()
1311.45Sapb	{
1321.45Sapb		local dn
1331.45Sapb		case "$1" in
1341.45Sapb		?*/*)	dn="${1%/*}" ;;
1351.45Sapb		/*)	dn=/ ;;
1361.45Sapb		*)	dn=. ;;
1371.45Sapb		esac
1381.45Sapb		printf "%s\n" "$dn"
1391.45Sapb	}
1401.45Sapb	;;
1411.45Sapb*)
1421.45Sapb	basename ()
1431.45Sapb	{
1441.45Sapb		local bn
1451.45Sapb		bn="${1##*/}"
1461.45Sapb		bn="${bn%$2}"
1471.45Sapb		echo "$bn"
1481.45Sapb	}
1491.45Sapb	dirname ()
1501.45Sapb	{
1511.45Sapb		local dn
1521.45Sapb		case "$1" in
1531.45Sapb		?*/*)	dn="${1%/*}" ;;
1541.45Sapb		/*)	dn=/ ;;
1551.45Sapb		*)	dn=. ;;
1561.45Sapb		esac
1571.45Sapb		echo "$dn"
1581.45Sapb	}
1591.45Sapb	;;
1601.45Sapbesac
1611.45Sapb
1621.9SlukemoIFS=$IFS
1631.9SlukemIFS="
1641.9Slukem"
1651.9Slukemfor x in $(
1661.43Sapb${MAKE} -B -f- all <<EOMAKE
1671.9Slukem.include <bsd.own.mk>
1681.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1691.33SjmcMKMANPAGES=no
1701.33Sjmc.else
1711.33SjmcMKMANPAGES=yes
1721.33Sjmc.endif
1731.72Smrg.if \${MKX11} != "no"
1741.72Smrg. if \${X11FLAVOUR} == "Xorg"
1751.72SmrgMKXORG:=yes
1761.72SmrgMKX11:=no
1771.72Smrg. else
1781.72SmrgMKXORG:=no
1791.72Smrg. endif
1801.72Smrg.endif
1811.9Slukemall:
1821.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1831.52Slukem		HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1841.12Slukem		${MKVARS}
1851.12Slukem	@echo "export \$i=\${\$i}"
1861.11Slukem.endfor
1871.9Slukem
1881.12SlukemEOMAKE
1891.9Slukem); do
1901.11Slukem#	echo 1>&2 "DEBUG: read $x"
1911.9Slukem	eval $x
1921.9Slukemdone
1931.9SlukemIFS=$oIFS
1941.9Slukem
1951.34Serhsetsdir=${0%/*}
1961.57Sjmmvnlists="base comp etc games man misc tests text"
1971.70Slukemxlists="xbase xcomp xetc xfont xserver"
1981.9Slukemobsolete=0
1991.76Stsutsuimodule=yes
2001.11Slukemif [ "${MACHINE}" = "evbppc" ]; then
2011.76Stsutsui	module=no			# Turn off MODULEs for some ports.
2021.9Slukemfi
2031.31Sjmc# Determine lib type. Do this first so stlib also gets set.
2041.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
2051.9Slukem	shlib=elf
2061.9Slukemelse
2071.9Slukem	shlib=aout
2081.9Slukemfi
2091.9Slukemstlib=$shlib
2101.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
2111.31Sjmcif [ "${MKPIC}" = "no" ]; then
2121.31Sjmc	shlib=no
2131.31Sjmcfi
2141.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
2151.9Slukem	shlib=no			# Turn off shlibs for some ports.
2161.9Slukemfi
2171.9Slukem
2181.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2191.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2201.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2211.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2221.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2231.60Sad
2241.9Slukem#
2251.9Slukem# list_set_files setfile [...]
2261.1Sdyoung# 
2271.9Slukem# Produce a packing list for setfile(s).
2281.9Slukem# In each file, a record consists of a path and a System Package name,
2291.9Slukem# separated by whitespace. E.g.,
2301.9Slukem#
2311.84Smrg# 	# $NetBSD: sets.subr,v 1.84 2009/06/18 21:05:35 mrg Exp $
2321.9Slukem# 	.			base-sys-root	[keyword[,...]]
2331.9Slukem# 	./altroot		base-sys-root
2341.9Slukem# 	./bin			base-sys-root
2351.9Slukem# 	./bin/[			base-util-root
2361.9Slukem# 	./bin/cat		base-util-root
2371.9Slukem#		[...]
2381.9Slukem#
2391.9Slukem# A # in the first column marks a comment.
2401.9Slukem#
2411.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2421.52Slukem# be printed.  All other keywords must be present.
2431.9Slukem#
2441.9Slukem# The third field is an optional comma separated list of keywords to
2451.9Slukem# control if a record is printed; every keyword listed must be enabled
2461.9Slukem# for the record to be printed.  The following keywords are available:
2471.9Slukem#	dummy			dummy entry (ignored)
2481.13Slukem#	obsolete		file is obsolete, and only printed if 
2491.13Slukem#				${obsolete} != 0
2501.13Slukem#
2511.22Slukem#	bfd			${MKBFD} != no
2521.22Slukem#	catpages		${MKCATPAGES} != no
2531.71Smrg#	compat			${MKCOMPAT} != no
2541.22Slukem#	crypto			${MKCRYPTO} != no
2551.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2561.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2571.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2581.22Slukem#	cvs			${MKCVS} != no
2591.53Slukem#	debug			${MKDEBUG} != no
2601.69Slukem#	debuglib		${MKDEBUGLIB} != no
2611.23Slukem#	doc			${MKDOC} != no
2621.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2631.52Slukem#	gcc			${MKGCC} != no
2641.36Smatt#	gcccmds			${MKGCCCMDS} != no
2651.32Sscw#	gdb			${MKGDB} != no
2661.22Slukem#	hesiod			${MKHESIOD} != no
2671.68Slukem#	html			${MKHTML} != no
2681.67Slukem#	inet6			${MKINET6} != no
2691.23Slukem#	info			${MKINFO} != no
2701.39Speter#	ipfilter		${MKIPFILTER} != no
2711.51Smrg#	iscsi			${MKISCSI} != no
2721.22Slukem#	kerberos		${MKKERBEROS} != no
2731.67Slukem#	ldap			${MKLDAP} != no
2741.22Slukem#	lint			${MKLINT} != no
2751.78Sagc#	lvm			${MKLVM} != no
2761.22Slukem#	man			${MKMAN} != no
2771.67Slukem#	manpages		${MKMANPAGES} != no
2781.22Slukem#	manz			${MKMANZ} != no
2791.23Slukem#	nls			${MKNLS} != no
2801.66Sdyoung#	nvi			${MKNVI} != no
2811.37She#	pam			${MKPAM} != no
2821.39Speter#	pf			${MKPF} != no
2831.67Slukem#	pic			${MKPIC} != no
2841.22Slukem#	postfix			${MKPOSTFIX} != no
2851.22Slukem#	profile			${MKPROFILE} != no
2861.24Slukem#	share			${MKSHARE} != no
2871.22Slukem#	skey			${MKSKEY} != no
2881.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2891.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2901.22Slukem#	yp			${MKYP} != no
2911.22Slukem#
2921.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2931.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2941.52Slukem#
2951.41Slukem#	use_inet6		${USE_INET6} != no
2961.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2971.41Slukem#	use_yp			${USE_YP} != no
2981.41Slukem#
2991.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
3001.22Slukem#				  automatically append ".gz" to the filename
3011.22Slukem#
3021.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3031.22Slukem#				  automatically append ".gz" to the filename
3041.1Sdyoung#
3051.8Slukemlist_set_files()
3061.8Slukem{
3071.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3081.65She		verbose=false
3091.65She	else
3101.65She		verbose=true
3111.65She	fi
3121.1Sdyoung	for setname; do
3131.65She		list=`list_set_lists $setname`
3141.65She		for l in $list; do
3151.65She			echo $l
3161.65She			if $verbose; then
3171.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3181.65She			fi
3191.65She		done
3201.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3211.43Sapb	${AWK} -v obsolete=${obsolete} '
3221.9Slukem		BEGIN {
3231.52Slukem			if (obsolete)
3241.52Slukem				wanted["obsolete"] = 1
3251.52Slukem		
3261.52Slukem			split("'"${MKVARS}"'", needvars)
3271.52Slukem			for (vi in needvars) {
3281.52Slukem				nv = needvars[vi]
3291.52Slukem				kw = tolower(nv)
3301.52Slukem				sub(/^mk/, "", kw)
3311.52Slukem				if (ENVIRON[nv] != "no")
3321.52Slukem					wanted[kw] = 1 
3331.52Slukem			}
3341.52Slukem
3351.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3361.52Slukem				wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3371.52Slukem				wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3381.9Slukem			}
3391.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3401.52Slukem				wanted[".cat"] = 1
3411.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3421.52Slukem				wanted[".man"] = 1
3431.9Slukem		}
3441.9Slukem
3451.9Slukem		/^#/ {
3461.9Slukem			next;
3471.9Slukem		}
3481.9Slukem
3491.9Slukem		NF > 2 && $3 != "-" {
3501.9Slukem			split($3, keywords, ",")
3511.9Slukem			show = 1
3521.52Slukem			haveobs = 0
3531.9Slukem			for (ki in keywords) {
3541.9Slukem				kw = keywords[ki]
3551.22Slukem				if (("manz" in wanted) &&
3561.22Slukem				    (kw == ".cat" || kw == ".man"))
3571.22Slukem					$1 = $1 ".gz"
3581.59Sjmmv				negated = match(kw, "! *")
3591.59Sjmmv				if (negated > 0) {
3601.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3611.59Sjmmv					if (kw in wanted)
3621.59Sjmmv						show = 0
3631.59Sjmmv				} else {
3641.59Sjmmv					if (! (kw in wanted))
3651.59Sjmmv						show = 0
3661.59Sjmmv				}
3671.52Slukem				if (kw == "obsolete")
3681.52Slukem					haveobs = 1
3691.9Slukem			}
3701.52Slukem			if (obsolete && ! haveobs)
3711.52Slukem				next
3721.9Slukem			if (show)
3731.9Slukem				print
3741.9Slukem			next
3751.9Slukem		}
3761.9Slukem
3771.9Slukem		{
3781.9Slukem			if (! obsolete)
3791.9Slukem				print
3801.9Slukem		}'
3811.9Slukem
3821.1Sdyoung}
3831.1Sdyoung
3841.1Sdyoung#
3851.1Sdyoung# list_set_lists setname
3861.1Sdyoung# 
3871.1Sdyoung# Print to stdout a list of files, one filename per line, which
3881.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3891.1Sdyoung#
3901.1Sdyoung# 	.../lists/base/mi
3911.1Sdyoung# 	.../lists/base/rescue.mi
3921.1Sdyoung# 	.../lists/base/md.i386
3931.9Slukem#		[...]
3941.1Sdyoung#
3951.9Slukem# For a given setname $set, the following files may be selected from
3961.9Slukem# .../list/$set:
3971.9Slukem#	mi
3981.11Slukem#	ad.${MACHINE_ARCH}
3991.11Slukem# (or)	ad.${MACHINE_CPU}
4001.11Slukem#	ad.${MACHINE_CPU}.shl
4011.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4021.11Slukem# (or)	md.${MACHINE}
4031.9Slukem#	stl.mi
4041.9Slukem#	stl.stlib
4051.9Slukem#	shl.mi
4061.9Slukem#	shl.shlib
4071.77Stsutsui#	module.mi			if ${module} != no
4081.77Stsutsui#	module.${MACHINE}		if ${module} != no
4091.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4101.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4111.9Slukem#	rescue.shl
4121.11Slukem#	rescue.${MACHINE}
4131.11Slukem#	rescue.ad.${MACHINE_ARCH}
4141.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4151.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4161.1Sdyoung#
4171.9Slukem# Environment:
4181.1Sdyoung# 	shlib
4191.1Sdyoung# 	stlib
4201.1Sdyoung#
4211.8Slukemlist_set_lists()
4221.8Slukem{
4231.1Sdyoung	setname=$1
4241.1Sdyoung
4251.9Slukem	setdir=$setsdir/lists/$setname
4261.9Slukem	echo $setdir/mi
4271.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4281.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4291.1Sdyoung		# since the arch-specific one will be more specific than
4301.1Sdyoung		# the cpu-specific one.
4311.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4321.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4331.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4341.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4351.1Sdyoung		fi
4361.1Sdyoung		if [ "$shlib" != "no" -a \
4371.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4381.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4391.1Sdyoung		fi
4401.1Sdyoung	fi
4411.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4421.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4431.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4441.11Slukem		echo $setdir/md.${MACHINE}
4451.1Sdyoung	fi
4461.9Slukem	if [ -f $setdir/stl.mi ]; then
4471.9Slukem		echo $setdir/stl.mi
4481.1Sdyoung	fi
4491.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4501.9Slukem		echo $setdir/stl.${stlib}
4511.1Sdyoung	fi
4521.1Sdyoung	if [ "$shlib" != "no" ]; then
4531.9Slukem		if [ -f $setdir/shl.mi ]; then
4541.9Slukem			echo $setdir/shl.mi
4551.7Sdyoung		fi
4561.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4571.9Slukem			echo $setdir/shl.${shlib}
4581.7Sdyoung		fi
4591.1Sdyoung	fi
4601.76Stsutsui	if [ "$module" != "no" ]; then
4611.76Stsutsui		if [ -f $setdir/module.mi ]; then
4621.76Stsutsui			echo $setdir/module.mi
4631.1Sdyoung		fi
4641.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4651.77Stsutsui			echo $setdir/module.${MACHINE}
4661.77Stsutsui		fi
4671.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4681.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4691.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4701.77Stsutsui			# specific one will be more specific than the
4711.77Stsutsui			# cpu-specific one.
4721.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4731.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4741.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4751.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4761.77Stsutsui			fi
4771.77Stsutsui		fi
4781.1Sdyoung	fi
4791.1Sdyoung
4801.9Slukem	if [ -f $setdir/rescue.mi ]; then
4811.9Slukem		echo $setdir/rescue.mi
4821.1Sdyoung	fi
4831.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
4841.11Slukem		echo $setdir/rescue.${MACHINE}
4851.1Sdyoung	fi
4861.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4871.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
4881.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
4891.1Sdyoung		# specific one will be more specific than the
4901.1Sdyoung		# cpu-specific one.
4911.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
4921.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
4931.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
4941.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
4951.1Sdyoung		fi
4961.10Sjmc		if [ "$shlib" != "no" -a \
4971.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
4981.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
4991.10Sjmc		fi
5001.1Sdyoung	fi
5011.5Sdyoung}
5021.5Sdyoung
5031.9Slukem# arch_to_cpu mach
5041.9Slukem#
5051.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5061.9Slukem# as determined by <bsd.own.mk>.
5071.9Slukem#
5081.8Slukemarch_to_cpu()
5091.8Slukem{
5101.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5111.5Sdyoung.include <bsd.own.mk>
5121.5Sdyoungall:
5131.5Sdyoung	@echo \${MACHINE_CPU}
5141.12SlukemEOMAKE
5151.1Sdyoung}
5161.46Sapb
5171.46Sapb# arch_to_endian mach
5181.46Sapb#
5191.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5201.46Sapb# as determined by <bsd.endian.mk>.
5211.46Sapb#
5221.46Sapbarch_to_endian()
5231.46Sapb{
5241.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5251.46Sapb.include <bsd.endian.mk>
5261.46Sapball:
5271.46Sapb	@echo \${TARGET_ENDIANNESS}
5281.46SapbEOMAKE
5291.46Sapb}
530