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