NetBSD/distrib/sets/makeplist

120 lines
2.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# Print out the files in some or all lists.
2003-06-01 02:56:37 +04:00
# Usage: makeplist [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
#
# set defaults
MAKE="${MAKE:-make} -j 1"
machine=${MACHINE:-`printf 'xxx:\n\techo ${MACHINE}' | ${MAKE} -s -f-`}
arch=${MACHINE_ARCH:-`printf 'xxx:\n\techo ${MACHINE_ARCH}' | ${MAKE} -s -f-`}
setd=`dirname $0`
prefix=/
usage() {
exec 1>&2
echo "Usage: $0 [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname"
echo " -a arch set arch (e.g, m68k, mips, powerpc) [$arch]"
echo " -m machine set machine (e.g, amiga, i386, macppc) [$machine]"
echo " -s setsdir directory to find sets [$setd]"
echo " -p prefix prefix for created plist [$prefix]"
echo " setname pkgname set and package to build plist for"
exit 1
}
# handle args
while : ; do
case $1 in
-a*)
arch=$2; shift
;;
-m*)
machine=$2; shift
;;
-s*)
setd=$2; shift
;;
-p*)
prefix=$2; shift
;;
-*)
usage
exit 1
;;
*)
break
;;
esac
shift
done
if [ -n "$1" ]; then
setname="$1"
else
usage
exit 1
fi
if [ -n "$2" ]; then
pkgname=$2
else
usage
exit 1
fi
# Convert mipse[lb] to mips after processing command line arguments.
arch=`echo $arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3,`
# Compute toolchain used on target cpu.
case "$machine" in
ns32k) shlib=aout ;;
*) case "$arch" in
sh3) shlib="" ;;
*) shlib=elf ;;
esac
esac
filename=/tmp/makeplist.$$
ffilename=/tmp/makeplist.files.$$
dfilename=/tmp/makeplist.dirs.$$
echo "@cwd $prefix" > $filename
(
cat $setd/lists/$setname/mi
# where does cpu get set? XXX - agc
if [ "$machine" != "$cpu" -a -f $setd/lists/$setname/ad.${arch} ]; then
cat $setd/lists/$setname/ad.${arch}
fi
if [ -f $setd/lists/$setname/md.${machine} ]; then
cat $setd/lists/$setname/md.${machine}
fi
if [ "$shlib" != "" ]; then
if [ -f $setd/lists/$setname/shl.mi ]; then
cat $setd/lists/$setname/shl.mi
fi
if [ -f $setd/lists/$setname/shl.${shlib} ]; then
cat $setd/lists/$setname/shl.${shlib}
fi
fi
)| env PLISTPKG=$pkgname awk -- '/^#/ { next } $2 == ENVIRON["PLISTPKG"] {sub("^\./", "", $1); print $1}' | sort -u >> $filename
env FFILENAME=$ffilename DFILENAME=$dfilename awk '
/^@cwd/ { prefix = $2; next }
{
s = sprintf("if [ -d %s%s ]; then echo @dirrm %s >> %s; else echo %s >> %s; fi", prefix, $0, $0, ENVIRON["DFILENAME"], $0, ENVIRON["FFILENAME"]);
system(s);
}' $filename
echo "@cwd $prefix"
if [ -s $ffilename ]; then
cat $ffilename
fi
if [ -s $dfilename ]; then
sort -r $dfilename
fi
rm -f $filename $ffilename $dfilename
exit 0