makeplist revision 1.7
11.1Sjwise#!/bin/sh 21.1Sjwise# 31.1Sjwise# Print out the files in some or all lists. 41.4Sdyoung# Usage: makeplist [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname 51.1Sjwise# 61.1Sjwise 71.1Sjwise# set defaults 81.3SlukemMAKE="${MAKE:-make} -j 1" 91.3Slukemmachine=${MACHINE:-`printf 'xxx:\n\techo ${MACHINE}' | ${MAKE} -s -f-`} 101.3Slukemarch=${MACHINE_ARCH:-`printf 'xxx:\n\techo ${MACHINE_ARCH}' | ${MAKE} -s -f-`} 111.1Sjwisesetd=`dirname $0` 121.1Sjwiseprefix=/ 131.1Sjwise 141.1Sjwiseusage() { 151.1Sjwiseexec 1>&2 161.1Sjwise 171.1Sjwiseecho "Usage: $0 [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname" 181.1Sjwiseecho " -a arch set arch (e.g, m68k, mips, powerpc) [$arch]" 191.1Sjwiseecho " -m machine set machine (e.g, amiga, i386, macppc) [$machine]" 201.1Sjwiseecho " -s setsdir directory to find sets [$setd]" 211.5Sdyoungecho " -p prefix prefix for created plist [$prefix]" 221.1Sjwiseecho " setname pkgname set and package to build plist for" 231.1Sjwise 241.1Sjwiseexit 1 251.1Sjwise} 261.1Sjwise 271.1Sjwise# handle args 281.1Sjwisewhile : ; do 291.1Sjwise case $1 in 301.1Sjwise -a*) 311.1Sjwise arch=$2; shift 321.1Sjwise ;; 331.1Sjwise -m*) 341.1Sjwise machine=$2; shift 351.1Sjwise ;; 361.1Sjwise -s*) 371.1Sjwise setd=$2; shift 381.1Sjwise ;; 391.1Sjwise -p*) 401.1Sjwise prefix=$2; shift 411.1Sjwise ;; 421.1Sjwise -*) 431.1Sjwise usage 441.1Sjwise exit 1 451.1Sjwise ;; 461.1Sjwise *) 471.1Sjwise break 481.1Sjwise ;; 491.1Sjwise esac 501.1Sjwise shift 511.1Sjwisedone 521.1Sjwiseif [ -n "$1" ]; then 531.1Sjwise setname="$1" 541.1Sjwiseelse 551.1Sjwise usage 561.1Sjwise exit 1 571.1Sjwisefi 581.1Sjwiseif [ -n "$2" ]; then 591.1Sjwise pkgname=$2 601.1Sjwiseelse 611.1Sjwise usage 621.1Sjwise exit 1 631.1Sjwisefi 641.1Sjwise 651.1Sjwise# Convert mipse[lb] to mips after processing command line arguments. 661.1Sjwisearch=`echo $arch | sed s,^mipse.,mips, | sed s,^sh3e.,sh3,` 671.1Sjwise 681.1Sjwise# Compute toolchain used on target cpu. 691.7Sagccase "$machine" in 701.7Sagcns32k) shlib=aout ;; 711.7Sagc*) case "$arch" in 721.7Sagc sh3) shlib="" ;; 731.7Sagc *) shlib=elf ;; 741.7Sagc esac 751.7Sagcesac 761.7Sagc 771.7Sagcfilename=/tmp/makeplist.$$ 781.7Sagcffilename=/tmp/makeplist.files.$$ 791.7Sagcdfilename=/tmp/makeplist.dirs.$$ 801.7Sagc 811.7Sagcecho "@cwd $prefix" > $filename 821.7Sagc( 831.7Sagc cat $setd/lists/$setname/mi 841.7Sagc# where does cpu get set? XXX - agc 851.7Sagc if [ "$machine" != "$cpu" -a -f $setd/lists/$setname/ad.${arch} ]; then 861.7Sagc cat $setd/lists/$setname/ad.${arch} 871.7Sagc fi 881.7Sagc if [ -f $setd/lists/$setname/md.${machine} ]; then 891.7Sagc cat $setd/lists/$setname/md.${machine} 901.7Sagc fi 911.7Sagc if [ "$shlib" != "" ]; then 921.7Sagc if [ -f $setd/lists/$setname/shl.mi ]; then 931.7Sagc cat $setd/lists/$setname/shl.mi 941.7Sagc fi 951.7Sagc if [ -f $setd/lists/$setname/shl.${shlib} ]; then 961.7Sagc cat $setd/lists/$setname/shl.${shlib} 971.7Sagc fi 981.7Sagc fi 991.7Sagc)| env PLISTPKG=$pkgname awk -- '/^#/ { next } $2 == ENVIRON["PLISTPKG"] {sub("^\./", "", $1); print $1}' | sort -u >> $filename 1001.7Sagc 1011.7Sagcenv FFILENAME=$ffilename DFILENAME=$dfilename awk ' 1021.7Sagc/^@cwd/ { prefix = $2; next } 1031.7Sagc{ 1041.7Sagc s = sprintf("if [ -d %s%s ]; then echo @dirrm %s >> %s; else echo %s >> %s; fi", prefix, $0, $0, ENVIRON["DFILENAME"], $0, ENVIRON["FFILENAME"]); 1051.7Sagc system(s); 1061.7Sagc}' $filename 1071.7Sagc 1081.7Sagcecho "@cwd $prefix" 1091.7Sagcif [ -s $ffilename ]; then 1101.7Sagc cat $ffilename 1111.1Sjwisefi 1121.7Sagcif [ -s $dfilename ]; then 1131.7Sagc sort -r $dfilename 1141.7Sagcfi 1151.7Sagc 1161.7Sagcrm -f $filename $ffilename $dfilename 1171.7Sagc 1181.7Sagcexit 0 1191.1Sjwise 120