sets.subr revision 1.92
11.92Suebayasi#	$NetBSD: sets.subr,v 1.92 2009/11/30 16:13:23 uebayasi 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.22SlukemMKVARS="\
271.22Slukem	MKBFD		\
281.87Sskrll	MKBINUTILS	\
291.22Slukem	MKCATPAGES	\
301.71Smrg	MKCOMPAT	\
311.22Slukem	MKCRYPTO	\
321.22Slukem	MKCRYPTO_IDEA	\
331.22Slukem	MKCRYPTO_MDC2	\
341.22Slukem	MKCRYPTO_RC5	\
351.22Slukem	MKCVS		\
361.67Slukem	MKDEBUG		\
371.69Slukem	MKDEBUGLIB	\
381.67Slukem	MKDOC		\
391.67Slukem	MKDYNAMICROOT	\
401.92Suebayasi	MKEXTSRC	\
411.52Slukem	MKGCC		\
421.36Smatt	MKGCCCMDS	\
431.32Sscw	MKGDB		\
441.22Slukem	MKHESIOD	\
451.68Slukem	MKHTML		\
461.67Slukem	MKINET6		\
471.23Slukem	MKINFO		\
481.39Speter	MKIPFILTER	\
491.51Smrg	MKISCSI		\
501.22Slukem	MKKERBEROS	\
511.85Sdyoung	MKKMOD		\
521.67Slukem	MKLDAP		\
531.22Slukem	MKLINT		\
541.78Sagc	MKLVM		\
551.22Slukem	MKMAN		\
561.33Sjmc	MKMANPAGES	\
571.22Slukem	MKMANZ		\
581.88Stsarna	MKMDNS		\
591.23Slukem	MKNLS		\
601.66Sdyoung	MKNVI		\
611.37She	MKPAM		\
621.39Speter	MKPF		\
631.30Smatt	MKPIC		\
641.22Slukem	MKPOSTFIX	\
651.22Slukem	MKPROFILE	\
661.24Slukem	MKSHARE		\
671.22Slukem	MKSKEY		\
681.40Stron	MKX11		\
691.84Smrg	MKX11FONTS	\
701.68Slukem	MKXORG		\
711.22Slukem	MKYP		\
721.89Shaad	MKZFS		\
731.41Slukem	USE_INET6	\
741.41Slukem	USE_KERBEROS	\
751.63Slukem	USE_LDAP	\
761.41Slukem	USE_YP		\
771.64She	NETBSDSRCDIR	\
781.65She	MAKEVERBOSE	\
791.22Slukem"
801.42Sapb#
811.42Sapb# The following variables refer to tools that are used when building sets:
821.42Sapb#
831.43Sapb: ${AWK:=awk}
841.42Sapb: ${CKSUM:=cksum}
851.43Sapb: ${COMM:=comm}
861.44Sapb: ${DATE:=date}
871.43Sapb: ${DB:=db}
881.43Sapb: ${EGREP:=egrep}
891.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
901.44Sapb: ${FGREP:=fgrep}
911.43Sapb: ${FIND:=find}
921.44Sapb: ${GREP:=grep}
931.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
941.44Sapb: ${HOSTNAME:=hostname}
951.42Sapb: ${HOST_SH:=sh}
961.43Sapb: ${IDENT:=ident}
971.43Sapb: ${JOIN:=join}
981.43Sapb: ${LS:=ls}
991.43Sapb: ${MAKE:=make}
1001.42Sapb: ${MKTEMP:=mktemp}
1011.43Sapb: ${MTREE:=mtree}
1021.43Sapb: ${PASTE:=paste}
1031.42Sapb: ${PAX:=pax}
1041.43Sapb: ${PKG_CREATE:=pkg_create}
1051.43Sapb: ${PRINTF:=printf}
1061.43Sapb: ${SED:=sed}
1071.43Sapb: ${SORT:=sort}
1081.44Sapb: ${STAT:=stat}
1091.44Sapb: ${TSORT:=tsort}
1101.43Sapb: ${UNAME:=uname}
1111.43Sapb: ${WC:=wc}
1121.43Sapb
1131.45Sapb#
1141.45Sapb# If printf is a shell builtin command, then we can
1151.45Sapb# implement cheaper versions of basename and dirname
1161.45Sapb# that do not involve any fork/exec overhead.
1171.45Sapb# If printf is not builtin, approximate it using echo,
1181.45Sapb# and hope there are no weird file names that cause
1191.45Sapb# some versions of echo to do the wrong thing.
1201.45Sapb# (Converting to this version of dirname speeded up the
1211.45Sapb# syspkgdeps script by an order of magnitude, from 68
1221.45Sapb# seconds to 6.3 seconds on one particular host.)
1231.45Sapb#
1241.45Sapb# Note that naive approximations for dirname
1251.45Sapb# using ${foo%/*} do not do the right thing in cases
1261.45Sapb# where the result should be "/" or ".".
1271.45Sapb#
1281.45Sapbcase "$(type printf)" in
1291.45Sapb*builtin*)
1301.45Sapb	basename ()
1311.45Sapb	{
1321.45Sapb		local bn
1331.45Sapb		bn="${1##*/}"
1341.45Sapb		bn="${bn%$2}"
1351.45Sapb		printf "%s\n" "$bn"
1361.45Sapb	}
1371.45Sapb	dirname ()
1381.45Sapb	{
1391.45Sapb		local dn
1401.45Sapb		case "$1" in
1411.45Sapb		?*/*)	dn="${1%/*}" ;;
1421.45Sapb		/*)	dn=/ ;;
1431.45Sapb		*)	dn=. ;;
1441.45Sapb		esac
1451.45Sapb		printf "%s\n" "$dn"
1461.45Sapb	}
1471.45Sapb	;;
1481.45Sapb*)
1491.45Sapb	basename ()
1501.45Sapb	{
1511.45Sapb		local bn
1521.45Sapb		bn="${1##*/}"
1531.45Sapb		bn="${bn%$2}"
1541.45Sapb		echo "$bn"
1551.45Sapb	}
1561.45Sapb	dirname ()
1571.45Sapb	{
1581.45Sapb		local dn
1591.45Sapb		case "$1" in
1601.45Sapb		?*/*)	dn="${1%/*}" ;;
1611.45Sapb		/*)	dn=/ ;;
1621.45Sapb		*)	dn=. ;;
1631.45Sapb		esac
1641.45Sapb		echo "$dn"
1651.45Sapb	}
1661.45Sapb	;;
1671.45Sapbesac
1681.45Sapb
1691.9SlukemoIFS=$IFS
1701.9SlukemIFS="
1711.9Slukem"
1721.9Slukemfor x in $(
1731.43Sapb${MAKE} -B -f- all <<EOMAKE
1741.9Slukem.include <bsd.own.mk>
1751.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1761.33SjmcMKMANPAGES=no
1771.33Sjmc.else
1781.33SjmcMKMANPAGES=yes
1791.33Sjmc.endif
1801.72Smrg.if \${MKX11} != "no"
1811.72Smrg. if \${X11FLAVOUR} == "Xorg"
1821.72SmrgMKXORG:=yes
1831.72SmrgMKX11:=no
1841.72Smrg. else
1851.72SmrgMKXORG:=no
1861.72Smrg. endif
1871.72Smrg.endif
1881.9Slukemall:
1891.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1901.87Sskrll		HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1911.12Slukem		${MKVARS}
1921.12Slukem	@echo "export \$i=\${\$i}"
1931.11Slukem.endfor
1941.9Slukem
1951.12SlukemEOMAKE
1961.9Slukem); do
1971.11Slukem#	echo 1>&2 "DEBUG: read $x"
1981.9Slukem	eval $x
1991.9Slukemdone
2001.9SlukemIFS=$oIFS
2011.9Slukem
2021.34Serhsetsdir=${0%/*}
2031.9Slukemobsolete=0
2041.76Stsutsuimodule=yes
2051.91Sdyoungif [ "${MKKMOD}" = "no" ]; then
2061.91Sdyoung	module=no			# MODULEs are off.
2071.91Sdyoungelif [ "${MACHINE}" = "evbppc" ]; then
2081.76Stsutsui	module=no			# Turn off MODULEs for some ports.
2091.9Slukemfi
2101.31Sjmc# Determine lib type. Do this first so stlib also gets set.
2111.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
2121.9Slukem	shlib=elf
2131.9Slukemelse
2141.9Slukem	shlib=aout
2151.9Slukemfi
2161.9Slukemstlib=$shlib
2171.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
2181.31Sjmcif [ "${MKPIC}" = "no" ]; then
2191.31Sjmc	shlib=no
2201.31Sjmcfi
2211.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
2221.9Slukem	shlib=no			# Turn off shlibs for some ports.
2231.9Slukemfi
2241.86Sjnemethif [ "$module" != "no" ]; then
2251.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
2261.86Sjnemethelse
2271.86Sjnemeth	nlists="base comp etc games man misc tests text"
2281.86Sjnemethfi
2291.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
2301.92Suebayasiextlists="extbase extcomp extetc"
2311.9Slukem
2321.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2331.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2341.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2351.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2361.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2371.60Sad
2381.9Slukem#
2391.9Slukem# list_set_files setfile [...]
2401.1Sdyoung# 
2411.9Slukem# Produce a packing list for setfile(s).
2421.9Slukem# In each file, a record consists of a path and a System Package name,
2431.9Slukem# separated by whitespace. E.g.,
2441.9Slukem#
2451.92Suebayasi# 	# $NetBSD: sets.subr,v 1.92 2009/11/30 16:13:23 uebayasi Exp $
2461.9Slukem# 	.			base-sys-root	[keyword[,...]]
2471.9Slukem# 	./altroot		base-sys-root
2481.9Slukem# 	./bin			base-sys-root
2491.9Slukem# 	./bin/[			base-util-root
2501.9Slukem# 	./bin/cat		base-util-root
2511.9Slukem#		[...]
2521.9Slukem#
2531.9Slukem# A # in the first column marks a comment.
2541.9Slukem#
2551.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2561.52Slukem# be printed.  All other keywords must be present.
2571.9Slukem#
2581.9Slukem# The third field is an optional comma separated list of keywords to
2591.9Slukem# control if a record is printed; every keyword listed must be enabled
2601.9Slukem# for the record to be printed.  The following keywords are available:
2611.9Slukem#	dummy			dummy entry (ignored)
2621.13Slukem#	obsolete		file is obsolete, and only printed if 
2631.13Slukem#				${obsolete} != 0
2641.13Slukem#
2651.87Sskrll#	bfd			obsolete, use binutils.
2661.87Sskrll#	binutils		${MKBINUTILS} != no
2671.22Slukem#	catpages		${MKCATPAGES} != no
2681.71Smrg#	compat			${MKCOMPAT} != no
2691.22Slukem#	crypto			${MKCRYPTO} != no
2701.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2711.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2721.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2731.22Slukem#	cvs			${MKCVS} != no
2741.53Slukem#	debug			${MKDEBUG} != no
2751.69Slukem#	debuglib		${MKDEBUGLIB} != no
2761.23Slukem#	doc			${MKDOC} != no
2771.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2781.92Suebayasi#	extsrc			${MKEXTSRC} != no
2791.52Slukem#	gcc			${MKGCC} != no
2801.36Smatt#	gcccmds			${MKGCCCMDS} != no
2811.32Sscw#	gdb			${MKGDB} != no
2821.22Slukem#	hesiod			${MKHESIOD} != no
2831.68Slukem#	html			${MKHTML} != no
2841.67Slukem#	inet6			${MKINET6} != no
2851.23Slukem#	info			${MKINFO} != no
2861.39Speter#	ipfilter		${MKIPFILTER} != no
2871.51Smrg#	iscsi			${MKISCSI} != no
2881.22Slukem#	kerberos		${MKKERBEROS} != no
2891.85Sdyoung#	kmod			${MKKMOD} != no
2901.67Slukem#	ldap			${MKLDAP} != no
2911.22Slukem#	lint			${MKLINT} != no
2921.78Sagc#	lvm			${MKLVM} != no
2931.22Slukem#	man			${MKMAN} != no
2941.67Slukem#	manpages		${MKMANPAGES} != no
2951.22Slukem#	manz			${MKMANZ} != no
2961.88Stsarna#	mdns			${MKMDNS} != no
2971.23Slukem#	nls			${MKNLS} != no
2981.66Sdyoung#	nvi			${MKNVI} != no
2991.37She#	pam			${MKPAM} != no
3001.39Speter#	pf			${MKPF} != no
3011.67Slukem#	pic			${MKPIC} != no
3021.22Slukem#	postfix			${MKPOSTFIX} != no
3031.22Slukem#	profile			${MKPROFILE} != no
3041.24Slukem#	share			${MKSHARE} != no
3051.22Slukem#	skey			${MKSKEY} != no
3061.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
3071.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
3081.22Slukem#	yp			${MKYP} != no
3091.89Shaad#	zfs			${MKZFS} != no
3101.22Slukem#
3111.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
3121.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
3131.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
3141.52Slukem#
3151.41Slukem#	use_inet6		${USE_INET6} != no
3161.41Slukem#	use_kerberos		${USE_KERBEROS} != no
3171.41Slukem#	use_yp			${USE_YP} != no
3181.41Slukem#
3191.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
3201.22Slukem#				  automatically append ".gz" to the filename
3211.22Slukem#
3221.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3231.22Slukem#				  automatically append ".gz" to the filename
3241.1Sdyoung#
3251.8Slukemlist_set_files()
3261.8Slukem{
3271.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3281.65She		verbose=false
3291.65She	else
3301.65She		verbose=true
3311.65She	fi
3321.1Sdyoung	for setname; do
3331.65She		list=`list_set_lists $setname`
3341.65She		for l in $list; do
3351.65She			echo $l
3361.65She			if $verbose; then
3371.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3381.65She			fi
3391.65She		done
3401.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3411.43Sapb	${AWK} -v obsolete=${obsolete} '
3421.9Slukem		BEGIN {
3431.52Slukem			if (obsolete)
3441.52Slukem				wanted["obsolete"] = 1
3451.52Slukem		
3461.52Slukem			split("'"${MKVARS}"'", needvars)
3471.52Slukem			for (vi in needvars) {
3481.52Slukem				nv = needvars[vi]
3491.52Slukem				kw = tolower(nv)
3501.52Slukem				sub(/^mk/, "", kw)
3511.52Slukem				if (ENVIRON[nv] != "no")
3521.52Slukem					wanted[kw] = 1 
3531.52Slukem			}
3541.52Slukem
3551.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3561.90Sdyoung				if ("binutils" in wanted)
3571.90Sdyoung					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
3581.90Sdyoung				if ("gcc" in wanted)
3591.90Sdyoung					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3601.90Sdyoung				if ("gdb" in wanted)
3611.90Sdyoung					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3621.9Slukem			}
3631.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3641.52Slukem				wanted[".cat"] = 1
3651.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3661.52Slukem				wanted[".man"] = 1
3671.9Slukem		}
3681.9Slukem
3691.9Slukem		/^#/ {
3701.9Slukem			next;
3711.9Slukem		}
3721.9Slukem
3731.9Slukem		NF > 2 && $3 != "-" {
3741.9Slukem			split($3, keywords, ",")
3751.9Slukem			show = 1
3761.52Slukem			haveobs = 0
3771.9Slukem			for (ki in keywords) {
3781.9Slukem				kw = keywords[ki]
3791.22Slukem				if (("manz" in wanted) &&
3801.22Slukem				    (kw == ".cat" || kw == ".man"))
3811.22Slukem					$1 = $1 ".gz"
3821.59Sjmmv				negated = match(kw, "! *")
3831.59Sjmmv				if (negated > 0) {
3841.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3851.59Sjmmv					if (kw in wanted)
3861.59Sjmmv						show = 0
3871.59Sjmmv				} else {
3881.59Sjmmv					if (! (kw in wanted))
3891.59Sjmmv						show = 0
3901.59Sjmmv				}
3911.52Slukem				if (kw == "obsolete")
3921.52Slukem					haveobs = 1
3931.9Slukem			}
3941.52Slukem			if (obsolete && ! haveobs)
3951.52Slukem				next
3961.9Slukem			if (show)
3971.9Slukem				print
3981.9Slukem			next
3991.9Slukem		}
4001.9Slukem
4011.9Slukem		{
4021.9Slukem			if (! obsolete)
4031.9Slukem				print
4041.9Slukem		}'
4051.9Slukem
4061.1Sdyoung}
4071.1Sdyoung
4081.1Sdyoung#
4091.1Sdyoung# list_set_lists setname
4101.1Sdyoung# 
4111.1Sdyoung# Print to stdout a list of files, one filename per line, which
4121.1Sdyoung# concatenate to create the packing list for setname. E.g.,
4131.1Sdyoung#
4141.1Sdyoung# 	.../lists/base/mi
4151.1Sdyoung# 	.../lists/base/rescue.mi
4161.1Sdyoung# 	.../lists/base/md.i386
4171.9Slukem#		[...]
4181.1Sdyoung#
4191.9Slukem# For a given setname $set, the following files may be selected from
4201.9Slukem# .../list/$set:
4211.9Slukem#	mi
4221.92Suebayasi#	mi.ext.*
4231.11Slukem#	ad.${MACHINE_ARCH}
4241.11Slukem# (or)	ad.${MACHINE_CPU}
4251.11Slukem#	ad.${MACHINE_CPU}.shl
4261.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4271.11Slukem# (or)	md.${MACHINE}
4281.9Slukem#	stl.mi
4291.92Suebayasi#	stl.${stlib}
4301.9Slukem#	shl.mi
4311.92Suebayasi#	shl.mi.ext.*
4321.92Suebayasi#	shl.${shlib}
4331.92Suebayasi#	shl.${shlib}.ext.*
4341.77Stsutsui#	module.mi			if ${module} != no
4351.77Stsutsui#	module.${MACHINE}		if ${module} != no
4361.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4371.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4381.9Slukem#	rescue.shl
4391.11Slukem#	rescue.${MACHINE}
4401.11Slukem#	rescue.ad.${MACHINE_ARCH}
4411.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4421.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4431.1Sdyoung#
4441.9Slukem# Environment:
4451.1Sdyoung# 	shlib
4461.1Sdyoung# 	stlib
4471.1Sdyoung#
4481.8Slukemlist_set_lists()
4491.8Slukem{
4501.1Sdyoung	setname=$1
4511.1Sdyoung
4521.9Slukem	setdir=$setsdir/lists/$setname
4531.9Slukem	echo $setdir/mi
4541.92Suebayasi	for _extsrc_pkg in ${EXTSRCS}; do
4551.92Suebayasi		if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then
4561.92Suebayasi			echo $setdir/mi.ext.${_extsrc_pkg}
4571.92Suebayasi		fi
4581.92Suebayasi	done
4591.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4601.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4611.1Sdyoung		# since the arch-specific one will be more specific than
4621.1Sdyoung		# the cpu-specific one.
4631.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4641.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4651.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4661.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4671.1Sdyoung		fi
4681.1Sdyoung		if [ "$shlib" != "no" -a \
4691.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4701.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4711.1Sdyoung		fi
4721.1Sdyoung	fi
4731.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4741.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4751.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4761.11Slukem		echo $setdir/md.${MACHINE}
4771.1Sdyoung	fi
4781.9Slukem	if [ -f $setdir/stl.mi ]; then
4791.9Slukem		echo $setdir/stl.mi
4801.1Sdyoung	fi
4811.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4821.9Slukem		echo $setdir/stl.${stlib}
4831.1Sdyoung	fi
4841.1Sdyoung	if [ "$shlib" != "no" ]; then
4851.9Slukem		if [ -f $setdir/shl.mi ]; then
4861.9Slukem			echo $setdir/shl.mi
4871.7Sdyoung		fi
4881.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4891.92Suebayasi			if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then
4901.92Suebayasi				echo $setdir/shl.mi.ext.${_extsrc_pkg}
4911.92Suebayasi			fi
4921.92Suebayasi		done
4931.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4941.9Slukem			echo $setdir/shl.${shlib}
4951.7Sdyoung		fi
4961.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4971.92Suebayasi			if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then
4981.92Suebayasi				echo $setdir/shl.${shlib}.ext.${_extsrc_pkg}
4991.92Suebayasi			fi
5001.92Suebayasi		done
5011.1Sdyoung	fi
5021.76Stsutsui	if [ "$module" != "no" ]; then
5031.76Stsutsui		if [ -f $setdir/module.mi ]; then
5041.76Stsutsui			echo $setdir/module.mi
5051.1Sdyoung		fi
5061.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
5071.77Stsutsui			echo $setdir/module.${MACHINE}
5081.77Stsutsui		fi
5091.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5101.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
5111.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
5121.77Stsutsui			# specific one will be more specific than the
5131.77Stsutsui			# cpu-specific one.
5141.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
5151.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
5161.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
5171.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
5181.77Stsutsui			fi
5191.77Stsutsui		fi
5201.1Sdyoung	fi
5211.1Sdyoung
5221.9Slukem	if [ -f $setdir/rescue.mi ]; then
5231.9Slukem		echo $setdir/rescue.mi
5241.1Sdyoung	fi
5251.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
5261.11Slukem		echo $setdir/rescue.${MACHINE}
5271.1Sdyoung	fi
5281.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5291.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
5301.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
5311.1Sdyoung		# specific one will be more specific than the
5321.1Sdyoung		# cpu-specific one.
5331.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
5341.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
5351.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
5361.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
5371.1Sdyoung		fi
5381.10Sjmc		if [ "$shlib" != "no" -a \
5391.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
5401.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
5411.10Sjmc		fi
5421.1Sdyoung	fi
5431.5Sdyoung}
5441.5Sdyoung
5451.9Slukem# arch_to_cpu mach
5461.9Slukem#
5471.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5481.9Slukem# as determined by <bsd.own.mk>.
5491.9Slukem#
5501.8Slukemarch_to_cpu()
5511.8Slukem{
5521.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5531.5Sdyoung.include <bsd.own.mk>
5541.5Sdyoungall:
5551.5Sdyoung	@echo \${MACHINE_CPU}
5561.12SlukemEOMAKE
5571.1Sdyoung}
5581.46Sapb
5591.46Sapb# arch_to_endian mach
5601.46Sapb#
5611.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5621.46Sapb# as determined by <bsd.endian.mk>.
5631.46Sapb#
5641.46Sapbarch_to_endian()
5651.46Sapb{
5661.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5671.46Sapb.include <bsd.endian.mk>
5681.46Sapball:
5691.46Sapb	@echo \${TARGET_ENDIANNESS}
5701.46SapbEOMAKE
5711.46Sapb}
572