sets.subr revision 1.88
11.88Stsarna#	$NetBSD: sets.subr,v 1.88 2009/09/29 23:56:26 tsarna 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.41Slukem	USE_INET6	\
711.41Slukem	USE_KERBEROS	\
721.63Slukem	USE_LDAP	\
731.41Slukem	USE_YP		\
741.64She	NETBSDSRCDIR	\
751.65She	MAKEVERBOSE	\
761.22Slukem"
771.42Sapb#
781.42Sapb# The following variables refer to tools that are used when building sets:
791.42Sapb#
801.43Sapb: ${AWK:=awk}
811.42Sapb: ${CKSUM:=cksum}
821.43Sapb: ${COMM:=comm}
831.44Sapb: ${DATE:=date}
841.43Sapb: ${DB:=db}
851.43Sapb: ${EGREP:=egrep}
861.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
871.44Sapb: ${FGREP:=fgrep}
881.43Sapb: ${FIND:=find}
891.44Sapb: ${GREP:=grep}
901.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
911.44Sapb: ${HOSTNAME:=hostname}
921.42Sapb: ${HOST_SH:=sh}
931.43Sapb: ${IDENT:=ident}
941.43Sapb: ${JOIN:=join}
951.43Sapb: ${LS:=ls}
961.43Sapb: ${MAKE:=make}
971.42Sapb: ${MKTEMP:=mktemp}
981.43Sapb: ${MTREE:=mtree}
991.43Sapb: ${PASTE:=paste}
1001.42Sapb: ${PAX:=pax}
1011.43Sapb: ${PKG_CREATE:=pkg_create}
1021.43Sapb: ${PRINTF:=printf}
1031.43Sapb: ${SED:=sed}
1041.43Sapb: ${SORT:=sort}
1051.44Sapb: ${STAT:=stat}
1061.44Sapb: ${TSORT:=tsort}
1071.43Sapb: ${UNAME:=uname}
1081.43Sapb: ${WC:=wc}
1091.43Sapb
1101.45Sapb#
1111.45Sapb# If printf is a shell builtin command, then we can
1121.45Sapb# implement cheaper versions of basename and dirname
1131.45Sapb# that do not involve any fork/exec overhead.
1141.45Sapb# If printf is not builtin, approximate it using echo,
1151.45Sapb# and hope there are no weird file names that cause
1161.45Sapb# some versions of echo to do the wrong thing.
1171.45Sapb# (Converting to this version of dirname speeded up the
1181.45Sapb# syspkgdeps script by an order of magnitude, from 68
1191.45Sapb# seconds to 6.3 seconds on one particular host.)
1201.45Sapb#
1211.45Sapb# Note that naive approximations for dirname
1221.45Sapb# using ${foo%/*} do not do the right thing in cases
1231.45Sapb# where the result should be "/" or ".".
1241.45Sapb#
1251.45Sapbcase "$(type printf)" in
1261.45Sapb*builtin*)
1271.45Sapb	basename ()
1281.45Sapb	{
1291.45Sapb		local bn
1301.45Sapb		bn="${1##*/}"
1311.45Sapb		bn="${bn%$2}"
1321.45Sapb		printf "%s\n" "$bn"
1331.45Sapb	}
1341.45Sapb	dirname ()
1351.45Sapb	{
1361.45Sapb		local dn
1371.45Sapb		case "$1" in
1381.45Sapb		?*/*)	dn="${1%/*}" ;;
1391.45Sapb		/*)	dn=/ ;;
1401.45Sapb		*)	dn=. ;;
1411.45Sapb		esac
1421.45Sapb		printf "%s\n" "$dn"
1431.45Sapb	}
1441.45Sapb	;;
1451.45Sapb*)
1461.45Sapb	basename ()
1471.45Sapb	{
1481.45Sapb		local bn
1491.45Sapb		bn="${1##*/}"
1501.45Sapb		bn="${bn%$2}"
1511.45Sapb		echo "$bn"
1521.45Sapb	}
1531.45Sapb	dirname ()
1541.45Sapb	{
1551.45Sapb		local dn
1561.45Sapb		case "$1" in
1571.45Sapb		?*/*)	dn="${1%/*}" ;;
1581.45Sapb		/*)	dn=/ ;;
1591.45Sapb		*)	dn=. ;;
1601.45Sapb		esac
1611.45Sapb		echo "$dn"
1621.45Sapb	}
1631.45Sapb	;;
1641.45Sapbesac
1651.45Sapb
1661.9SlukemoIFS=$IFS
1671.9SlukemIFS="
1681.9Slukem"
1691.9Slukemfor x in $(
1701.43Sapb${MAKE} -B -f- all <<EOMAKE
1711.9Slukem.include <bsd.own.mk>
1721.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1731.33SjmcMKMANPAGES=no
1741.33Sjmc.else
1751.33SjmcMKMANPAGES=yes
1761.33Sjmc.endif
1771.72Smrg.if \${MKX11} != "no"
1781.72Smrg. if \${X11FLAVOUR} == "Xorg"
1791.72SmrgMKXORG:=yes
1801.72SmrgMKX11:=no
1811.72Smrg. else
1821.72SmrgMKXORG:=no
1831.72Smrg. endif
1841.72Smrg.endif
1851.9Slukemall:
1861.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1871.87Sskrll		HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1881.12Slukem		${MKVARS}
1891.12Slukem	@echo "export \$i=\${\$i}"
1901.11Slukem.endfor
1911.9Slukem
1921.12SlukemEOMAKE
1931.9Slukem); do
1941.11Slukem#	echo 1>&2 "DEBUG: read $x"
1951.9Slukem	eval $x
1961.9Slukemdone
1971.9SlukemIFS=$oIFS
1981.9Slukem
1991.34Serhsetsdir=${0%/*}
2001.9Slukemobsolete=0
2011.76Stsutsuimodule=yes
2021.11Slukemif [ "${MACHINE}" = "evbppc" ]; then
2031.76Stsutsui	module=no			# Turn off MODULEs for some ports.
2041.9Slukemfi
2051.31Sjmc# Determine lib type. Do this first so stlib also gets set.
2061.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
2071.9Slukem	shlib=elf
2081.9Slukemelse
2091.9Slukem	shlib=aout
2101.9Slukemfi
2111.9Slukemstlib=$shlib
2121.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
2131.31Sjmcif [ "${MKPIC}" = "no" ]; then
2141.31Sjmc	shlib=no
2151.31Sjmcfi
2161.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
2171.9Slukem	shlib=no			# Turn off shlibs for some ports.
2181.9Slukemfi
2191.86Sjnemethif [ "$module" != "no" ]; then
2201.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
2211.86Sjnemethelse
2221.86Sjnemeth	nlists="base comp etc games man misc tests text"
2231.86Sjnemethfi
2241.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
2251.9Slukem
2261.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2271.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2281.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2291.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2301.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2311.60Sad
2321.9Slukem#
2331.9Slukem# list_set_files setfile [...]
2341.1Sdyoung# 
2351.9Slukem# Produce a packing list for setfile(s).
2361.9Slukem# In each file, a record consists of a path and a System Package name,
2371.9Slukem# separated by whitespace. E.g.,
2381.9Slukem#
2391.88Stsarna# 	# $NetBSD: sets.subr,v 1.88 2009/09/29 23:56:26 tsarna Exp $
2401.9Slukem# 	.			base-sys-root	[keyword[,...]]
2411.9Slukem# 	./altroot		base-sys-root
2421.9Slukem# 	./bin			base-sys-root
2431.9Slukem# 	./bin/[			base-util-root
2441.9Slukem# 	./bin/cat		base-util-root
2451.9Slukem#		[...]
2461.9Slukem#
2471.9Slukem# A # in the first column marks a comment.
2481.9Slukem#
2491.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2501.52Slukem# be printed.  All other keywords must be present.
2511.9Slukem#
2521.9Slukem# The third field is an optional comma separated list of keywords to
2531.9Slukem# control if a record is printed; every keyword listed must be enabled
2541.9Slukem# for the record to be printed.  The following keywords are available:
2551.9Slukem#	dummy			dummy entry (ignored)
2561.13Slukem#	obsolete		file is obsolete, and only printed if 
2571.13Slukem#				${obsolete} != 0
2581.13Slukem#
2591.87Sskrll#	bfd			obsolete, use binutils.
2601.87Sskrll#	binutils		${MKBINUTILS} != no
2611.22Slukem#	catpages		${MKCATPAGES} != no
2621.71Smrg#	compat			${MKCOMPAT} != no
2631.22Slukem#	crypto			${MKCRYPTO} != no
2641.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2651.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2661.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2671.22Slukem#	cvs			${MKCVS} != no
2681.53Slukem#	debug			${MKDEBUG} != no
2691.69Slukem#	debuglib		${MKDEBUGLIB} != no
2701.23Slukem#	doc			${MKDOC} != no
2711.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2721.52Slukem#	gcc			${MKGCC} != no
2731.36Smatt#	gcccmds			${MKGCCCMDS} != no
2741.32Sscw#	gdb			${MKGDB} != no
2751.22Slukem#	hesiod			${MKHESIOD} != no
2761.68Slukem#	html			${MKHTML} != no
2771.67Slukem#	inet6			${MKINET6} != no
2781.23Slukem#	info			${MKINFO} != no
2791.39Speter#	ipfilter		${MKIPFILTER} != no
2801.51Smrg#	iscsi			${MKISCSI} != no
2811.22Slukem#	kerberos		${MKKERBEROS} != no
2821.85Sdyoung#	kmod			${MKKMOD} != no
2831.67Slukem#	ldap			${MKLDAP} != no
2841.22Slukem#	lint			${MKLINT} != no
2851.78Sagc#	lvm			${MKLVM} != no
2861.22Slukem#	man			${MKMAN} != no
2871.67Slukem#	manpages		${MKMANPAGES} != no
2881.22Slukem#	manz			${MKMANZ} != no
2891.88Stsarna#	mdns			${MKMDNS} != no
2901.23Slukem#	nls			${MKNLS} != no
2911.66Sdyoung#	nvi			${MKNVI} != no
2921.37She#	pam			${MKPAM} != no
2931.39Speter#	pf			${MKPF} != no
2941.67Slukem#	pic			${MKPIC} != no
2951.22Slukem#	postfix			${MKPOSTFIX} != no
2961.22Slukem#	profile			${MKPROFILE} != no
2971.24Slukem#	share			${MKSHARE} != no
2981.22Slukem#	skey			${MKSKEY} != no
2991.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
3001.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
3011.22Slukem#	yp			${MKYP} != no
3021.22Slukem#
3031.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
3041.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
3051.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
3061.52Slukem#
3071.41Slukem#	use_inet6		${USE_INET6} != no
3081.41Slukem#	use_kerberos		${USE_KERBEROS} != no
3091.41Slukem#	use_yp			${USE_YP} != no
3101.41Slukem#
3111.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
3121.22Slukem#				  automatically append ".gz" to the filename
3131.22Slukem#
3141.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3151.22Slukem#				  automatically append ".gz" to the filename
3161.1Sdyoung#
3171.8Slukemlist_set_files()
3181.8Slukem{
3191.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3201.65She		verbose=false
3211.65She	else
3221.65She		verbose=true
3231.65She	fi
3241.1Sdyoung	for setname; do
3251.65She		list=`list_set_lists $setname`
3261.65She		for l in $list; do
3271.65She			echo $l
3281.65She			if $verbose; then
3291.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3301.65She			fi
3311.65She		done
3321.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3331.43Sapb	${AWK} -v obsolete=${obsolete} '
3341.9Slukem		BEGIN {
3351.52Slukem			if (obsolete)
3361.52Slukem				wanted["obsolete"] = 1
3371.52Slukem		
3381.52Slukem			split("'"${MKVARS}"'", needvars)
3391.52Slukem			for (vi in needvars) {
3401.52Slukem				nv = needvars[vi]
3411.52Slukem				kw = tolower(nv)
3421.52Slukem				sub(/^mk/, "", kw)
3431.52Slukem				if (ENVIRON[nv] != "no")
3441.52Slukem					wanted[kw] = 1 
3451.52Slukem			}
3461.52Slukem
3471.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3481.87Sskrll				wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
3491.52Slukem				wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3501.52Slukem				wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3511.9Slukem			}
3521.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3531.52Slukem				wanted[".cat"] = 1
3541.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3551.52Slukem				wanted[".man"] = 1
3561.9Slukem		}
3571.9Slukem
3581.9Slukem		/^#/ {
3591.9Slukem			next;
3601.9Slukem		}
3611.9Slukem
3621.9Slukem		NF > 2 && $3 != "-" {
3631.9Slukem			split($3, keywords, ",")
3641.9Slukem			show = 1
3651.52Slukem			haveobs = 0
3661.9Slukem			for (ki in keywords) {
3671.9Slukem				kw = keywords[ki]
3681.22Slukem				if (("manz" in wanted) &&
3691.22Slukem				    (kw == ".cat" || kw == ".man"))
3701.22Slukem					$1 = $1 ".gz"
3711.59Sjmmv				negated = match(kw, "! *")
3721.59Sjmmv				if (negated > 0) {
3731.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3741.59Sjmmv					if (kw in wanted)
3751.59Sjmmv						show = 0
3761.59Sjmmv				} else {
3771.59Sjmmv					if (! (kw in wanted))
3781.59Sjmmv						show = 0
3791.59Sjmmv				}
3801.52Slukem				if (kw == "obsolete")
3811.52Slukem					haveobs = 1
3821.9Slukem			}
3831.52Slukem			if (obsolete && ! haveobs)
3841.52Slukem				next
3851.9Slukem			if (show)
3861.9Slukem				print
3871.9Slukem			next
3881.9Slukem		}
3891.9Slukem
3901.9Slukem		{
3911.9Slukem			if (! obsolete)
3921.9Slukem				print
3931.9Slukem		}'
3941.9Slukem
3951.1Sdyoung}
3961.1Sdyoung
3971.1Sdyoung#
3981.1Sdyoung# list_set_lists setname
3991.1Sdyoung# 
4001.1Sdyoung# Print to stdout a list of files, one filename per line, which
4011.1Sdyoung# concatenate to create the packing list for setname. E.g.,
4021.1Sdyoung#
4031.1Sdyoung# 	.../lists/base/mi
4041.1Sdyoung# 	.../lists/base/rescue.mi
4051.1Sdyoung# 	.../lists/base/md.i386
4061.9Slukem#		[...]
4071.1Sdyoung#
4081.9Slukem# For a given setname $set, the following files may be selected from
4091.9Slukem# .../list/$set:
4101.9Slukem#	mi
4111.11Slukem#	ad.${MACHINE_ARCH}
4121.11Slukem# (or)	ad.${MACHINE_CPU}
4131.11Slukem#	ad.${MACHINE_CPU}.shl
4141.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4151.11Slukem# (or)	md.${MACHINE}
4161.9Slukem#	stl.mi
4171.9Slukem#	stl.stlib
4181.9Slukem#	shl.mi
4191.9Slukem#	shl.shlib
4201.77Stsutsui#	module.mi			if ${module} != no
4211.77Stsutsui#	module.${MACHINE}		if ${module} != no
4221.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4231.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4241.9Slukem#	rescue.shl
4251.11Slukem#	rescue.${MACHINE}
4261.11Slukem#	rescue.ad.${MACHINE_ARCH}
4271.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4281.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4291.1Sdyoung#
4301.9Slukem# Environment:
4311.1Sdyoung# 	shlib
4321.1Sdyoung# 	stlib
4331.1Sdyoung#
4341.8Slukemlist_set_lists()
4351.8Slukem{
4361.1Sdyoung	setname=$1
4371.1Sdyoung
4381.9Slukem	setdir=$setsdir/lists/$setname
4391.9Slukem	echo $setdir/mi
4401.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4411.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4421.1Sdyoung		# since the arch-specific one will be more specific than
4431.1Sdyoung		# the cpu-specific one.
4441.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4451.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4461.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4471.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4481.1Sdyoung		fi
4491.1Sdyoung		if [ "$shlib" != "no" -a \
4501.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4511.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4521.1Sdyoung		fi
4531.1Sdyoung	fi
4541.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4551.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4561.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4571.11Slukem		echo $setdir/md.${MACHINE}
4581.1Sdyoung	fi
4591.9Slukem	if [ -f $setdir/stl.mi ]; then
4601.9Slukem		echo $setdir/stl.mi
4611.1Sdyoung	fi
4621.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4631.9Slukem		echo $setdir/stl.${stlib}
4641.1Sdyoung	fi
4651.1Sdyoung	if [ "$shlib" != "no" ]; then
4661.9Slukem		if [ -f $setdir/shl.mi ]; then
4671.9Slukem			echo $setdir/shl.mi
4681.7Sdyoung		fi
4691.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4701.9Slukem			echo $setdir/shl.${shlib}
4711.7Sdyoung		fi
4721.1Sdyoung	fi
4731.76Stsutsui	if [ "$module" != "no" ]; then
4741.76Stsutsui		if [ -f $setdir/module.mi ]; then
4751.76Stsutsui			echo $setdir/module.mi
4761.1Sdyoung		fi
4771.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4781.77Stsutsui			echo $setdir/module.${MACHINE}
4791.77Stsutsui		fi
4801.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4811.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4821.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4831.77Stsutsui			# specific one will be more specific than the
4841.77Stsutsui			# cpu-specific one.
4851.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4861.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4871.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4881.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4891.77Stsutsui			fi
4901.77Stsutsui		fi
4911.1Sdyoung	fi
4921.1Sdyoung
4931.9Slukem	if [ -f $setdir/rescue.mi ]; then
4941.9Slukem		echo $setdir/rescue.mi
4951.1Sdyoung	fi
4961.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
4971.11Slukem		echo $setdir/rescue.${MACHINE}
4981.1Sdyoung	fi
4991.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5001.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
5011.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
5021.1Sdyoung		# specific one will be more specific than the
5031.1Sdyoung		# cpu-specific one.
5041.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
5051.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
5061.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
5071.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
5081.1Sdyoung		fi
5091.10Sjmc		if [ "$shlib" != "no" -a \
5101.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
5111.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
5121.10Sjmc		fi
5131.1Sdyoung	fi
5141.5Sdyoung}
5151.5Sdyoung
5161.9Slukem# arch_to_cpu mach
5171.9Slukem#
5181.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5191.9Slukem# as determined by <bsd.own.mk>.
5201.9Slukem#
5211.8Slukemarch_to_cpu()
5221.8Slukem{
5231.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5241.5Sdyoung.include <bsd.own.mk>
5251.5Sdyoungall:
5261.5Sdyoung	@echo \${MACHINE_CPU}
5271.12SlukemEOMAKE
5281.1Sdyoung}
5291.46Sapb
5301.46Sapb# arch_to_endian mach
5311.46Sapb#
5321.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5331.46Sapb# as determined by <bsd.endian.mk>.
5341.46Sapb#
5351.46Sapbarch_to_endian()
5361.46Sapb{
5371.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5381.46Sapb.include <bsd.endian.mk>
5391.46Sapball:
5401.46Sapb	@echo \${TARGET_ENDIANNESS}
5411.46SapbEOMAKE
5421.46Sapb}
543