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