sets.subr revision 1.83
11.83Sapb#	$NetBSD: sets.subr,v 1.83 2009/04/07 20:46:20 apb 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.68Slukem	MKXORG		\
641.22Slukem	MKYP		\
651.41Slukem	USE_INET6	\
661.41Slukem	USE_KERBEROS	\
671.63Slukem	USE_LDAP	\
681.41Slukem	USE_YP		\
691.64She	NETBSDSRCDIR	\
701.65She	MAKEVERBOSE	\
711.22Slukem"
721.42Sapb#
731.42Sapb# The following variables refer to tools that are used when building sets:
741.42Sapb#
751.43Sapb: ${AWK:=awk}
761.42Sapb: ${CKSUM:=cksum}
771.43Sapb: ${COMM:=comm}
781.44Sapb: ${DATE:=date}
791.43Sapb: ${DB:=db}
801.43Sapb: ${EGREP:=egrep}
811.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
821.44Sapb: ${FGREP:=fgrep}
831.43Sapb: ${FIND:=find}
841.44Sapb: ${GREP:=grep}
851.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
861.44Sapb: ${HOSTNAME:=hostname}
871.42Sapb: ${HOST_SH:=sh}
881.43Sapb: ${IDENT:=ident}
891.43Sapb: ${JOIN:=join}
901.43Sapb: ${LS:=ls}
911.43Sapb: ${MAKE:=make}
921.42Sapb: ${MKTEMP:=mktemp}
931.43Sapb: ${MTREE:=mtree}
941.43Sapb: ${PASTE:=paste}
951.42Sapb: ${PAX:=pax}
961.43Sapb: ${PKG_CREATE:=pkg_create}
971.43Sapb: ${PRINTF:=printf}
981.43Sapb: ${SED:=sed}
991.43Sapb: ${SORT:=sort}
1001.44Sapb: ${STAT:=stat}
1011.44Sapb: ${TSORT:=tsort}
1021.43Sapb: ${UNAME:=uname}
1031.43Sapb: ${WC:=wc}
1041.43Sapb
1051.45Sapb#
1061.45Sapb# If printf is a shell builtin command, then we can
1071.45Sapb# implement cheaper versions of basename and dirname
1081.45Sapb# that do not involve any fork/exec overhead.
1091.45Sapb# If printf is not builtin, approximate it using echo,
1101.45Sapb# and hope there are no weird file names that cause
1111.45Sapb# some versions of echo to do the wrong thing.
1121.45Sapb# (Converting to this version of dirname speeded up the
1131.45Sapb# syspkgdeps script by an order of magnitude, from 68
1141.45Sapb# seconds to 6.3 seconds on one particular host.)
1151.45Sapb#
1161.45Sapb# Note that naive approximations for dirname
1171.45Sapb# using ${foo%/*} do not do the right thing in cases
1181.45Sapb# where the result should be "/" or ".".
1191.45Sapb#
1201.45Sapbcase "$(type printf)" in
1211.45Sapb*builtin*)
1221.45Sapb	basename ()
1231.45Sapb	{
1241.45Sapb		local bn
1251.45Sapb		bn="${1##*/}"
1261.45Sapb		bn="${bn%$2}"
1271.45Sapb		printf "%s\n" "$bn"
1281.45Sapb	}
1291.45Sapb	dirname ()
1301.45Sapb	{
1311.45Sapb		local dn
1321.45Sapb		case "$1" in
1331.45Sapb		?*/*)	dn="${1%/*}" ;;
1341.45Sapb		/*)	dn=/ ;;
1351.45Sapb		*)	dn=. ;;
1361.45Sapb		esac
1371.45Sapb		printf "%s\n" "$dn"
1381.45Sapb	}
1391.45Sapb	;;
1401.45Sapb*)
1411.45Sapb	basename ()
1421.45Sapb	{
1431.45Sapb		local bn
1441.45Sapb		bn="${1##*/}"
1451.45Sapb		bn="${bn%$2}"
1461.45Sapb		echo "$bn"
1471.45Sapb	}
1481.45Sapb	dirname ()
1491.45Sapb	{
1501.45Sapb		local dn
1511.45Sapb		case "$1" in
1521.45Sapb		?*/*)	dn="${1%/*}" ;;
1531.45Sapb		/*)	dn=/ ;;
1541.45Sapb		*)	dn=. ;;
1551.45Sapb		esac
1561.45Sapb		echo "$dn"
1571.45Sapb	}
1581.45Sapb	;;
1591.45Sapbesac
1601.45Sapb
1611.9SlukemoIFS=$IFS
1621.9SlukemIFS="
1631.9Slukem"
1641.9Slukemfor x in $(
1651.43Sapb${MAKE} -B -f- all <<EOMAKE
1661.9Slukem.include <bsd.own.mk>
1671.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1681.33SjmcMKMANPAGES=no
1691.33Sjmc.else
1701.33SjmcMKMANPAGES=yes
1711.33Sjmc.endif
1721.72Smrg.if \${MKX11} != "no"
1731.72Smrg. if \${X11FLAVOUR} == "Xorg"
1741.72SmrgMKXORG:=yes
1751.72SmrgMKX11:=no
1761.72Smrg. else
1771.72SmrgMKXORG:=no
1781.72Smrg. endif
1791.72Smrg.endif
1801.9Slukemall:
1811.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1821.52Slukem		HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1831.12Slukem		${MKVARS}
1841.12Slukem	@echo "export \$i=\${\$i}"
1851.11Slukem.endfor
1861.9Slukem
1871.12SlukemEOMAKE
1881.9Slukem); do
1891.11Slukem#	echo 1>&2 "DEBUG: read $x"
1901.9Slukem	eval $x
1911.9Slukemdone
1921.9SlukemIFS=$oIFS
1931.9Slukem
1941.34Serhsetsdir=${0%/*}
1951.57Sjmmvnlists="base comp etc games man misc tests text"
1961.70Slukemxlists="xbase xcomp xetc xfont xserver"
1971.9Slukemobsolete=0
1981.76Stsutsuimodule=yes
1991.11Slukemif [ "${MACHINE}" = "evbppc" ]; then
2001.76Stsutsui	module=no			# Turn off MODULEs for some ports.
2011.9Slukemfi
2021.31Sjmc# Determine lib type. Do this first so stlib also gets set.
2031.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
2041.9Slukem	shlib=elf
2051.9Slukemelse
2061.9Slukem	shlib=aout
2071.9Slukemfi
2081.9Slukemstlib=$shlib
2091.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
2101.31Sjmcif [ "${MKPIC}" = "no" ]; then
2111.31Sjmc	shlib=no
2121.31Sjmcfi
2131.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
2141.9Slukem	shlib=no			# Turn off shlibs for some ports.
2151.9Slukemfi
2161.9Slukem
2171.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2181.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2191.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2201.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2211.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2221.60Sad
2231.9Slukem#
2241.9Slukem# list_set_files setfile [...]
2251.1Sdyoung# 
2261.9Slukem# Produce a packing list for setfile(s).
2271.9Slukem# In each file, a record consists of a path and a System Package name,
2281.9Slukem# separated by whitespace. E.g.,
2291.9Slukem#
2301.83Sapb# 	# $NetBSD: sets.subr,v 1.83 2009/04/07 20:46:20 apb Exp $
2311.9Slukem# 	.			base-sys-root	[keyword[,...]]
2321.9Slukem# 	./altroot		base-sys-root
2331.9Slukem# 	./bin			base-sys-root
2341.9Slukem# 	./bin/[			base-util-root
2351.9Slukem# 	./bin/cat		base-util-root
2361.9Slukem#		[...]
2371.9Slukem#
2381.9Slukem# A # in the first column marks a comment.
2391.9Slukem#
2401.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2411.52Slukem# be printed.  All other keywords must be present.
2421.9Slukem#
2431.9Slukem# The third field is an optional comma separated list of keywords to
2441.9Slukem# control if a record is printed; every keyword listed must be enabled
2451.9Slukem# for the record to be printed.  The following keywords are available:
2461.9Slukem#	dummy			dummy entry (ignored)
2471.13Slukem#	obsolete		file is obsolete, and only printed if 
2481.13Slukem#				${obsolete} != 0
2491.13Slukem#
2501.22Slukem#	bfd			${MKBFD} != no
2511.22Slukem#	catpages		${MKCATPAGES} != no
2521.71Smrg#	compat			${MKCOMPAT} != no
2531.22Slukem#	crypto			${MKCRYPTO} != no
2541.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2551.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2561.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2571.22Slukem#	cvs			${MKCVS} != no
2581.53Slukem#	debug			${MKDEBUG} != no
2591.69Slukem#	debuglib		${MKDEBUGLIB} != no
2601.23Slukem#	doc			${MKDOC} != no
2611.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2621.52Slukem#	gcc			${MKGCC} != no
2631.36Smatt#	gcccmds			${MKGCCCMDS} != no
2641.32Sscw#	gdb			${MKGDB} != no
2651.22Slukem#	hesiod			${MKHESIOD} != no
2661.68Slukem#	html			${MKHTML} != no
2671.67Slukem#	inet6			${MKINET6} != no
2681.23Slukem#	info			${MKINFO} != no
2691.39Speter#	ipfilter		${MKIPFILTER} != no
2701.51Smrg#	iscsi			${MKISCSI} != no
2711.22Slukem#	kerberos		${MKKERBEROS} != no
2721.67Slukem#	ldap			${MKLDAP} != no
2731.22Slukem#	lint			${MKLINT} != no
2741.78Sagc#	lvm			${MKLVM} != no
2751.22Slukem#	man			${MKMAN} != no
2761.67Slukem#	manpages		${MKMANPAGES} != no
2771.22Slukem#	manz			${MKMANZ} != no
2781.23Slukem#	nls			${MKNLS} != no
2791.66Sdyoung#	nvi			${MKNVI} != no
2801.37She#	pam			${MKPAM} != no
2811.39Speter#	pf			${MKPF} != no
2821.67Slukem#	pic			${MKPIC} != no
2831.22Slukem#	postfix			${MKPOSTFIX} != no
2841.22Slukem#	profile			${MKPROFILE} != no
2851.24Slukem#	share			${MKSHARE} != no
2861.22Slukem#	skey			${MKSKEY} != no
2871.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2881.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2891.22Slukem#	yp			${MKYP} != no
2901.22Slukem#
2911.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2921.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2931.52Slukem#
2941.41Slukem#	use_inet6		${USE_INET6} != no
2951.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2961.41Slukem#	use_yp			${USE_YP} != no
2971.41Slukem#
2981.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
2991.22Slukem#				  automatically append ".gz" to the filename
3001.22Slukem#
3011.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3021.22Slukem#				  automatically append ".gz" to the filename
3031.1Sdyoung#
3041.8Slukemlist_set_files()
3051.8Slukem{
3061.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3071.65She		verbose=false
3081.65She	else
3091.65She		verbose=true
3101.65She	fi
3111.1Sdyoung	for setname; do
3121.65She		list=`list_set_lists $setname`
3131.65She		for l in $list; do
3141.65She			echo $l
3151.65She			if $verbose; then
3161.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3171.65She			fi
3181.65She		done
3191.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3201.43Sapb	${AWK} -v obsolete=${obsolete} '
3211.9Slukem		BEGIN {
3221.52Slukem			if (obsolete)
3231.52Slukem				wanted["obsolete"] = 1
3241.52Slukem		
3251.52Slukem			split("'"${MKVARS}"'", needvars)
3261.52Slukem			for (vi in needvars) {
3271.52Slukem				nv = needvars[vi]
3281.52Slukem				kw = tolower(nv)
3291.52Slukem				sub(/^mk/, "", kw)
3301.52Slukem				if (ENVIRON[nv] != "no")
3311.52Slukem					wanted[kw] = 1 
3321.52Slukem			}
3331.52Slukem
3341.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3351.52Slukem				wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3361.52Slukem				wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3371.9Slukem			}
3381.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3391.52Slukem				wanted[".cat"] = 1
3401.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3411.52Slukem				wanted[".man"] = 1
3421.9Slukem		}
3431.9Slukem
3441.9Slukem		/^#/ {
3451.9Slukem			next;
3461.9Slukem		}
3471.9Slukem
3481.9Slukem		NF > 2 && $3 != "-" {
3491.9Slukem			split($3, keywords, ",")
3501.9Slukem			show = 1
3511.52Slukem			haveobs = 0
3521.9Slukem			for (ki in keywords) {
3531.9Slukem				kw = keywords[ki]
3541.22Slukem				if (("manz" in wanted) &&
3551.22Slukem				    (kw == ".cat" || kw == ".man"))
3561.22Slukem					$1 = $1 ".gz"
3571.59Sjmmv				negated = match(kw, "! *")
3581.59Sjmmv				if (negated > 0) {
3591.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3601.59Sjmmv					if (kw in wanted)
3611.59Sjmmv						show = 0
3621.59Sjmmv				} else {
3631.59Sjmmv					if (! (kw in wanted))
3641.59Sjmmv						show = 0
3651.59Sjmmv				}
3661.52Slukem				if (kw == "obsolete")
3671.52Slukem					haveobs = 1
3681.9Slukem			}
3691.52Slukem			if (obsolete && ! haveobs)
3701.52Slukem				next
3711.9Slukem			if (show)
3721.9Slukem				print
3731.9Slukem			next
3741.9Slukem		}
3751.9Slukem
3761.9Slukem		{
3771.9Slukem			if (! obsolete)
3781.9Slukem				print
3791.9Slukem		}'
3801.9Slukem
3811.1Sdyoung}
3821.1Sdyoung
3831.1Sdyoung#
3841.1Sdyoung# list_set_lists setname
3851.1Sdyoung# 
3861.1Sdyoung# Print to stdout a list of files, one filename per line, which
3871.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3881.1Sdyoung#
3891.1Sdyoung# 	.../lists/base/mi
3901.1Sdyoung# 	.../lists/base/rescue.mi
3911.1Sdyoung# 	.../lists/base/md.i386
3921.9Slukem#		[...]
3931.1Sdyoung#
3941.9Slukem# For a given setname $set, the following files may be selected from
3951.9Slukem# .../list/$set:
3961.9Slukem#	mi
3971.11Slukem#	ad.${MACHINE_ARCH}
3981.11Slukem# (or)	ad.${MACHINE_CPU}
3991.11Slukem#	ad.${MACHINE_CPU}.shl
4001.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4011.11Slukem# (or)	md.${MACHINE}
4021.9Slukem#	stl.mi
4031.9Slukem#	stl.stlib
4041.9Slukem#	shl.mi
4051.9Slukem#	shl.shlib
4061.77Stsutsui#	module.mi			if ${module} != no
4071.77Stsutsui#	module.${MACHINE}		if ${module} != no
4081.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4091.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4101.9Slukem#	rescue.shl
4111.11Slukem#	rescue.${MACHINE}
4121.11Slukem#	rescue.ad.${MACHINE_ARCH}
4131.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4141.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4151.1Sdyoung#
4161.9Slukem# Environment:
4171.1Sdyoung# 	shlib
4181.1Sdyoung# 	stlib
4191.1Sdyoung#
4201.8Slukemlist_set_lists()
4211.8Slukem{
4221.1Sdyoung	setname=$1
4231.1Sdyoung
4241.9Slukem	setdir=$setsdir/lists/$setname
4251.9Slukem	echo $setdir/mi
4261.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4271.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4281.1Sdyoung		# since the arch-specific one will be more specific than
4291.1Sdyoung		# the cpu-specific one.
4301.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4311.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4321.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4331.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4341.1Sdyoung		fi
4351.1Sdyoung		if [ "$shlib" != "no" -a \
4361.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4371.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4381.1Sdyoung		fi
4391.1Sdyoung	fi
4401.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4411.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4421.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4431.11Slukem		echo $setdir/md.${MACHINE}
4441.1Sdyoung	fi
4451.9Slukem	if [ -f $setdir/stl.mi ]; then
4461.9Slukem		echo $setdir/stl.mi
4471.1Sdyoung	fi
4481.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4491.9Slukem		echo $setdir/stl.${stlib}
4501.1Sdyoung	fi
4511.1Sdyoung	if [ "$shlib" != "no" ]; then
4521.9Slukem		if [ -f $setdir/shl.mi ]; then
4531.9Slukem			echo $setdir/shl.mi
4541.7Sdyoung		fi
4551.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4561.9Slukem			echo $setdir/shl.${shlib}
4571.7Sdyoung		fi
4581.1Sdyoung	fi
4591.76Stsutsui	if [ "$module" != "no" ]; then
4601.76Stsutsui		if [ -f $setdir/module.mi ]; then
4611.76Stsutsui			echo $setdir/module.mi
4621.1Sdyoung		fi
4631.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4641.77Stsutsui			echo $setdir/module.${MACHINE}
4651.77Stsutsui		fi
4661.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4671.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4681.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4691.77Stsutsui			# specific one will be more specific than the
4701.77Stsutsui			# cpu-specific one.
4711.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4721.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4731.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4741.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4751.77Stsutsui			fi
4761.77Stsutsui		fi
4771.1Sdyoung	fi
4781.1Sdyoung
4791.9Slukem	if [ -f $setdir/rescue.mi ]; then
4801.9Slukem		echo $setdir/rescue.mi
4811.1Sdyoung	fi
4821.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
4831.11Slukem		echo $setdir/rescue.${MACHINE}
4841.1Sdyoung	fi
4851.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4861.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
4871.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
4881.1Sdyoung		# specific one will be more specific than the
4891.1Sdyoung		# cpu-specific one.
4901.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
4911.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
4921.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
4931.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
4941.1Sdyoung		fi
4951.10Sjmc		if [ "$shlib" != "no" -a \
4961.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
4971.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
4981.10Sjmc		fi
4991.1Sdyoung	fi
5001.5Sdyoung}
5011.5Sdyoung
5021.9Slukem# arch_to_cpu mach
5031.9Slukem#
5041.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5051.9Slukem# as determined by <bsd.own.mk>.
5061.9Slukem#
5071.8Slukemarch_to_cpu()
5081.8Slukem{
5091.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5101.5Sdyoung.include <bsd.own.mk>
5111.5Sdyoungall:
5121.5Sdyoung	@echo \${MACHINE_CPU}
5131.12SlukemEOMAKE
5141.1Sdyoung}
5151.46Sapb
5161.46Sapb# arch_to_endian mach
5171.46Sapb#
5181.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5191.46Sapb# as determined by <bsd.endian.mk>.
5201.46Sapb#
5211.46Sapbarch_to_endian()
5221.46Sapb{
5231.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5241.46Sapb.include <bsd.endian.mk>
5251.46Sapball:
5261.46Sapb	@echo \${TARGET_ENDIANNESS}
5271.46SapbEOMAKE
5281.46Sapb}
529