-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_crosstool.sh
executable file
·142 lines (118 loc) · 4.52 KB
/
build_crosstool.sh
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
#!/bin/bash
# Take input from /dev/null.
exec < /dev/null
# stop on any error, echo commands.
set -ex
# Set locale to C, so that e.g., 'sort' will work consistently regardless
# of system and user environment settings.
LC_ALL=C
export LC_ALL
absname=`readlink -f "$0"`
absroot="${absname%/*}"
[ -f "${absroot}/grte/grte.cfg" ] || {
error "could not find ${absroot}/grte/grte.cfg"
}
. "${absroot}/grte/grte.cfg"
GRTEROOT="${1}/v${GRTEVERSION}"
tb=`readlink -f "${2}"`
GRTEBASENAME="${GRTE_PACKAGE_PREFIX}$(basename $1)v${GRTEVERSION}"
STAGING="${tb}/staging"
RESULTS="${tb}/results"
DEB_DIR=${RESULTS}/debs
# Directory that stores upstream sources
CROSSTOOL_SOURCES=$3
# Crosstool configuration
CROSSTOOL_VERSION="v2"
CROSSTOOL_GCC_VERSION="4.9"
# Assume the clang source code is checked out following
# http://clang.llvm.org/get_started.html
CROSSTOOL_CLANG_VERSION="4.0"
: ${crosstool_rpmver:="1.0"}
# Update this each time new RPM's are built.
: ${crosstool_rpmrel:="8"}
export PARALLELMFLAGS="${JFLAGS:-j8}"
[ -z "${EMAIL}" ] && {
EMAIL="[email protected]"
export EMAIL
}
# Install the packages for GRTE, mostly GDE
for pkg in runtime headers gde; do
dpkg -i ${DEB_DIR}/${GRTEBASENAME}-${pkg}_${grte_rpmver}-${grte_rpmrel}_amd64.deb
done
# sed -e "s:/usr/lrte/v3/lib64/::g" -i /usr/lrte/v3/lib64/libm.so
# Use bash as shell, other "source" command inside rpm spec will fail.
ln -sf /bin/bash /bin/sh
# install packages that are needed by building binutils and clang
apt-get update
apt-get install -y flex bison rpm texinfo texi2html libxml2-dev make alien wget
function build_rpm() {
local rpmrel=$1
local spec_file=$2
rpmbuild \
--dbpath /dev/null \
--define "_hash_empty_files 1" \
--define "_sourcedir ${CROSSTOOL_SOURCES}" \
--define "_topdir ${STAGING}" \
--define "_rpmtopdir ${STAGING}" \
--define 'disable_debuginfo t' \
--define "maintainer_email ${EMAIL}" \
--define "grte_basename ${GRTEBASENAME}" \
--define "grte_root ${GRTEROOT}" \
--define "grte_version ${GRTEVERSION}" \
--define "grte_gcc_version ${gcc_version}" \
--define "grte_glibc_version ${glibc_version}" \
--define "grte_rpmver ${grte_rpmver}" \
--define "grte_rpmrel ${grte_rpmrel}" \
--define "binutils_version ${binutils_version}" \
--define "gmp_version ${gmp_version}" \
--define "mpfr_version ${mpfr_version}" \
--define "mpc_version ${mpc_version}" \
--define "crosstool_scripts ${absroot}/crosstool/scripts" \
--define "crosstool_version ${CROSSTOOL_VERSION}" \
--define "crosstool_rpmver ${crosstool_rpmver}" \
--define "crosstool_rpmrel ${rpmrel}" \
--define "crosstool_gcc_version ${CROSSTOOL_GCC_VERSION}" \
--define "gcc_svn_version ${GCC_SVN_VERSION}" \
--define "crosstool_clang_version ${CROSSTOOL_CLANG_VERSION}" \
--define "clang_svn_version ${CLANG_SVN_VERSION}" \
-bb ${spec_file}
}
function package() {
local name=$1 # gcc, clang
local version=$2 # gcc version, or clang version
local svn_version=$3
local rpm_rel=${crosstool_rpmrel}.${svn_version}svn
build_rpm ${rpm_rel} crosstool/crosstool-grte-${name}.spec
local package_prefix="${GRTEBASENAME}-crosstool${CROSSTOOL_VERSION}-${name}-${version}"
local rpm="RPMS/x86_64/${package_prefix}-${crosstool_rpmver}-${rpm_rel}.x86_64.rpm"
pushd $STAGING
${absroot}/crosstool/scripts/rpm_to_deb "$rpm"
mv "${package_prefix}_${crosstool_rpmver}-${rpm_rel}_amd64.deb" \
"${package_prefix}_${crosstool_rpmver}-${rpm_rel}_amd64.changes" \
"${RESULTS}/debs/"
mv "$rpm" "${RESULTS}/rpms/"
popd
}
set -e
# For test rpm creation and deb conversion.
# package foo ${CROSSTOOL_GCC_VERSION} ${GCC_SVN_VERSION}
[ -z "${SKIP_CROSSTOOL_GCC}" ] && {
package gcc ${CROSSTOOL_GCC_VERSION} ${GCC_SVN_VERSION}
}
# Install the crosstool gcc to build clang
dpkg -i ${DEB_DIR}/${GRTEBASENAME}-crosstool${CROSSTOOL_VERSION}-gcc-${CROSSTOOL_GCC_VERSION}_${crosstool_rpmver}-${crosstool_rpmrel}.${GCC_SVN_VERSION}svn_amd64.deb
# Build cmake because cmake in ubuntu 13 is too old
mkdir -p ${STAGING}/cmake
CMAKE_VERSION=3.8.2
if [ ! -e ${CROSSTOOL_SOURCES}/cmake-${CMAKE_VERSION}.tar.gz ]; then
pushd ${CROSSTOOL_SOURCES}
wget http://cmake.org/files/v3.8/cmake-${CMAKE_VERSION}.tar.gz
popd
fi
tar zxf ${CROSSTOOL_SOURCES}/cmake-${CMAKE_VERSION}.tar.gz -C ${STAGING}/cmake
pushd ${STAGING}/cmake/cmake-${CMAKE_VERSION}
./configure --parallel=${PARALLELMFLAGS}
make ${PARALLELMFLAGS}
make install
popd
package clang ${CROSSTOOL_CLANG_VERSION} ${CLANG_SVN_VERSION}