sets.subr revision 1.10
1# $NetBSD: sets.subr,v 1.10 2003/12/29 20:54:58 jmc Exp $ 2# 3 4# 5# Set environment variables containing defaults for sets.subr 6# functions and callers: 7# setsdir path to src/distrib/sets 8# nlists list of base sets 9# xlists list of x11 sets 10# obsolete controls if obsolete files are selected instead 11# have_gcc3 <bsd.own.mk> ${HAVE_GCC3} 12# lkm if != "no", enable LKM sets 13# machine <bsd.own.mk> ${MACHINE} 14# machine_arch <bsd.own.mk> ${MACHINE_ARCH} 15# machine_cpu <bsd.own.mk> ${MACHINE_CPU} 16# mkkerberos <bsd.own.mk> ${MKKERBEROS} 17# mkkerberos4 <bsd.own.mk> ${MKKERBEROS4} 18# mklint <bsd.own.mk> ${MKLINT} 19# object_fmt <bsd.own.mk> ${OBJECT_FMT} 20# shlib shared library format (a.out, elf, or "") 21# stlib static library format (a.out, elf) 22# toolchain_missing <bsd.own.mk> ${TOOLCHAIN_MISSING} 23# use_tools_toolchain <bsd.own.mk> ${USE_TOOLS_TOOLCHAIN} 24# x11_version version of XF86 (3 or 4) 25 26oIFS=$IFS 27IFS=" 28" 29for x in $( 30${MAKE:-make} -B -f- all <<EOF 31.include <bsd.own.mk> 32all: 33 @echo have_gcc3=\${HAVE_GCC3} 34 @echo machine=\${MACHINE} 35 @echo machine_arch=\${MACHINE_ARCH} 36 @echo machine_cpu=\${MACHINE_CPU} 37 @echo mkkerberos4=\${MKKERBEROS4} 38 @echo mkkerberos=\${MKKERBEROS} 39 @echo mklint=\${MKLINT} 40 @echo object_fmt=\${OBJECT_FMT} 41 @echo toolchain_missing=\${TOOLCHAIN_MISSING} 42 @echo use_tools_toolchain=\${USE_TOOLS_TOOLCHAIN} 43.if defined(USE_XF86_4) && (\${USE_XF86_4} != no) 44 @echo x11_version=4 45.else 46 @echo x11_version=3 47.endif 48 49EOF 50); do 51 eval $x 52done 53IFS=$oIFS 54 55setsdir=$(dirname $0) 56nlists="base comp etc games man misc text" 57case $x11_version in 583) xlists="xbase3 xcomp3 xcontrib3 xfont3 xmisc3 xserver3" ;; 594) xlists="xbase4 xcomp4 xcontrib4 xfont4 xmisc4 xserver4" ;; 60*) xlists="xbase xcomp xcontrib xfont xmisc xserver" ;; 61esac 62obsolete=0 63lkm=yes 64if [ "$machine" = "evbppc" ]; then 65 lkm=no # Turn off LKMs for some ports. 66fi 67# Determine lib type. 68if [ "$object_fmt" = "ELF" ]; then 69 shlib=elf 70else 71 shlib=aout 72fi 73stlib=$shlib 74if [ "$machine_cpu" = "sh3" -o "$machine_arch" = "m68000" ]; then 75 shlib=no # Turn off shlibs for some ports. 76fi 77 78 79# 80# list_set_files setfile [...] 81# 82# Produce a packing list for setfile(s). 83# In each file, a record consists of a path and a System Package name, 84# separated by whitespace. E.g., 85# 86# # $NetBSD: sets.subr,v 1.10 2003/12/29 20:54:58 jmc Exp $ 87# . base-sys-root [keyword[,...]] 88# ./altroot base-sys-root 89# ./bin base-sys-root 90# ./bin/[ base-util-root 91# ./bin/cat base-util-root 92# [...] 93# 94# A # in the first column marks a comment. 95# 96# If ${obsolete} != 0, only entries with an "obsolete" keyword will 97# be printed. 98# 99# The third field is an optional comma separated list of keywords to 100# control if a record is printed; every keyword listed must be enabled 101# for the record to be printed. The following keywords are available: 102# dummy dummy entry (ignored) 103# kerberos4 <bsd.own.mk> ${MKKERBEROS4} != no 104# kerberos <bsd.own.mk> ${MKKERBEROS} != no 105# lint <bsd.own.mk> ${MKLINT} != no 106# obsolete file is obsolete, and only printed if 107# ${obsolete} != 0 108# 109list_set_files() 110{ 111 for setname; do 112 list_set_lists $setname 113 done | xargs cat | \ 114 env \ 115 MKKERBEROS4=${mkkerberos4} \ 116 MKKERBEROS=${mkkerberos} \ 117 MKLINT=${mklint} \ 118 awk -v obsolete=${obsolete} ' 119 BEGIN { 120 if (! obsolete) { 121 split("kerberos4 kerberos lint", 122 needvars) 123 for (vi in needvars) { 124 nv = needvars[vi] 125 if (ENVIRON["MK" toupper(nv)] != "no") 126 wanted[nv] = 1 127 } 128 } 129 } 130 131 /^#/ { 132 next; 133 } 134 135 NF > 2 && $3 != "-" { 136 split($3, keywords, ",") 137 show = 1 138 for (ki in keywords) { 139 kw = keywords[ki] 140 if (kw == "obsolete") { 141 if (obsolete) 142 print 143 next 144 } 145 if (! (kw in wanted)) 146 show = 0 147 } 148 if (show) 149 print 150 next 151 } 152 153 { 154 if (! obsolete) 155 print 156 }' 157 158} 159 160# 161# list_set_lists setname 162# 163# Print to stdout a list of files, one filename per line, which 164# concatenate to create the packing list for setname. E.g., 165# 166# .../lists/base/mi 167# .../lists/base/rescue.mi 168# .../lists/base/md.i386 169# [...] 170# 171# For a given setname $set, the following files may be selected from 172# .../list/$set: 173# mi 174# ad.${machine_arch} 175# (or) ad.${machine_cpu} 176# ad.${machine_cpu}.shl 177# md.${machine}.${machine_arch} 178# (or) md.${machine} 179# stl.mi 180# stl.stlib 181# shl.mi 182# shl.shlib 183# lkm.mi if ${lkm} != no 184# gcc.mi 185# gcc.shl 186# tc.mi 187# tc.shl 188# rescue.shl 189# rescue.${machine} 190# rescue.ad.${machine_arch} 191# (or) rescue.ad.${machine_cpu} 192# rescue.ad.${machine_cpu}.shl 193# 194# Environment: 195# shlib 196# stlib 197# 198list_set_lists() 199{ 200 setname=$1 201 202 setdir=$setsdir/lists/$setname 203 echo $setdir/mi 204 if [ "$machine" != "$machine_arch" ]; then 205 # Prefer an ad.${machine_arch} over an ad.${machine_cpu}, 206 # since the arch-specific one will be more specific than 207 # the cpu-specific one. 208 if [ -f $setdir/ad.${machine_arch} ]; then 209 echo $setdir/ad.${machine_arch} 210 elif [ -f $setdir/ad.${machine_cpu} ]; then 211 echo $setdir/ad.${machine_cpu} 212 fi 213 if [ "$shlib" != "no" -a \ 214 -f $setdir/ad.${machine_cpu}.shl ]; then 215 echo $setdir/ad.${machine_cpu}.shl 216 fi 217 fi 218 if [ -f $setdir/md.${machine}.${machine_arch} ]; then 219 echo $setdir/md.${machine}.${machine_arch} 220 elif [ -f $setdir/md.${machine} ]; then 221 echo $setdir/md.${machine} 222 fi 223 if [ -f $setdir/stl.mi ]; then 224 echo $setdir/stl.mi 225 fi 226 if [ -f $setdir/stl.${stlib} ]; then 227 echo $setdir/stl.${stlib} 228 fi 229 if [ "$shlib" != "no" ]; then 230 if [ -f $setdir/shl.mi ]; then 231 echo $setdir/shl.mi 232 fi 233 if [ -f $setdir/shl.${shlib} ]; then 234 echo $setdir/shl.${shlib} 235 fi 236 fi 237 if [ "$lkm" != "no" ]; then 238 if [ -f $setdir/lkm.mi ]; then 239 echo $setdir/lkm.mi 240 fi 241 fi 242 if [ "$toolchain_missing" != "yes" ]; then 243 if [ "$have_gcc3" = "yes" ]; then 244 if [ -f $setdir/gcc.mi ]; then 245 echo $setdir/gcc.mi 246 fi 247 if [ "$shlib" != "no" ]; then 248 if [ -f $setdir/gcc.shl ]; then 249 echo $setdir/gcc.shl 250 fi 251 fi 252 else 253 if [ -f $setdir/tc.mi ]; then 254 echo $setdir/tc.mi 255 fi 256 if [ "$shlib" != "no" ]; then 257 if [ -f $setdir/tc.shl ]; then 258 echo $setdir/tc.shl 259 fi 260 fi 261 fi 262 fi 263 264 if [ -f $setdir/rescue.mi ]; then 265 echo $setdir/rescue.mi 266 fi 267 if [ -f $setdir/rescue.${machine} ]; then 268 echo $setdir/rescue.${machine} 269 fi 270 if [ "$machine" != "$machine_arch" ]; then 271 # Prefer a rescue.ad.${machine_arch} over a 272 # rescue.ad.${machine_cpu}, since the arch- 273 # specific one will be more specific than the 274 # cpu-specific one. 275 if [ -f $setdir/rescue.ad.${machine_arch} ]; then 276 echo $setdir/rescue.ad.${machine_arch} 277 elif [ -f $setdir/rescue.ad.${machine_cpu} ]; then 278 echo $setdir/rescue.ad.${machine_cpu} 279 fi 280 if [ "$shlib" != "no" -a \ 281 -f $setdir/rescue.ad.${machine_cpu}.shl ]; then 282 echo $setdir/rescue.ad.${machine_cpu}.shl 283 fi 284 fi 285} 286 287# arch_to_cpu mach 288# 289# Print the $MACHINE_CPU for $MACHINE_ARCH=mach, 290# as determined by <bsd.own.mk>. 291# 292arch_to_cpu() 293{ 294 MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOF 295.include <bsd.own.mk> 296all: 297 @echo \${MACHINE_CPU} 298EOF 299} 300