# $NetBSD: sets.subr,v 1.10 2003/12/29 20:54:58 jmc Exp $ # # # Set environment variables containing 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 # have_gcc3 ${HAVE_GCC3} # lkm if != "no", enable LKM sets # machine ${MACHINE} # machine_arch ${MACHINE_ARCH} # machine_cpu ${MACHINE_CPU} # mkkerberos ${MKKERBEROS} # mkkerberos4 ${MKKERBEROS4} # mklint ${MKLINT} # object_fmt ${OBJECT_FMT} # shlib shared library format (a.out, elf, or "") # stlib static library format (a.out, elf) # toolchain_missing ${TOOLCHAIN_MISSING} # use_tools_toolchain ${USE_TOOLS_TOOLCHAIN} # x11_version version of XF86 (3 or 4) oIFS=$IFS IFS=" " for x in $( ${MAKE:-make} -B -f- all < all: @echo have_gcc3=\${HAVE_GCC3} @echo machine=\${MACHINE} @echo machine_arch=\${MACHINE_ARCH} @echo machine_cpu=\${MACHINE_CPU} @echo mkkerberos4=\${MKKERBEROS4} @echo mkkerberos=\${MKKERBEROS} @echo mklint=\${MKLINT} @echo object_fmt=\${OBJECT_FMT} @echo toolchain_missing=\${TOOLCHAIN_MISSING} @echo use_tools_toolchain=\${USE_TOOLS_TOOLCHAIN} .if defined(USE_XF86_4) && (\${USE_XF86_4} != no) @echo x11_version=4 .else @echo x11_version=3 .endif EOF ); do eval $x done IFS=$oIFS setsdir=$(dirname $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 xcontrib xfont xmisc xserver" ;; esac obsolete=0 lkm=yes if [ "$machine" = "evbppc" ]; then lkm=no # Turn off LKMs for some ports. fi # Determine lib type. if [ "$object_fmt" = "ELF" ]; then shlib=elf else shlib=aout fi stlib=$shlib if [ "$machine_cpu" = "sh3" -o "$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.10 2003/12/29 20:54:58 jmc 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) # kerberos4 ${MKKERBEROS4} != no # kerberos ${MKKERBEROS} != no # lint ${MKLINT} != no # obsolete file is obsolete, and only printed if # ${obsolete} != 0 # list_set_files() { for setname; do list_set_lists $setname done | xargs cat | \ env \ MKKERBEROS4=${mkkerberos4} \ MKKERBEROS=${mkkerberos} \ MKLINT=${mklint} \ awk -v obsolete=${obsolete} ' BEGIN { if (! obsolete) { split("kerberos4 kerberos lint", needvars) for (vi in needvars) { nv = needvars[vi] if (ENVIRON["MK" toupper(nv)] != "no") wanted[nv] = 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 (! (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 . # arch_to_cpu() { MACHINE_ARCH=${1} ${MAKE:-make} -f- all < all: @echo \${MACHINE_CPU} EOF }