sets.subr revision 1.12
1# $NetBSD: sets.subr,v 1.12 2004/01/03 12:23:11 lukem Exp $ 2# 3 4# 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# obsolete controls if obsolete files are selected instead 10# lkm if != "no", enable LKM sets 11# shlib shared library format (a.out, elf, or "") 12# stlib static library format (a.out, elf) 13# x11_version version of XF86 (3 or 4) 14# 15# The following <bsd.own.mk> variables are exported to the environment: 16# MACHINE 17# MACHINE_ARCH 18# MACHINE_CPU 19# HAVE_GCC3 20# TOOLCHAIN_MISSING 21# OBJECT_FMT 22# MKKERBEROS 23# MKKERBEROS4 24# MKLINT 25# MKPOSTFIX 26# MKSENDMAIL 27 28MKVARS="MKKERBEROS MKKERBEROS4 MKLINT MKPOSTFIX MKSENDMAIL" 29 30oIFS=$IFS 31IFS=" 32" 33for x in $( 34${MAKE:-make} -B -f- all <<EOMAKE 35.include <bsd.own.mk> 36all: 37.for i in MACHINE MACHINE_ARCH MACHINE_CPU \ 38 HAVE_GCC3 OBJECT_FMT TOOLCHAIN_MISSING \ 39 ${MKVARS} 40 @echo "export \$i=\${\$i}" 41.endfor 42.if defined(USE_XF86_4) && (\${USE_XF86_4} != "no") 43 @echo x11_version=4 44.else 45 @echo x11_version=3 46.endif 47 48EOMAKE 49); do 50# echo 1>&2 "DEBUG: read $x" 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.12 2004/01/03 12:23:11 lukem 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# kerberos <bsd.own.mk> ${MKKERBEROS} != no 104# kerberos4 <bsd.own.mk> ${MKKERBEROS4} != no 105# lint <bsd.own.mk> ${MKLINT} != no 106# postfix <bsd.own.mk> ${MKPOSTFIX} != no 107# sendmail <bsd.own.mk> ${MKSENDMAIL} != no 108# obsolete file is obsolete, and only printed if 109# ${obsolete} != 0 110# 111list_set_files() 112{ 113 for setname; do 114 list_set_lists $setname 115 done | xargs cat | \ 116 awk -v obsolete=${obsolete} ' 117 BEGIN { 118 if (! obsolete) { 119 split("'"${MKVARS}"'", needvars) 120 for (vi in needvars) { 121 nv = needvars[vi] 122 kw = tolower(substr(nv, 3)) 123 if (ENVIRON[nv] != "no") 124 wanted[kw] = 1 125 } 126 } 127 } 128 129 /^#/ { 130 next; 131 } 132 133 NF > 2 && $3 != "-" { 134 split($3, keywords, ",") 135 show = 1 136 for (ki in keywords) { 137 kw = keywords[ki] 138 if (kw == "obsolete") { 139 if (obsolete) 140 print 141 next 142 } 143 if (! (kw in wanted)) 144 show = 0 145 } 146 if (show) 147 print 148 next 149 } 150 151 { 152 if (! obsolete) 153 print 154 }' 155 156} 157 158# 159# list_set_lists setname 160# 161# Print to stdout a list of files, one filename per line, which 162# concatenate to create the packing list for setname. E.g., 163# 164# .../lists/base/mi 165# .../lists/base/rescue.mi 166# .../lists/base/md.i386 167# [...] 168# 169# For a given setname $set, the following files may be selected from 170# .../list/$set: 171# mi 172# ad.${MACHINE_ARCH} 173# (or) ad.${MACHINE_CPU} 174# ad.${MACHINE_CPU}.shl 175# md.${MACHINE}.${MACHINE_ARCH} 176# (or) md.${MACHINE} 177# stl.mi 178# stl.stlib 179# shl.mi 180# shl.shlib 181# lkm.mi if ${lkm} != no 182# gcc.mi 183# gcc.shl 184# tc.mi 185# tc.shl 186# rescue.shl 187# rescue.${MACHINE} 188# rescue.ad.${MACHINE_ARCH} 189# (or) rescue.ad.${MACHINE_CPU} 190# rescue.ad.${MACHINE_CPU}.shl 191# 192# Environment: 193# shlib 194# stlib 195# 196list_set_lists() 197{ 198 setname=$1 199 200 setdir=$setsdir/lists/$setname 201 echo $setdir/mi 202 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 203 # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU}, 204 # since the arch-specific one will be more specific than 205 # the cpu-specific one. 206 if [ -f $setdir/ad.${MACHINE_ARCH} ]; then 207 echo $setdir/ad.${MACHINE_ARCH} 208 elif [ -f $setdir/ad.${MACHINE_CPU} ]; then 209 echo $setdir/ad.${MACHINE_CPU} 210 fi 211 if [ "$shlib" != "no" -a \ 212 -f $setdir/ad.${MACHINE_CPU}.shl ]; then 213 echo $setdir/ad.${MACHINE_CPU}.shl 214 fi 215 fi 216 if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then 217 echo $setdir/md.${MACHINE}.${MACHINE_ARCH} 218 elif [ -f $setdir/md.${MACHINE} ]; then 219 echo $setdir/md.${MACHINE} 220 fi 221 if [ -f $setdir/stl.mi ]; then 222 echo $setdir/stl.mi 223 fi 224 if [ -f $setdir/stl.${stlib} ]; then 225 echo $setdir/stl.${stlib} 226 fi 227 if [ "$shlib" != "no" ]; then 228 if [ -f $setdir/shl.mi ]; then 229 echo $setdir/shl.mi 230 fi 231 if [ -f $setdir/shl.${shlib} ]; then 232 echo $setdir/shl.${shlib} 233 fi 234 fi 235 if [ "$lkm" != "no" ]; then 236 if [ -f $setdir/lkm.mi ]; then 237 echo $setdir/lkm.mi 238 fi 239 fi 240 if [ "${TOOLCHAIN_MISSING}" != "yes" ]; then 241 if [ "${HAVE_GCC3}" = "yes" ]; then 242 if [ -f $setdir/gcc.mi ]; then 243 echo $setdir/gcc.mi 244 fi 245 if [ "$shlib" != "no" ]; then 246 if [ -f $setdir/gcc.shl ]; then 247 echo $setdir/gcc.shl 248 fi 249 fi 250 else 251 if [ -f $setdir/tc.mi ]; then 252 echo $setdir/tc.mi 253 fi 254 if [ "$shlib" != "no" ]; then 255 if [ -f $setdir/tc.shl ]; then 256 echo $setdir/tc.shl 257 fi 258 fi 259 fi 260 fi 261 262 if [ -f $setdir/rescue.mi ]; then 263 echo $setdir/rescue.mi 264 fi 265 if [ -f $setdir/rescue.${MACHINE} ]; then 266 echo $setdir/rescue.${MACHINE} 267 fi 268 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 269 # Prefer a rescue.ad.${MACHINE_ARCH} over a 270 # rescue.ad.${MACHINE_CPU}, since the arch- 271 # specific one will be more specific than the 272 # cpu-specific one. 273 if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then 274 echo $setdir/rescue.ad.${MACHINE_ARCH} 275 elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then 276 echo $setdir/rescue.ad.${MACHINE_CPU} 277 fi 278 if [ "$shlib" != "no" -a \ 279 -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then 280 echo $setdir/rescue.ad.${MACHINE_CPU}.shl 281 fi 282 fi 283} 284 285# arch_to_cpu mach 286# 287# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 288# as determined by <bsd.own.mk>. 289# 290arch_to_cpu() 291{ 292 MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOMAKE 293.include <bsd.own.mk> 294all: 295 @echo \${MACHINE_CPU} 296EOMAKE 297} 298