-
Notifications
You must be signed in to change notification settings - Fork 7
/
:mkucbcmd
188 lines (180 loc) · 4.32 KB
/
:mkucbcmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ident "@(#)mk::mkucbcmd 1.1.4.1"
#
if i386
then
echo ""
echo ""
echo " Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T"
echo " All Rights Reserved"
echo ""
echo " THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T"
echo " The copyright notice above does not evidence any actual or"
echo " intended publication of such source code."
echo ""
echo ""
echo ""
fi
echo $0 started at `date`
MAKE=${MAKE:-make}
CLOBBER=${CLOBBER:-"ON"}
# If we are in a cross compilation environment then use cross compiler
if [ "$ROOT" != "" ]
then
if u3b2 || u3b15
then
AS=m32as export AS
CC=m32cc export CC
LD=m32ld export LD
fi
if i386
then
AS=i386as export AS
CC=i386cc export CC
LD=i386ld export LD
fi
else
AS=as export AS
CC=cc export CC
LD=ld export LD
fi
LORDER=${PFX}lorder
TSORT=${PFX}tsort
export LORDER TSORT
# Insure that only one machine type is valid
# Note: the redirection is needed to handle the possibility
# of a nonexistent file in the $MACH machine list
MACH="vax pdp11 u3b2 u3b u3b15 i386"
if [ ! -d $ROOT/usr/ucb ] ; then mkdir $ROOT/usr/ucb ; fi
(truecnt=0
for mach in $MACH
do
`$mach`
if [ $? -eq 0 ]
then
truecnt=`expr $truecnt + 1`
fi
done
if [ $truecnt -ne 1 ]
then
echo ":mkcmd: **** Only one of the following machine types can"
echo " be true: $MACH"
exit 1
fi ) 2>/dev/null
#
places=${places-$ROOT/etc/places}
if [ -r $places ]
then
. $places
else
SRC=${SRC-$ROOT/usr/src}
LSRC=${LSRC-$ROOT/usr/lsrc}
BIN=${BIN-$ROOT/bin}
UBIN=${UBIN-$ROOT/usr/bin}
LBIN=${LBIN-$ROOT/usr/lbin}
fi
LDFILE=${LDFILE-${SRC}/ldflags}
# Initialize default flag values:
# fflag - controls the FFLAG varible. It is set to either null
# (use hardware floating point) or '-f' (use software
# simulation floating point).
# sflag - shared text, turns off the -i and -n loader options.
# Saves the intermediate .c file from a yacc or lex in
# <filename>.x for later :mkcmd runs.
# ldlibs - shared library flag. It is either "-lnsl_s" (build w/the
# shared libnsl_s.a) or "-lc_s -lnsl_s" (build w/both
# shared libc_s.a and libnsl_s.a). Default is both.
# iflag - seperate I&D space. It is either set to '-i' (when building
# certain commands on a 16-bit machine (e.g. PDP11/70)
# or null (for all other cases).
# symlink -variable to pass symbolic links to makefiles
fflag=
sflag=
iflag=
CCSTYPE=${CCSTYPE:-ELF}; export CCSTYPE
if [ x$CCSTYPE = xCOFF ]
then
ldlibs=${LDLIBS:-"-lc_s"}
else
ldlibs=${LDLIBS:-"-dy"}
fi
ldflags=
_SHORARCH_="-dn" export _SHORARCH_
symlink=${SYMLINK:-"ln -s"}
for opt in $*
do
case $opt in
-f) fflag="-f"
;;
-s) sflag=-s
yaccrm="YACCRM=:"
iflag=
;;
-*) echo ":mkcmd; **** unknown option '$opt' - ignored"
;;
*) break
;;
esac
shift
done
#
# Process remaining arguments as source that needs to be built.
# The three interesting variables are:
# B - basename of each argument
# BASE - basename of each option with its dot suffix removed
# OBJ - file to be installed if the build is successful
#
cd $SRC/ucbcmd
arguments=$*
for arg in $arguments
do(
OBJ=
B=`basename $arg`
# if not a directory then remove suffix and determine the file type
if [ "$source" = "$SRC" -a -f $LSRC/ucbcmd/$B ]
then source=$LSRC
cd ${source}/ucbcmd
fi
#
if [ -r $LDFILE ]
then ldflags=`grep "^${BASE} " $LDFILE | sed -e "s/${BASE} //"`
if [ -z "$fflag" ]
then ldflags=`echo $ldflags | sed -e 's/-f//'`
fi
if [ "$sflag" = "-s" ]
then ldflags=`echo $ldflags | sed -e 's/-i//'`
else if [ `expr x$ldflags : '.*-i'` != 0 ]
then ldflags=`echo $ldflags | sed -e 's/-n//'`
fi
fi
else ldflags=""
fi
#
# Now build the command
BASE=$B
if [ -d $B ]
then echo "cd $B"
cd $B
if [ -f $B.mk ]
then CMD="$MAKE -b -f $B.mk ARGS=\"${ARGS}\" SYMLINK='$symlink' LDLIBS='$ldlibs' IFLAG=\"$iflag\" FFLAG=\"$fflag\" install"
if [ "$ldflags" ]
then CMD="$CMD LDFLAGS='$ldflags'"
fi
echo "$CMD"
if eval $CMD
then ret=0
else ret=1
fi
CMD="$MAKE -b -f $B.mk SYMLINK='$symlink' LDLIBS='$ldlibs' IFLAG=\"$iflag\" FFLAG=\"$fflag\" $yaccrm clobber"
test "$CLOBBER" != "OFF" &&
(echo "$CMD" ; eval $CMD)
if [ $ret -ne 0 ]
then echo "**** Build of ${BASE} failed ($MAKE)"
fi
else echo "**** Build of $B failed (no makefile found in directory)"
fi
rm -f *.o
else echo ":mkcmd: *** no directory found for $B under $source"
fi
#
# If build was successful install new object in appropriate bin
);done