sets.subr revision 1.100
11.100Suebayasi#	$NetBSD: sets.subr,v 1.100 2009/12/02 17:51:30 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.41Slukem	USE_INET6	\
351.41Slukem	USE_KERBEROS	\
361.63Slukem	USE_LDAP	\
371.41Slukem	USE_YP		\
381.64She	NETBSDSRCDIR	\
391.65She	MAKEVERBOSE	\
401.22Slukem"
411.42Sapb#
421.42Sapb# The following variables refer to tools that are used when building sets:
431.42Sapb#
441.43Sapb: ${AWK:=awk}
451.42Sapb: ${CKSUM:=cksum}
461.43Sapb: ${COMM:=comm}
471.44Sapb: ${DATE:=date}
481.43Sapb: ${DB:=db}
491.43Sapb: ${EGREP:=egrep}
501.43Sapb: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
511.44Sapb: ${FGREP:=fgrep}
521.43Sapb: ${FIND:=find}
531.44Sapb: ${GREP:=grep}
541.43Sapb: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
551.99Sapb: ${HOSTNAME_CMD:=hostname}	# ${HOSTNAME} is special to bash(1)
561.42Sapb: ${HOST_SH:=sh}
571.43Sapb: ${IDENT:=ident}
581.43Sapb: ${JOIN:=join}
591.43Sapb: ${LS:=ls}
601.43Sapb: ${MAKE:=make}
611.42Sapb: ${MKTEMP:=mktemp}
621.43Sapb: ${MTREE:=mtree}
631.43Sapb: ${PASTE:=paste}
641.42Sapb: ${PAX:=pax}
651.43Sapb: ${PRINTF:=printf}
661.43Sapb: ${SED:=sed}
671.43Sapb: ${SORT:=sort}
681.44Sapb: ${STAT:=stat}
691.44Sapb: ${TSORT:=tsort}
701.43Sapb: ${UNAME:=uname}
711.43Sapb: ${WC:=wc}
721.43Sapb
731.45Sapb#
741.45Sapb# If printf is a shell builtin command, then we can
751.45Sapb# implement cheaper versions of basename and dirname
761.45Sapb# that do not involve any fork/exec overhead.
771.45Sapb# If printf is not builtin, approximate it using echo,
781.45Sapb# and hope there are no weird file names that cause
791.45Sapb# some versions of echo to do the wrong thing.
801.45Sapb# (Converting to this version of dirname speeded up the
811.45Sapb# syspkgdeps script by an order of magnitude, from 68
821.45Sapb# seconds to 6.3 seconds on one particular host.)
831.45Sapb#
841.45Sapb# Note that naive approximations for dirname
851.45Sapb# using ${foo%/*} do not do the right thing in cases
861.45Sapb# where the result should be "/" or ".".
871.45Sapb#
881.45Sapbcase "$(type printf)" in
891.45Sapb*builtin*)
901.45Sapb	basename ()
911.45Sapb	{
921.45Sapb		local bn
931.45Sapb		bn="${1##*/}"
941.45Sapb		bn="${bn%$2}"
951.45Sapb		printf "%s\n" "$bn"
961.45Sapb	}
971.45Sapb	dirname ()
981.45Sapb	{
991.45Sapb		local dn
1001.45Sapb		case "$1" in
1011.45Sapb		?*/*)	dn="${1%/*}" ;;
1021.45Sapb		/*)	dn=/ ;;
1031.45Sapb		*)	dn=. ;;
1041.45Sapb		esac
1051.45Sapb		printf "%s\n" "$dn"
1061.45Sapb	}
1071.45Sapb	;;
1081.45Sapb*)
1091.45Sapb	basename ()
1101.45Sapb	{
1111.45Sapb		local bn
1121.45Sapb		bn="${1##*/}"
1131.45Sapb		bn="${bn%$2}"
1141.45Sapb		echo "$bn"
1151.45Sapb	}
1161.45Sapb	dirname ()
1171.45Sapb	{
1181.45Sapb		local dn
1191.45Sapb		case "$1" in
1201.45Sapb		?*/*)	dn="${1%/*}" ;;
1211.45Sapb		/*)	dn=/ ;;
1221.45Sapb		*)	dn=. ;;
1231.45Sapb		esac
1241.45Sapb		echo "$dn"
1251.45Sapb	}
1261.45Sapb	;;
1271.45Sapbesac
1281.45Sapb
1291.9SlukemoIFS=$IFS
1301.9SlukemIFS="
1311.9Slukem"
1321.100Suebayasi
1331.100Suebayasifor x in $(
1341.100Suebayasi	${MAKE} -B -f- all <<EOMAKE
1351.97Suebayasi.include <bsd.own.mk>
1361.97Suebayasiall:
1371.100Suebayasi	@echo "export _MKVARS_yes=\"\${_MKVARS.yes}\""
1381.100Suebayasi	@echo "export _MKVARS_no=\"\${_MKVARS.no}\""
1391.100Suebayasi
1401.97SuebayasiEOMAKE
1411.100Suebayasi); do
1421.100Suebayasi	eval $x
1431.97Suebayasidone
1441.100Suebayasi
1451.9Slukemfor x in $(
1461.43Sapb${MAKE} -B -f- all <<EOMAKE
1471.9Slukem.include <bsd.own.mk>
1481.33Sjmc.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
1491.33SjmcMKMANPAGES=no
1501.33Sjmc.else
1511.33SjmcMKMANPAGES=yes
1521.33Sjmc.endif
1531.72Smrg.if \${MKX11} != "no"
1541.72Smrg. if \${X11FLAVOUR} == "Xorg"
1551.72SmrgMKXORG:=yes
1561.72SmrgMKX11:=no
1571.72Smrg. else
1581.72SmrgMKXORG:=no
1591.72Smrg. endif
1601.72Smrg.endif
1611.9Slukemall:
1621.11Slukem.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
1631.87Sskrll		HAVE_BINUTILS HAVE_GCC HAVE_GDB OBJECT_FMT TOOLCHAIN_MISSING \
1641.100Suebayasi		${MKEXTRAVARS} ${_MKVARS_yes} ${_MKVARS_no}
1651.96Suebayasi	@echo "export \$i=\"\${\$i}\""
1661.11Slukem.endfor
1671.9Slukem
1681.12SlukemEOMAKE
1691.9Slukem); do
1701.100Suebayasi	echo 1>&2 "DEBUG: read $x"
1711.9Slukem	eval $x
1721.9Slukemdone
1731.100Suebayasi
1741.9SlukemIFS=$oIFS
1751.9Slukem
1761.100SuebayasiMKVARS="$MKEXTRAVARS $_MKVARS_yes $_MKVARS_no"
1771.100Suebayasi
1781.34Serhsetsdir=${0%/*}
1791.9Slukemobsolete=0
1801.76Stsutsuimodule=yes
1811.91Sdyoungif [ "${MKKMOD}" = "no" ]; then
1821.91Sdyoung	module=no			# MODULEs are off.
1831.91Sdyoungelif [ "${MACHINE}" = "evbppc" ]; then
1841.76Stsutsui	module=no			# Turn off MODULEs for some ports.
1851.9Slukemfi
1861.31Sjmc# Determine lib type. Do this first so stlib also gets set.
1871.31Sjmcif [ "${OBJECT_FMT}" = "ELF" ]; then
1881.9Slukem	shlib=elf
1891.9Slukemelse
1901.9Slukem	shlib=aout
1911.9Slukemfi
1921.9Slukemstlib=$shlib
1931.31Sjmc# Now check for MKPIC or specials and turn off shlib if need be.
1941.31Sjmcif [ "${MKPIC}" = "no" ]; then
1951.31Sjmc	shlib=no
1961.31Sjmcfi
1971.29Suweif [ "${MACHINE_ARCH}" = "m68000" ]; then
1981.9Slukem	shlib=no			# Turn off shlibs for some ports.
1991.9Slukemfi
2001.86Sjnemethif [ "$module" != "no" ]; then
2011.86Sjnemeth	nlists="base comp etc games man misc modules tests text"
2021.86Sjnemethelse
2031.86Sjnemeth	nlists="base comp etc games man misc tests text"
2041.86Sjnemethfi
2051.86Sjnemethxlists="xbase xcomp xetc xfont xserver"
2061.92Suebayasiextlists="extbase extcomp extetc"
2071.9Slukem
2081.64SheOSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
2091.81SrmindMODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
2101.62SadSUBST="s#@MODULEDIR@#${MODULEDIR}#g"
2111.62SadSUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
2121.62SadSUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
2131.60Sad
2141.9Slukem#
2151.9Slukem# list_set_files setfile [...]
2161.1Sdyoung# 
2171.9Slukem# Produce a packing list for setfile(s).
2181.9Slukem# In each file, a record consists of a path and a System Package name,
2191.9Slukem# separated by whitespace. E.g.,
2201.9Slukem#
2211.100Suebayasi# 	# $NetBSD: sets.subr,v 1.100 2009/12/02 17:51:30 uebayasi Exp $
2221.9Slukem# 	.			base-sys-root	[keyword[,...]]
2231.9Slukem# 	./altroot		base-sys-root
2241.9Slukem# 	./bin			base-sys-root
2251.9Slukem# 	./bin/[			base-util-root
2261.9Slukem# 	./bin/cat		base-util-root
2271.9Slukem#		[...]
2281.9Slukem#
2291.9Slukem# A # in the first column marks a comment.
2301.9Slukem#
2311.9Slukem# If ${obsolete} != 0, only entries with an "obsolete" keyword will
2321.52Slukem# be printed.  All other keywords must be present.
2331.9Slukem#
2341.9Slukem# The third field is an optional comma separated list of keywords to
2351.9Slukem# control if a record is printed; every keyword listed must be enabled
2361.9Slukem# for the record to be printed.  The following keywords are available:
2371.9Slukem#	dummy			dummy entry (ignored)
2381.13Slukem#	obsolete		file is obsolete, and only printed if 
2391.13Slukem#				${obsolete} != 0
2401.13Slukem#
2411.87Sskrll#	bfd			obsolete, use binutils.
2421.87Sskrll#	binutils		${MKBINUTILS} != no
2431.22Slukem#	catpages		${MKCATPAGES} != no
2441.71Smrg#	compat			${MKCOMPAT} != no
2451.22Slukem#	crypto			${MKCRYPTO} != no
2461.22Slukem#	crypto_idea		${MKCRYPTO_IDEA} != no
2471.22Slukem#	crypto_mdc2		${MKCRYPTO_MDC2} != no
2481.22Slukem#	crypto_rc5		${MKCRYPTO_RC5} != no
2491.22Slukem#	cvs			${MKCVS} != no
2501.53Slukem#	debug			${MKDEBUG} != no
2511.69Slukem#	debuglib		${MKDEBUGLIB} != no
2521.23Slukem#	doc			${MKDOC} != no
2531.67Slukem#	dynamicroot		${MKDYNAMICROOT} != no
2541.92Suebayasi#	extsrc			${MKEXTSRC} != no
2551.52Slukem#	gcc			${MKGCC} != no
2561.36Smatt#	gcccmds			${MKGCCCMDS} != no
2571.32Sscw#	gdb			${MKGDB} != no
2581.22Slukem#	hesiod			${MKHESIOD} != no
2591.68Slukem#	html			${MKHTML} != no
2601.67Slukem#	inet6			${MKINET6} != no
2611.23Slukem#	info			${MKINFO} != no
2621.39Speter#	ipfilter		${MKIPFILTER} != no
2631.51Smrg#	iscsi			${MKISCSI} != no
2641.22Slukem#	kerberos		${MKKERBEROS} != no
2651.85Sdyoung#	kmod			${MKKMOD} != no
2661.67Slukem#	ldap			${MKLDAP} != no
2671.22Slukem#	lint			${MKLINT} != no
2681.78Sagc#	lvm			${MKLVM} != no
2691.22Slukem#	man			${MKMAN} != no
2701.67Slukem#	manpages		${MKMANPAGES} != no
2711.22Slukem#	manz			${MKMANZ} != no
2721.88Stsarna#	mdns			${MKMDNS} != no
2731.23Slukem#	nls			${MKNLS} != no
2741.66Sdyoung#	nvi			${MKNVI} != no
2751.37She#	pam			${MKPAM} != no
2761.39Speter#	pf			${MKPF} != no
2771.67Slukem#	pic			${MKPIC} != no
2781.22Slukem#	postfix			${MKPOSTFIX} != no
2791.22Slukem#	profile			${MKPROFILE} != no
2801.24Slukem#	share			${MKSHARE} != no
2811.22Slukem#	skey			${MKSKEY} != no
2821.73Smrg#	x11			${MKX11} != no && ${X11FLAVOUR} != "Xorg"
2831.73Smrg#	xorg			${MKX11} != no && ${X11FLAVOUR} == "Xorg"
2841.22Slukem#	yp			${MKYP} != no
2851.89Shaad#	zfs			${MKZFS} != no
2861.22Slukem#
2871.87Sskrll#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
2881.52Slukem#	gcc=<n>			<n> = value of ${HAVE_GCC}
2891.52Slukem#	gdb=<n>			<n> = value of ${HAVE_GDB}
2901.52Slukem#
2911.41Slukem#	use_inet6		${USE_INET6} != no
2921.41Slukem#	use_kerberos		${USE_KERBEROS} != no
2931.41Slukem#	use_yp			${USE_YP} != no
2941.41Slukem#
2951.22Slukem#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
2961.22Slukem#				  automatically append ".gz" to the filename
2971.22Slukem#
2981.22Slukem#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
2991.22Slukem#				  automatically append ".gz" to the filename
3001.1Sdyoung#
3011.8Slukemlist_set_files()
3021.8Slukem{
3031.83Sapb	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
3041.65She		verbose=false
3051.65She	else
3061.65She		verbose=true
3071.65She	fi
3081.1Sdyoung	for setname; do
3091.65She		list=`list_set_lists $setname`
3101.65She		for l in $list; do
3111.65She			echo $l
3121.65She			if $verbose; then
3131.82Sapb				echo >&2 "DEBUG: list_set_files: $l"
3141.65She			fi
3151.65She		done
3161.62Sad	done | xargs cat | ${SED} ${SUBST} | \
3171.43Sapb	${AWK} -v obsolete=${obsolete} '
3181.9Slukem		BEGIN {
3191.52Slukem			if (obsolete)
3201.52Slukem				wanted["obsolete"] = 1
3211.52Slukem		
3221.100Suebayasi			split("'"${MKVARS}"'", needvars)
3231.52Slukem			for (vi in needvars) {
3241.52Slukem				nv = needvars[vi]
3251.52Slukem				kw = tolower(nv)
3261.52Slukem				sub(/^mk/, "", kw)
3271.52Slukem				if (ENVIRON[nv] != "no")
3281.52Slukem					wanted[kw] = 1 
3291.52Slukem			}
3301.52Slukem
3311.52Slukem			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
3321.90Sdyoung				if ("binutils" in wanted)
3331.90Sdyoung					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
3341.90Sdyoung				if ("gcc" in wanted)
3351.90Sdyoung					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
3361.90Sdyoung				if ("gdb" in wanted)
3371.90Sdyoung					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
3381.9Slukem			}
3391.52Slukem			if (("man" in wanted) && ("catpages" in wanted))
3401.52Slukem				wanted[".cat"] = 1
3411.52Slukem			if (("man" in wanted) && ("manpages" in wanted))
3421.52Slukem				wanted[".man"] = 1
3431.9Slukem		}
3441.9Slukem
3451.9Slukem		/^#/ {
3461.9Slukem			next;
3471.9Slukem		}
3481.9Slukem
3491.9Slukem		NF > 2 && $3 != "-" {
3501.9Slukem			split($3, keywords, ",")
3511.9Slukem			show = 1
3521.52Slukem			haveobs = 0
3531.9Slukem			for (ki in keywords) {
3541.9Slukem				kw = keywords[ki]
3551.22Slukem				if (("manz" in wanted) &&
3561.22Slukem				    (kw == ".cat" || kw == ".man"))
3571.22Slukem					$1 = $1 ".gz"
3581.59Sjmmv				negated = match(kw, "! *")
3591.59Sjmmv				if (negated > 0) {
3601.59Sjmmv					kw = substr(kw, RSTART + RLENGTH)
3611.59Sjmmv					if (kw in wanted)
3621.59Sjmmv						show = 0
3631.59Sjmmv				} else {
3641.59Sjmmv					if (! (kw in wanted))
3651.59Sjmmv						show = 0
3661.59Sjmmv				}
3671.52Slukem				if (kw == "obsolete")
3681.52Slukem					haveobs = 1
3691.9Slukem			}
3701.52Slukem			if (obsolete && ! haveobs)
3711.52Slukem				next
3721.9Slukem			if (show)
3731.9Slukem				print
3741.9Slukem			next
3751.9Slukem		}
3761.9Slukem
3771.9Slukem		{
3781.9Slukem			if (! obsolete)
3791.9Slukem				print
3801.9Slukem		}'
3811.9Slukem
3821.1Sdyoung}
3831.1Sdyoung
3841.1Sdyoung#
3851.1Sdyoung# list_set_lists setname
3861.1Sdyoung# 
3871.1Sdyoung# Print to stdout a list of files, one filename per line, which
3881.1Sdyoung# concatenate to create the packing list for setname. E.g.,
3891.1Sdyoung#
3901.1Sdyoung# 	.../lists/base/mi
3911.1Sdyoung# 	.../lists/base/rescue.mi
3921.1Sdyoung# 	.../lists/base/md.i386
3931.9Slukem#		[...]
3941.1Sdyoung#
3951.9Slukem# For a given setname $set, the following files may be selected from
3961.9Slukem# .../list/$set:
3971.9Slukem#	mi
3981.92Suebayasi#	mi.ext.*
3991.11Slukem#	ad.${MACHINE_ARCH}
4001.11Slukem# (or)	ad.${MACHINE_CPU}
4011.11Slukem#	ad.${MACHINE_CPU}.shl
4021.11Slukem#	md.${MACHINE}.${MACHINE_ARCH}
4031.11Slukem# (or)	md.${MACHINE}
4041.9Slukem#	stl.mi
4051.92Suebayasi#	stl.${stlib}
4061.9Slukem#	shl.mi
4071.92Suebayasi#	shl.mi.ext.*
4081.92Suebayasi#	shl.${shlib}
4091.92Suebayasi#	shl.${shlib}.ext.*
4101.77Stsutsui#	module.mi			if ${module} != no
4111.77Stsutsui#	module.${MACHINE}		if ${module} != no
4121.77Stsutsui#	module.ad.${MACHINE_ARCH}	if ${module} != no
4131.77Stsutsui# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
4141.9Slukem#	rescue.shl
4151.11Slukem#	rescue.${MACHINE}
4161.11Slukem#	rescue.ad.${MACHINE_ARCH}
4171.11Slukem# (or)	rescue.ad.${MACHINE_CPU}
4181.11Slukem# 	rescue.ad.${MACHINE_CPU}.shl
4191.1Sdyoung#
4201.9Slukem# Environment:
4211.1Sdyoung# 	shlib
4221.1Sdyoung# 	stlib
4231.1Sdyoung#
4241.8Slukemlist_set_lists()
4251.8Slukem{
4261.1Sdyoung	setname=$1
4271.1Sdyoung
4281.9Slukem	setdir=$setsdir/lists/$setname
4291.9Slukem	echo $setdir/mi
4301.92Suebayasi	for _extsrc_pkg in ${EXTSRCS}; do
4311.92Suebayasi		if [ -f $setdir/mi.ext.${_extsrc_pkg} ]; then
4321.92Suebayasi			echo $setdir/mi.ext.${_extsrc_pkg}
4331.92Suebayasi		fi
4341.92Suebayasi	done
4351.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4361.11Slukem		# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
4371.1Sdyoung		# since the arch-specific one will be more specific than
4381.1Sdyoung		# the cpu-specific one.
4391.11Slukem		if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
4401.11Slukem			echo $setdir/ad.${MACHINE_ARCH}
4411.11Slukem		elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
4421.11Slukem			echo $setdir/ad.${MACHINE_CPU}
4431.1Sdyoung		fi
4441.1Sdyoung		if [ "$shlib" != "no" -a \
4451.11Slukem		     -f $setdir/ad.${MACHINE_CPU}.shl ]; then
4461.11Slukem			echo $setdir/ad.${MACHINE_CPU}.shl
4471.1Sdyoung		fi
4481.1Sdyoung	fi
4491.11Slukem	if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
4501.11Slukem		echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
4511.11Slukem	elif [ -f $setdir/md.${MACHINE} ]; then
4521.11Slukem		echo $setdir/md.${MACHINE}
4531.1Sdyoung	fi
4541.9Slukem	if [ -f $setdir/stl.mi ]; then
4551.9Slukem		echo $setdir/stl.mi
4561.1Sdyoung	fi
4571.9Slukem	if [ -f $setdir/stl.${stlib} ]; then
4581.9Slukem		echo $setdir/stl.${stlib}
4591.1Sdyoung	fi
4601.1Sdyoung	if [ "$shlib" != "no" ]; then
4611.9Slukem		if [ -f $setdir/shl.mi ]; then
4621.9Slukem			echo $setdir/shl.mi
4631.7Sdyoung		fi
4641.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4651.92Suebayasi			if [ -f $setdir/shl.mi.ext.${_extsrc_pkg} ]; then
4661.92Suebayasi				echo $setdir/shl.mi.ext.${_extsrc_pkg}
4671.92Suebayasi			fi
4681.92Suebayasi		done
4691.9Slukem		if [ -f $setdir/shl.${shlib} ]; then
4701.9Slukem			echo $setdir/shl.${shlib}
4711.7Sdyoung		fi
4721.92Suebayasi		for _extsrc_pkg in ${EXTSRCS}; do
4731.92Suebayasi			if [ -f $setdir/shl.${shlib}.ext.${_extsrc_pkg} ]; then
4741.92Suebayasi				echo $setdir/shl.${shlib}.ext.${_extsrc_pkg}
4751.92Suebayasi			fi
4761.92Suebayasi		done
4771.1Sdyoung	fi
4781.76Stsutsui	if [ "$module" != "no" ]; then
4791.76Stsutsui		if [ -f $setdir/module.mi ]; then
4801.76Stsutsui			echo $setdir/module.mi
4811.1Sdyoung		fi
4821.77Stsutsui		if [ -f $setdir/module.${MACHINE} ]; then
4831.77Stsutsui			echo $setdir/module.${MACHINE}
4841.77Stsutsui		fi
4851.77Stsutsui		if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
4861.77Stsutsui			# Prefer a module.ad.${MACHINE_ARCH} over a
4871.77Stsutsui			# module.ad.${MACHINE_CPU}, since the arch-
4881.77Stsutsui			# specific one will be more specific than the
4891.77Stsutsui			# cpu-specific one.
4901.77Stsutsui			if [ -f $setdir/module.ad.${MACHINE_ARCH} ]; then
4911.77Stsutsui				echo $setdir/module.ad.${MACHINE_ARCH}
4921.77Stsutsui			elif [ -f $setdir/module.ad.${MACHINE_CPU} ]; then
4931.77Stsutsui				echo $setdir/module.ad.${MACHINE_CPU}
4941.77Stsutsui			fi
4951.77Stsutsui		fi
4961.1Sdyoung	fi
4971.1Sdyoung
4981.9Slukem	if [ -f $setdir/rescue.mi ]; then
4991.9Slukem		echo $setdir/rescue.mi
5001.1Sdyoung	fi
5011.11Slukem	if [ -f $setdir/rescue.${MACHINE} ]; then
5021.11Slukem		echo $setdir/rescue.${MACHINE}
5031.1Sdyoung	fi
5041.11Slukem	if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
5051.11Slukem		# Prefer a rescue.ad.${MACHINE_ARCH} over a
5061.11Slukem		# rescue.ad.${MACHINE_CPU}, since the arch-
5071.1Sdyoung		# specific one will be more specific than the
5081.1Sdyoung		# cpu-specific one.
5091.11Slukem		if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
5101.11Slukem			echo $setdir/rescue.ad.${MACHINE_ARCH}
5111.11Slukem		elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
5121.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}
5131.1Sdyoung		fi
5141.10Sjmc		if [ "$shlib" != "no" -a \
5151.11Slukem		     -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
5161.11Slukem			echo $setdir/rescue.ad.${MACHINE_CPU}.shl
5171.10Sjmc		fi
5181.1Sdyoung	fi
5191.5Sdyoung}
5201.5Sdyoung
5211.9Slukem# arch_to_cpu mach
5221.9Slukem#
5231.11Slukem# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
5241.9Slukem# as determined by <bsd.own.mk>.
5251.9Slukem#
5261.8Slukemarch_to_cpu()
5271.8Slukem{
5281.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5291.5Sdyoung.include <bsd.own.mk>
5301.5Sdyoungall:
5311.5Sdyoung	@echo \${MACHINE_CPU}
5321.12SlukemEOMAKE
5331.1Sdyoung}
5341.46Sapb
5351.46Sapb# arch_to_endian mach
5361.46Sapb#
5371.46Sapb# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
5381.46Sapb# as determined by <bsd.endian.mk>.
5391.46Sapb#
5401.46Sapbarch_to_endian()
5411.46Sapb{
5421.56Sapb	MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
5431.46Sapb.include <bsd.endian.mk>
5441.46Sapball:
5451.46Sapb	@echo \${TARGET_ENDIANNESS}
5461.46SapbEOMAKE
5471.46Sapb}
548