5 # The following variables contain defaults for sets.subr functions and callers:
6 # setsdir path to src/distrib/sets
7 # nlists list of base sets
8 # xlists list of x11 sets
9 # extlists list of extsrc sets
10 # obsolete controls if obsolete files are selected instead
11 # module if != "no", enable MODULE sets
12 # shlib shared library format (a.out, elf, or "")
13 # stlib static library format (a.out, elf)
15 # The following <bsd.own.mk> variables are exported to the environment:
28 # The following variables refer to tools that are used when building sets:
36 : ${ENV_CMD:=env} # ${ENV} is special to sh(1), ksh(1), etc.
40 : ${GZIP_CMD:=gzip} # ${GZIP} is special to gzip(1)
41 : ${HOSTNAME_CMD:=hostname} # ${HOSTNAME} is special to bash(1)
61 # If printf is a shell builtin command, then we can
62 # implement cheaper versions of basename and dirname
63 # that do not involve any fork/exec overhead.
64 # If printf is not builtin, approximate it using echo,
65 # and hope there are no weird file names that cause
66 # some versions of echo to do the wrong thing.
67 # (Converting to this version of dirname speeded up the
68 # syspkgdeps script by an order of magnitude, from 68
69 # seconds to 6.3 seconds on one particular host.)
71 # Note that naive approximations for dirname
72 # using ${foo%/*} do not do the right thing in cases
73 # where the result should be "/" or ".".
75 case "$(type printf)" in
107 ?*/*) dn="${1%/*}" ;;
122 for x in $( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars ); do
128 MKVARS="$( ${MAKE} -B -f ${rundir}/mkvars.mk mkvars | ${SED} -e 's,=.*,,' | ${XARGS} )"
135 if [ "${MKKMOD}" = "no" ]; then
136 module=no # MODULEs are off.
138 # Determine lib type. Do this first so stlib also gets set.
139 if [ "${OBJECT_FMT}" = "ELF" ]; then
145 # Now check for MKPIC or specials and turn off shlib if need be.
146 if [ "${MKPIC}" = "no" ]; then
149 if [ "$module" != "no" ]; then
150 nlists="base comp etc games man misc modules tests text"
152 nlists="base comp etc games man misc tests text"
154 xlists="xbase xcomp xetc xfont xserver"
155 extlists="extbase extcomp extetc"
157 OSRELEASE=`${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh`
158 MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
159 SUBST="s#@MODULEDIR@#${MODULEDIR}#g"
160 SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
161 SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
164 # list_set_files setfile [...]
166 # Produce a packing list for setfile(s).
167 # In each file, a record consists of a path and a System Package name,
168 # separated by whitespace. E.g.,
171 # . base-sys-root [keyword[,...]]
172 # ./altroot base-sys-root
173 # ./bin base-sys-root
174 # ./bin/[ base-util-root
175 # ./bin/cat base-util-root
178 # A # in the first column marks a comment.
180 # If ${obsolete} != 0, only entries with an "obsolete" keyword will
181 # be printed. All other keywords must be present.
183 # The third field is an optional comma separated list of keywords to
184 # control if a record is printed; every keyword listed must be enabled
185 # for the record to be printed. The following keywords are available:
186 # dummy dummy entry (ignored)
187 # obsolete file is obsolete, and only printed if
190 # bfd obsolete, use binutils.
191 # binutils ${MKBINUTILS} != no
192 # catpages ${MKCATPAGES} != no
193 # compat ${MKCOMPAT} != no
194 # crypto ${MKCRYPTO} != no
195 # crypto_idea ${MKCRYPTO_IDEA} != no
196 # crypto_mdc2 ${MKCRYPTO_MDC2} != no
197 # crypto_rc5 ${MKCRYPTO_RC5} != no
199 # debug ${MKDEBUG} != no
200 # debuglib ${MKDEBUGLIB} != no
202 # dynamicroot ${MKDYNAMICROOT} != no
203 # extsrc ${MKEXTSRC} != no
205 # gcccmds ${MKGCCCMDS} != no
207 # hesiod ${MKHESIOD} != no
208 # html ${MKHTML} != no
209 # inet6 ${MKINET6} != no
210 # info ${MKINFO} != no
211 # ipfilter ${MKIPFILTER} != no
212 # iscsi ${MKISCSI} != no
213 # kerberos ${MKKERBEROS} != no
214 # kmod ${MKKMOD} != no
215 # ldap ${MKLDAP} != no
216 # lint ${MKLINT} != no
219 # manpages ${MKMANPAGES} != no
220 # manz ${MKMANZ} != no
221 # mdns ${MKMDNS} != no
227 # postfix ${MKPOSTFIX} != no
228 # profile ${MKPROFILE} != no
229 # share ${MKSHARE} != no
230 # skey ${MKSKEY} != no
231 # x11 ${MKX11} != no && ${X11FLAVOUR} != "Xorg"
232 # xorg ${MKX11} != no && ${X11FLAVOUR} == "Xorg"
236 # binutils=<n> <n> = value of ${HAVE_BINUTILS}
237 # gcc=<n> <n> = value of ${HAVE_GCC}
238 # gdb=<n> <n> = value of ${HAVE_GDB}
240 # use_inet6 ${USE_INET6} != no
241 # use_kerberos ${USE_KERBEROS} != no
242 # use_yp ${USE_YP} != no
244 # .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no"
245 # automatically append ".gz" to the filename
247 # .man if ${MKMANZ} != "no" && ${MKMAN} != "no"
248 # automatically append ".gz" to the filename
252 if [ ${MAKEVERBOSE:-2} -lt 3 ]; then
257 print_set_lists "$@" | \
258 ${AWK} -v obsolete=${obsolete} '
261 wanted["obsolete"] = 1
263 split("'"${MKVARS}"'", needvars)
264 for (vi in needvars) {
268 if (ENVIRON[nv] != "no")
272 if ("'"${TOOLCHAIN_MISSING}"'" != "yes") {
273 if ("binutils" in wanted)
274 wanted["binutils=" "'"${HAVE_BINUTILS}"'"] = 1
276 wanted["gcc=" "'"${HAVE_GCC}"'"] = 1
278 wanted["gdb=" "'"${HAVE_GDB}"'"] = 1
280 if (("man" in wanted) && ("catpages" in wanted))
282 if (("man" in wanted) && ("manpages" in wanted))
290 NF > 2 && $3 != "-" {
291 split($3, keywords, ",")
294 for (ki in keywords) {
296 if (("manz" in wanted) &&
297 (kw == ".cat" || kw == ".man"))
299 negated = match(kw, "! *")
301 kw = substr(kw, RSTART + RLENGTH)
305 if (! (kw in wanted))
308 if (kw == "obsolete")
311 if (obsolete && ! haveobs)
326 # list_set_lists setname
328 # Print to stdout a list of files, one filename per line, which
329 # concatenate to create the packing list for setname. E.g.,
332 # .../lists/base/rescue.mi
333 # .../lists/base/md.i386
336 # For a given setname $set, the following files may be selected from
341 # (or) ad.${MACHINE_CPU}
342 # ad.${MACHINE_CPU}.shl
343 # md.${MACHINE}.${MACHINE_ARCH}
351 # module.mi if ${module} != no
352 # module.${MACHINE} if ${module} != no
353 # module.ad.${MACHINE_ARCH} if ${module} != no
354 # (or) module.ad.${MACHINE_CPU} if ${module} != no
357 # rescue.ad.${MACHINE_ARCH}
358 # (or) rescue.ad.${MACHINE_CPU}
359 # rescue.ad.${MACHINE_CPU}.shl
369 list_set_lists_mi $setname
370 list_set_lists_ad $setname
371 list_set_lists_md $setname
372 list_set_lists_stl $setname
373 list_set_lists_shl $setname
374 list_set_lists_module $setname
375 list_set_lists_rescue $setname
381 setdir=$setsdir/lists/$1
388 setdir=$setsdir/lists/$1
389 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
390 list_set_lists_common_ad $1
395 setdir=$setsdir/lists/$1
396 echo_if_exist $setdir/md.${MACHINE}.${MACHINE_ARCH} || \
397 echo_if_exist $setdir/md.${MACHINE}
402 setdir=$setsdir/lists/$1
403 echo_if_exist $setdir/stl.mi
404 echo_if_exist $setdir/stl.${stlib}
409 setdir=$setsdir/lists/$1
410 [ "$shlib" != "no" ] || return
411 echo_if_exist $setdir/shl.mi
412 echo_if_exist $setdir/shl.${shlib}
415 list_set_lists_module()
417 setdir=$setsdir/lists/$1
418 [ "$module" != "no" ] || return
419 echo_if_exist $setdir/module.mi
420 echo_if_exist $setdir/module.${MACHINE}
421 # XXX module never has .shl
422 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
423 list_set_lists_common_ad $1 module
426 list_set_lists_rescue()
428 setdir=$setsdir/lists/$1
429 echo_if_exist $setdir/rescue.mi
430 echo_if_exist $setdir/rescue.${MACHINE}
431 [ "${MACHINE}" != "${MACHINE_ARCH}" ] && \
432 list_set_lists_common_ad $1 rescue
435 list_set_lists_common_ad()
437 setdir=$setsdir/lists/$1; _prefix=$2
439 [ -n "$_prefix" ] && prefix="$_prefix".
441 # Prefer a <prefix>.ad.${MACHINE_ARCH} over a
442 # <prefix>.ad.${MACHINE_CPU}, since the arch-
443 # specific one will be more specific than the
445 echo_if_exist $setdir/${prefix}ad.${MACHINE_ARCH} || \
446 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}
447 [ "$shlib" != "no" ] && \
448 echo_if_exist $setdir/${prefix}ad.${MACHINE_CPU}.shl
457 echo_if_exist_foreach()
459 local _list=$1; shift
460 for _suffix in $@; do
461 echo_if_exist ${_list}.${_suffix}
468 list=`list_set_lists $setname`
472 echo >&2 "DEBUG: list_set_files: $l"
475 done | ${XARGS} ${SED} ${SUBST}
480 # Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
481 # as determined by <bsd.own.mk>.
485 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
486 .include <bsd.own.mk>
488 @echo \${MACHINE_CPU}
492 # arch_to_endian mach
494 # Print the ${TARGET_ENDIANNESS} for ${MACHINE_ARCH}=mach,
495 # as determined by <bsd.endian.mk>.
499 MACHINE_ARCH=${1} ${MAKE} -B -f- all <<EOMAKE
500 .include <bsd.endian.mk>
502 @echo \${TARGET_ENDIANNESS}
516 # print_set_lists_{base,x,ext}
517 # list_set_lists_{base,x,ext}
518 # list_set_files_{base,x,ext}
519 for func in print_set_lists list_set_lists list_set_files; do
520 for x in base x ext; do
521 if [ $x = base ]; then
526 eval ${func}_${x} \(\) \{ $func \$$list \; \}