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