1#!/bin/sh
2#
3# $NetBSD: makeflist,v 1.76 2009/12/05 15:56:25 cegger 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=
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		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			ext)	lists="${lists} ${extlists}" ;;
42			esac
43		done
44		IFS="${save_IFS}"
45		;;
46	# backward compat
47	b)
48		lists="${nlists} ${xlists}"
49		;;
50	x)
51		lists="${xlists}"
52		;;
53	y)
54		lists="${extlists}"
55		;;
56	l)
57		listonly=1
58		;;
59	o)
60		obsolete=1
61		;;
62	a)
63		MACHINE_ARCH="${OPTARG}"
64		MACHINE_CPU="$(arch_to_cpu "${OPTARG}")"
65		;;
66	m)
67		MACHINE="${OPTARG}"
68		;;
69	s)
70		setsdir="${OPTARG}"
71		;;
72	*)
73		usage
74		;;
75	esac
76done
77shift $((${OPTIND} - 1))
78if [ -n "$1" ]; then
79	lists="$*"
80fi
81
82if [ -n "${listonly}" ]; then
83	echo ${lists} | tr ' ' '\n'
84	exit 0
85fi
86
87list_set_files ${lists:-${nlists}} | ${AWK} '{print $1}' | ${SORT} -u
88