Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
#	$NetBSD: sets.subr,v 1.204 2022/09/10 12:31:42 rillig Exp $
#

#
# The following variables contain defaults for sets.subr functions and callers:
#	setsdir			path to src/distrib/sets
#	nlists			list of base sets
#	xlists			list of x11 sets
#	obsolete		controls if obsolete files are selected instead
#	module			if != "no", enable MODULE sets
#	shlib			shared library format (a.out, elf, or "")
#	stlib			static library format (a.out, elf)
#
# The following <bsd.own.mk> variables are exported to the environment:
#	MACHINE
#	MACHINE_ARCH
#	MACHINE_CPU
#	HAVE_ACPI
#	HAVE_BINUTILS
#	HAVE_GCC
#	HAVE_GDB
#	HAVE_NVMM
#	HAVE_OPENSSL
#	HAVE_SSP
#	HAVE_UEFI
#	TOOLCHAIN_MISSING
#	OBJECT_FMT
# as well as:
#

#
# The following variables refer to tools that are used when building sets:
#
: ${AWK:=awk}
: ${CKSUM:=cksum}
: ${COMM:=comm}
: ${DATE:=date}
: ${DB:=db}
: ${EGREP:=egrep}
: ${ENV_CMD:=env}       # ${ENV} is special to sh(1), ksh(1), etc.
: ${FGREP:=fgrep}
: ${FIND:=find}
: ${GREP:=grep}
: ${GZIP_CMD:=gzip}     # ${GZIP} is special to gzip(1)
: ${HOSTNAME_CMD:=hostname}	# ${HOSTNAME} is special to bash(1)
: ${HOST_SH:=sh}
: ${IDENT:=ident}
: ${JOIN:=join}
: ${LS:=ls}
: ${MAKE:=make}
: ${MKTEMP:=mktemp}
: ${MTREE:=mtree}
: ${PASTE:=paste}
: ${PAX:=pax}
: ${PRINTF:=printf}
: ${SED:=sed}
: ${SORT:=sort}
: ${STAT:=stat}
: ${TSORT:=tsort}
: ${UNAME:=uname}
: ${WC:=wc}
: ${XARGS:=xargs}

