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