NetBSD/distrib/sets/sets.subr

377 lines
8.2 KiB
Plaintext

# $NetBSD: sets.subr,v 1.40 2005/03/22 09:28:24 tron 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
# lkm if != "no", enable LKM sets
# shlib shared library format (a.out, elf, or "")
# stlib static library format (a.out, elf)
# x11_version version of XFree86. one of:
# "" cross built from src/x11
# 3 XFree86 3.x from xsrc/xc
# 4 XFree86 4.x from xsrc/xfree/xc
#
# The following <bsd.own.mk> variables are exported to the environment:
# MACHINE
# MACHINE_ARCH
# MACHINE_CPU
# HAVE_GCC3
# TOOLCHAIN_MISSING
# OBJECT_FMT
# as well as:
#
MKVARS="\
MKBFD \
MKCATPAGES \
MKCRYPTO \
MKCRYPTO_IDEA \
MKCRYPTO_MDC2 \
MKCRYPTO_RC5 \
MKCVS \
MKGCCCMDS \
MKDOC \
MKGDB \
MKHESIOD \
MKINFO \
MKIPFILTER \
MKINET6 \
MKKERBEROS \
MKKERBEROS4 \
MKLINT \
MKMAN \
MKMANPAGES \
MKMANZ \
MKNLS \
MKPAM \
MKPF \
MKPIC \
MKPOSTFIX \
MKPROFILE \
MKSENDMAIL \
MKSHARE \
MKSKEY \
MKUUCP \
MKX11 \
MKYP \
"
oIFS=$IFS
IFS="
"
for x in $(
${MAKE:-make} -B -f- all <<EOMAKE
.include <bsd.own.mk>
.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall))
MKMANPAGES=no
.else
MKMANPAGES=yes
.endif
all:
.for i in MACHINE MACHINE_ARCH MACHINE_CPU \
HAVE_GCC3 OBJECT_FMT TOOLCHAIN_MISSING \
${MKVARS}
@echo "export \$i=\${\$i}"
.endfor
.if (\${MKX11:Uno} != "no")
@echo x11_version=""
.else
@echo x11_version=4
.endif
EOMAKE
); do
# echo 1>&2 "DEBUG: read $x"
eval $x
done
IFS=$oIFS
setsdir=${0%/*}
nlists="base comp etc games man misc text"
case $x11_version in
3) xlists="xbase3 xcomp3 xcontrib3 xfont3 xmisc3 xserver3" ;;
4) xlists="xbase4 xcomp4 xcontrib4 xfont4 xmisc4 xserver4" ;;
"") xlists="xbase xcomp xetc xfont xserver" ;;
*) xlists="" ;; # unknown!
esac
obsolete=0
lkm=yes
if [ "${MACHINE}" = "evbppc" ]; then
lkm=no # Turn off LKMs for some ports.
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
if [ "${MACHINE_ARCH}" = "m68000" ]; then
shlib=no # Turn off shlibs for some ports.
fi
#
# 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.40 2005/03/22 09:28:24 tron 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.
#
# 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 following keywords are available:
# dummy dummy entry (ignored)
# obsolete file is obsolete, and only printed if
# ${obsolete} != 0
#
# bfd ${MKBFD} != no
# catpages ${MKCATPAGES} != no
# crypto ${MKCRYPTO} != no
# crypto_idea ${MKCRYPTO_IDEA} != no
# crypto_mdc2 ${MKCRYPTO_MDC2} != no
# crypto_rc5 ${MKCRYPTO_RC5} != no
# cvs ${MKCVS} != no
# doc ${MKDOC} != no
# gcccmds ${MKGCCCMDS} != no
# gdb ${MKGDB} != no
# hesiod ${MKHESIOD} != no
# info ${MKINFO} != no
# ipfilter ${MKIPFILTER} != no
# inet6 ${MKINET6} != no
# kerberos ${MKKERBEROS} != no
# kerberos4 ${MKKERBEROS4} != no
# lint ${MKLINT} != no
# man ${MKMAN} != no
# manz ${MKMANZ} != no
# nls ${MKNLS} != no
# pam ${MKPAM} != no
# pf ${MKPF} != no
# postfix ${MKPOSTFIX} != no
# profile ${MKPROFILE} != no
# sendmail ${MKSENDMAIL} != no
# share ${MKSHARE} != no
# skey ${MKSKEY} != no
# uucp ${MKUUCP} != no
# yp ${MKYP} != no
#
# .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()
{
for setname; do
list_set_lists $setname
done | xargs cat | \
awk -v obsolete=${obsolete} '
BEGIN {
if (! obsolete) {
split("'"${MKVARS}"'", needvars)
for (vi in needvars) {
nv = needvars[vi]
kw = tolower(substr(nv, 3))
if (ENVIRON[nv] != "no")
wanted[kw] = 1
}
if (("man" in wanted) && ("catpages" in wanted))
wanted[".cat"] = 1
if (("man" in wanted) && ("manpages" in wanted))
wanted[".man"] = 1
}
}
/^#/ {
next;
}
NF > 2 && $3 != "-" {
split($3, keywords, ",")
show = 1
for (ki in keywords) {
kw = keywords[ki]
if (kw == "obsolete") {
if (obsolete)
print
next
}
if (("manz" in wanted) &&
(kw == ".cat" || kw == ".man"))
$1 = $1 ".gz"
if (! (kw in wanted))
show = 0
}
if (show)
print
next
}
{
if (! obsolete)
print
}'
}
#
# 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
# 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.shlib
# lkm.mi if ${lkm} != no
# gcc.mi
# gcc.shl
# tc.mi
# tc.shl
# 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
setdir=$setsdir/lists/$setname
echo $setdir/mi
if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
# Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU},
# since the arch-specific one will be more specific than
# the cpu-specific one.
if [ -f $setdir/ad.${MACHINE_ARCH} ]; then
echo $setdir/ad.${MACHINE_ARCH}
elif [ -f $setdir/ad.${MACHINE_CPU} ]; then
echo $setdir/ad.${MACHINE_CPU}
fi
if [ "$shlib" != "no" -a \
-f $setdir/ad.${MACHINE_CPU}.shl ]; then
echo $setdir/ad.${MACHINE_CPU}.shl
fi
fi
if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then
echo $setdir/md.${MACHINE}.${MACHINE_ARCH}
elif [ -f $setdir/md.${MACHINE} ]; then
echo $setdir/md.${MACHINE}
fi
if [ -f $setdir/stl.mi ]; then
echo $setdir/stl.mi
fi
if [ -f $setdir/stl.${stlib} ]; then
echo $setdir/stl.${stlib}
fi
if [ "$shlib" != "no" ]; then
if [ -f $setdir/shl.mi ]; then
echo $setdir/shl.mi
fi
if [ -f $setdir/shl.${shlib} ]; then
echo $setdir/shl.${shlib}
fi
fi
if [ "$lkm" != "no" ]; then
if [ -f $setdir/lkm.mi ]; then
echo $setdir/lkm.mi
fi
fi
if [ "${TOOLCHAIN_MISSING}" != "yes" ]; then
if [ "${HAVE_GCC3}" = "yes" ]; then
if [ -f $setdir/gcc.mi ]; then
echo $setdir/gcc.mi
fi
if [ "$shlib" != "no" ]; then
if [ -f $setdir/gcc.shl ]; then
echo $setdir/gcc.shl
fi
fi
else
if [ -f $setdir/tc.mi ]; then
echo $setdir/tc.mi
fi
if [ "$shlib" != "no" ]; then
if [ -f $setdir/tc.shl ]; then
echo $setdir/tc.shl
fi
fi
fi
fi
if [ -f $setdir/rescue.mi ]; then
echo $setdir/rescue.mi
fi
if [ -f $setdir/rescue.${MACHINE} ]; then
echo $setdir/rescue.${MACHINE}
fi
if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then
# Prefer a rescue.ad.${MACHINE_ARCH} over a
# rescue.ad.${MACHINE_CPU}, since the arch-
# specific one will be more specific than the
# cpu-specific one.
if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then
echo $setdir/rescue.ad.${MACHINE_ARCH}
elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then
echo $setdir/rescue.ad.${MACHINE_CPU}
fi
if [ "$shlib" != "no" -a \
-f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then
echo $setdir/rescue.ad.${MACHINE_CPU}.shl
fi
fi
}
# arch_to_cpu mach
#
# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach,
# as determined by <bsd.own.mk>.
#
arch_to_cpu()
{
MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOMAKE
.include <bsd.own.mk>
all:
@echo \${MACHINE_CPU}
EOMAKE
}