-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Debian
executable file
·222 lines (189 loc) · 7.16 KB
/
README.Debian
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/bash
# To compile NachOS on a Debian environment (x86), you need to
# install the folowing packages:
# build-essential
# g++-multilib (on x86-64 only)
# and a MIPS cross-compiler. See below.
# At the end of the document, you will find a script that can help
# to create a cross-compiler on Debian. However, currently (11/2011),
# Debian is migrating toward multiarch and the script does not work.
#
# What I propose is to install Debian packages of a GCC MIPS cross-compiler
# that has been compiled from and on a Debian squeeze (stable)
# These packages should work on Debian stable (squeeze), testing (wheezy)
# and unstable (sid). They also work on Ubuntu sometimes requiring to
# manually install a extra package.
#
# Only the AMD64 and i386 architecture is supported by these pre-compiled
# packages, not the i386 one.
#
# Just run this script (or look at it and type the commands yourself) to
# install a MIPS cross-compiler
set -e
# either this script must be called as root or the user must be
# able to use sudo
if [ "$(whoami)" = root ]; then
ROOT=
else
ROOT=sudo
fi
# Check that we are on amd64 or i386
case "$(uname -m)" in
x86_64)
ARCH=amd64
;;
i*86)
ARCH=i386
;;
*)
echo "Wrong architechture $(uname -m). Aborting." 1>&2
exit 1
esac
install_package() {
local UPDATE=
if [ "$1" = --no-update ]; then
UPDATE=": skipping "
shift
fi
$UPDATE $ROOT apt-get update
local p
local INST_REQ=
for p in $1 ; do
if dpkg -l "$p" | grep -s '^ii' ; then
:
else
INST_REQ=1
break
fi
done
if [ -z "$INST_REQ" ]; then
return 0
fi
set +x
echo "**************************************************************"
echo "* Installing the $1 package(s) from your distrib"
echo "* $2"
echo "**************************************************************"
echo "* Refuse the installation (and try to install it yourself *"
echo "* with your usual package manager) if something seems wrong *"
echo "* (packages that need to be removed, to many packages *"
echo "* upgraded, ...) *"
echo "**************************************************************"
set -x
$ROOT apt-get install $1 $3
}
# choose installation method
if [ "$(apt-cache -q policy gcc-mipsel-linux-gnu)" == "" ] ; then
cat <<EOF
MIPS cross compiler does not seem available in your distrib.
Use mandelbrot or a virtual machine.
Some distrib can have external repositories with cross compilers.
For example, for Debian 8 (jessie), you can type (as root):
echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/cross-compilers.list
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add -
apt-get update
And restart this script
EOF
else
install_package build-essential "Installing basic development tools (make, gcc, g++, etc.)"
NO_UPDATE=--no-update
echo "MIPS cross compiler seems available in your distrib. Trying to use it"
if ! dpkg --print-foreign-architectures | grep -sq mipsel ; then
echo "Adding mipsel as a foreign architecture on your system"
$ROOT dpkg --add-architecture mipsel
NO_UPDATE=
fi
if test "$ARCH" = amd64 ; then
GCC_VER=$(gcc --version | head -1 | \
sed -e 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+\( .*\)\?$/\1/p;d')
if [ -z "$GCC_VER" ]; then
echo "Cannot find your GCC version. Aborting."
exit 1
fi
GCC_VER_MAJ="$(echo $GCC_VER | cut -d . -f 1)"
if ! dpkg --print-foreign-architectures | grep -sq i386 ; then
echo "Adding i386 as a foreign architecture on your system"
$ROOT dpkg --add-architecture i386
NO_UPDATE=
fi
fi
install_package $NO_UPDATE gcc-mipsel-linux-gnu "Installing the cross-compiler of your distrib. gcc-multiarch and g++-multiarch might be asked to be removed"
if test "$ARCH" = amd64 ; then
PACKAGES=
if [ "$(apt-cache -q policy g++-${GCC_VER_MAJ}-multilib)" != "" ] ; then
PACKAGES="$PACKAGES g++-${GCC_VER_MAJ}-multilib"
else
# before gcc 5
PACKAGES="$PACKAGES libc6-dev:i386 lib32stdc++-$GCC_VER-dev"
fi
install_package --no-update "$PACKAGES linux-libc-dev:i386" \
"in order to compile NachOS on amd64 systems" gcc-mipsel-linux-gnu
fi
echo "Ok, you should be able to compile NachOS"
exit 0
fi
############################################################################
####### # # ######
# ## # # #
# # # # # #
##### # # # # #
# # # # # #
# # ## # #
####### # # ######
# never go further: creating a MIPS cross-compiler is not working for now
exit 0
############################################################################
# Here is a script to build and install a cross compiler to be used on Nachos
#
# Contrary to previous document, this script build a recent cross compiler
# (gcc 4.6 by default) so gcc 2.95 is not used anymore.
# improvement: software is installed as real packages on the system
# inconvenient: only works for Debian (unstable and perhaps
# testing/wheezy) and it could perhaps work with ubuntu (feedback welcome)
#
# Note: recent gcc requires the target libc to build the cross-compiler.
# This is why I cannot tell how to build one only from gcc sources
# (as it was done with gcc 2.95)
# I think I put all required commands. Howver, it is probably better
# to copy and paste the command to be able to look at the results
#
# WARNING: building the cross compiler itself requires lots of time and
# lots of available disk space. It is probably possible to reduce this
# if we build only the C cross compiler (and not C++, ...) but I did not
# look if this can be easily done.
# Do not copy-paste the next line in a interractive shell
# (else your shell will exit as soon as a command does not succeed)
set -ex
mkdir -p tools
cd tools
TARGET=mipsel-linux-gnu
if test "$(ls binutils-$TARGET_*.deb 2>/dev/null)" ; then
echo "Skipping building and installing binutils (already there)"
else
apt-get source binutils
sudo apt-get build-dep binutils
sudo apt-get install fakeroot build-essential binutils-multiarch
cd binutils-*
# on squeeze, replace the following line by
# env TARGET=$TARGET fakeroot debian/rules binary-cross
env TARGET=$TARGET dpkg-buildpackage -b -uc -us
cd ..
sudo dpkg -i binutils-$TARGET_*.deb
fi
sudo apt-get install dpkg-cross xapt
sudo xapt --mirror http://ftp.fr.debian.org/debian/ \
--arch mipsel --suite unstable --keep-cache libc6-dev libc6 \
libc6-dev-mips64 libc6-dev-mipsn32 libc6-mips64 linux-libc-dev libc6-mipsn32
# At least 4.5. Previous does not have a correct cross-compiler build setup
GCC_V=4.6
apt-get source gcc-${GCC_V}
sudo apt-get build-dep gcc-${GCC_V}
sudo apt-get install gcc-${GCC_V}-source
cd gcc-${GCC_V}-*
env GCC_TARGET=mipsel debian/rules control
env GCC_TARGET=mipsel dpkg-buildpackage -rfakeroot -us -uc -b
cd ..
sudo dpkg -i gcc-${GCC_V}-mipsel-linux-gnu_*.deb gcc-${GCC_V}-mipsel-linux-gnu-base_*.deb cpp-${GCC_V}-mipsel-linux-gnu_*.deb libgcc1-mipsel-cross_*.deb libgomp1-mipsel-cross_*.deb
# Once the packages are installed, all the tools directory can be removed.
# This version of nachos will automatically detect and use this cross-compiler
# Enjoy.