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