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