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