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