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