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 81unset PLATFORM 82 83while ($#argv >= 1) 84 if ("$argv[1]" =~ -*) then 85 switch ("$argv[1]") 86 case "-c": 87 case "-config": 88 set doconfig 89 breaksw 90 case "-cpu": 91 if ($#argv < 2) then 92 echo "${prog}: missing argument to ${argv[1]}" 93 exit 1 94 endif 95 set MACHINE="$argv[2]" 96 shift 97 breaksw 98 case "-soc": 99 if ($#argv < 2) then 100 echo "${prog}: missing argument to ${argv[1]}" 101 exit 1 102 endif 103 set SOC_CONFIG="$argv[2]" 104 shift 105 breaksw 106 case "-platform": 107 if ($#argv < 2) then 108 echo "${prog}: missing argument to ${argv[1]}" 109 exit 1 110 endif 111 set PLATFORM="$argv[2]" 112 shift 113 breaksw 114 case "-d": 115 if ($#argv < 2) then 116 echo "${prog}: missing argument to ${argv[1]}" 117 exit 1 118 endif 119 set OBJDIR="$argv[2]" 120 shift 121 breaksw 122 case "-m": 123 if ($#argv < 2) then 124 echo "${prog}: missing argument to ${argv[1]}" 125 exit 1 126 endif 127 set MASTER_CONF_DIR="$argv[2]" 128 shift 129 breaksw 130 case "-s": 131 if ($#argv < 2) then 132 echo "${prog}: missing argument to ${argv[1]}" 133 exit 1 134 endif 135 set SOURCEDIR="$argv[2]" 136 shift 137 breaksw 138 case "-verbose": 139 set beverbose 140 breaksw 141 case "-p": 142 case "-profile": 143 set profile 144 breaksw 145 default: 146 echo "${prog}: ${argv[1]}: unknown switch" 147 exit 1 148 breaksw 149 endsw 150 shift 151 else 152 break 153 endif 154end 155 156if ($#argv == 0) set argv=(GENERIC) 157 158if (! $?MACHINE) then 159 echo "${prog}: MACHINE not set" 160 exit 1 161endif 162 163set cpu=`echo $MACHINE | tr A-Z a-z` 164set ID=`echo $MACHINE | tr a-z A-Z` 165set MASTER_DIR=${MASTER_CONF_DIR} 166set MASTER = ${MASTER_DIR}/MASTER 167 168foreach master_file (${MASTER}.${cpu}.${SOC_CONFIG}.${PLATFORM} ${MASTER}.${cpu}.${SOC_CONFIG} ${MASTER}.${cpu}.${PLATFORM} ${MASTER}.${cpu}) 169 if (-f $master_file) then 170 set MASTER_CPU = $master_file 171 break 172 endif 173end 174 175if ($?beverbose) then 176 echo MASTER_CPU=$MASTER_CPU 177endif 178 179foreach SYS ($argv) 180 set SYSID=${SYS}_${ID} 181 set SYSCONF=$OBJDIR/config.$SYSID 182 set BLDDIR=$OBJDIR 183 if ($?beverbose) then 184 echo "[ generating $SYSID from $MASTER_DIR/MASTER{,.$cpu}{,.local} ]" 185 endif 186 echo +$SYS \ 187 | \ 188 cat $MASTER $MASTER_CPU - \ 189 $MASTER $MASTER_CPU \ 190 | \ 191 unifdef -t -DPLATFORM_${PLATFORM} -DCPU_$cpu -DSOC_CONFIG_${SOC_CONFIG} -DSYS_${SYS} - \ 192 | \ 193 sed -n \ 194 -e "/^+/{" \ 195 -e "s;[-+];#&;gp" \ 196 -e 't loop' \ 197 -e ': loop' \ 198 -e 'n' \ 199 -e '/^#/b loop' \ 200 -e '/^$/b loop' \ 201 -e 's;^\([^#]*\).*#[ ]*<\(.*\)>[ ]*$;\2#\1;' \ 202 -e 't not' \ 203 -e 's;\([^#]*\).*;#\1;' \ 204 -e 't not' \ 205 -e ': not' \ 206 -e 's;[ ]*$;;' \ 207 -e 's;^\!\(.*\);\1#\!;' \ 208 -e 'p' \ 209 -e 't loop' \ 210 -e 'b loop' \ 211 -e '}' \ 212 -e "/^[^#]/d" \ 213 -e 's; ; ;g' \ 214 -e "s;^# *\([^ ]*\)[ ]*=[ ]*\[\(.*\)\].*;\1#\2;p" \ 215 | \ 216 awk '-F#' '\ 217part == 0 && $1 != "" {\ 218 m[$1]=m[$1] " " $2;\ 219 next;\ 220}\ 221part == 0 && $1 == "" {\ 222 for (i=NF;i>1;i--){\ 223 s=substr($i,2);\ 224 c[++na]=substr($i,1,1);\ 225 a[na]=s;\ 226 }\ 227 while (na > 0){\ 228 s=a[na];\ 229 d=c[na--];\ 230 if (m[s] == "") {\ 231 f[s]=d;\ 232 } else {\ 233 nx=split(m[s],x," ");\ 234 for (j=nx;j>0;j--) {\ 235 z=x[j];\ 236 a[++na]=z;\ 237 c[na]=d;\ 238 }\ 239 }\ 240 }\ 241 part=1;\ 242 next;\ 243}\ 244part != 0 {\ 245 if ($1 != "") {\ 246 n=split($1,x,",");\ 247 ok=0;\ 248 for (i=1;i<=n;i++) {\ 249 if (f[x[i]] == "+") {\ 250 ok=1;\ 251 }\ 252 }\ 253 if (NF > 2 && ok == 0 || NF <= 2 && ok != 0) {\ 254 print $2; \ 255 }\ 256 } else { \ 257 print $2; \ 258 }\ 259}\ 260' >$SYSCONF.new 261 if (-z $SYSCONF.new) then 262 echo "${prog}: ${$SYSID}: no such configuration in $MASTER_DIR/MASTER{,.$cpu}" 263 rm -f $SYSCONF.new 264 endif 265# 266# These paths are used by config. 267# 268# "builddir" is the name of the directory where kernel binaries 269# are put. It is a single path element, never absolute, and is 270# always relative to "objectdir". "builddir" is used by config 271# solely to determine where to put files created by "config" (e.g. 272# the created Makefile and *.h's.) 273# 274# "objectdir" is the name of the directory which will hold "builddir". 275# It is a path; if relative, it is relative to the current directory 276# where config is run. It's sole use is to be prepended to "builddir" 277# to indicate where config-created files are to be placed (see above). 278# 279# "sourcedir" is the location of the sources used to build the kernel. 280# It is a path; if relative, it is relative to the directory specified 281# by the concatenation of "objectdir" and "builddir" (i.e. where the 282# kernel binaries are put). 283# 284 echo 'builddir "."' >> $SYSCONF.new 285 echo 'objectdir "'$OBJDIR'"' >> $SYSCONF.new 286 set SRCDIR=`dirname $SOURCE` 287 echo 'sourcedir "'$SRCROOT'"' >> $SYSCONF.new 288 if (-f $SYSCONF) then 289 diff $SYSCONF $SYSCONF.new 290 rm -f $SYSCONF.old 291 mv $SYSCONF $SYSCONF.old 292 endif 293 rm -f $SYSCONF 294 mv $SYSCONF.new $SYSCONF 295 if ($?doconfig) then 296 if ($?beverbose) then 297 echo "[ configuring $SYSID ]" 298 endif 299 if ($?profile) then 300 $CONFIG_DIR/config -c $SOURCEDIR -p $SYSCONF 301 else 302 $CONFIG_DIR/config -c $SOURCEDIR $SYSCONF 303 endif 304 endif 305end 306