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