#
# If printf is a shell builtin command, then we can
# implement cheaper versions of basename and dirname
# that do not involve any fork/exec overhead.
# If printf is not builtin, approximate it using echo,
# and hope there are no weird file names that cause
# some versions of echo to do the wrong thing.
# (Converting to this version of dirname speeded up the
# syspkgdeps script by an order of magnitude, from 68
# seconds to 6.3 seconds on one particular host.)
#
# Note that naive approximations for dirname
# using ${foo%/*} do not do the right thing in cases
# where the result should be "/" or ".".
#
case "$(type printf)" in
*builtin*)
	basename ()
	{
		local bn
		bn="${1##*/}"
		bn="${bn%$2}"
		printf "%s\n" "$bn"
	}
	dirname ()
	{
		local dn
		case "$1" in
		?*/*)	dn="${1%/*}" ;;
		/*)	dn=/ ;;
		*)	dn=. ;;
		esac
		printf "%s\n" "$dn"
	}
	;;
*)
	basename ()
	{
		local bn
		bn="${1##*/}"
		bn="${bn%$2}"
		echo "$bn"
	}
	dirname ()
	{
		local dn
		case "$1" in
		?*/*)	dn="${1%/*}" ;;
		/*)	dn=/ ;;
		*)	dn=. ;;
		esac
		echo "$dn"
	}
	;;
esac

#####

oIFS=$IFS
IFS="
"

for x in $( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do
	eval export $x
done

IFS=$oIFS

MKVARS="$( MAKEVERBOSE= ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )"

#####

setsdir=${rundir}
obsolete=0
if [ "${MKKMOD}" = "no" ]; then
	module=no			# MODULEs are off.
	modset=""
else
	module=yes
	modset="modules"
fi
if [ "${MKATF}" = "no" ]; then
	testset=""
else
	testset="tests"
fi
if [ "${MKDEBUG}" = "no" -a "${MKDEBUGLIB}" = "no" ]; then
	debugset=""
	xdebugset=""
else
	debugset="debug"
	xdebugset="xdebug"
fi
if [ "${MKDTB}" = "no" ]; then
	dtbset=""
else
	dtbset="dtb"
fi
# Determine lib type. Do this first so stlib also gets set.
if [ "${OBJECT_FMT}" = "ELF" ]; then
	shlib=elf
else
	shlib=aout
fi
stlib=$shlib
# Now check for MKPIC or specials and turn off shlib if need be.
if [ "${MKPIC}" = "no" ]; then
	shlib=no
fi
nlists="base comp $debugset $dtbset etc games gpufw man misc $modset rescue $testset text"
xlists="xbase xcomp $xdebugset xetc xfont xserver"

OSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k)
if [ "${KERNEL_DIR}" = "yes" ]; then
	MODULEDIR="netbsd/modules"
else
	MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
fi
SUBST="s#@MODULEDIR@#${MODULEDIR}#g"
SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"

#
# list_set_files setfile [...]
#
# Produce a packing list for setfile(s).
# In each file, a record consists of a path and a System Package name,
# separated by whitespace. E.g.,
#
# 	# $NetBSD: sets.subr,v 1.204 2022/09/10 12:31:42 rillig Exp $
# 	.			base-sys-root	[keyword[,...]]
# 	./altroot		base-sys-root
# 	./bin			base-sys-root
# 	./bin/[			base-util-root
# 	./bin/cat		base-util-root
#		[...]
#
# A # in the first column marks a comment.
#
# If ${obsolete} != 0, only entries with an "obsolete" keyword will
# be printed.  All other keywords must be present.
#
# The third field is an optional comma separated list of keywords to
# control if a record is printed; every keyword listed must be enabled
# for the record to be printed. The list of all available make variables
# that can be turned on or off can be found by running in this directory:
#
#	make -f mkvars.mk mkvarsyesno
#
# These MK<NAME> variables can be used as selectors in the sets as <name>.
#
# The following extra keywords are also available, listed by:
#
#	make -f mkvars.mk mkextravars
#
# These are:
#    1. The HAVE_<name>:
#	ssp			${HAVE_SSP} != no
#	libgcc_eh		${HAVE_LIBGCC_EH} != no
#	acpi			${HAVE_ACPI} != no
#	binutils=<n>		<n> = value of ${HAVE_BINUTILS}
#	gcc=<n>			<n> = value of ${HAVE_GCC}
#	gdb=<n>			<n> = value of ${HAVE_GDB}
#	mesa_ver=<n>		<n> = value of ${HAVE_MESA_VER}
#	nvmm			${HAVE_NVMM} != no
#	openssl=<n>		<n> = value of ${HAVE_OPENSSL}
#	uefi			${HAVE_UEFI} != no
#	xorg_server_ver=<n>	<n> = value of ${HAVE_XORG_SERVER_VER}
#	xorg_glamor		${HAVE_XORG_GLAMOR} != no
#
#    2. The USE_<name>:
#	use_inet6		${USE_INET6} != no
#	use_kerberos		${USE_KERBEROS} != no
#	use_ldap		${USE_LDAP} != no
#	use_yp			${USE_YP} != no
#
#    3. Finally:
#	dummy			dummy entry (ignored)
#	obsolete		file is obsolete, and only printed if
#				${obsolete} != 0
#
#	solaris			${MKDTRACE} != no or ${MKZFS} != no or ${MKCTF} != no
#
#
#	endian=<n>		<n> = value of ${TARGET_ENDIANNESS}
#
#
#	.cat			if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
#				  automatically append ".gz" to the filename
#
#	.man			if ${MKMANZ} != "no" && ${MKMAN} != "no"
#				  automatically append ".gz" to the filename
#
list_set_files()
{
	if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
		verbose=false
	else
		verbose=true
	fi
	local CONFIGS="$( list_kernel_configs )"
	print_set_lists "$@" | \
	${AWK} -v obsolete=${obsolete} '
		function addkmod(line, fname, prefix, pat, patlen) {
			if (substr(line, 1, patlen) != pat) {
				return
			}
			for (d in kmodarchdirs) {
				xd = prefix kmodarchdirs[d]
				xline = xd substr(line, patlen + 1)
				xfname = xd substr(fname, patlen + 1)
				list[xline] = xfname
			}
		}
		function adddebugkernel(line, fname, pat, patlen) {
			if (pat == "" || substr(line, 1, patlen) != pat) {
				return 0
			}
			split("'"${CONFIGS}"'", configs)
			for (d in configs) {
				xfname = fname
				sub("@CONFIG@", configs[d], xfname)
				xline = line;
				sub("@CONFIG@", configs[d], xline)
				list[xline] = xfname
			}
			return 1
		}
		BEGIN {
			if (obsolete)
				wanted["obsolete"] = 1

			split("'"${MKVARS}"'", needvars)
			doingcompat = 0
			doingcompattests = 0
			ignoredkeywords["compatdir"] = 1
			ignoredkeywords["compatfile"] = 1
			ignoredkeywords["compattestdir"] = 1
			ignoredkeywords["compattestfile"] = 1
			ignoredkeywords["compatx11dir"] = 1
			ignoredkeywords["compatx11file"] = 1
			for (vi in needvars) {
				nv = needvars[vi]
				kw = tolower(nv)
				sub(/^mk/, "", kw)
				sub(/^have_/, "", kw)
				sub(/^target_endianness/, "endian", kw)
				if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATARCHDIRS" && nv != "KMODARCHDIRS") {
					wanted[kw] = 1
				}
			}

			if ("compat" in wanted) {
				doingcompat = 1;
				split("'"${COMPATARCHDIRS}"'", compatarchdirs, ",");
				compatdirkeywords["compatdir"] = 1
				compatfilekeywords["compatfile"] = 1

				if (wanted["compattests"]) {
					doingcompattests = 1;
					compatdirkeywords["compattestdir"] = 1
					compatfilekeywords["compattestfile"] = 1
				}
				if (wanted["compatx11"]) {
					doingcompatx11 = 1;
					compatdirkeywords["compatx11dir"] = 1
					compatfilekeywords["compatx11file"] = 1
				}
			}

			if (("kmod" in wanted) && ("compatmodules" in wanted)) {
				split("'"${KMODARCHDIRS}"'", kmodarchdirs, ",");
				kmodprefix = "./stand/"
				kmodpat = kmodprefix ENVIRON["MACHINE"]
				l_kmodpat = length(kmodpat)
				kmoddbprefix = "./usr/libdata/debug/stand/"
				kmoddbpat = kmoddbprefix ENVIRON["MACHINE"]
				l_kmoddbpat = length(kmoddbpat)
			}
			if ("debug" in wanted) {
				debugkernelname = "./usr/libdata/debug/netbsd-@CONFIG@.debug"
				l_debugkernelname = length(debugkernelname);
			}

			if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
				if ("binutils" in wanted)
					wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
				if ("gcc" in wanted)
					wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
				if ("gdb" in wanted)
					wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
			}
			if ("acpi" in wanted) {
				wanted["acpi=" "'"${HAVE_ACPI}"'"] = 1
			}
			if ("mesa_ver" in wanted) {
				wanted["mesa_ver=" "'"${HAVE_MESA_VER}"'"] = 1
			}
			if ("nvmm" in wanted) {
				wanted["nvmm=" "'"${HAVE_NVMM}"'"] = 1
			}
			if ("openssl" in wanted) {
				wanted["openssl=" "'"${HAVE_OPENSSL}"'"] = 1
			}
			if ("xorg_server_ver" in wanted) {
				wanted["xorg_server_ver=" "'"${HAVE_XORG_SERVER_VER}"'"] = 1
			}
			if ("uefi" in wanted) {
				wanted["uefi=" "'"${HAVE_UEFI}"'"] = 1
			}
			if (("man" in wanted) && ("catpages" in wanted))
				wanted[".cat"] = 1
			if (("man" in wanted) && ("manpages" in wanted))
				wanted[".man"] = 1
			if ("endian" in wanted)
				wanted["endian=" "'"${TARGET_ENDIANNESS}"'"] = 1
			if ("machine" in wanted)
				wanted["machine=" "'"${MACHINE}"'"] = 1
			if ("machine_arch" in wanted)
				wanted["machine_arch=" "'"${MACHINE_ARCH}"'"] = 1
			if ("machine_cpu" in wanted)
				wanted["machine_cpu=" "'"${MACHINE_CPU}"'"] = 1
		}

		/^#/ {
			next;
		}

		/^-/ {
			notwanted[substr($1, 2)] = 1;
			delete list [substr($1, 2)];
			next;
		}


		NF > 2 && $3 != "-" {
			if (notwanted[$1] != "")
				next;
			split($3, keywords, ",")
			show = 1
			haveobs = 0
			iscompatfile = 0
			havekmod = 0
			iscompatdir = 0
			for (ki in keywords) {
				kw = keywords[ki]
				if (("manz" in wanted) &&
				    (kw == ".cat" || kw == ".man"))
					$1 = $1 ".gz"
				if (substr(kw, 1, 1) == "!") {
					kw = substr(kw, 2)
					if (kw in wanted)
						show = 0
				} else if (kw in compatdirkeywords) {
					iscompatdir = 1
				} else if (kw in compatfilekeywords) {
					iscompatfile = 1
				} else if (kw == "nocompatmodules") {
					havekmod = -1
				} else if (kw in ignoredkeywords) {
					# ignore
				} else if (! (kw in wanted)) {
					show = 0
				} else if (kw == "kmod" && havekmod == 0) {
					havekmod = 1
				}
				if (kw == "obsolete")
					haveobs = 1
			}
			if (iscompatdir) {
				for (d in cpaths) {
					if (cpaths[d] == $1 "/")
						next
				}
				cpaths[ncpaths++] = $1 "/"
			}
			if (obsolete && ! haveobs)
				next
			if (!show)
				next
			if (adddebugkernel($0, $1, debugkernelname, l_debugkernelname))
				next

			list[$1] = $0
			if (havekmod > 0) {
				addkmod($0, $1, kmodprefix, kmodpat, l_kmodpat)
				addkmod($0, $1, kmoddbprefix, kmoddbpat, l_kmoddbpat)
				next
			}

			if (!doingcompat || !(iscompatfile || iscompatdir))
				next

			if (iscompatfile) {
				emitcompat[$1] = 1;
				next
			}
			for (d in compatarchdirs) {
				tmp = $0
				xfile = $1 "/" compatarchdirs[d]
				tmp = xfile substr(tmp, length($1) + 1)
				if (xfile in notwanted)
					continue;
				sub("compatdir","compat",tmp);
				sub("compattestdir","compat",tmp);
				list[xfile] = tmp
			}
			next
		}

		{
			if ($1 in notwanted)
				next;
			if (! obsolete)
				list[$1] = $0
		}

		END {
			for (i in list) {
				print list[i]
				if (! (i in emitcompat))
					continue;
				l_i = length(i)
				l = 0
				for (j in cpaths) {
					lx = length(cpaths[j])
					if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) {
						continue;
					}
					if (lx > l) {
						l = lx;
						cpath = cpaths[j];
					}
				}
				for (d in compatarchdirs) {
					tmp = list[i]
					extrapath = compatarchdirs[d] "/"
					xfile = cpath extrapath substr(i, l + 1)
					if (xfile in notwanted)
						continue;
					sub("compatfile","compat",tmp);
					sub("compattestfile","compat",tmp);
					tmp = xfile substr(tmp, l_i + 1)
					print tmp;
				}
			}
		}'

}

#
# list_set_lists setname
#
# Print to stdout a list of files, one filename per line, which
# concatenate to create the packing list for setname. E.g.,
#
# 	.../lists/base/mi
# 	.../lists/base/rescue.mi
# 	.../lists/base/md.i386
#		[...]
#
# For a given setname $set, the following files may be selected from
# .../list/$set:
#	mi
#	mi.ext.*
#	ad.${MACHINE_ARCH}
# (or)	ad.${MACHINE_CPU}
#	ad.${MACHINE_CPU}.shl
#	md.${MACHINE}.${MACHINE_ARCH}
# (or)	md.${MACHINE}
#	stl.mi
#	stl.${stlib}
#	shl.mi
#	shl.mi.ext.*
#	shl.${shlib}
#	shl.${shlib}.ext.*
#	module.mi			if ${module} != no
#	module.${MACHINE}		if ${module} != no
#	module.ad.${MACHINE_ARCH}	if ${module} != no
# (or)	module.ad.${MACHINE_CPU}	if ${module} != no
#	rescue.shl
#	rescue.${MACHINE}
#	rescue.ad.${MACHINE_ARCH}
# (or)	rescue.ad.${MACHINE_CPU}
# 	rescue.ad.${MACHINE_CPU}.shl
#
# Environment:
# 	shlib
# 	stlib
#
list_set_lists()
{
	setname=$1

	list_set_lists_mi $setname
	list_set_lists_ad $setname
	list_set_lists_md $setname
	list_set_lists_stl $setname
	list_set_lists_shl $setname
	list_set_lists_module $setname
	list_set_lists_rescue $setname
	return 0
}

list_set_lists_mi()
{
	setdir=$setsdir/lists/$1
	# always exist!
	echo $setdir/mi
}

list_set_lists_ad()
{
	setdir=$setsdir/lists/$1
	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
	list_set_lists_common_ad $1
}

list_set_lists_md()
{
	setdir=$setsdir/lists/$1
	echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
	echo_if_exist $setdir/md.${MACHINE}
}

list_set_lists_stl()
{
	setdir=$setsdir/lists/$1
	echo_if_exist $setdir/stl.mi
	echo_if_exist $setdir/stl.${stlib}
}

list_set_lists_shl()
{
	setdir=$setsdir/lists/$1
	[ "$shlib" != "no" ] || return
	echo_if_exist $setdir/shl.mi
	echo_if_exist $setdir/shl.${shlib}
}

list_set_lists_module()
{
	setdir=$setsdir/lists/$1
	[ "$module" != "no" ] || return
	echo_if_exist $setdir/module.mi
	echo_if_exist $setdir/module.${MACHINE}
	echo_if_exist $setdir/module.ad.${MACHINE}
	echo_if_exist $setdir/module.md.${MACHINE}
	# XXX module never has .shl
	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
	list_set_lists_common_ad $1 module
}

list_set_lists_rescue()
{
	setdir=$setsdir/lists/$1
	echo_if_exist $setdir/rescue.mi
	echo_if_exist $setdir/rescue.${MACHINE}
	[ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
	list_set_lists_common_ad $1 rescue
}

list_set_lists_common_ad()
{
	setdir=$setsdir/lists/$1; _prefix=$2

	[ -n "$_prefix" ] && prefix="$_prefix".

	# Prefer a <prefix>.ad.${MACHINE_ARCH} over a
	# <prefix>.ad.${MACHINE_CPU}, since the arch-
	# specific one will be more specific than the
	# cpu-specific one.
	echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
	[ "$shlib" != "no" ] && \
	echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
}

echo_if_exist()
{
	[ -f $1 ] && echo $1
	return $?
}

echo_if_exist_foreach()
{
	local _list=$1; shift
	for _suffix in $@; do
		echo_if_exist ${_list}.${_suffix}
	done
}

print_set_lists()
{
	for setname; do
		list=$(list_set_lists $setname)
		for l in $list; do
			echo $l
			if $verbose; then
				echo >&2 "DEBUG: list_set_files: $l"
			fi
		done
	done | ${XARGS} ${SED} ${SUBST}
}


list_kernel_configs()
{
	(cd ${NETBSDSRCDIR}/etc
	MAKEFLAGS= \
	${MAKE} -m ${NETBSDSRCDIR}/share/mk -V '${ALL_KERNELS}')
}

# arch_to_cpu mach
#
# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
# as determined by <bsd.own.mk>.
#
arch_to_cpu()
{
	MACHINE_ARCH=${1} MAKEFLAGS= \
	${MAKE} -m ${NETBSDSRCDIR}/share/mk \
		-f ${NETBSDSRCDIR}/share/mk/bsd.own.mk \
		-V '${MACHINE_CPU}'
}

# arch_to_endian mach
#
# Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
# as determined by <bsd.endian.mk>.
#
arch_to_endian()
{
	MACHINE_ARCH=${1} MAKEFLAGS= \
	${MAKE} -m ${NETBSDSRCDIR}/share/mk \
		-f ${NETBSDSRCDIR}/share/mk/bsd.endian.mk \
		-V '${TARGET_ENDIANNESS}'
}

#####

# print_mkvars
print_mkvars()
{
	for v in $MKVARS; do
		eval echo $v=\$$v
	done
}

# print_set_lists_{base,x,ext}
# list_set_lists_{base,x,ext}
# list_set_files_{base,x,ext}
for func in print_set_lists list_set_lists list_set_files; do
	for x in base x ext; do
		if [ $x = base ]; then
			list=nlists
		else
			list=${x}lists
		fi
		eval ${func}_${x} \(\) \{ $func \$$list \; \}
	done
done