This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·199 lines (165 loc) · 4.77 KB
/
configure
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
190
191
192
193
194
195
196
197
198
199
#!/bin/sh
#
# Configure script for OS/161 tree.
# This generates the file "defs.mk" at the top level of the tree.
#
# Usage: ./configure [options]
# where you can get a list of the options by doing ./configure --help.
#
# Must be run with the top of the OS/161 tree as its current directory.
#
# Note: while this superficially acts like a GNU Autoconf configure
# script, it was not generated by autoconf. Scripts generated by
# autoconf are much harder to read. :-)
#
# If this script bombs out, you can create defs.mk by hand based on
# the comments in mk/os161.config.mk.
#
# Target hardware platform and machine type.
PLATFORM='sys161'
MACHINE='mips'
# Default optimize/debug flag: optimize.
DEBUG='-O2'
# Default location of the root of the installed system.
# Note that we quote it such that the reference to the home directory
# is a make variable, not a shell variable. This means it gets expanded
# when make runs rather than when this script runs.
OSTREE='$(HOME)/os161/root'
# By default don't explicitly configure a Python interpreter.
PYTHON_INTERPRETER=
# Assume this
HOST_CC=gcc
##################################################
#
# Check to make sure we're in the right place.
if [ ! -d kern/main ]; then
echo 'Please run configure from the top of the OS/161 tree.'
exit 1
fi
#
# Process the command-line options.
while [ "x$1" != x ]; do
case "$1" in
--debug) DEBUG='-g';;
--ostree=*) OSTREE=`echo $1 | sed 's,^[^=]*=,,'`;;
--help|*)
more <<EOF
Usage: ./configure [options]
where the options are:
--help Print this message.
--debug Compile the user-level programs with debug info.
This is disabled by default because there's no
support for userlevel source debugging in OS/161.
(Note: debug info in the kernel is controlled by
the kernel config file.)
--ostree=PATH Install the compiled system in a directory tree
rooted at PATH. Default is \$HOME/os161/root.
EOF
exit
;;
esac
shift
done
# Check if the host system supports 4.4BSD <err.h>.
printf "Checking for <err.h>... "
cat > __conftest.c <<EOF
#include <err.h>
int
main()
{
err(0, "works");
return 1;
}
EOF
OK=0
if $HOST_CC __conftest.c -o __conftest >/dev/null 2>&1; then
if ./__conftest >/dev/null 2>&1; then
OK=1
fi
fi
rm -f __conf*
if [ $OK = 1 ]; then
echo 'yes'
else
echo 'no'
COMPAT_CFLAGS="${COMPATCFLAGS} -DNEED_ERR"
COMPAT_TARGETS="${HOSTTARGETS} install-errh"
fi
# Check if the host system has ntohll() and htonll().
printf "Checking for ntohll()..."
cat > __conftest.c <<EOF
#include <arpa/inet.h>
int
main()
{
int ok = ntohll(0xbeefbeefbeefbeefULL) != 0;
return !ok; /* exit(0) for success */
}
EOF
OK=0
if $HOST_CC __conftest.c -o __conftest >/dev/null 2>&1; then
if ./__conftest >/dev/null 2>&1; then
OK=1
fi
fi
rm -f __conf*
if [ $OK = 1 ]; then
echo 'yes'
else
echo 'no'
COMPAT_CFLAGS="${COMPATCFLAGS} -DNEED_NTOHLL"
HOST_CFLAGS="${HOST_CFLAGS} -DDECLARE_NTOHLL"
fi
# Look for a Python interpreter.
PYTHON=
for PYNAME in \
python python2.7 \
/usr/local/bin/python /usr/local/bin/python2.7 \
/usr/pkg/bin/python /usr/pkg/bin/python2.7 \
/opt/bin/python /opt/bin/python2.7 \
; do
PYVERSION=`($PYNAME -V) 2>&1 || echo none`
case "$PYVERSION" in
Python\ 2.*|Python\ 3.*) PYTHON=$PYNAME;;
none) ;;
*) ;; # ?
esac
done
case "$PYTHON" in
python) ;;
/*) PYTHON_INTERPRETER="$PYTHON";;
*) PYTHON_INTERPRETER="/usr/bin/env $PYTHON";;
esac
####################
# Now generate defs.mk.
echo 'Generating defs.mk.'
(
# First, put an explanatory comment at the top.
cat <<EOF
# This file was generated by configure. Edits will disappear if you rerun
# configure. If you find that you need to edit this file to make things
# work, let the course staff know and we'll try to fix the configure script.
#
# The purpose of this file is to hold all the makefile definitions
# needed to adjust the OS/161 build process to any particular
# environment. If I've done it right, all you need to do is rerun the
# configure script and make clean if you start working on a different
# host OS. If I've done it mostly right, you may need to edit this
# file but you still hopefully won't need to edit any of the
# makefiles.
#
# The things that can be set here are documented in mk/os161.config.mk.
#
EOF
echo "OSTREE=${OSTREE}"
echo "PLATFORM=${PLATFORM}"
echo "MACHINE=${MACHINE}"
echo "COMPAT_CFLAGS=${COMPAT_CFLAGS}"
echo "COMPAT_TARGETS=${COMPAT_TARGETS}"
if [ "x$HOST_CFLAGS" != x ]; then
echo "HOST_CFLAGS+=$HOST_CFLAGS"
fi
if [ "x$PYTHON_INTERPRETER" != x ]; then
echo "PYTHON_INTERPRETER=$PYTHON_INTERPRETER"
fi
) > defs.mk