sets.subr revision 1.41
1# $NetBSD: sets.subr,v 1.41 2005/05/01 07:06:09 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# as well as: 26# 27MKVARS="\ 28 MKBFD \ 29 MKCATPAGES \ 30 MKCRYPTO \ 31 MKCRYPTO_IDEA \ 32 MKCRYPTO_MDC2 \ 33 MKCRYPTO_RC5 \ 34 MKCVS \ 35 MKGCCCMDS \ 36 MKDOC \ 37 MKGDB \ 38 MKHESIOD \ 39 MKINFO \ 40 MKIPFILTER \ 41 MKINET6 \ 42 MKKERBEROS \ 43 MKKERBEROS4 \ 44 MKLINT \ 45 MKMAN \ 46 MKMANPAGES \ 47 MKMANZ \ 48 MKNLS \ 49 MKPAM \ 50 MKPF \ 51 MKPIC \ 52 MKPOSTFIX \ 53 MKPROFILE \ 54 MKSENDMAIL \ 55 MKSHARE \ 56 MKSKEY \ 57 MKUUCP \ 58 MKX11 \ 59 MKYP \ 60 USE_INET6 \ 61 USE_KERBEROS \ 62 USE_YP \ 63" 64 65oIFS=$IFS 66IFS=" 67" 68for x in $( 69${MAKE:-make} -B -f- all <<EOMAKE 70.include <bsd.own.mk> 71.if (\${MKMAN} == "no" || empty(MANINSTALL:Mmaninstall)) 72MKMANPAGES=no 73.else 74MKMANPAGES=yes 75.endif 76all: 77.for i in MACHINE MACHINE_ARCH MACHINE_CPU \ 78 HAVE_GCC3 OBJECT_FMT TOOLCHAIN_MISSING \ 79 ${MKVARS} 80 @echo "export \$i=\${\$i}" 81.endfor 82.if (\${MKX11:Uno} != "no") 83 @echo x11_version="" 84.else 85 @echo x11_version=4 86.endif 87 88EOMAKE 89); do 90# echo 1>&2 "DEBUG: read $x" 91 eval $x 92done 93IFS=$oIFS 94 95setsdir=${0%/*} 96nlists="base comp etc games man misc text" 97case $x11_version in 983) xlists="xbase3 xcomp3 xcontrib3 xfont3 xmisc3 xserver3" ;; 994) xlists="xbase4 xcomp4 xcontrib4 xfont4 xmisc4 xserver4" ;; 100"") xlists="xbase xcomp xetc xfont xserver" ;; 101*) xlists="" ;; # unknown! 102esac 103obsolete=0 104lkm=yes 105if [ "${MACHINE}" = "evbppc" ]; then 106 lkm=no # Turn off LKMs for some ports. 107fi 108# Determine lib type. Do this first so stlib also gets set. 109if [ "${OBJECT_FMT}" = "ELF" ]; then 110 shlib=elf 111else 112 shlib=aout 113fi 114stlib=$shlib 115# Now check for MKPIC or specials and turn off shlib if need be. 116if [ "${MKPIC}" = "no" ]; then 117 shlib=no 118fi 119if [ "${MACHINE_ARCH}" = "m68000" ]; then 120 shlib=no # Turn off shlibs for some ports. 121fi 122 123# 124# list_set_files setfile [...] 125# 126# Produce a packing list for setfile(s). 127# In each file, a record consists of a path and a System Package name, 128# separated by whitespace. E.g., 129# 130# # $NetBSD: sets.subr,v 1.41 2005/05/01 07:06:09 lukem Exp $ 131# . base-sys-root [keyword[,...]] 132# ./altroot base-sys-root 133# ./bin base-sys-root 134# ./bin/[ base-util-root 135# ./bin/cat base-util-root 136# [...] 137# 138# A # in the first column marks a comment. 139# 140# If ${obsolete} != 0, only entries with an "obsolete" keyword will 141# be printed. 142# 143# The third field is an optional comma separated list of keywords to 144# control if a record is printed; every keyword listed must be enabled 145# for the record to be printed. The following keywords are available: 146# dummy dummy entry (ignored) 147# obsolete file is obsolete, and only printed if 148# ${obsolete} != 0 149# 150# bfd ${MKBFD} != no 151# catpages ${MKCATPAGES} != no 152# crypto ${MKCRYPTO} != no 153# crypto_idea ${MKCRYPTO_IDEA} != no 154# crypto_mdc2 ${MKCRYPTO_MDC2} != no 155# crypto_rc5 ${MKCRYPTO_RC5} != no 156# cvs ${MKCVS} != no 157# doc ${MKDOC} != no 158# gcccmds ${MKGCCCMDS} != no 159# gdb ${MKGDB} != no 160# hesiod ${MKHESIOD} != no 161# info ${MKINFO} != no 162# ipfilter ${MKIPFILTER} != no 163# inet6 ${MKINET6} != no 164# kerberos ${MKKERBEROS} != no 165# kerberos4 ${MKKERBEROS4} != no 166# lint ${MKLINT} != no 167# man ${MKMAN} != no 168# manz ${MKMANZ} != no 169# nls ${MKNLS} != no 170# pam ${MKPAM} != no 171# pf ${MKPF} != no 172# postfix ${MKPOSTFIX} != no 173# profile ${MKPROFILE} != no 174# sendmail ${MKSENDMAIL} != no 175# share ${MKSHARE} != no 176# skey ${MKSKEY} != no 177# uucp ${MKUUCP} != no 178# yp ${MKYP} != no 179# 180# use_inet6 ${USE_INET6} != no 181# use_kerberos ${USE_KERBEROS} != no 182# use_yp ${USE_YP} != no 183# 184# .cat if ${MKMANZ} != "no" && ${MKCATPAGES} != "no" 185# automatically append ".gz" to the filename 186# 187# .man if ${MKMANZ} != "no" && ${MKMAN} != "no" 188# automatically append ".gz" to the filename 189# 190list_set_files() 191{ 192 for setname; do 193 list_set_lists $setname 194 done | xargs cat | \ 195 awk -v obsolete=${obsolete} ' 196 BEGIN { 197 if (! obsolete) { 198 split("'"${MKVARS}"'", needvars) 199 for (vi in needvars) { 200 nv = needvars[vi] 201 kw = tolower(nv) 202 sub(/^mk/, "", kw) 203 if (ENVIRON[nv] != "no") 204 wanted[kw] = 1 205 } 206 if (("man" in wanted) && ("catpages" in wanted)) 207 wanted[".cat"] = 1 208 if (("man" in wanted) && ("manpages" in wanted)) 209 wanted[".man"] = 1 210 } 211 } 212 213 /^#/ { 214 next; 215 } 216 217 NF > 2 && $3 != "-" { 218 split($3, keywords, ",") 219 show = 1 220 for (ki in keywords) { 221 kw = keywords[ki] 222 if (kw == "obsolete") { 223 if (obsolete) 224 print 225 next 226 } 227 if (("manz" in wanted) && 228 (kw == ".cat" || kw == ".man")) 229 $1 = $1 ".gz" 230 if (! (kw in wanted)) 231 show = 0 232 } 233 if (show) 234 print 235 next 236 } 237 238 { 239 if (! obsolete) 240 print 241 }' 242 243} 244 245# 246# list_set_lists setname 247# 248# Print to stdout a list of files, one filename per line, which 249# concatenate to create the packing list for setname. E.g., 250# 251# .../lists/base/mi 252# .../lists/base/rescue.mi 253# .../lists/base/md.i386 254# [...] 255# 256# For a given setname $set, the following files may be selected from 257# .../list/$set: 258# mi 259# ad.${MACHINE_ARCH} 260# (or) ad.${MACHINE_CPU} 261# ad.${MACHINE_CPU}.shl 262# md.${MACHINE}.${MACHINE_ARCH} 263# (or) md.${MACHINE} 264# stl.mi 265# stl.stlib 266# shl.mi 267# shl.shlib 268# lkm.mi if ${lkm} != no 269# gcc.mi 270# gcc.shl 271# tc.mi 272# tc.shl 273# rescue.shl 274# rescue.${MACHINE} 275# rescue.ad.${MACHINE_ARCH} 276# (or) rescue.ad.${MACHINE_CPU} 277# rescue.ad.${MACHINE_CPU}.shl 278# 279# Environment: 280# shlib 281# stlib 282# 283list_set_lists() 284{ 285 setname=$1 286 287 setdir=$setsdir/lists/$setname 288 echo $setdir/mi 289 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 290 # Prefer an ad.${MACHINE_ARCH} over an ad.${MACHINE_CPU}, 291 # since the arch-specific one will be more specific than 292 # the cpu-specific one. 293 if [ -f $setdir/ad.${MACHINE_ARCH} ]; then 294 echo $setdir/ad.${MACHINE_ARCH} 295 elif [ -f $setdir/ad.${MACHINE_CPU} ]; then 296 echo $setdir/ad.${MACHINE_CPU} 297 fi 298 if [ "$shlib" != "no" -a \ 299 -f $setdir/ad.${MACHINE_CPU}.shl ]; then 300 echo $setdir/ad.${MACHINE_CPU}.shl 301 fi 302 fi 303 if [ -f $setdir/md.${MACHINE}.${MACHINE_ARCH} ]; then 304 echo $setdir/md.${MACHINE}.${MACHINE_ARCH} 305 elif [ -f $setdir/md.${MACHINE} ]; then 306 echo $setdir/md.${MACHINE} 307 fi 308 if [ -f $setdir/stl.mi ]; then 309 echo $setdir/stl.mi 310 fi 311 if [ -f $setdir/stl.${stlib} ]; then 312 echo $setdir/stl.${stlib} 313 fi 314 if [ "$shlib" != "no" ]; then 315 if [ -f $setdir/shl.mi ]; then 316 echo $setdir/shl.mi 317 fi 318 if [ -f $setdir/shl.${shlib} ]; then 319 echo $setdir/shl.${shlib} 320 fi 321 fi 322 if [ "$lkm" != "no" ]; then 323 if [ -f $setdir/lkm.mi ]; then 324 echo $setdir/lkm.mi 325 fi 326 fi 327 if [ "${TOOLCHAIN_MISSING}" != "yes" ]; then 328 if [ "${HAVE_GCC3}" = "yes" ]; then 329 if [ -f $setdir/gcc.mi ]; then 330 echo $setdir/gcc.mi 331 fi 332 if [ "$shlib" != "no" ]; then 333 if [ -f $setdir/gcc.shl ]; then 334 echo $setdir/gcc.shl 335 fi 336 fi 337 else 338 if [ -f $setdir/tc.mi ]; then 339 echo $setdir/tc.mi 340 fi 341 if [ "$shlib" != "no" ]; then 342 if [ -f $setdir/tc.shl ]; then 343 echo $setdir/tc.shl 344 fi 345 fi 346 fi 347 fi 348 349 if [ -f $setdir/rescue.mi ]; then 350 echo $setdir/rescue.mi 351 fi 352 if [ -f $setdir/rescue.${MACHINE} ]; then 353 echo $setdir/rescue.${MACHINE} 354 fi 355 if [ "${MACHINE}" != "${MACHINE_ARCH}" ]; then 356 # Prefer a rescue.ad.${MACHINE_ARCH} over a 357 # rescue.ad.${MACHINE_CPU}, since the arch- 358 # specific one will be more specific than the 359 # cpu-specific one. 360 if [ -f $setdir/rescue.ad.${MACHINE_ARCH} ]; then 361 echo $setdir/rescue.ad.${MACHINE_ARCH} 362 elif [ -f $setdir/rescue.ad.${MACHINE_CPU} ]; then 363 echo $setdir/rescue.ad.${MACHINE_CPU} 364 fi 365 if [ "$shlib" != "no" -a \ 366 -f $setdir/rescue.ad.${MACHINE_CPU}.shl ]; then 367 echo $setdir/rescue.ad.${MACHINE_CPU}.shl 368 fi 369 fi 370} 371 372# arch_to_cpu mach 373# 374# Print the ${MACHINE_CPU} for ${MACHINE_ARCH}=mach, 375# as determined by <bsd.own.mk>. 376# 377arch_to_cpu() 378{ 379 MACHINE_ARCH=${1} ${MAKE:-make} -f- all <<EOMAKE 380.include <bsd.own.mk> 381all: 382 @echo \${MACHINE_CPU} 383EOMAKE 384} 385