Home | History | Annotate | Line # | Download | only in sets
      1 #!/bin/sh
      2 #
      3 # $NetBSD: makeflist,v 1.80 2023/11/08 13:02:47 christos Exp $
      4 #
      5 # Print out the files in some or all lists.
      6 # Usage: makeflist [-bxlo] [-a arch] [-m machine] [-s setsdir] [setname ...]
      7 #
      8 
      9 rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
     10 . "${rundir}/sets.subr"
     11 lists=
     12 
     13 usage()
     14 {
     15 	cat 1>&2 <<USAGE
     16 Usage: ${0##*/} [-L base,x] [-bxo] [-a arch] [-m machine] [-s setsdir] [setname [...]]
     17 	-L base,x	print specified lists
     18 	-b		print netbsd + x11 lists
     19 	-x		print make x11 lists
     20 	-l		just list the selected set names, not the contents
     21 	-o		only match obsolete files
     22 	-a arch		set arch (e.g, m68k, mipseb, mipsel, powerpc) [${MACHINE_ARCH}]
     23 	-m machine	set machine (e.g, amiga, i386, macppc) [${MACHINE}]
     24 	-s setsdir	directory to find sets [${setsdir}]
     25 	[setname [...]]	sets to build [${lists}]
     26 USAGE
     27 	exit 1
     28 }
     29 
     30 umask 022
     31 # handle args
     32 while getopts L:bxloa:m:s: ch; do
     33 	case ${ch} in
     34 	L)
     35 		save_IFS="${IFS}"
     36 		IFS=,
     37 		for _list in ${OPTARG}; do
     38 			case $_list in
     39 			base)	lists="${lists} ${nlists}" ;;
     40 			x)	lists="${lists} ${xlists}" ;;
     41 			esac
     42 		done
     43 		IFS="${save_IFS}"
     44 		;;
     45 	# backward compat
     46 	b)
     47 		lists="${nlists} ${xlists}"
     48 		;;
     49 	x)
     50 		lists="${xlists}"
     51 		;;
     52 	l)
     53 		listonly=1
     54 		;;
     55 	o)
     56 		obsolete=1
     57 		;;
     58 	a)
     59 		MACHINE_ARCH="${OPTARG}"
     60 		MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
     61 		;;
     62 	m)
     63 		MACHINE="${OPTARG}"
     64 		;;
     65 	s)
     66 		setsdir="${OPTARG}"
     67 		;;
     68 	*)
     69 		usage
     70 		;;
     71 	esac
     72 done
     73 shift $((${OPTIND} - 1))
     74 if [ -n "$1" ]; then
     75 	lists="$*"
     76 fi
     77 
     78 if [ -n "${listonly}" ]; then
     79 	echo ${lists} | tr ' ' '\n'
     80 	exit 0
     81 fi
     82 
     83 list_set_files ${lists:-${nlists}} | ${AWK} '{print $1}' | ${SORT} -u
     84