forked from labx-technologies-llc/mb-linux-labx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildtools.sh
More file actions
executable file
·127 lines (101 loc) · 2.35 KB
/
buildtools.sh
File metadata and controls
executable file
·127 lines (101 loc) · 2.35 KB
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
#!/bin/bash
if [ "$MAKE" == "" ]; then
export MAKE=gmake
fi
# Check for most likely missing packages and executables
if ! which gcc > /dev/null 2>&1
then
echo "This script requires GCC to be present"
exit 1
fi
if ! which awk > /dev/null 2>&1
then
echo "This script requires awk to be present"
exit 1
fi
if ! which flex > /dev/null 2>&1
then
echo "This script requires flex to be present"
exit 1
fi
if ! which bison > /dev/null 2>&1
then
echo "This script requires bison to be present"
exit 1
fi
if ! which gmake > /dev/null 2>&1
then
echo "This script requires gmake to be present (if make is gnu make make a symlink for gmake)"
exit 1
fi
if ! which genromfs > /dev/null 2>&1
then
echo "This script requires genromfs to be present"
exit 1
fi
if [ ! -f /usr/include/zlib.h ]
then
echo "This script requires zlib development package to be present"
exit 1
fi
if ! which msgfmt > /dev/null 2>&1
then
echo "This script requires gettext to be present"
exit 1
fi
if ! which makeinfo > /dev/null 2>&1
then
echo "This script requires texinfo to be present"
echo "(for GDB compilation procedure)"
exit 1
fi
GCC4_DIR="mb_gnu"
if [ ! -d "$GCC4_DIR" ]; then
echo "$GCC4_DIR should link to the gcc 4 toolchain source"
exit 1;
fi
# Build xilinx toolchain
echo "Building Binutils / GCC4 / GDB toolchain (Xilinx tree)"
(
cd "$GCC4_DIR" \
&& bash build_binutils.sh && bash build_elf2flt.sh && bash build_gcc.sh && bash build_gdb.sh
)||(
echo "Build failed, see mb_gnu/build directory for logs"
exit 1
)
echo "Building device tree compiler"
(cd dtc \
&& make
) || (
echo "Build failed"
exit 1
)
# Move tools to some convenient location
echo "Installing both toolchains in tools/"
mkdir tools 2>/dev/null
rm -rf tools/gcc4
if [ "`uname -s`" = "Darwin" ]
then
LOCALPLATFORM=""
else
if [ "`uname -m`" = "x86_64" ]
then
LOCALPLATFORM="lin64"
else
LOCALPLATFORM="lin"
fi
fi
mv "mb_gnu/release/${LOCALPLATFORM}" tools/gcc4
(
cd tools/gcc4/bin \
&& ls mb-* | awk -F- '{print "ln -s " $1 "-" $2 " " $1 "-xilinx-elf-" $2 }' | /bin/sh
)
# Preparing new PATH
CURRDIR=`pwd`
NEWPATH=`(
echo "${PATH}" | tr ':' '\n' | grep -v "${CURRDIR}"
echo -n "${CURRDIR}/tools/gcc4/bin"
) | tr '\n' ':'`
echo "export PATH=${NEWPATH}" > prepare.sh
echo "export MB_LINUX=$CURRDIR" >> prepare.sh
echo "Run \". prepare.sh\" from this directory before cross-compiling for MicroBlaze"