sets.subr revision 1.102
11.100Suebayasi#	$NetBSD: sets.subr,v 1.102 2009/12/03 13:45:11 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.95Suebayasi
271.95Suebayasi# XXX don't hardcode
281.95SuebayasiMKEXTRAVARS="\
291.98Suebayasi	EXTSRCS		\
301.100Suebayasi	MKBFD		\
311.100Suebayasi	MKCOMPAT	\
321.100Suebayasi	MKDYNAMICROOT	\
331.100Suebayasi	MKMANPAGES	\
341.102Suebayasi	MKXORG		\
351.41Slukem	USE_INET6	\
361.41Slukem	USE_KERBEROS	\
371.63Slukem	USE_LDAP	\
381.41Slukem	USE_YP		\
391.64She	NETBSDSRCDIR	\
401.65She	MAKEVERBOSE	\
411.22Slukem"
421.42Sapb#
431.42Sapb# The following variables refer to tools that are used when building sets:
441.42Sapb#
451.43Sapb: ${AWK:=awk}
461.42Sapb: ${CKSUM:=cksum}
471.43Sapb: ${COMM:=comm}
481.44Sapb: ${DATE:=date}
491.43Sapb: ${DB:=db}
501.43Sapb: ${EGREP:=egrep}
511.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
521.44Sapb: ${FGREP:=fgrep}
531.43Sapb: ${FIND:=find}
541.44Sapb: ${GREP:=grep}
551.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
561.99Sapb: ${HOSTNAME_CMD:=hostname}	# ${HOSTNAME} is special to bash(1)
571.42Sapb: ${HOST_SH:=sh}
581.43Sapb: ${IDENT:=ident}
591.43Sapb: ${JOIN:=join}
601.43Sapb: ${LS:=ls}
611.43Sapb: ${MAKE:=make}
621.42Sapb: ${MKTEMP:=mktemp}
631.43Sapb: ${MTREE:=mtree}
641.43Sapb: ${PASTE:=paste}
651.42Sapb: ${PAX:=pax}
661.43Sapb: ${PRINTF:=printf}
671.43Sapb: ${SED:=sed}
681.43Sapb: ${SORT:=sort}
691.44Sapb: ${STAT:=stat}
701.44Sapb: ${TSORT:=tsort}
711.43Sapb: ${UNAME:=uname}
721.43Sapb: ${WC:=wc}
731.43Sapb
741.45Sapb#
751.45Sapb# If printf is a shell builtin command, then we can
761.45Sapb# implement cheaper versions of basename and dirname
771.45Sapb# that do not involve any fork/exec overhead.
781.45Sapb# If printf is not builtin, approximate it using echo,
791.45Sapb# and hope there are no weird file names that cause
801.45Sapb# some versions of echo to do the wrong thing.
811.45Sapb# (Converting to this version of dirname speeded up the
821.45Sapb# syspkgdeps script by an order of magnitude, from 68
831.45Sapb# seconds to 6.3 seconds on one particular host.)
841.45Sapb#
851.45Sapb# Note that naive approximations for dirname
861.45Sapb# using ${foo%/*} do not do the right thing in cases
871.45Sapb# where the result should be "/" or ".".
881.45Sapb#
891.45Sapbcase "$(type printf)" in
901.45Sapb*builtin*)
911.45Sapb	basename ()
921.45Sapb	{
931.45Sapb		local bn
941.45Sapb		bn="${1##*/}"
951.45Sapb		bn="${bn%$2}"
961.45Sapb		printf "%s\n" "$bn"
971.45Sapb	}
981.45Sapb	dirname ()
991.45Sapb	{
1001.45Sapb		local dn
1011.45Sapb		case "$1" in
1021.45Sapb		?*/*)	dn="${1%/*}" ;;
1031.45Sapb		/*)	dn=/ ;;
1041.45Sapb		*)	dn=. ;;
1051.45Sapb		esac
1061.45Sapb		printf "%s\n" "$dn"
1071.45Sapb	}
1081.45Sapb	;;
1091.45Sapb*)
1101.45Sapb	basename ()
1111.45Sapb	{
1121.45Sapb		local bn
1131.45Sapb		bn="${1##*/}"
1141.45Sapb		bn="${bn%$2}"
1151.45Sapb		echo "$bn"
1161.45Sapb	}
1171.45Sapb	dirname ()
1181.45Sapb	{
1191.45Sapb		local dn
1201.45Sapb		case "$1" in
1211.45Sapb		?*/*)	dn="${1%/*}" ;;
1221.45Sapb		/*)	dn=/ ;;
1231.45Sapb		*)	dn=. ;;
1241.45Sapb		esac
1251.45Sapb		echo "$dn"
1261.45Sapb	}
1271.45Sapb	;;
1281.45Sapbesac
1291.45Sapb
1301.9SlukemoIFS=$IFS
1311.9SlukemIFS="
1321.9Slukem"
1331.100Suebayasi
1341.100Suebayasifor x in $(
1351.100Suebayasi	${MAKE} -B -f- all <<EOMAKE
1361.97Suebayasi.include <bsd.own.mk>
1371.97Suebayasiall:
1381.100Suebayasi	@echo "export _MKVARS_yes=\"\${_MKVARS.yes}\""
1391.100Suebayasi	@echo "export _MKVARS_no=\"\${_MKVARS.no}\""
1401.100Suebayasi
1411.97SuebayasiEOMAKE
1421.100Suebayasi); do
1431.100Suebayasi	eval $x
1441.97Suebayasidone
1451.100Suebayasi
1461.9Slukemfor x in $(
1471.43Sapb${MAKE} -B -f- all <<EOMAKE
1481.9Slukem.include <bsd.own.mk>
1491.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1501.33SjmcMKMANPAGES=no
1511.33Sjmc.else
1521.33SjmcMKMANPAGES=yes
1531.33Sjmc.endif
1541.72Smrg.if \${MKX11} != "no"
1551.72Smrg. if \${X11FLAVOUR} == "Xorg"
1561.72SmrgMKXORG:=yes
1571.72SmrgMKX11:=no
1581.72Smrg. else
1591.72SmrgMKXORG:=no
1601.72Smrg. endif
1611.72Smrg.endif
1621.9Slukemall:
1631.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1641.87Sskrll		HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1651.100Suebayasi		${MKEXTRAVARS} ${_MKVARS_yes} ${_MKVARS_no}
1661.96Suebayasi	@echo "export \$i=\"\${\$i}\""
1671.11Slukem.endfor
1681.9Slukem
1691.12SlukemEOMAKE
1701.9Slukem); do
1711.101Suebayasi#	echo 1>&2 "DEBUG: read $x"
1721.9Slukem	eval $x
1731.9Slukemdone
1741.100Suebayasi
1751.9SlukemIFS=$oIFS
1761.9Slukem
1771.100SuebayasiMKVARS="$MKEXTRAVARS $_MKVARS_yes $_MKVARS_no"
1781.100Suebayasi
1791.34Serhsetsdir=${0%/*}
1801.9Slukemobsolete=0
1811.76Stsutsuimodule=yes
1821.91Sdyoungif [ "${MKKMOD}" = "no" ]; then
1831.91Sdyoung	module=no			# MODULEs are off.
1841.91Sdyoungelif [ "${MACHINE}" = "evbppc" ]; then
1851.76Stsutsui	module=no			# Turn off MODULEs for some ports.
1861.9Slukemfi
1871.31Sjmc# Determine lib type. Do this first so stlib also gets set.
1881.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
1891.9Slukem	shlib=elf
1901.9Slukemelse
1911.9Slukem	shlib=aout
1921.9Slukemfi
1931.9Slukemstlib=$shlib
1941.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
1951.31Sjmcif [ "${MKPIC}" = "no" ]; then
1961.31Sjmc	shlib=no
1971.31Sjmcfi
1981.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
1991.9Slukem	shlib=no			# Turn off shlibs for some ports.
2001.9Slukemfi
2011.86Sjnemethif [ "$module" != "no" ]; then
2021.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
2031.86Sjnemethelse
2041.86Sjnemeth	nlists="base comp etc games man misc tests text"
2051.86Sjnemethfi
2061.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
2071.92Suebayasiextlists="extbase extcomp extetc"
2081.9Slukem
2091.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2101.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2111.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2121.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2131.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2141.60Sad
2151.9Slukem#
2161.9Slukem# list_set_files setfile [...]
2171.1Sdyoung# 
2181.9Slukem# Produce a packing list for setfile(s).
2191.9Slukem# In each file, a record consists of a path and a System Package name,
2201.9Slukem# separated by whitespace. E.g.,
2211.9Slukem#
2221.100Suebayasi# 	# $NetBSD: sets.subr,v 1.102 2009/12/03 13:45:11 uebayasi Exp $
2231.9Slukem# 	.			base-sys-root	[keyword[,...]]
2241.9Slukem# 	./altroot		base-sys-root
2251.9Slukem# 	./bin			base-sys-root
2261.9Slukem# 	./bin/[			base-util-root
2271.9Slukem# 	./bin/cat		base-util-root
2281.9Slukem#		[...]
2291.9Slukem#
2301.9Slukem# A # in the first column marks a comment.
2311.9Slukem#
2321.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2331.52Slukem# be printed.  All other keywords must be present.
2341.9Slukem#
2351.9Slukem# The third field is an optional comma separated list of keywords to
2361.9Slukem# control if a record is printed; every keyword listed must be enabled
2371.9Slukem# for the record to be printed.  The following keywords are available:
2381.9Slukem#	dummy			dummy entry (ignored)
2391.13Slukem#	obsolete		file is obsolete, and only printed if 
2401.13Slukem#				${obsolete} != 0
2411.13Slukem#
2421.87Sskrll#	bfd			obsolete, use binutils.
2431.87Sskrll#	binutils		${MKBINUTILS} != no
2441.22Slukem#	catpages		${MKCATPAGES} != no
2451.71Smrg#	compat			${MKCOMPAT} != no
2461.22Slukem#	crypto			${MKCRYPTO} != no
2471.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2481.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2491.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2501.22Slukem#	cvs			${MKCVS} != no
2511.53Slukem#	debug			${MKDEBUG} != no
2521.69Slukem#	debuglib		${MKDEBUGLIB} != no
2531.23Slukem#	doc			${MKDOC} != no
2541.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2551.92Suebayasi#	extsrc			${MKEXTSRC} != no
2561.52Slukem#	gcc			${MKGCC} != no
2571.36Smatt#	gcccmds			${MKGCCCMDS} != no
2581.32Sscw#	gdb			${MKGDB} != no
2591.22Slukem#	hesiod			${MKHESIOD} != no
2601.68Slukem#	html			${MKHTML} != no
2611.67Slukem#	inet6			${MKINET6} != no
2621.23Slukem#	info			${MKINFO} != no
2631.39Speter#	ipfilter		${MKIPFILTER} != no
2641.51Smrg#	iscsi			${MKISCSI} != no
2651.22Slukem#	kerberos		${MKKERBEROS} != no
2661.85Sdyoung#	kmod			${MKKMOD} != no
2671.67Slukem#	ldap			${MKLDAP} != no
2681.22Slukem#	lint			${MKLINT} != no
2691.78Sagc#	lvm			${MKLVM} != no
2701.22Slukem#	man			${MKMAN} != no
2711.67Slukem#	manpages		${MKMANPAGES} != no
2721.22Slukem#	manz			${MKMANZ} != no
2731.88Stsarna#	mdns			${MKMDNS} != no
2741.23Slukem#	nls			${MKNLS} != no
2751.66Sdyoung#	nvi			${MKNVI} != no
2761.37She#	pam			${MKPAM} != no
2771.39Speter#	pf			${MKPF} != no
2781.67Slukem#	pic			${MKPIC} != no
2791.22Slukem#	postfix			${MKPOSTFIX} != no
2801.22Slukem#	profile			${MKPROFILE} != no
2811.24Slukem#	share			${MKSHARE} != no
2821.22Slukem#	skey			${MKSKEY} != no
2831.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2841.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2851.22Slukem#	yp			${MKYP} != no
2861.89Shaad#	zfs			${MKZFS} != no
2871.22Slukem#
2881.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
2891.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2901.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2911.52Slukem#
2921.41Slukem#	use_inet6		${USE_INET6} != no
2931.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2941.41Slukem#	use_yp			${USE_YP} != no
2951.41Slukem#
2961.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
2971.22Slukem#				  automatically append ".gz" to the filename
2981.22Slukem#
2991.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
3001.22Slukem#				  automatically append ".gz" to the filename
3011.1Sdyoung#
3021.8Slukemlist_set_files()
3031.8Slukem{
3041.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3051.65She		verbose=false
3061.65She	else
3071.65She		verbose=true
3081.65She	fi
3091.1Sdyoung	for setname; do
3101.65She		list=`list_set_lists $setname`
3111.65She		for l in $list; do
3121.65She			echo $l
3131.65She			if $verbose; then
3141.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3151.65She			fi
3161.65She		done
3171.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3181.43Sapb	${AWK} -v obsolete=${obsolete} '
3191.9Slukem		BEGIN {
3201.52Slukem			if (obsolete)
3211.52Slukem				wanted["obsolete"] = 1
3221.52Slukem		
3231.100Suebayasi			split("'"${MKVARS}"'", needvars)
3241.52Slukem			for (vi in needvars) {
3251.52Slukem				nv = needvars[vi]
3261.52Slukem				kw = tolower(nv)
3271.52Slukem				sub(/^mk/, "", kw)
3281.52Slukem				if (ENVIRON[nv] != "no")
3291.52Slukem					wanted[kw] = 1 
3301.52Slukem			}
3311.52Slukem
3321.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3331.90Sdyoung				if ("binutils" in wanted)
3341.90Sdyoung					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
3351.90Sdyoung				if ("gcc" in wanted)
3361.90Sdyoung					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3371.90Sdyoung				if ("gdb" in wanted)
3381.90Sdyoung					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3391.9Slukem			}
3401.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3411.52Slukem				wanted[".cat"] = 1
3421.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3431.52Slukem				wanted[".man"] = 1
3441.9Slukem		}
3451.9Slukem
3461.9Slukem		/^#/ {
3471.9Slukem			next;
3481.9Slukem		}
3491.9Slukem
3501.9Slukem		NF > 2 && $3 != "-" {
3511.9Slukem			split($3, keywords, ",")
3521.9Slukem			show = 1
3531.52Slukem			haveobs = 0
3541.9Slukem			for (ki in keywords) {
3551.9Slukem				kw = keywords[ki]
3561.22Slukem				if (("manz" in wanted) &&
3571.22Slukem				    (kw == ".cat" || kw == ".man"))
3581.22Slukem					$1 = $1 ".gz"
3591.59Sjmmv				negated = match(kw, "! *")
3601.59Sjmmv				if (negated > 0) {
3611.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3621.59Sjmmv					if (kw in wanted)
3631.59Sjmmv						show = 0
3641.59Sjmmv				} else {
3651.59Sjmmv					if (! (kw in wanted))
3661.59Sjmmv						show = 0
3671.59Sjmmv				}
3681.52Slukem				if (kw == "obsolete")
3691.52Slukem					haveobs = 1
3701.9Slukem			}
3711.52Slukem			if (obsolete && ! haveobs)
3721.52Slukem				next
3731.9Slukem			if (show)
3741.9Slukem				print
3751.9Slukem			next
3761.9Slukem		}
3771.9Slukem
3781.9Slukem		{
3791.9Slukem			if (! obsolete)
3801.9Slukem				print
3811.9Slukem		}'
3821.9Slukem
3831.1Sdyoung}
3841.1Sdyoung
3851.1Sdyoung#
3861.1Sdyoung# list_set_lists setname
3871.1Sdyoung# 
3881.1Sdyoung# Print to stdout a list of files, one filename per line, which
3891.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3901.1Sdyoung#
3911.1Sdyoung# 	.../lists/base/mi
3921.1Sdyoung# 	.../lists/base/rescue.mi
3931.1Sdyoung# 	.../lists/base/md.i386
3941.9Slukem#		[...]
3951.1Sdyoung#
3961.9Slukem# For a given setname $set, the following files may be selected from
3971.9Slukem# .../list/$set:
3981.9Slukem#	mi
3991.92Suebayasi#	mi.ext.*
4001.11Slukem#	ad.${MACHINE_ARCH}
4011.11Slukem# (or)	ad.${MACHINE_CPU}
4021.11Slukem#	ad.${MACHINE_CPU}.shl
4031.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4041.11Slukem# (or)	md.${MACHINE}
4051.9Slukem#	stl.mi
4061.92Suebayasi#	stl.${stlib}
4071.9Slukem#	shl.mi
4081.92Suebayasi#	shl.mi.ext.*
4091.92Suebayasi#	shl.${shlib}
4101.92Suebayasi#	shl.${shlib}.ext.*
4111.77Stsutsui#	module.mi			if ${module} != no
4121.77Stsutsui#	module.${MACHINE}		if ${module} != no
4131.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4141.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4151.9Slukem#	rescue.shl
4161.11Slukem#	rescue.${MACHINE}
4171.11Slukem#	rescue.ad.${MACHINE_ARCH}
4181.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4191.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4201.1Sdyoung#
4211.9Slukem# Environment:
4221.1Sdyoung# 	shlib
4231.1Sdyoung# 	stlib
4241.1Sdyoung#
4251.8Slukemlist_set_lists()
4261.8Slukem{
4271.1Sdyoung	setname=$1
4281.1Sdyoung
4291.9Slukem	setdir=$setsdir/lists/$setname
4301.9Slukem	echo $setdir/mi
4311.92Suebayasi	for _extsrc_pkg in ${EXTSRCS}; do
4321.92Suebayasi		if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then
4331.92Suebayasi			echo $setdir/mi.ext.${_extsrc_pkg}
4341.92Suebayasi		fi
4351.92Suebayasi	done
4361.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4371.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4381.1Sdyoung		# since the arch-specific one will be more specific than
4391.1Sdyoung		# the cpu-specific one.
4401.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4411.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4421.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4431.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4441.1Sdyoung		fi
4451.1Sdyoung		if [ "$shlib" != "no" -a \
4461.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4471.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4481.1Sdyoung		fi
4491.1Sdyoung	fi
4501.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4511.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4521.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4531.11Slukem		echo $setdir/md.${MACHINE}
4541.1Sdyoung	fi
4551.9Slukem	if [ -f $setdir/stl.mi ]; then
4561.9Slukem		echo $setdir/stl.mi
4571.1Sdyoung	fi
4581.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4591.9Slukem		echo $setdir/stl.${stlib}
4601.1Sdyoung	fi
4611.1Sdyoung	if [ "$shlib" != "no" ]; then
4621.9Slukem		if [ -f $setdir/shl.mi ]; then
4631.9Slukem			echo $setdir/shl.mi
4641.7Sdyoung		fi
4651.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4661.92Suebayasi			if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then
4671.92Suebayasi				echo $setdir/shl.mi.ext.${_extsrc_pkg}
4681.92Suebayasi			fi
4691.92Suebayasi		done
4701.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4711.9Slukem			echo $setdir/shl.${shlib}
4721.7Sdyoung		fi
4731.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4741.92Suebayasi			if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then
4751.92Suebayasi				echo $setdir/shl.${shlib}.ext.${_extsrc_pkg}
4761.92Suebayasi			fi
4771.92Suebayasi		done
4781.1Sdyoung	fi
4791.76Stsutsui	if [ "$module" != "no" ]; then
4801.76Stsutsui		if [ -f $setdir/module.mi ]; then
4811.76Stsutsui			echo $setdir/module.mi
4821.1Sdyoung		fi
4831.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4841.77Stsutsui			echo $setdir/module.${MACHINE}
4851.77Stsutsui		fi
4861.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4871.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4881.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4891.77Stsutsui			# specific one will be more specific than the
4901.77Stsutsui			# cpu-specific one.
4911.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4921.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4931.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4941.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4951.77Stsutsui			fi
4961.77Stsutsui		fi
4971.1Sdyoung	fi
4981.1Sdyoung
4991.9Slukem	if [ -f $setdir/rescue.mi ]; then
5001.9Slukem		echo $setdir/rescue.mi
5011.1Sdyoung	fi
5021.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
5031.11Slukem		echo $setdir/rescue.${MACHINE}
5041.1Sdyoung	fi
5051.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5061.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
5071.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
5081.1Sdyoung		# specific one will be more specific than the
5091.1Sdyoung		# cpu-specific one.
5101.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
5111.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
5121.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
5131.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
5141.1Sdyoung		fi
5151.10Sjmc		if [ "$shlib" != "no" -a \
5161.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
5171.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
5181.10Sjmc		fi
5191.1Sdyoung	fi
5201.5Sdyoung}
5211.5Sdyoung
5221.9Slukem# arch_to_cpu mach
5231.9Slukem#
5241.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5251.9Slukem# as determined by <bsd.own.mk>.
5261.9Slukem#
5271.8Slukemarch_to_cpu()
5281.8Slukem{
5291.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5301.5Sdyoung.include <bsd.own.mk>
5311.5Sdyoungall:
5321.5Sdyoung	@echo \${MACHINE_CPU}
5331.12SlukemEOMAKE
5341.1Sdyoung}
5351.46Sapb
5361.46Sapb# arch_to_endian mach
5371.46Sapb#
5381.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5391.46Sapb# as determined by <bsd.endian.mk>.
5401.46Sapb#
5411.46Sapbarch_to_endian()
5421.46Sapb{
5431.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5441.46Sapb.include <bsd.endian.mk>
5451.46Sapball:
5461.46Sapb	@echo \${TARGET_ENDIANNESS}
5471.46SapbEOMAKE
5481.46Sapb}
549