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