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