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