ansible: Deploy legacy cross compilers on Debian nodes
[lttng-ci.git] / automation / ansible / roles / cross-compilers / files / script.sh
1 #!/bin/bash -x
2
3 SRC_DIR="${SRC_DIR:-/src/gcc-releases-gcc-4.8.5}"
4 PATCH_DIR="${PATCH_DIR:-/src/patches}"
5 TARGET="${TARGET:-aarch64-linux-gnu}"
6 HOST="${HOST:-x86_64-linux-gnu}"
7 CONFIGURE_ARGS="${CONFIGURE_ARGS:-}"
8 MAKE_ARGS="${MAKE_ARGS:-}"
9 MAKE_INSTALL_ARGS="${MAKE_INSTALL_ARGS:-}"
10
11 OWD="$(pwd)"
12 cd "${SRC_DIR}" || exit 1
13 while read -r line ; do
14 EXT=$(echo "$line" | rev | cut -d. -f1 | rev)
15 PATCH_LEVEL=1
16 if [[ "${EXT}" =~ [0-9]+ ]] ; then
17 PATCH_LEVEL="${EXT}"
18 fi
19 patch -p"${PATCH_LEVEL}" < "${line}"
20 done < <(find "${PATCH_DIR}" -type f)
21 cd "${OWD}"
22
23 TARGET_ARGS=()
24 case "${TARGET}" in
25 aarch64-linux-gnu)
26 TARGET_ARGS+=(
27 --enable-fix-cortex-a64-84319
28 )
29 ;;
30 arm-linux-gnueabihf)
31 TARGET_ARGS+=(
32 --with-arch=armv7-a
33 --with-float=hard
34 --with-fpu=vfpv3-d16
35 --with-mode=thumb
36 )
37 ;;
38 i686-linux-gnu)
39 TARGET_ARGS+=(
40 --with-arch-i686
41 --with-tune=generic
42 )
43 ;;
44 powerpc64le-linux-gnu)
45 TARGET_ARGS+=(
46 --enable-secureplt
47 --enable-targets=powerpcle-linux
48 --with-cpu=power8
49 --with-long-double-128
50 )
51 ;;
52 powerpc-linux-gnu)
53 TARGET_ARGS+=(
54 --disable-softfloat
55 --enable-secureplt
56 --enable-targets=powerpc-linux,powerpc64-linux
57 --with-cpu=default32
58 --with-long-double-128
59 )
60 ;;
61 riscv64-linux-gnu)
62 echo "Not supported in gcc-4.8"
63 exit 0
64 ;;
65 s390x-linux-gnu)
66 TARGET_ARGS+=(
67 --with-arch=zEC12
68 --with-long-double-128
69 )
70 ;;
71 *)
72 echo "Unrecognized target: ${TARGET}"
73 exit 0
74 ;;
75 esac
76
77 "${SRC_DIR}/configure" --build="${HOST}" --host="${HOST}" --enable-languages=c,c++ \
78 --program-prefix="${TARGET}-" --target="${TARGET}" --program-suffix=-4.8 \
79 --prefix=/usr/ --with-system-zlib \
80 --libexecdir=/usr/lib/ --libdir=/usr/lib/ \
81 --disable-nls --disable-shared --enable-host-shared \
82 --disable-bootstrap --enable-threads=posix --enable-default-pie \
83 --with-sysroot=/ --includedir=/usr/"${TARGET}"/include \
84 --without-target-system-zlib --enable-multiarch
85 ${TARGET_ARGS[@]} ${CONFIGURE_ARGS} \
86 CFLAGS='-std=gnu99' CXXFLAGS='-std=gnu++98'
87
88 make -j"${NPROC:-$(nproc)}" ${MAKE_ARGS} \
89 CFLAGS='-std=gnu99' CXXFLAGS='-std=gnu++98'
90
91 make install ${MAKE_INSTALL_ARGS}
92 mkdir -p /output/usr/lib/ /output/usr/bin/
93 cp -r /usr/lib/gcc-cross /output/usr/lib/
94 cp /usr/bin/*-4.8 /output/usr/bin/
This page took 0.032709 seconds and 5 git commands to generate.