forked from mod-audio/mod-plugin-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·145 lines (111 loc) · 5.44 KB
/
bootstrap.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
143
144
145
#!/bin/bash
#######################################################################################################################
# check arguments
PLATFORM=${1}
BUILDTARGET=${2}
if [ -z "${PLATFORM}" ]; then
echo "Usage: $0 <platform>"
echo " Where platform can be modduo[-static], modduox[-static], moddwarf or x86_64"
exit 1
fi
if [ -n "${BUILDTARGET}" ]; then
if [ "${BUILDTARGET}" != "all" ] && [ "${BUILDTARGET}" != "toolchain" ]; then
echo "Usage: $0 <platform> [build-target]"
echo " Where build-target can be toolchain or all"
exit 1
fi
fi
#######################################################################################################################
# Import common code and variables
source .common
#######################################################################################################################
# download and extract crosstool-ng
if [ ! -f ${BUILD_DIR}/${CT_NG_VERSION}/configure ]; then
if [ ! -f ${DOWNLOAD_DIR}/${CT_NG_FILE} ]; then
wget ${CT_NG_LINK}/${CT_NG_FILE} -O ${DOWNLOAD_DIR}/${CT_NG_FILE}
fi
mkdir -p ${BUILD_DIR}/${CT_NG_VERSION}
tar xf ${DOWNLOAD_DIR}/${CT_NG_FILE} -C ${BUILD_DIR}/${CT_NG_VERSION} --strip-components=1
if [ "${CT_NG_VERSION}" = "crosstool-ng-1.22.0" ]; then
patch -d ${BUILD_DIR}/${CT_NG_VERSION} -p1 -i ${SOURCE_DIR}/patches/${CT_NG_VERSION}/001_bash5-compat.patch
patch -d ${BUILD_DIR}/${CT_NG_VERSION} -p1 -i ${SOURCE_DIR}/patches/${CT_NG_VERSION}/002_binutils-2.26.patch
patch -d ${BUILD_DIR}/${CT_NG_VERSION} -p1 -i ${SOURCE_DIR}/patches/${CT_NG_VERSION}/003_linaro-2017.01.patch
cp -r ${SOURCE_DIR}/patches/${CT_NG_VERSION}/bin-utils-2.26 ${BUILD_DIR}/${CT_NG_VERSION}/patches/binutils/2.26
cp ${SOURCE_DIR}/patches/${CT_NG_VERSION}/gcc-4.9.3/*.patch ${BUILD_DIR}/${CT_NG_VERSION}/patches/gcc/4.9.3/
elif [ "${CT_NG_VERSION}" = "crosstool-ng-1.24.0" ]; then
patch -d ${BUILD_DIR}/${CT_NG_VERSION} -p1 -i ${SOURCE_DIR}/patches/${CT_NG_VERSION}/001_linaro-2019.12.patch
patch -d ${BUILD_DIR}/${CT_NG_VERSION} -p1 -i ${SOURCE_DIR}/patches/${CT_NG_VERSION}/002_linaro-gcc7-selects.patch
fi
fi
#######################################################################################################################
# build crosstool-ng
cd ${BUILD_DIR}/${CT_NG_VERSION}
if [ ! -f .config ]; then
cp ${SOURCE_DIR}/toolchain/${PLATFORM}.config .config
sed -i -e "s|CT_LOCAL_TARBALLS_DIR=.*|CT_LOCAL_TARBALLS_DIR=\"${DOWNLOAD_DIR}\"|" .config
sed -i -e "s|CT_PREFIX_DIR=.*|CT_PREFIX_DIR=\"${TOOLCHAIN_DIR}\"|" .config
fi
if [ ! -f .stamp_configured ]; then
# ./bootstrap
./configure --enable-local
touch .stamp_configured
fi
if [ ! -f .stamp_built1 ]; then
# ct-ng 1.22 does not build correctly against latest distros
if [ "${CT_NG_VERSION}" = "crosstool-ng-1.22.0" ]; then
sed -i -e 's/ifneq ($(strip $(CT_MAKEFLAGS)),)/ifneq (,)/' Makefile
make build-bin build-lib
else
make
fi
touch .stamp_built1
fi
# for static targets: keep old name for backwards compatibility, plus add static suffix
if [ "${PLATFORM}" == "modduo-static" ]; then
sed -i -e 's/CT_TARGET_SYS="${CT_TARGET_SYS}hf"/CT_TARGET_SYS="${CT_TARGET_SYS}hf.static"/' scripts/build/arch/arm.sh
elif [ "${PLATFORM}" == "modduox-static" ]; then
sed -i -e 's/CT_TARGET_SYS=gnu;/CT_TARGET_SYS=gnueabi.static;/' scripts/functions
fi
if [ ! -f .stamp_built2 ]; then
./ct-ng build
touch .stamp_built2
fi
#######################################################################################################################
# download and extract buildroot
if [ ! -d ${BUILD_DIR}/${BUILDROOT_VERSION} ]; then
if [ ! -f ${DOWNLOAD_DIR}/${BUILDROOT_FILE} ]; then
wget ${BUILDROOT_LINK}/${BUILDROOT_FILE} -O ${DOWNLOAD_DIR}/${BUILDROOT_FILE}
fi
tar xf ${DOWNLOAD_DIR}/${BUILDROOT_FILE} -C ${BUILD_DIR}
patch -d ${BUILD_DIR}/${BUILDROOT_VERSION} -p1 -i ${SOURCE_DIR}/patches/buildroot-2016.02/001_aarch64-and-cortex-a53.patch
patch -d ${BUILD_DIR}/${BUILDROOT_VERSION} -p1 -i ${SOURCE_DIR}/patches/buildroot-2016.02/002_cortex-a35.patch
patch -d ${BUILD_DIR}/${BUILDROOT_VERSION} -p1 -i ${SOURCE_DIR}/patches/buildroot-2016.02/003_gcc-7.patch
patch -d ${BUILD_DIR}/${BUILDROOT_VERSION} -p1 -i ${SOURCE_DIR}/patches/buildroot-2016.02/004_static-toolchain.patch
fi
#######################################################################################################################
# buildroot setup
export DOWNLOAD_PATH=${DOWNLOAD_DIR}
export TOOLCHAIN_PATH=${TOOLCHAIN_DIR}
mkdir -p /tmp/skeleton/usr/bin
mkdir -p /tmp/skeleton/usr/lib
mkdir -p /tmp/skeleton/usr/sbin
ln -sf usr/bin /tmp/skeleton/
ln -sf usr/lib /tmp/skeleton/
ln -sf usr/sbin /tmp/skeleton/
cd ${BUILD_DIR}/${BUILDROOT_VERSION}
#######################################################################################################################
# patching buildroot packages
for dir in `ls ${SOURCE_DIR}/global-packages`; do
rm -rf package/${dir}
cp -r ${SOURCE_DIR}/global-packages/${dir} package/${dir}
done
for dir in `ls ${SOURCE_DIR}/patches/packages`; do
cp ${SOURCE_DIR}/patches/packages/${dir}/*.patch package/${dir}/
done
#######################################################################################################################
# initial first build
${BR2_MAKE} ${PLATFORM}_defconfig
if [ "${BUILDTARGET}" != "toolchain" ]; then
${BR2_MAKE}
fi
#######################################################################################################################