sets.subr revision 1.89
11.89Shaad#	$NetBSD: sets.subr,v 1.89 2009/10/07 22:22:18 haad 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.87Sskrll#	HAVE_BINUTILS
191.48Smrg#	HAVE_GCC
201.52Slukem#	HAVE_GDB
211.11Slukem#	TOOLCHAIN_MISSING
221.11Slukem#	OBJECT_FMT
231.22Slukem# as well as:
241.22Slukem#
251.22SlukemMKVARS="\
261.22Slukem	MKBFD		\
271.87Sskrll	MKBINUTILS	\
281.22Slukem	MKCATPAGES	\
291.71Smrg	MKCOMPAT	\
301.22Slukem	MKCRYPTO	\
311.22Slukem	MKCRYPTO_IDEA	\
321.22Slukem	MKCRYPTO_MDC2	\
331.22Slukem	MKCRYPTO_RC5	\
341.22Slukem	MKCVS		\
351.67Slukem	MKDEBUG		\
361.69Slukem	MKDEBUGLIB	\
371.67Slukem	MKDOC		\
381.67Slukem	MKDYNAMICROOT	\
391.52Slukem	MKGCC		\
401.36Smatt	MKGCCCMDS	\
411.32Sscw	MKGDB		\
421.22Slukem	MKHESIOD	\
431.68Slukem	MKHTML		\
441.67Slukem	MKINET6		\
451.23Slukem	MKINFO		\
461.39Speter	MKIPFILTER	\
471.51Smrg	MKISCSI		\
481.22Slukem	MKKERBEROS	\
491.85Sdyoung	MKKMOD		\
501.67Slukem	MKLDAP		\
511.22Slukem	MKLINT		\
521.78Sagc	MKLVM		\
531.22Slukem	MKMAN		\
541.33Sjmc	MKMANPAGES	\
551.22Slukem	MKMANZ		\
561.88Stsarna	MKMDNS		\
571.23Slukem	MKNLS		\
581.66Sdyoung	MKNVI		\
591.37She	MKPAM		\
601.39Speter	MKPF		\
611.30Smatt	MKPIC		\
621.22Slukem	MKPOSTFIX	\
631.22Slukem	MKPROFILE	\
641.24Slukem	MKSHARE		\
651.22Slukem	MKSKEY		\
661.40Stron	MKX11		\
671.84Smrg	MKX11FONTS	\
681.68Slukem	MKXORG		\
691.22Slukem	MKYP		\
701.89Shaad	MKZFS		\
711.41Slukem	USE_INET6	\
721.41Slukem	USE_KERBEROS	\
731.63Slukem	USE_LDAP	\
741.41Slukem	USE_YP		\
751.64She	NETBSDSRCDIR	\
761.65She	MAKEVERBOSE	\
771.22Slukem"
781.42Sapb#
791.42Sapb# The following variables refer to tools that are used when building sets:
801.42Sapb#
811.43Sapb: ${AWK:=awk}
821.42Sapb: ${CKSUM:=cksum}
831.43Sapb: ${COMM:=comm}
841.44Sapb: ${DATE:=date}
851.43Sapb: ${DB:=db}
861.43Sapb: ${EGREP:=egrep}
871.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
881.44Sapb: ${FGREP:=fgrep}
891.43Sapb: ${FIND:=find}
901.44Sapb: ${GREP:=grep}
911.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
921.44Sapb: ${HOSTNAME:=hostname}
931.42Sapb: ${HOST_SH:=sh}
941.43Sapb: ${IDENT:=ident}
951.43Sapb: ${JOIN:=join}
961.43Sapb: ${LS:=ls}
971.43Sapb: ${MAKE:=make}
981.42Sapb: ${MKTEMP:=mktemp}
991.43Sapb: ${MTREE:=mtree}
1001.43Sapb: ${PASTE:=paste}
1011.42Sapb: ${PAX:=pax}
1021.43Sapb: ${PKG_CREATE:=pkg_create}
1031.43Sapb: ${PRINTF:=printf}
1041.43Sapb: ${SED:=sed}
1051.43Sapb: ${SORT:=sort}
1061.44Sapb: ${STAT:=stat}
1071.44Sapb: ${TSORT:=tsort}
1081.43Sapb: ${UNAME:=uname}
1091.43Sapb: ${WC:=wc}
1101.43Sapb
1111.45Sapb#
1121.45Sapb# If printf is a shell builtin command, then we can
1131.45Sapb# implement cheaper versions of basename and dirname
1141.45Sapb# that do not involve any fork/exec overhead.
1151.45Sapb# If printf is not builtin, approximate it using echo,
1161.45Sapb# and hope there are no weird file names that cause
1171.45Sapb# some versions of echo to do the wrong thing.
1181.45Sapb# (Converting to this version of dirname speeded up the
1191.45Sapb# syspkgdeps script by an order of magnitude, from 68
1201.45Sapb# seconds to 6.3 seconds on one particular host.)
1211.45Sapb#
1221.45Sapb# Note that naive approximations for dirname
1231.45Sapb# using ${foo%/*} do not do the right thing in cases
1241.45Sapb# where the result should be "/" or ".".
1251.45Sapb#
1261.45Sapbcase "$(type printf)" in
1271.45Sapb*builtin*)
1281.45Sapb	basename ()
1291.45Sapb	{
1301.45Sapb		local bn
1311.45Sapb		bn="${1##*/}"
1321.45Sapb		bn="${bn%$2}"
1331.45Sapb		printf "%s\n" "$bn"
1341.45Sapb	}
1351.45Sapb	dirname ()
1361.45Sapb	{
1371.45Sapb		local dn
1381.45Sapb		case "$1" in
1391.45Sapb		?*/*)	dn="${1%/*}" ;;
1401.45Sapb		/*)	dn=/ ;;
1411.45Sapb		*)	dn=. ;;
1421.45Sapb		esac
1431.45Sapb		printf "%s\n" "$dn"
1441.45Sapb	}
1451.45Sapb	;;
1461.45Sapb*)
1471.45Sapb	basename ()
1481.45Sapb	{
1491.45Sapb		local bn
1501.45Sapb		bn="${1##*/}"
1511.45Sapb		bn="${bn%$2}"
1521.45Sapb		echo "$bn"
1531.45Sapb	}
1541.45Sapb	dirname ()
1551.45Sapb	{
1561.45Sapb		local dn
1571.45Sapb		case "$1" in
1581.45Sapb		?*/*)	dn="${1%/*}" ;;
1591.45Sapb		/*)	dn=/ ;;
1601.45Sapb		*)	dn=. ;;
1611.45Sapb		esac
1621.45Sapb		echo "$dn"
1631.45Sapb	}
1641.45Sapb	;;
1651.45Sapbesac
1661.45Sapb
1671.9SlukemoIFS=$IFS
1681.9SlukemIFS="
1691.9Slukem"
1701.9Slukemfor x in $(
1711.43Sapb${MAKE} -B -f- all <<EOMAKE
1721.9Slukem.include <bsd.own.mk>
1731.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1741.33SjmcMKMANPAGES=no
1751.33Sjmc.else
1761.33SjmcMKMANPAGES=yes
1771.33Sjmc.endif
1781.72Smrg.if \${MKX11} != "no"
1791.72Smrg. if \${X11FLAVOUR} == "Xorg"
1801.72SmrgMKXORG:=yes
1811.72SmrgMKX11:=no
1821.72Smrg. else
1831.72SmrgMKXORG:=no
1841.72Smrg. endif
1851.72Smrg.endif
1861.9Slukemall:
1871.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1881.87Sskrll		HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1891.12Slukem		${MKVARS}
1901.12Slukem	@echo "export \$i=\${\$i}"
1911.11Slukem.endfor
1921.9Slukem
1931.12SlukemEOMAKE
1941.9Slukem); do
1951.11Slukem#	echo 1>&2 "DEBUG: read $x"
1961.9Slukem	eval $x
1971.9Slukemdone
1981.9SlukemIFS=$oIFS
1991.9Slukem
2001.34Serhsetsdir=${0%/*}
2011.9Slukemobsolete=0
2021.76Stsutsuimodule=yes
2031.11Slukemif [ "${MACHINE}" = "evbppc" ]; then
2041.76Stsutsui	module=no			# Turn off MODULEs for some ports.
2051.9Slukemfi
2061.31Sjmc# Determine lib type. Do this first so stlib also gets set.
2071.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
2081.9Slukem	shlib=elf
2091.9Slukemelse
2101.9Slukem	shlib=aout
2111.9Slukemfi
2121.9Slukemstlib=$shlib
2131.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
2141.31Sjmcif [ "${MKPIC}" = "no" ]; then
2151.31Sjmc	shlib=no
2161.31Sjmcfi
2171.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
2181.9Slukem	shlib=no			# Turn off shlibs for some ports.
2191.9Slukemfi
2201.86Sjnemethif [ "$module" != "no" ]; then
2211.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
2221.86Sjnemethelse
2231.86Sjnemeth	nlists="base comp etc games man misc tests text"
2241.86Sjnemethfi
2251.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
2261.9Slukem
2271.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2281.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2291.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2301.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2311.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2321.60Sad
2331.9Slukem#
2341.9Slukem# list_set_files setfile [...]
2351.1Sdyoung# 
2361.9Slukem# Produce a packing list for setfile(s).
2371.9Slukem# In each file, a record consists of a path and a System Package name,
2381.9Slukem# separated by whitespace. E.g.,
2391.9Slukem#
2401.89Shaad# 	# $NetBSD: sets.subr,v 1.89 2009/10/07 22:22:18 haad Exp $
2411.9Slukem# 	.			base-sys-root	[keyword[,...]]
2421.9Slukem# 	./altroot		base-sys-root
2431.9Slukem# 	./bin			base-sys-root
2441.9Slukem# 	./bin/[			base-util-root
2451.9Slukem# 	./bin/cat		base-util-root
2461.9Slukem#		[...]
2471.9Slukem#
2481.9Slukem# A # in the first column marks a comment.
2491.9Slukem#
2501.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2511.52Slukem# be printed.  All other keywords must be present.
2521.9Slukem#
2531.9Slukem# The third field is an optional comma separated list of keywords to
2541.9Slukem# control if a record is printed; every keyword listed must be enabled
2551.9Slukem# for the record to be printed.  The following keywords are available:
2561.9Slukem#	dummy			dummy entry (ignored)
2571.13Slukem#	obsolete		file is obsolete, and only printed if 
2581.13Slukem#				${obsolete} != 0
2591.13Slukem#
2601.87Sskrll#	bfd			obsolete, use binutils.
2611.87Sskrll#	binutils		${MKBINUTILS} != no
2621.22Slukem#	catpages		${MKCATPAGES} != no
2631.71Smrg#	compat			${MKCOMPAT} != no
2641.22Slukem#	crypto			${MKCRYPTO} != no
2651.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2661.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2671.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2681.22Slukem#	cvs			${MKCVS} != no
2691.53Slukem#	debug			${MKDEBUG} != no
2701.69Slukem#	debuglib		${MKDEBUGLIB} != no
2711.23Slukem#	doc			${MKDOC} != no
2721.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2731.52Slukem#	gcc			${MKGCC} != no
2741.36Smatt#	gcccmds			${MKGCCCMDS} != no
2751.32Sscw#	gdb			${MKGDB} != no
2761.22Slukem#	hesiod			${MKHESIOD} != no
2771.68Slukem#	html			${MKHTML} != no
2781.67Slukem#	inet6			${MKINET6} != no
2791.23Slukem#	info			${MKINFO} != no
2801.39Speter#	ipfilter		${MKIPFILTER} != no
2811.51Smrg#	iscsi			${MKISCSI} != no
2821.22Slukem#	kerberos		${MKKERBEROS} != no
2831.85Sdyoung#	kmod			${MKKMOD} != no
2841.67Slukem#	ldap			${MKLDAP} != no
2851.22Slukem#	lint			${MKLINT} != no
2861.78Sagc#	lvm			${MKLVM} != no
2871.22Slukem#	man			${MKMAN} != no
2881.67Slukem#	manpages		${MKMANPAGES} != no
2891.22Slukem#	manz			${MKMANZ} != no
2901.88Stsarna#	mdns			${MKMDNS} != no
2911.23Slukem#	nls			${MKNLS} != no
2921.66Sdyoung#	nvi			${MKNVI} != no
2931.37She#	pam			${MKPAM} != no
2941.39Speter#	pf			${MKPF} != no
2951.67Slukem#	pic			${MKPIC} != no
2961.22Slukem#	postfix			${MKPOSTFIX} != no
2971.22Slukem#	profile			${MKPROFILE} != no
2981.24Slukem#	share			${MKSHARE} != no
2991.22Slukem#	skey			${MKSKEY} != no
3001.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
3011.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
3021.22Slukem#	yp			${MKYP} != no
3031.89Shaad#	zfs			${MKZFS} != no
3041.22Slukem#
3051.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
3061.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
3071.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
3081.52Slukem#
3091.41Slukem#	use_inet6		${USE_INET6} != no
3101.41Slukem#	use_kerberos		${USE_KERBEROS} != no
3111.41Slukem#	use_yp			${USE_YP} != no
3121.41Slukem#
3131.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
3141.22Slukem#				  automatically append ".gz" to the filename
3151.22Slukem#
3161.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3171.22Slukem#				  automatically append ".gz" to the filename
3181.1Sdyoung#
3191.8Slukemlist_set_files()
3201.8Slukem{
3211.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3221.65She		verbose=false
3231.65She	else
3241.65She		verbose=true
3251.65She	fi
3261.1Sdyoung	for setname; do
3271.65She		list=`list_set_lists $setname`
3281.65She		for l in $list; do
3291.65She			echo $l
3301.65She			if $verbose; then
3311.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3321.65She			fi
3331.65She		done
3341.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3351.43Sapb	${AWK} -v obsolete=${obsolete} '
3361.9Slukem		BEGIN {
3371.52Slukem			if (obsolete)
3381.52Slukem				wanted["obsolete"] = 1
3391.52Slukem		
3401.52Slukem			split("'"${MKVARS}"'", needvars)
3411.52Slukem			for (vi in needvars) {
3421.52Slukem				nv = needvars[vi]
3431.52Slukem				kw = tolower(nv)
3441.52Slukem				sub(/^mk/, "", kw)
3451.52Slukem				if (ENVIRON[nv] != "no")
3461.52Slukem					wanted[kw] = 1 
3471.52Slukem			}
3481.52Slukem
3491.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3501.87Sskrll				wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
3511.52Slukem				wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3521.52Slukem				wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3531.9Slukem			}
3541.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3551.52Slukem				wanted[".cat"] = 1
3561.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3571.52Slukem				wanted[".man"] = 1
3581.9Slukem		}
3591.9Slukem
3601.9Slukem		/^#/ {
3611.9Slukem			next;
3621.9Slukem		}
3631.9Slukem
3641.9Slukem		NF > 2 && $3 != "-" {
3651.9Slukem			split($3, keywords, ",")
3661.9Slukem			show = 1
3671.52Slukem			haveobs = 0
3681.9Slukem			for (ki in keywords) {
3691.9Slukem				kw = keywords[ki]
3701.22Slukem				if (("manz" in wanted) &&
3711.22Slukem				    (kw == ".cat" || kw == ".man"))
3721.22Slukem					$1 = $1 ".gz"
3731.59Sjmmv				negated = match(kw, "! *")
3741.59Sjmmv				if (negated > 0) {
3751.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3761.59Sjmmv					if (kw in wanted)
3771.59Sjmmv						show = 0
3781.59Sjmmv				} else {
3791.59Sjmmv					if (! (kw in wanted))
3801.59Sjmmv						show = 0
3811.59Sjmmv				}
3821.52Slukem				if (kw == "obsolete")
3831.52Slukem					haveobs = 1
3841.9Slukem			}
3851.52Slukem			if (obsolete && ! haveobs)
3861.52Slukem				next
3871.9Slukem			if (show)
3881.9Slukem				print
3891.9Slukem			next
3901.9Slukem		}
3911.9Slukem
3921.9Slukem		{
3931.9Slukem			if (! obsolete)
3941.9Slukem				print
3951.9Slukem		}'
3961.9Slukem
3971.1Sdyoung}
3981.1Sdyoung
3991.1Sdyoung#
4001.1Sdyoung# list_set_lists setname
4011.1Sdyoung# 
4021.1Sdyoung# Print to stdout a list of files, one filename per line, which
4031.1Sdyoung# concatenate to create the packing list for setname. E.g.,
4041.1Sdyoung#
4051.1Sdyoung# 	.../lists/base/mi
4061.1Sdyoung# 	.../lists/base/rescue.mi
4071.1Sdyoung# 	.../lists/base/md.i386
4081.9Slukem#		[...]
4091.1Sdyoung#
4101.9Slukem# For a given setname $set, the following files may be selected from
4111.9Slukem# .../list/$set:
4121.9Slukem#	mi
4131.11Slukem#	ad.${MACHINE_ARCH}
4141.11Slukem# (or)	ad.${MACHINE_CPU}
4151.11Slukem#	ad.${MACHINE_CPU}.shl
4161.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4171.11Slukem# (or)	md.${MACHINE}
4181.9Slukem#	stl.mi
4191.9Slukem#	stl.stlib
4201.9Slukem#	shl.mi
4211.9Slukem#	shl.shlib
4221.77Stsutsui#	module.mi			if ${module} != no
4231.77Stsutsui#	module.${MACHINE}		if ${module} != no
4241.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4251.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4261.9Slukem#	rescue.shl
4271.11Slukem#	rescue.${MACHINE}
4281.11Slukem#	rescue.ad.${MACHINE_ARCH}
4291.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4301.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4311.1Sdyoung#
4321.9Slukem# Environment:
4331.1Sdyoung# 	shlib
4341.1Sdyoung# 	stlib
4351.1Sdyoung#
4361.8Slukemlist_set_lists()
4371.8Slukem{
4381.1Sdyoung	setname=$1
4391.1Sdyoung
4401.9Slukem	setdir=$setsdir/lists/$setname
4411.9Slukem	echo $setdir/mi
4421.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4431.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4441.1Sdyoung		# since the arch-specific one will be more specific than
4451.1Sdyoung		# the cpu-specific one.
4461.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4471.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4481.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4491.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4501.1Sdyoung		fi
4511.1Sdyoung		if [ "$shlib" != "no" -a \
4521.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4531.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4541.1Sdyoung		fi
4551.1Sdyoung	fi
4561.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4571.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4581.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4591.11Slukem		echo $setdir/md.${MACHINE}
4601.1Sdyoung	fi
4611.9Slukem	if [ -f $setdir/stl.mi ]; then
4621.9Slukem		echo $setdir/stl.mi
4631.1Sdyoung	fi
4641.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4651.9Slukem		echo $setdir/stl.${stlib}
4661.1Sdyoung	fi
4671.1Sdyoung	if [ "$shlib" != "no" ]; then
4681.9Slukem		if [ -f $setdir/shl.mi ]; then
4691.9Slukem			echo $setdir/shl.mi
4701.7Sdyoung		fi
4711.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4721.9Slukem			echo $setdir/shl.${shlib}
4731.7Sdyoung		fi
4741.1Sdyoung	fi
4751.76Stsutsui	if [ "$module" != "no" ]; then
4761.76Stsutsui		if [ -f $setdir/module.mi ]; then
4771.76Stsutsui			echo $setdir/module.mi
4781.1Sdyoung		fi
4791.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4801.77Stsutsui			echo $setdir/module.${MACHINE}
4811.77Stsutsui		fi
4821.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4831.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4841.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4851.77Stsutsui			# specific one will be more specific than the
4861.77Stsutsui			# cpu-specific one.
4871.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4881.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4891.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4901.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4911.77Stsutsui			fi
4921.77Stsutsui		fi
4931.1Sdyoung	fi
4941.1Sdyoung
4951.9Slukem	if [ -f $setdir/rescue.mi ]; then
4961.9Slukem		echo $setdir/rescue.mi
4971.1Sdyoung	fi
4981.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
4991.11Slukem		echo $setdir/rescue.${MACHINE}
5001.1Sdyoung	fi
5011.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5021.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
5031.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
5041.1Sdyoung		# specific one will be more specific than the
5051.1Sdyoung		# cpu-specific one.
5061.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
5071.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
5081.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
5091.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
5101.1Sdyoung		fi
5111.10Sjmc		if [ "$shlib" != "no" -a \
5121.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
5131.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
5141.10Sjmc		fi
5151.1Sdyoung	fi
5161.5Sdyoung}
5171.5Sdyoung
5181.9Slukem# arch_to_cpu mach
5191.9Slukem#
5201.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5211.9Slukem# as determined by <bsd.own.mk>.
5221.9Slukem#
5231.8Slukemarch_to_cpu()
5241.8Slukem{
5251.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5261.5Sdyoung.include <bsd.own.mk>
5271.5Sdyoungall:
5281.5Sdyoung	@echo \${MACHINE_CPU}
5291.12SlukemEOMAKE
5301.1Sdyoung}
5311.46Sapb
5321.46Sapb# arch_to_endian mach
5331.46Sapb#
5341.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5351.46Sapb# as determined by <bsd.endian.mk>.
5361.46Sapb#
5371.46Sapbarch_to_endian()
5381.46Sapb{
5391.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5401.46Sapb.include <bsd.endian.mk>
5411.46Sapball:
5421.46Sapb	@echo \${TARGET_ENDIANNESS}
5431.46SapbEOMAKE
5441.46Sapb}
545