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