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