-
Notifications
You must be signed in to change notification settings - Fork 6
/
conf.sysv.sh
executable file
·191 lines (186 loc) · 4.74 KB
/
conf.sysv.sh
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
189
#!/bin/sh
# $Author: djh $ $Date: 1994/10/10 08:54:05 $
# $Header: /mac/src/cap60/RCS/conf.sysv.sh,v 2.2 1994/10/10 08:54:05 djh Rel djh $
# $Revision: 2.2 $
# CAP System V configuration aid shell script. This ain't perfect,
# but it's a start
#
# execute with /bin/sh conf.sysv.sh if your system won't run it (ksh is okay
# too)
#
# Usage: conf.sysv.sh [output file name]
#
mydir=`pwd`
PCAT=/bin/cat
PGREP=grep
if [ -f /usr/ccs/bin/nm ]; then
PNM="/usr/ccs/bin/nm -p"
else
PNM=/bin/nm
fi
ccompiler=cc
export PGREP
# define to sh or /bin/sh if shell scripts can't be "executed" for some reason
USESH=""
needfcntldoth=0
usechown=0
echo "This is the CAP System V configuration aid script. This will"
echo "attempt to help you generate "define"s suitable for inclusion in"
echo "netat/sysvcompat.h for a particular machine"
echo
echo "Please refer to NOTES and PORTING before you run if you haven't"
echo "already"
echo
echo
if [ -f /bin/uname ]; then
uname > /dev/null 2>/dev/null
sysv=$?
else
sysv=1
fi
if [ $sysv -ne 0 ]; then
echo "Your system is probably not a System V based machine, but"
echo "we shall proceed in any event"
fi
echo
echo "Seeing if we need to include fcntl.h for definitions normally"
echo "found in <sys/file.h> under BSD"
echo "Temporary files: /tmp/csv$$.c, csv$$.o"
echo "[Hit carriage return to continue]"
read ans
trap "
echo Exiting... Wait..
if [ -f /tmp/csv$$.c ]; then rm -f /tmp/csv$$.c; fi;
if [ -f csv$$.o ]; then rm -f csv$$.o fi
exit 255" 2
if [ -f /usr/include/sys/file.h ]; then
exec > /tmp/csv$$.c
echo "#include <sys/file.h>"
echo "main(){int i = O_RDONLY|O_WRONLY|O_RDWR|O_TRUNC;}"
exec > /dev/tty
${ccompiler} -c /tmp/csv$$.c > /dev/null 2>/dev/null
rc=$?
else
rc=1
fi
if [ $rc -ne 0 ]; then
echo
echo "We will include <fcntl.h> to get mappings for O_RDONLY, etc"
echo "since they don't seem to be in <sys/file.h>"
needfcntldoth=1
else
echo
echo "Shouldn't need fcntl.h"
fi
if [ -f /tmp/csv$$.c ]; then rm -f /tmp/csv$$.c; fi
if [ -f csv$$.o ]; then rm -f csv$$.o; fi
trap 2
echo
echo "Seeing if we can use chown to give away files"
echo "Temporary files: /tmp/csv$$.c, xsv$$"
echo "[Hit carriage return to continue]"
read ans
trap "
echo Exiting... Wait...
if [ -f /tmp/csv$$.c ]; then rm -f /tmp/csv$$.c; fi;
if [ -f xsv$$ ]; then rm -f xsv$$ fi
exit 255" 2
exec > /tmp/csv$$.c
echo "main(){int u=getuid(),g=getgid();u++;exit(chown(\"/tmp/csv$$.c\",u,g));}"
exec > /dev/tty
${ccompiler} -o xsv$$ /tmp/csv$$.c > /dev/null 2>/dev/null
rc=$?
if [ $rc -eq 0 -a -f xsv$$ ]; then
./xsv$$
rc=$?
else
rc=1
fi
if [ $rc -eq 0 ]; then
echo
echo "Yes, we can use chown to give away files."
usechown=1
else
echo
echo "Can't use chown"
fi
if [ -f /tmp/csv$$.c ]; then rm -f /tmp/csv$$.c; fi
if [ -f xsv$$ ]; then rm -f xsv$$; fi
trap 2
echo
echo "Checking for various system calls and required header files for"
echo "System V compatibility"
echo "Temporary files: defines.tmp (not erased), /tmp/csv$$"
echo
echo "[Hit carriage return to continue]"
read ans
echo
trap "
echo Exiting... Wait...
if [ -f /tmp/csv$$ ]; then rm -f /tmp/csv$$; fi; exit 255" 2
if [ -f /lib/386/Slibc.a ]; then
echo "Getting name list from /lib/386/Slib[cx].a..."
${PNM} /lib/386/Slibc.a > /tmp/csv$$
${PNM} /lib/386/Slibx.a >> /tmp/csv$$
else
echo "Getting name list from /lib/libc.a..."
${PNM} /lib/libc.a > /tmp/csv$$
fi
names=$?
if [ $names -ne 0 ]; then
echo "Couldn't get the name list!"
else
echo "Done, running function configuration"
${USESH} ./conf.func.sh /tmp/csv$$ conf.sysv.lst cpp defines.tmp
rc=$?
if [ $rc -eq 1 ]; then
if [ -z "${USESH}" ]; then
sh conf.func.sh /tmp/csv$$ conf.sysv.lst cpp defines.tmp
fi
fi
echo "Done."
fi
rm -f /tmp/csv$$
trap 2
# now setup
if [ -z "$1" ]; then
of=sysv.cpp
else
of=$1
fi
echo
echo "[Hit carriage return to continue]"
read ans
echo
if [ -f ${of} ]; then
echo "Getting ready to overwrite existing ${of}"
else
echo "Getting ready to create ${of}"
fi
echo "[Hit carriage return to continue]"
read ans
echo "Creating ${of}"
exec > ${of}
echo "If all the defines are commented out, then you really don't need"
echo "to put the output into sysvcompat.h"
echo
cat defines.tmp
if [ $needfcntldoth -eq 1 ]; then
echo "# define NEEDFCNTLDOTH /* if need fcntl.h for O_... */"
else
echo "/* # define NEEDFCNTLDOTH */ /* if need fcntl.h for O_... */"
fi
if [ $usechown -eq 1 ]; then
echo "# define USECHOWN /* sysv allows us */"
else
echo "/* # define USECHOWN */ /* sysv allows us */"
fi
exec > /dev/tty
echo "${of} configured"
echo
echo "Done. ${of} now contains a set of defines suitable for inclusion"
echo "in sysvcompat.h. You should include them with an ifdef approriate"
echo "for your machine"
echo
echo "If all the defines are commented out, then you really don't need"
echo "to put the output into sysvcompat.h"