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