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