/
Makefile
212 lines (192 loc) · 7.27 KB
/
Makefile
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
TARGET=or1k-linux-gnu
ARCH=openrisc
DIR=$(CURDIR)
BUILDDIR=/srv/build
MAKEOPTS=-j$(shell ls /sys/bus/cpu/devices/ | wc -l)
# Enable if playing with the linker
#EXTRA_BINUTILS="--enable-cgen-maint"
NATIVE_TARGET=x86_64-linux
all: linux
clean:
(cd linux/; ARHC="openrisc" make clean)
rm -fr /srv/compilers/openrisc-devel/*
rm -f .building .*-stamp || true
rm -fr ${BUILDDIR}/build-*
rm -fr ${DIR}/initramfs/lib ${DIR}/initramfs/usr/lib
binutils: .binutils-stamp
boot-gcc: .boot-gcc-stamp
linux-headers: .linux-headers-stamp
glibc: .glibc-stamp
gcc: .gcc-stamp
dejagnu: .dejagnu-stamp
or1ksim: .or1ksim-stamp
qemu: .qemu-stamp
root: .root-stamp
linux: .linux-stamp
gdb: .gdb-stamp
gdbserver: .gdbserver-stamp
binutils-native: .binutils-native-stamp
gcc-native: .gcc-native-stamp
.PHONY: all clean binutils boot-gcc linux-headers glibc gcc dejagnu
.PHONY: or1ksim root linux gdb gdbserver binutils-native gcc-native qemu
.binutils-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-src
mkdir ${BUILDDIR}/build-or1k-src
(cd ${BUILDDIR}/build-or1k-src && \
${DIR}/binutils-gdb/configure --target=${TARGET} --prefix=/srv/compilers/openrisc-devel \
--disable-shared --disable-itcl --disable-tk --disable-tcl --disable-winsup \
--disable-libgui --disable-rda --disable-sid --disable-sim --disable-gdb \
--with-sysroot --disable-newlib --disable-libgloss ${EXTRA_BINUTILS} && \
make ${MAKEOPTS} && \
make install)
touch $(@)
.boot-gcc-stamp: .binutils-stamp
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-gcc
mkdir ${BUILDDIR}/build-or1k-gcc
(cd ${BUILDDIR}/build-or1k-gcc && \
${DIR}/or1k-gcc/configure --target=${TARGET} --prefix=/srv/compilers/openrisc-devel \
--disable-libssp --disable-decimal-float --enable-vtable-verify \
--enable-languages=c --without-headers \
--enable-threads=single --disable-libgomp --disable-libmudflap \
--disable-shared --disable-libquadmath --disable-libatomic && \
make ${MAKEOPTS} && \
make install)
touch $(@)
.linux-headers-stamp:
echo "$(@)" > .building
cd linux && \
make ARCH="${ARCH}" INSTALL_HDR_PATH=/srv/compilers/openrisc-devel/${TARGET}/sys-root/usr headers_install && \
make ARCH="${ARCH}" INSTALL_HDR_PATH=${DIR}/initramfs/usr headers_install
touch $(@)
.glibc-stamp: .linux-headers-stamp .boot-gcc-stamp
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-glibc
mkdir ${BUILDDIR}/build-or1k-glibc
(cd ${BUILDDIR}/build-or1k-glibc && \
${DIR}/or1k-glibc/configure --host=${TARGET} \
--prefix=/usr \
--with-headers=/srv/compilers/openrisc-devel/${TARGET}/sys-root/usr/include && \
make -C ${DIR}/or1k-glibc/locale -r objdir="${BUILDDIR}/build-or1k-glibc" C-translit.h && \
make ${MAKEOPTS} && \
make install_root=/srv/compilers/openrisc-devel/${TARGET}/sys-root install -j && \
make install_root=${DIR}/initramfs install -j)
touch $(@)
.gcc-stamp: .glibc-stamp
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-gcc
mkdir ${BUILDDIR}/build-or1k-gcc
(cd ${BUILDDIR}/build-or1k-gcc && \
${DIR}/or1k-gcc/configure --target=${TARGET} --prefix=/srv/compilers/openrisc-devel \
--enable-languages=c,c++ --enable-threads=posix \
--disable-libgomp --disable-libmudflap --enable-vtable-verify \
--with-sysroot=/srv/compilers/openrisc-devel/${TARGET}/sys-root --disable-multilib && \
make ${MAKEOPTS} && \
make install)
cp -aR /srv/compilers/openrisc-devel/${TARGET}/lib/*.so* ${DIR}/initramfs/lib/
${TARGET}-strip ${DIR}/initramfs/lib/*.so* || true
touch $(@)
.binutils-native-stamp: .gcc-stamp
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-src-native
mkdir ${BUILDDIR}/build-or1k-src-native
(cd ${BUILDDIR}/build-or1k-src-native && \
${DIR}/binutils-gdb/configure --host=${TARGET} --target=${TARGET} \
--prefix=/usr \
--disable-shared --disable-itcl --disable-tk --disable-tcl --disable-winsup \
--disable-libgui --disable-rda --disable-sid --disable-sim --disable-gdb \
--with-sysroot --disable-newlib --disable-libgloss --disable-werror && \
make ${MAKEOPTS} && \
make DESTDIR=${DIR}/initramfs/ install)
touch $(@)
.gcc-native-stamp: .gcc-stamp .binutils-native-stamp
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-gcc-native
mkdir ${BUILDDIR}/build-or1k-gcc-native
(cd ${BUILDDIR}/build-or1k-gcc-native && \
${DIR}/or1k-gcc/configure --target=${TARGET} --host=${TARGET} --prefix=/usr \
--enable-languages=c,c++ --enable-threads=posix --disable-lto --enable-static \
--disable-libgomp --disable-libmudflap --enable-vtable-verify \
--with-sysroot=/ --with-gmp=${DIR}/initramfs/ \
--with-mpc=${DIR}/initramfs/ \
--with-mpfr=${DIR}/initramfs/ \
--with-build-sysroot=/srv/compilers/openrisc-devel/${TARGET}/sys-root && \
make ${MAKEOPTS} && \
make DESTDIR=${DIR}/initramfs/ install)
touch $(@)
.dejagnu-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-dejagnu
mkdir ${BUILDDIR}/build-or1k-dejagnu
(cd ${BUILDDIR}/build-or1k-dejagnu && \
${DIR}/or1k-dejagnu/configure --target=${TARGET} \
--prefix=/srv/compilers/openrisc-devel &&\
make ${MAKEOPTS} && \
make install)
ln -sf ${DIR}/tests/or1k-linux-sim.exp \
/srv/compilers/openrisc-devel/share/dejagnu/baseboards/
touch $(@)
.or1ksim-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1ksim
mkdir ${BUILDDIR}/build-or1ksim
(cd ${BUILDDIR}/build-or1ksim && \
${DIR}/or1ksim/configure && \
make ${MAKEOPTS} && sudo make install)
touch $(@)
.qemu-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-qemu
mkdir ${BUILDDIR}/build-qemu
(cd ${BUILDDIR}/build-qemu && \
${DIR}/or1k-qemu/configure --enable-virtfs --static \
--target-list=or32-softmmu,or32-linux-user \
--enable-trace-backend=simple --disable-werror && \
make ${MAKEOPTS} && sudo make install)
touch $(@)
.root-stamp: .gcc-stamp
echo "$(@)" > .building
(cd tools && make)
(cd initramfs/; mkdir -p dev proc sys mnt tmp srv)
sudo rm -f initramfs/etc/ssh/ssh_host_*
sudo ssh-keygen -f initramfs/etc/ssh/ssh_host_rsa_key -C or1k -N '' -t rsa
sudo ssh-keygen -f initramfs/etc/ssh/ssh_host_dsa_key -C or1k -N '' -t dsa
sudo ssh-keygen -f initramfs/etc/ssh/ssh_host_ecdsa_key -C or1k -N '' -t ecdsa
rmdir initramfs/var/empty
sudo mkdir initramfs/var/empty
sudo mkdir -p initramfs/root/.ssh
sudo cp ~/.ssh/id_rsa.pub initramfs/root/.ssh/authorized_keys
touch $(@)
.linux-stamp: .boot-gcc-stamp
echo "$(@)" > .building
cp Linux-config linux/.config
sed -i 's/elf32-or32/elf32-or1k/g' linux/arch/openrisc/kernel/vmlinux.lds*
cp or1ksim.dts linux/arch/openrisc/boot/dts/
(cd linux && \
ARCH="openrisc" make ${MAKEOPTS})
touch $(@)
# (2014-01-05, bluecmd) GDB do not work as of yet
.gdb-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-gdb
mkdir ${BUILDDIR}/build-or1k-gdb
(cd ${BUILDDIR}/build-or1k-gdb && \
${DIR}/or1k-src/configure --target=${TARGET} --prefix=/srv/compilers/openrisc-devel \
--disable-tk --disable-tcl --disable-itcl --disable-libgui --disable-werror && \
make ${MAKEOPTS} all-bfd && \
make ${MAKEOPTS} all-gdb && \
make install-gdb)
touch $(@)
# (2014-01-05, bluecmd) GDB do not work as of yet
.gdbserver-stamp:
echo "$(@)" > .building
rm -fr ${BUILDDIR}/build-or1k-gdbserver
mkdir ${BUILDDIR}/build-or1k-gdbserver
(cd ${BUILDDIR}/build-or1k-gdbserver && \
${DIR}/or1k-src/gdb/gdbserver/configure --host=${TARGET} \
--prefix=/srv/compilers/openrisc-devel \
--disable-werror && \
make ${MAKEOPTS} && \
make install)
touch $(@)