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