makeplist revision 1.8
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.8Sdyoungfor x in $(
91.8Sdyoung${MAKE:-make} -f- all <<EOF
101.8Sdyoung.include <bsd.own.mk>
111.8Sdyoungall:
121.8Sdyoung	@echo machine=\${MACHINE}
131.8Sdyoung	@echo machine_arch=\${MACHINE_ARCH}
141.8Sdyoung	@echo machine_cpu=\${MACHINE_CPU}
151.8Sdyoung	@echo object_fmt=\${OBJECT_FMT}
161.8Sdyoung	@echo toolchain_missing=\${TOOLCHAIN_MISSING}
171.8Sdyoung.if defined(USE_XF86_4) && (\${USE_XF86_4} != no)
181.8Sdyoung	@echo x11_version=4
191.8Sdyoung.else
201.8Sdyoung	@echo x11_version=3
211.8Sdyoung.endif
221.8Sdyoung
231.8SdyoungEOF
241.8Sdyoung); do
251.8Sdyoung	eval $x
261.8Sdyoungdone
271.8Sdyoung
281.8Sdyoung. ./sets.subr
291.1Sjwisesetd=`dirname $0`
301.1Sjwiseprefix=/
311.1Sjwise
321.1Sjwiseusage() {
331.1Sjwiseexec 1>&2
341.1Sjwise
351.1Sjwiseecho "Usage: $0 [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname"
361.8Sdyoungecho "	-a arch		set arch (e.g, m68k, mips, powerpc)	[$machine_arch]"
371.1Sjwiseecho "	-m machine	set machine (e.g, amiga, i386, macppc)	[$machine]"
381.1Sjwiseecho "	-s setsdir	directory to find sets			[$setd]"
391.5Sdyoungecho "	-p prefix	prefix for created plist		[$prefix]"
401.1Sjwiseecho "	setname pkgname	set and package to build plist for"
411.1Sjwise
421.1Sjwiseexit 1
431.1Sjwise}
441.1Sjwise
451.1Sjwise# handle args
461.1Sjwisewhile : ; do
471.1Sjwise	case $1 in
481.1Sjwise	-a*)
491.8Sdyoung		machine_arch=$2; shift
501.1Sjwise		;;
511.1Sjwise	-m*)
521.1Sjwise		machine=$2; shift
531.1Sjwise		;;
541.1Sjwise	-s*)
551.1Sjwise		setd=$2; shift
561.1Sjwise		;;
571.1Sjwise	-p*)
581.1Sjwise		prefix=$2; shift
591.1Sjwise		;;
601.1Sjwise	-*)
611.1Sjwise		usage
621.1Sjwise		;;
631.1Sjwise	*)
641.1Sjwise		break
651.1Sjwise		;;
661.1Sjwise	esac
671.1Sjwise	shift
681.1Sjwisedone
691.1Sjwiseif [ -n "$1" ]; then
701.1Sjwise	setname="$1"
711.1Sjwiseelse
721.1Sjwise	usage
731.1Sjwisefi
741.1Sjwiseif [ -n "$2" ]; then
751.1Sjwise	pkgname=$2
761.1Sjwiseelse
771.1Sjwise	usage
781.1Sjwisefi
791.1Sjwise
801.8Sdyoung# Determine lib type.
811.8Sdyoungif [ "$object_fmt" = "ELF" ]; then
821.8Sdyoung	shlib=elf
831.8Sdyoungelse
841.8Sdyoung	shlib=aout
851.8Sdyoungfi
861.8Sdyoungstlib=$shlib
871.1Sjwise
881.8Sdyoung# Turn off shlibs for some ports.
891.8Sdyoungif [ "$machine_cpu" = "sh3" -o "$machine_arch" = "m68000" ]; then
901.8Sdyoung	shlib=no
911.8Sdyoungfi
921.8Sdyounglkm=yes
931.8Sdyoung# Turn off LKMs for some ports.
941.8Sdyoungif [ "$machine" = "evbppc" ]; then
951.8Sdyoung	lkm=no
961.8Sdyoungfi
971.7Sagc
981.7Sagcfilename=/tmp/makeplist.$$ 
991.7Sagcffilename=/tmp/makeplist.files.$$ 
1001.7Sagcdfilename=/tmp/makeplist.dirs.$$ 
1011.7Sagc
1021.8Sdyounglist_set_files $setname | \
1031.8Sdyoungenv PLISTPKG=$pkgname awk -- '/^#/ { next } $2 == ENVIRON["PLISTPKG"] {sub("^\./", "", $1); print $1}' | sort -u > $filename
1041.8Sdyoung
1051.8SdyoungSELECTDIRS="-maxdepth 0 -type d"
1061.8SdyoungSELECTNONDIRS="-maxdepth 0 ! -type d"
1071.8Sdyoung
1081.8Sdyoungcd $prefix
1091.8Sdyoung#
1101.8Sdyoung# match the directories
1111.8Sdyoung#
1121.8Sdyoungxargs echo $SELECTDIRS < $filename | \
1131.8Sdyoungwhile read ignore ignore ignore ignore args; do
1141.8Sdyoung	[ -z "$args" ] && break 
1151.8Sdyoung	find $args $SELECTDIRS
1161.8Sdyoungdone | awk '{ print "@dirrm " $1; }' > $dfilename
1171.8Sdyoung
1181.8Sdyoung#
1191.8Sdyoung# match the non-directories
1201.8Sdyoung#
1211.8Sdyoungxargs echo $SELECTNONDIRS < $filename | \
1221.8Sdyoungwhile read ignore ignore ignore ignore ignore args; do
1231.8Sdyoung	[ -z "$args" ] && break 
1241.8Sdyoung	find $args $SELECTNONDIRS
1251.8Sdyoungdone > $ffilename
1261.8Sdyoung
1271.8Sdyoungcd -
1281.7Sagc
1291.7Sagcecho "@cwd $prefix"
1301.7Sagcif [ -s $ffilename ]; then
1311.7Sagc	cat $ffilename
1321.1Sjwisefi
1331.7Sagcif [ -s $dfilename ]; then
1341.7Sagc        sort -r $dfilename
1351.7Sagcfi
1361.7Sagc
1371.7Sagcrm -f $filename $ffilename $dfilename
1381.7Sagc
1391.7Sagcexit 0
1401.1Sjwise
141