#!/bin/csh -f
set path = ($path .)
set prog=$0
set prog=$prog:t
set nonomatch
set OBJDIR=../BUILD
if ("`/usr/bin/uname`" == "Rhapsody" ) then
set CONFIG_DIR=/usr/local/bin
else
set CONFIG_DIR=/usr/bin
endif
unset domake
unset doconfig
unset beverbose
unset MACHINE
unset profile
while ($ if ("$argv[1]" =~ -*) then
switch ("$argv[1]")
case "-c":
case "-config":
set doconfig
breaksw
case "-m":
case "-make":
set domake
breaksw
case "-cpu":
if ($ echo "${prog}: missing argument to ${argv[1]}"
exit 1
endif
set MACHINE="$argv[2]"
shift
breaksw
case "-d":
if ($ echo "${prog}: missing argument to ${argv[1]}"
exit 1
endif
set OBJDIR="$argv[2]"
shift
breaksw
case "-verbose":
set beverbose
breaksw
case "-p":
case "-profile":
set profile
breaksw
default:
echo "${prog}: ${argv[1]}: unknown switch"
exit 1
breaksw
endsw
shift
else
break
endif
end
if ($
if (! $?MACHINE) then
if (-d /NextApps) then
set MACHINE=`hostinfo | awk '/MC680x0/ { printf("m68k") } /MC880x0/ { printf("m88k") }'`
endif
endif
if (! $?MACHINE) then
if (-f /etc/machine) then
set MACHINE="`/etc/machine`"
else
echo "${prog}: no /etc/machine, specify machine type with -cpu"
echo "${prog}: e.g. ${prog} -cpu VAX CONFIGURATION"
exit 1
endif
endif
set FEATURES_EXTRA=
switch ("$MACHINE")
case IBMRT:
set cpu=ca
set ID=RT
set FEATURES_EXTRA="romp_dualcall.h romp_fpa.h"
breaksw
case SUN:
set cpu=sun3
set ID=SUN3
breaksw
default:
set cpu=`echo $MACHINE | tr A-Z a-z`
set ID=`echo $MACHINE | tr a-z A-Z`
breaksw
endsw
set FEATURES=../h/features.h
set FEATURES_H=(cs_*.h mach_*.h net_*.h\
cputypes.h cpus.h vice.h\
$FEATURES_EXTRA)
set MASTER_DIR=../conf
set MASTER = ${MASTER_DIR}/MASTER
set MASTER_CPU=${MASTER}.${cpu}
set MASTER_LOCAL = ${MASTER}.local
set MASTER_CPU_LOCAL = ${MASTER_CPU}.local
if (! -f $MASTER_LOCAL) set MASTER_LOCAL = ""
if (! -f $MASTER_CPU_LOCAL) set MASTER_CPU_LOCAL = ""
if (! -d $OBJDIR) then
if ($?beverbose) then
echo "[ creating $OBJDIR ]"
endif
mkdir -p $OBJDIR
endif
foreach SYS ($argv)
set SYSID=${SYS}_${ID}
set SYSCONF=$OBJDIR/config.$SYSID
set BLDDIR=$OBJDIR
if ($?beverbose) then
echo "[ generating $SYSID from $MASTER_DIR/MASTER{,.$cpu}{,.local} ]"
endif
echo +$SYS \
| \
cat $MASTER $MASTER_LOCAL $MASTER_CPU $MASTER_CPU_LOCAL - \
$MASTER $MASTER_LOCAL $MASTER_CPU $MASTER_CPU_LOCAL \
| \
sed -n \
-e "/^+/{" \
-e "s;[-+];#&;gp" \
-e 't loop' \
-e ': loop' \
-e 'n' \
-e '/^ -e '/^$/b loop' \
-e 's;^\([^ -e 't not' \
-e 's;\([^ -e 't not' \
-e ': not' \
-e 's;[ ]*$;;' \
-e 's;^\!\(.*\);\1 -e 'p' \
-e 't loop' \
-e 'b loop' \
-e '}' \
-e "/^[^#]/d" \
-e 's; ; ;g' \
-e "s;^# *\([^ ]*\)[ ]*=[ ]*\[\(.*\)\].*;\1#\2;p" \
| \
awk '-Fpart == 0 && $1 != "" {\
m[$1]=m[$1] " " $2;\
next;\
}\
part == 0 && $1 == "" {\
for (i=NF;i>1;i--){\
s=substr($i,2);\
c[++na]=substr($i,1,1);\
a[na]=s;\
}\
while (na > 0){\
s=a[na];\
d=c[na--];\
if (m[s] == "") {\
f[s]=d;\
} else {\
nx=split(m[s],x," ");\
for (j=nx;j>0;j--) {\
z=x[j];\
a[++na]=z;\
c[na]=d;\
}\
}\
}\
part=1;\
next;\
}\
part != 0 {\
if ($1 != "") {\
n=split($1,x,",");\
ok=0;\
for (i=1;i<=n;i++) {\
if (f[x[i]] == "+") {\
ok=1;\
}\
}\
if (NF > 2 && ok == 0 || NF <= 2 && ok != 0) {\
print $2; \
}\
} else { \
print $2; \
}\
}\
' >$SYSCONF.new
if (-z $SYSCONF.new) then
echo "${prog}: ${$SYSID}: no such configuration in $MASTER_DIR/MASTER{,.$cpu}"
rm -f $SYSCONF.new
endif
if (! -d $BLDDIR) then
if ($?beverbose) then
echo "[ creating $BLDDIR ]"
endif
mkdir -p $BLDDIR
endif
echo 'builddir "."' >> $SYSCONF.new
set OBJRELDIR=`$RELPATH $OBJROOT $OBJDIR`
echo 'objectdir "'$OBJROOT'/'$OBJRELDIR'"' >> $SYSCONF.new
set SRCDIR=`dirname $SOURCE`
echo 'sourcedir "'$SRCROOT'"' >> $SYSCONF.new
if (-f $SYSCONF) then
diff $SYSCONF $SYSCONF.new
rm -f $SYSCONF.old
mv $SYSCONF $SYSCONF.old
endif
rm -f $SYSCONF
mv $SYSCONF.new $SYSCONF
if ($?doconfig) then
if ($?beverbose) then
echo "[ configuring $SYSID ]"
endif
if ($?profile) then
$CONFIG_DIR/config -c $MASTER_DIR -p $SYSCONF
else
$CONFIG_DIR/config -c $MASTER_DIR $SYSCONF
endif
endif
if ($?domake) then
if ($?beverbose) then
echo "[ making $SYSID ]"
endif
(cd $BLDDIR; make)
endif
end