1#!/bin/csh -f 2set path = ($path .) 3###################################################################### 4# HISTORY 5# 1-Dec-87 Michael Young (mwyoung) at Carnegie-Mellon University 6# Added "-verbose" switch, so this script produces no output 7# in the normal case. 8# 9# 10-Oct-87 Mike Accetta (mja) at Carnegie-Mellon University 10# Flushed cmu_*.h and spin_locks.h 11# [ V5.1(XF18) ] 12# 13# 6-Apr-87 Avadis Tevanian (avie) at Carnegie-Mellon University 14# Use MASTER.local and MASTER.<machine>.local for generation of 15# configuration files in addition to MASTER and MASTER.<machine>. 16# 17# 25-Mar-87 Mike Accetta (mja) at Carnegie-Mellon University 18# Removed use of obsolete wb_*.h files when building the feature 19# list; modified to save the previous configuration file and 20# display the differences between it and the new file. 21# [ V5.1(F8) ] 22# 23# 25-Mar-87 Avadis Tevanian (avie) at Carnegie-Mellon University 24# If there is no /etc/machine just print out a message telling 25# user to use the -cpu option. I thought this script was supposed 26# to work even without a /etc/machine, but it doesn't... and this 27# is the easiest way out. 28# 29# 13-Mar-87 Mike Accetta (mja) at Carnegie-Mellon University 30# Added "romp_fpa.h" file to extra features for the RT. 31# [ V5.1(F7) ] 32# 33# 11-Mar-87 Mike Accetta (mja) at Carnegie-Mellon University 34# Updated to maintain the appropriate configuration features file 35# in the "machine" directory whenever the corresponding 36# configuration is generated. This replaces the old mechanism of 37# storing this directly in the <sys/features.h> file since it was 38# machine dependent and also precluded building programs for more 39# than one configuration from the same set of sources. 40# [ V5.1(F6) ] 41# 42# 21-Feb-87 Mike Accetta (mja) at Carnegie-Mellon University 43# Fixed to require wired-in cpu type names for only those 44# machines where the kernel name differs from that provided by 45# /etc/machine (i.e. IBMRT => ca and SUN => sun3); updated to 46# permit configuration descriptions in both machine indepedent 47# and dependent master configuration files so that attributes can 48# be grouped accordingly. 49# [ V5.1(F3) ] 50# 51# 17-Jan-87 Mike Accetta (mja) at Carnegie-Mellon University 52# Updated to work from any directory at the same level as 53# "conf"; generate configuration from both MASTER and 54# MASTER.<machine-type> files; added -cpu switch. 55# [ V5.1(F1) ] 56# 57# 18-Aug-86 Mike Accetta (mja) at Carnegie-Mellon University 58# Added -make switch and changed meaning of -config; upgraded to 59# allow multiple attributes per configuration and to define 60# configurations in terms of these attributes within MASTER. 61# 62# 14-Apr-83 Mike Accetta (mja) at Carnegie-Mellon University 63# Added -config switch to only run /etc/config without 64# "make depend" and "make". 65# 66###################################################################### 67 68set prog=$0 69set prog=$prog:t 70set nonomatch 71set OBJDIR=../BUILD 72set SOURCEDIR=. 73set CONFIG_DIR=$OBJROOT/SETUP/config 74set MASTER_CONF_DIR=. 75 76unset doconfig 77unset beverbose 78unset MACHINE 79unset profile 80unset SOC_CONFIG 81 82while ($#argv >= 1) 83 if ("$argv[1]" =~ -*) then 84 switch ("$argv[1]") 85 case "-c": 86 case "-config": 87 set doconfig 88 breaksw 89 case "-cpu": 90 if ($#argv < 2) then 91 echo "${prog}: missing argument to ${argv[1]}" 92 exit 1 93 endif 94 set MACHINE="$argv[2]" 95 shift 96 breaksw 97 case "-soc": 98 if ($#argv < 2) then 99 echo "${prog}: missing argument to ${argv[1]}" 100 exit 1 101 endif 102 set SOC_CONFIG="$argv[2]" 103 shift 104 breaksw 105 case "-d": 106 if ($#argv < 2) then 107 echo "${prog}: missing argument to ${argv[1]}" 108 exit 1 109 endif 110 set OBJDIR="$argv[2]" 111 shift 112 breaksw 113 case "-m": 114 if ($#argv < 2) then 115 echo "${prog}: missing argument to ${argv[1]}" 116 exit 1 117 endif 118 set MASTER_CONF_DIR="$argv[2]" 119 shift 120 breaksw 121 case "-s": 122 if ($#argv < 2) then 123 echo "${prog}: missing argument to ${argv[1]}" 124 exit 1 125 endif 126 set SOURCEDIR="$argv[2]" 127 shift 128 breaksw 129 case "-verbose": 130 set beverbose 131 breaksw 132 case "-p": 133 case "-profile": 134 set profile 135 breaksw 136 default: 137 echo "${prog}: ${argv[1]}: unknown switch" 138 exit 1 139 breaksw 140 endsw 141 shift 142 else 143 break 144 endif 145end 146 147if ($#argv == 0) set argv=(GENERIC) 148 149if (! $?MACHINE) then 150 echo "${prog}: MACHINE not set" 151 exit 1 152endif 153 154set cpu=`echo $MACHINE | tr A-Z a-z` 155set ID=`echo $MACHINE | tr a-z A-Z` 156set MASTER_DIR=${MASTER_CONF_DIR} 157set MASTER = ${MASTER_DIR}/MASTER 158set MASTER_CPU=${MASTER}.${cpu} 159set MASTER_CPU_PER_SOC=${MASTER}.${cpu}.${SOC_CONFIG} 160if (-f $MASTER_CPU_PER_SOC) set MASTER_CPU = ${MASTER_CPU_PER_SOC} 161 162foreach SYS ($argv) 163 set SYSID=${SYS}_${ID} 164 set SYSCONF=$OBJDIR/config.$SYSID 165 set BLDDIR=$OBJDIR 166 if ($?beverbose) then 167 echo "[ generating $SYSID from $MASTER_DIR/MASTER{,.$cpu}{,.local} ]" 168 endif 169 echo +$SYS \ 170 | \ 171 cat $MASTER $MASTER_CPU - \ 172 $MASTER $MASTER_CPU \ 173 | \ 174 sed -n \ 175 -e "/^+/{" \ 176 -e "s;[-+];#&;gp" \ 177 -e 't loop' \ 178 -e ': loop' \ 179 -e 'n' \ 180 -e '/^#/b loop' \ 181 -e '/^$/b loop' \ 182 -e 's;^\([^#]*\).*#[ ]*<\(.*\)>[ ]*$;\2#\1;' \ 183 -e 't not' \ 184 -e 's;\([^#]*\).*;#\1;' \ 185 -e 't not' \ 186 -e ': not' \ 187 -e 's;[ ]*$;;' \ 188 -e 's;^\!\(.*\);\1#\!;' \ 189 -e 'p' \ 190 -e 't loop' \ 191 -e 'b loop' \ 192 -e '}' \ 193 -e "/^[^#]/d" \ 194 -e 's; ; ;g' \ 195 -e "s;^# *\([^ ]*\)[ ]*=[ ]*\[\(.*\)\].*;\1#\2;p" \ 196 | \ 197 awk '-F#' '\ 198part == 0 && $1 != "" {\ 199 m[$1]=m[$1] " " $2;\ 200 next;\ 201}\ 202part == 0 && $1 == "" {\ 203 for (i=NF;i>1;i--){\ 204 s=substr($i,2);\ 205 c[++na]=substr($i,1,1);\ 206 a[na]=s;\ 207 }\ 208 while (na > 0){\ 209 s=a[na];\ 210 d=c[na--];\ 211 if (m[s] == "") {\ 212 f[s]=d;\ 213 } else {\ 214 nx=split(m[s],x," ");\ 215 for (j=nx;j>0;j--) {\ 216 z=x[j];\ 217 a[++na]=z;\ 218 c[na]=d;\ 219 }\ 220 }\ 221 }\ 222 part=1;\ 223 next;\ 224}\ 225part != 0 {\ 226 if ($1 != "") {\ 227 n=split($1,x,",");\ 228 ok=0;\ 229 for (i=1;i<=n;i++) {\ 230 if (f[x[i]] == "+") {\ 231 ok=1;\ 232 }\ 233 }\ 234 if (NF > 2 && ok == 0 || NF <= 2 && ok != 0) {\ 235 print $2; \ 236 }\ 237 } else { \ 238 print $2; \ 239 }\ 240}\ 241' >$SYSCONF.new 242 if (-z $SYSCONF.new) then 243 echo "${prog}: ${$SYSID}: no such configuration in $MASTER_DIR/MASTER{,.$cpu}" 244 rm -f $SYSCONF.new 245 endif 246# 247# These paths are used by config. 248# 249# "builddir" is the name of the directory where kernel binaries 250# are put. It is a single path element, never absolute, and is 251# always relative to "objectdir". "builddir" is used by config 252# solely to determine where to put files created by "config" (e.g. 253# the created Makefile and *.h's.) 254# 255# "objectdir" is the name of the directory which will hold "builddir". 256# It is a path; if relative, it is relative to the current directory 257# where config is run. It's sole use is to be prepended to "builddir" 258# to indicate where config-created files are to be placed (see above). 259# 260# "sourcedir" is the location of the sources used to build the kernel. 261# It is a path; if relative, it is relative to the directory specified 262# by the concatenation of "objectdir" and "builddir" (i.e. where the 263# kernel binaries are put). 264# 265 echo 'builddir "."' >> $SYSCONF.new 266 echo 'objectdir "'$OBJDIR'"' >> $SYSCONF.new 267 set SRCDIR=`dirname $SOURCE` 268 echo 'sourcedir "'$SRCROOT'"' >> $SYSCONF.new 269 if (-f $SYSCONF) then 270 diff $SYSCONF $SYSCONF.new 271 rm -f $SYSCONF.old 272 mv $SYSCONF $SYSCONF.old 273 endif 274 rm -f $SYSCONF 275 mv $SYSCONF.new $SYSCONF 276 if ($?doconfig) then 277 if ($?beverbose) then 278 echo "[ configuring $SYSID ]" 279 endif 280 if ($?profile) then 281 $CONFIG_DIR/config -c $SOURCEDIR -p $SYSCONF 282 else 283 $CONFIG_DIR/config -c $SOURCEDIR $SYSCONF 284 endif 285 endif 286end 287