-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·151 lines (124 loc) · 4 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
#!/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)/cs350-os161/root'
# Assume this
HOST_CC=gcc
##################################################
#
# Check to make sure we're in the right place.
if [ ! -d kern/startup ]; then
echo 'Please run configure from the top of the OS/161 tree.'
exit 1
fi
# UW Mod
# Default toolchain name.
TOOLPREFIX="cs350-"
#
# Process the command-line options.
while [ "x$1" != x ]; do
case "$1" in
--debug) DEBUG='-g';;
--ostree=*) OSTREE=`echo $1 | sed 's,^[^=]*=,,'`;;
# UW Mod
--toolprefix=*) TOOLPREFIX=`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/cs161/root.
--toolprefix=NAME Set up to use compiler and tools named with a
prefix of NAME. The default is "cs350-", so the
tools used are called cs350-gcc, cs350-ld, etc.
The directory with these tools should be on your
shell's search path.
EOF
exit
;;
esac
shift
done
# Check if the host system supports 4.4BSD <err.h>.
echo -n "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
####################
# 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}"
# UW Mod
echo "TOOLPREFIX=${TOOLPREFIX}"
) > defs.mk