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