Martin Roth | 0ad5fbd | 2020-12-24 12:06:38 -0700 | [diff] [blame] | 1 | #!/usr/bin/env sh |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 2 | # shellcheck disable=SC2030,SC2031,SC2059 |
| 3 | # The above line must be directly after the shebang line. |
| 4 | # Disables these warnings: |
| 5 | # 2030 - Modification of var is local (to subshell caused by pipeline). |
| 6 | # shell check 0.4.6 gets confused by the read -t 1 command and interprets |
| 7 | # the '1' as $1 getting modified. |
| 8 | # 2031 - var was modified in a subshell. That change might be lost. |
| 9 | # caused by shell check bug with SC2030? This causes any $1 from that |
| 10 | # point on to be flagged. |
| 11 | # 2059 - Don't use variables in the printf format string. Use printf "..%s.." "$foo". |
| 12 | # This is used for all of our color printing. |
| 13 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 14 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 15 | # SPDX-License-Identifier: GPL-2.0-only |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 16 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 17 | cd "$(dirname "$0")" || exit 1 |
Patrick Georgi | 8135dba | 2015-03-17 21:05:20 +0100 | [diff] [blame] | 18 | |
Felix Singer | 02750d0 | 2021-10-17 15:43:21 +0200 | [diff] [blame] | 19 | if [ -z "$CROSSGCC_VERSION" ]; then |
| 20 | CROSSGCC_VERSION="$(git log -n 1 --pretty=%cd --date=short .)_$(git log -n 1 --pretty=%h .)" |
| 21 | fi |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 22 | |
| 23 | # default settings |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 24 | PACKAGE=GCC |
Stefan Reinauer | d764912 | 2015-06-09 11:44:25 -0700 | [diff] [blame] | 25 | TARGETDIR=$(pwd)/xgcc |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 26 | TARGETARCH=i386-elf |
Nico Huber | 66c2c1a | 2016-09-20 13:09:29 +0200 | [diff] [blame] | 27 | DEFAULT_LANGUAGES=c |
| 28 | LANGUAGES= |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 29 | DESTDIR= |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 30 | SAVETEMPS=0 |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 31 | BOOTSTRAP=0 |
Martin Roth | 2c6a806 | 2016-11-14 11:58:39 -0700 | [diff] [blame] | 32 | THREADS=1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 33 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 34 | # GCC toolchain version numbers |
Patrick Georgi | 0afb90a | 2021-05-10 23:34:18 +0200 | [diff] [blame] | 35 | GMP_VERSION=6.2.1 |
Elyes HAOUAS | 150c438 | 2020-07-11 00:40:15 +0200 | [diff] [blame] | 36 | MPFR_VERSION=4.1.0 |
Patrick Georgi | f963a0f | 2021-05-10 23:35:51 +0200 | [diff] [blame] | 37 | MPC_VERSION=1.2.1 |
Patrick Georgi | b0d87f7 | 2021-05-10 23:39:45 +0200 | [diff] [blame] | 38 | GCC_VERSION=11.2.0 |
Patrick Georgi | f28e368 | 2021-05-10 23:33:00 +0200 | [diff] [blame] | 39 | BINUTILS_VERSION=2.37 |
Elyes Haouas | 9a8d0a0 | 2022-03-31 21:36:51 +0200 | [diff] [blame] | 40 | IASL_VERSION=20220331 |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 41 | # CLANG version number |
Elyes HAOUAS | a0b8032 | 2021-11-17 19:23:22 +0100 | [diff] [blame] | 42 | CLANG_VERSION=13.0.1 |
Elyes Haouas | 6d97691 | 2022-03-31 09:14:56 +0200 | [diff] [blame] | 43 | CMAKE_VERSION=3.23.0 |
Elyes HAOUAS | 1ba663c | 2020-08-23 07:50:32 +0200 | [diff] [blame] | 44 | NASM_VERSION=2.15.05 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 46 | # GCC toolchain archive locations |
Martin Roth | 1484c03 | 2016-03-08 09:37:14 -0700 | [diff] [blame] | 47 | # These are sanitized by the jenkins toolchain test builder, so if |
| 48 | # a completely new URL is added here, it probably needs to be added |
| 49 | # to the jenkins build as well, or the builder won't download it. |
Doug Gale | 43ae433 | 2017-09-27 22:10:16 -0400 | [diff] [blame] | 50 | GMP_ARCHIVE="https://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}.tar.xz" |
| 51 | MPFR_ARCHIVE="https://ftpmirror.gnu.org/mpfr/mpfr-${MPFR_VERSION}.tar.xz" |
| 52 | MPC_ARCHIVE="https://ftpmirror.gnu.org/mpc/mpc-${MPC_VERSION}.tar.gz" |
Patrick Georgi | b1d26f0 | 2018-05-02 17:13:34 +0200 | [diff] [blame] | 53 | GCC_ARCHIVE="https://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz" |
Iru Cai | 776b5ba | 2017-07-28 21:40:34 +0800 | [diff] [blame] | 54 | BINUTILS_ARCHIVE="https://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.xz" |
Patrick Georgi | 85bb946 | 2016-02-11 17:22:16 +0100 | [diff] [blame] | 55 | IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix2-${IASL_VERSION}.tar.gz" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 56 | # CLANG toolchain archive locations |
Elyes HAOUAS | 8f1853c | 2020-08-02 09:46:15 +0200 | [diff] [blame] | 57 | LLVM_ARCHIVE="https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/llvm-${CLANG_VERSION}.src.tar.xz" |
| 58 | CLANG_ARCHIVE="https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/clang-${CLANG_VERSION}.src.tar.xz" |
| 59 | CRT_ARCHIVE="https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/compiler-rt-${CLANG_VERSION}.src.tar.xz" |
| 60 | CTE_ARCHIVE="https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VERSION}/clang-tools-extra-${CLANG_VERSION}.src.tar.xz" |
Patrick Georgi | 5a76a53 | 2021-06-03 08:48:26 +0200 | [diff] [blame] | 61 | CMAKE_ARCHIVE="https://cmake.org/files/v${CMAKE_VERSION%.*}/cmake-${CMAKE_VERSION}.tar.gz" |
Martin Roth | d70f5fa | 2019-05-26 17:24:19 -0600 | [diff] [blame] | 62 | NASM_ARCHIVE="https://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 63 | |
Nico Huber | afda56e | 2017-12-07 17:50:53 +0100 | [diff] [blame] | 64 | ALL_ARCHIVES="$GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE \ |
Patrick Georgi | f32eed1 | 2021-10-16 10:50:00 +0200 | [diff] [blame] | 65 | $GCC_ARCHIVE $BINUTILS_ARCHIVE $IASL_ARCHIVE \ |
| 66 | $LLVM_ARCHIVE $CLANG_ARCHIVE \ |
Elyes HAOUAS | 91fb139 | 2020-01-20 15:33:11 +0100 | [diff] [blame] | 67 | $CRT_ARCHIVE $CTE_ARCHIVE $CMAKE_ARCHIVE $NASM_ARCHIVE" |
Martin Roth | 58c68d5 | 2016-03-01 15:22:42 -0700 | [diff] [blame] | 68 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 69 | # GCC toolchain directories |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 70 | GMP_DIR="gmp-${GMP_VERSION}" |
| 71 | MPFR_DIR="mpfr-${MPFR_VERSION}" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 72 | MPC_DIR="mpc-${MPC_VERSION}" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 73 | # shellcheck disable=SC2034 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 74 | GCC_DIR="gcc-${GCC_VERSION}" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 75 | # shellcheck disable=SC2034 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 76 | BINUTILS_DIR="binutils-${BINUTILS_VERSION}" |
Patrick Georgi | 85bb946 | 2016-02-11 17:22:16 +0100 | [diff] [blame] | 77 | IASL_DIR="acpica-unix2-${IASL_VERSION}" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 78 | # CLANG toolchain directories |
| 79 | LLVM_DIR="llvm-${CLANG_VERSION}.src" |
Elyes HAOUAS | 8f1853c | 2020-08-02 09:46:15 +0200 | [diff] [blame] | 80 | CLANG_DIR="clang-${CLANG_VERSION}.src" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 81 | CRT_DIR="compiler-rt-${CLANG_VERSION}.src" |
| 82 | CTE_DIR="clang-tools-extra-${CLANG_VERSION}.src" |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 83 | CMAKE_DIR="cmake-${CMAKE_VERSION}" |
Martin Roth | d70f5fa | 2019-05-26 17:24:19 -0600 | [diff] [blame] | 84 | NASM_DIR="nasm-${NASM_VERSION}" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 85 | |
Patrick Georgi | 6321f52 | 2015-02-27 23:36:26 +0100 | [diff] [blame] | 86 | unset MAKELEVEL MAKEFLAGS |
| 87 | |
Patrick Georgi | 1861ff7 | 2011-10-31 12:15:55 +0100 | [diff] [blame] | 88 | red='\033[0;31m' |
| 89 | RED='\033[1;31m' |
| 90 | green='\033[0;32m' |
| 91 | GREEN='\033[1;32m' |
| 92 | blue='\033[0;34m' |
Patrick Georgi | 1861ff7 | 2011-10-31 12:15:55 +0100 | [diff] [blame] | 93 | CYAN='\033[1;36m' |
| 94 | NC='\033[0m' # No Color |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 95 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 96 | UNAME=$(if uname | grep -iq cygwin; then echo Cygwin; else uname; fi) |
Martin Roth | 8846382 | 2016-01-07 11:03:36 -0700 | [diff] [blame] | 97 | HALT_FOR_TOOLS=0 |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 98 | |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 99 | hostcc() |
| 100 | { |
| 101 | # $1 "host" or "target" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 102 | if [ "$BOOTSTRAP" = 1 ] && [ "$1" = target ]; then |
| 103 | echo "$DESTDIR$TARGETDIR/bin/gcc" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 104 | else |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 105 | echo "$CC" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 106 | fi |
| 107 | } |
| 108 | |
| 109 | hostcxx() |
| 110 | { |
| 111 | # $1 "host" or "target" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 112 | if [ "$BOOTSTRAP" = 1 ] && [ "$1" = target ]; then |
| 113 | echo "$DESTDIR$TARGETDIR/bin/g++" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 114 | else |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 115 | echo "$CXX" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 116 | fi |
| 117 | } |
| 118 | |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 119 | normalize_dirs() |
| 120 | { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 121 | mkdir -p "$DESTDIR$TARGETDIR/lib" |
| 122 | test -d "$DESTDIR$TARGETDIR/lib32" && mv "$DESTDIR$TARGETDIR"/lib32/* "$DESTDIR$TARGETDIR/lib" |
| 123 | test -d "$DESTDIR$TARGETDIR/lib64" && mv "$DESTDIR$TARGETDIR"/lib64/* "$DESTDIR$TARGETDIR/lib" |
Martin Roth | 1039d27 | 2022-01-31 10:17:43 -0700 | [diff] [blame] | 124 | rm -rf "$DESTDIR$TARGETDIR/lib32" "$DESTDIR$TARGETDIR/lib64" |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 125 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 126 | perl -pi -e "s,/lib32,/lib," "$DESTDIR$TARGETDIR"/lib/*.la |
| 127 | perl -pi -e "s,/lib64,/lib," "$DESTDIR$TARGETDIR"/lib/*.la |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 130 | countdown() |
| 131 | { |
| 132 | tout=${1:-10} |
| 133 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 134 | printf "\nPress Ctrl-C to abort, Enter to continue... %2ds" "$tout" |
| 135 | while [ "$tout" -gt 0 ]; do |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 136 | sleep 1 |
| 137 | tout=$((tout - 1)) |
| 138 | printf "\b\b\b%2ds" $tout |
| 139 | done |
| 140 | printf "\n" |
| 141 | } |
| 142 | |
| 143 | timeout() |
| 144 | { |
| 145 | tout=${1:-10} |
| 146 | |
| 147 | # Ignore SIGUSR1, should interrupt `read` though. |
| 148 | trap false USR1 |
| 149 | # Clean up in case the user aborts. |
| 150 | trap 'kill $counter > /dev/null 2>&1' EXIT |
| 151 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 152 | (countdown "$tout"; kill -USR1 $$)& |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 153 | counter=$! |
| 154 | |
| 155 | # Some shells with sh compatibility mode (e.g. zsh, mksh) only |
| 156 | # let us interrupt `read` if a non-standard -t parameter is given. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 157 | # shellcheck disable=SC2034,SC2039,SC2162 |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 158 | if echo | read -t 1 foo 2>/dev/null; then |
| 159 | read -t $((tout + 1)) foo |
| 160 | else |
| 161 | read foo |
| 162 | fi |
| 163 | |
| 164 | kill $counter > /dev/null 2>&1 |
| 165 | trap - USR1 EXIT |
| 166 | } |
| 167 | |
Stefan Reinauer | 93a9630 | 2015-06-15 12:36:53 -0700 | [diff] [blame] | 168 | please_install() |
| 169 | { |
Martin Roth | 8846382 | 2016-01-07 11:03:36 -0700 | [diff] [blame] | 170 | HALT_FOR_TOOLS=1 |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 171 | # shellcheck disable=SC1091 |
Patrick Georgi | 5da95dc | 2015-07-17 23:33:05 +0200 | [diff] [blame] | 172 | test -r /etc/os-release && . /etc/os-release |
Alex Thiessen | 72d1089 | 2018-01-12 01:45:53 +0000 | [diff] [blame] | 173 | # vanilla debian doesn't define `ID_LIKE`, just `ID` |
| 174 | if [ -z "${ID_LIKE}" ] && [ -n "${ID}" ]; then |
| 175 | ID_LIKE=${ID} |
| 176 | fi |
Stefan Reinauer | 93a9630 | 2015-06-15 12:36:53 -0700 | [diff] [blame] | 177 | case "$ID_LIKE" in |
| 178 | debian) solution="sudo apt-get install $1" ;; |
| 179 | suse) solution="sudo zypper install $1" ;; |
| 180 | *) solution="using your OS packaging system" ;; |
| 181 | esac |
| 182 | |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 183 | printf "${RED}ERROR:${red} Missing tool: Please install '$1'. (eg $solution)${NC}\n" >&2 |
Martin Roth | e396317 | 2016-01-06 13:54:32 -0700 | [diff] [blame] | 184 | if [ -n "$2" ]; then |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 185 | printf "${RED}ERROR:${red} or install '$2'.${NC}\n" >&2 |
Martin Roth | e396317 | 2016-01-06 13:54:32 -0700 | [diff] [blame] | 186 | fi |
Stefan Reinauer | 93a9630 | 2015-06-15 12:36:53 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 189 | searchtool() |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 190 | { |
| 191 | # $1 short name |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 192 | # $2 search string |
| 193 | # $3 soft fail if set |
Martin Roth | e396317 | 2016-01-06 13:54:32 -0700 | [diff] [blame] | 194 | # $4 alternative package to install on failure |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 195 | # result: file name of that tool on stdout |
| 196 | # or no output if nothing suitable was found |
| 197 | search=GNU |
| 198 | if [ -n "$2" ]; then |
| 199 | search="$2" |
| 200 | fi |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 201 | for i in "$1" "g$1" "gnu$1"; do |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 202 | if [ -x "$(command -v "$i" 2>/dev/null)" ]; then |
Stefan Reinauer | dbc0087 | 2015-06-09 11:50:05 -0700 | [diff] [blame] | 203 | if [ "$(cat /dev/null | $i --version 2>&1 | grep -c "$search")" \ |
| 204 | -gt 0 ]; then |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 205 | echo "$i" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 206 | return |
| 207 | fi |
| 208 | fi |
| 209 | done |
Andrew Wu | b67e9a1 | 2014-04-28 18:13:44 +0800 | [diff] [blame] | 210 | # A workaround for OSX 10.9 and some BSDs, whose nongnu |
| 211 | # patch and tar also work. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 212 | if [ "$UNAME" = "Darwin" ] || [ "$UNAME" = "FreeBSD" ] || [ "$UNAME" = "NetBSD" ] || [ "$UNAME" = "OpenBSD" ]; then |
| 213 | if [ "$1" = "patch" ] || [ "$1" = "tar" ]; then |
| 214 | if [ -x "$(command -v "$1" 2>/dev/null)" ]; then |
| 215 | echo "$1" |
Zheng Bao | 36156ff | 2012-09-28 16:18:58 +0800 | [diff] [blame] | 216 | return |
| 217 | fi |
| 218 | fi |
| 219 | fi |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 220 | if echo "$1" | grep -q "sum" ; then |
| 221 | algor=$(echo "$1" | sed -e 's,sum,,') |
| 222 | if [ -x "$(command -v "$1" 2>/dev/null)" ]; then |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 223 | #xxxsum [file] |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 224 | echo "$1" |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 225 | return |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 226 | elif [ -x "$(command -v "$algor" 2>/dev/null)" ]; then |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 227 | #xxx [file] |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 228 | echo "$algor" |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 229 | return |
Martin Roth | d55f5eb | 2017-06-15 11:37:26 -0600 | [diff] [blame] | 230 | elif [ -x "$(command -v openssl 2>/dev/null)" ]; then |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 231 | #openssl xxx [file] |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 232 | echo openssl "$algor" |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 233 | return |
Martin Roth | d55f5eb | 2017-06-15 11:37:26 -0600 | [diff] [blame] | 234 | elif [ -x "$(command -v cksum 2>/dev/null)" ]; then |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 235 | #cksum -a xxx [file] |
| 236 | #cksum has special options in NetBSD. Actually, NetBSD will use the second case above. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 237 | echo "buildgcc" | cksum -a "$algor" > /dev/null 2>/dev/null && \ |
| 238 | echo cksum -a "$algor" |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 239 | return |
zbao | 939dc84 | 2015-04-30 04:44:07 +0800 | [diff] [blame] | 240 | fi |
| 241 | fi |
Martin Roth | e396317 | 2016-01-06 13:54:32 -0700 | [diff] [blame] | 242 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 243 | [ -z "$3" ] && please_install "$1" "$4" |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 244 | false |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Martin Roth | 591790f | 2016-03-20 20:39:04 -0600 | [diff] [blame] | 247 | # Run a compile check of the specified library option to see if it's installed |
| 248 | check_for_library() { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 249 | LIBRARY_FLAGS="$1" |
| 250 | LIBRARY_PACKAGES="$2" |
| 251 | LIBTEST_FILE=.libtest |
Martin Roth | 591790f | 2016-03-20 20:39:04 -0600 | [diff] [blame] | 252 | |
| 253 | echo "int main(int argc, char **argv) { (void) argc; (void) argv; return 0; }" > "${LIBTEST_FILE}.c" |
| 254 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 255 | # shellcheck disable=SC2086 |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 256 | "$CC" $CFLAGS $LIBRARY_FLAGS "${LIBTEST_FILE}.c" -o "${LIBTEST_FILE}" >/dev/null 2>&1 || \ |
Martin Roth | 591790f | 2016-03-20 20:39:04 -0600 | [diff] [blame] | 257 | please_install "$LIBRARY_PACKAGES" |
| 258 | rm -rf "${LIBTEST_FILE}.c" "${LIBTEST_FILE}" |
| 259 | } |
| 260 | |
Nico Huber | aee7f46 | 2016-09-20 12:55:19 +0200 | [diff] [blame] | 261 | buildcc_major() { |
| 262 | echo "${GCC_VERSION}" | cut -d. -f1 |
| 263 | } |
| 264 | |
Nico Huber | 26267a7 | 2016-12-04 02:45:58 +0100 | [diff] [blame] | 265 | buildcc_minor() { |
| 266 | echo "${GCC_VERSION}" | cut -d. -f2 |
| 267 | } |
| 268 | |
Nico Huber | aee7f46 | 2016-09-20 12:55:19 +0200 | [diff] [blame] | 269 | buildcc_version() { |
| 270 | echo "${GCC_VERSION}" | cut -d. -f1-2 |
| 271 | } |
| 272 | |
| 273 | hostcc_major() { |
| 274 | (echo __GNUC__ | ${CC} -E - 2>/dev/null || echo 0) | tail -1 |
| 275 | } |
| 276 | |
| 277 | hostcc_minor() { |
| 278 | (echo __GNUC_MINOR__ | ${CC} -E - 2>/dev/null || echo 0) | tail -1 |
| 279 | } |
| 280 | |
| 281 | hostcc_version() { |
| 282 | printf "%d.%d" "$(hostcc_major)" "$(hostcc_minor)" |
| 283 | } |
| 284 | |
Nico Huber | 7579716 | 2016-09-20 13:01:57 +0200 | [diff] [blame] | 285 | hostcc_has_gnat1() { |
| 286 | [ -x "$(${CC} -print-prog-name=gnat1)" ] |
| 287 | } |
| 288 | |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 289 | have_gnat() { |
| 290 | hostcc_has_gnat1 && \ |
| 291 | searchtool gnatbind "Free Software Foundation" nofail > /dev/null |
| 292 | } |
| 293 | |
Nico Huber | 7579716 | 2016-09-20 13:01:57 +0200 | [diff] [blame] | 294 | ada_requested() { |
| 295 | echo "${LANGUAGES}" | grep -q '\<ada\>' |
| 296 | } |
| 297 | |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 298 | download() { |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 299 | package=$1 |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 300 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 301 | archive="$(eval echo \$$package"_ARCHIVE")" |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 302 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 303 | FILE=$(basename "$archive") |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 304 | printf " * $FILE " |
| 305 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 306 | if test -f "tarballs/$FILE"; then |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 307 | printf "(cached)... " |
zbao | d22b9ea | 2015-08-30 23:35:16 -0400 | [diff] [blame] | 308 | else |
Paul Menzel | b2ba395 | 2015-06-12 11:58:14 +0200 | [diff] [blame] | 309 | printf "(downloading from $archive)" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 310 | rm -f "tarballs/$FILE" |
| 311 | cd tarballs || exit 1 |
| 312 | download_showing_percentage "$archive" |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 313 | cd .. |
zbao | d22b9ea | 2015-08-30 23:35:16 -0400 | [diff] [blame] | 314 | fi |
| 315 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 316 | if [ ! -f "tarballs/$FILE" ]; then |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 317 | printf "${RED}Failed to download $FILE.${NC}\n" |
Stefan Reinauer | dbc0087 | 2015-06-09 11:50:05 -0700 | [diff] [blame] | 318 | exit 1 |
| 319 | fi |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 322 | # Compute the hash of the package given in $1, and print it raw (just the |
| 323 | # hexadecimal hash). |
| 324 | compute_hash() { |
| 325 | package=$1 |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 326 | # shellcheck disable=SC2086 |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 327 | archive="$(eval echo \$$package"_ARCHIVE")" |
| 328 | file="$(basename "$archive")" |
| 329 | |
| 330 | if test -z "$CHECKSUM"; then |
| 331 | echo "${RED}\$CHECKSUM program missing. This is bad.${NC}" 1>&2 |
| 332 | exit 1 |
| 333 | fi |
| 334 | |
| 335 | $CHECKSUM "tarballs/$file" 2>/dev/null | sed -e 's@.*\([0-9a-f]\{40,\}\).*@\1@' |
| 336 | } |
| 337 | |
| 338 | error_hash_missing() { |
| 339 | package="$1" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 340 | # shellcheck disable=SC2086 |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 341 | archive="$(eval echo \$$package"_ARCHIVE")" |
| 342 | file="$(basename "$archive")" |
| 343 | |
| 344 | fullhashfile="util/crossgcc/sum/$file.cksum" |
| 345 | printf "${RED}hash file missing:${NC}\n\n" 1>&2 |
| 346 | printf "Please verify util/crossgcc/tarball/$file carefully\n" 1>&2 |
| 347 | printf "(using PGP if possible), and then rename\n" 1>&2 |
| 348 | printf " ${CYAN}${fullhashfile}.calc${NC}\n" 1>&2 |
| 349 | printf " to ${CYAN}${fullhashfile}${NC}\n\n" 1>&2 |
| 350 | |
| 351 | exit 1 |
| 352 | } |
| 353 | |
| 354 | # Read the known hash file of the package given in $1, and print it raw. |
| 355 | get_known_hash() { |
| 356 | package=$1 |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 357 | # shellcheck disable=SC2086 |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 358 | archive="$(eval echo \$$package"_ARCHIVE")" |
| 359 | file="$(basename "$archive")" |
| 360 | hashfile="sum/$file.cksum" |
| 361 | |
| 362 | if [ ! -f "$hashfile" ]; then |
| 363 | calc_hash="$(compute_hash "$package")" || exit 1 |
| 364 | echo "$calc_hash tarballs/$file" > "${hashfile}.calc" |
| 365 | |
| 366 | error_hash_missing "$package" |
| 367 | exit 1 |
| 368 | fi |
| 369 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 370 | sed -e 's@.*\([0-9a-f]\{40,\}\).*@\1@' < "$hashfile" |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | error_hash_mismatch() { |
| 374 | package=$1 |
| 375 | known_hash="$2" |
| 376 | computed_hash="$3" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 377 | # shellcheck disable=SC2086 |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 378 | archive="$(eval echo \$$package"_ARCHIVE")" |
| 379 | file="$(basename "$archive")" |
| 380 | |
| 381 | printf "${RED}hash mismatch:${NC}\n\n" |
| 382 | printf " expected (known) hash: $known_hash\n" |
| 383 | printf "calculated hash of downloaded file: $computed_hash\n\n" |
| 384 | |
| 385 | printf "If you think this is due to a network error, please delete\n" |
| 386 | printf " ${CYAN}util/crossgcc/tarballs/$file${NC}\n" |
| 387 | printf "and try again. If the problem persists, it may be due to an\n" |
| 388 | printf "administration error on the file server, or you might be\n" |
| 389 | printf "subject to a Man-in-the-Middle attack\n\n" |
| 390 | |
| 391 | exit 1 |
| 392 | } |
| 393 | |
| 394 | # verify_hash - Check that the hash of the file given in $1 matches the known |
| 395 | # hash; Bail out on mismatch or missing hash file. |
| 396 | verify_hash() { |
| 397 | package=$1 |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 398 | # shellcheck disable=SC2086 |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 399 | archive="$(eval echo \$$package"_ARCHIVE")" |
| 400 | |
| 401 | known_hash="$(get_known_hash "$package")" || exit "$?" |
| 402 | computed_hash="$(compute_hash "$package")" || exit "$?" |
| 403 | |
| 404 | if [ "$known_hash" != "$computed_hash" ]; then |
| 405 | error_hash_mismatch "$package" "$known_hash" "$computed_hash" |
| 406 | exit 1 |
| 407 | fi |
| 408 | |
Jonathan Neuschäfer | cb76069e | 2018-10-01 09:45:49 +0200 | [diff] [blame] | 409 | printf "${GREEN}hash verified (${known_hash})${NC}\n" |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 410 | } |
| 411 | |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 412 | unpack_and_patch() { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 413 | package="$1" |
| 414 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 415 | archive="$(eval echo \$$package"_ARCHIVE")" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 416 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 417 | dir="$(eval echo \$$package"_DIR")" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 418 | test -d "${dir}" && test -f "${dir}/.unpack_success" || ( |
| 419 | printf " * $(basename "$archive")\n" |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 420 | FLAGS=zxf |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 421 | suffix=$(echo "$archive" | sed 's,.*\.,,') |
Martin Roth | 95f7b22 | 2016-03-20 12:38:48 -0600 | [diff] [blame] | 422 | if [ "$suffix" = "gz" ] && [ -n "$PIGZ" ]; then FLAGS="-I pigz -xf" |
| 423 | elif [ "$suffix" = "gz" ]; then FLAGS=zxf |
| 424 | elif [ "$suffix" = "bz2" ] && [ -n "$LBZIP2" ]; then FLAGS="-I lbzip2 -xf" |
| 425 | elif [ "$suffix" = "bz2" ]; then FLAGS=jxf |
| 426 | elif [ "$suffix" = "xz" ]; then FLAGS="--xz -xf" |
| 427 | elif [ "$suffix" = "lzma" ]; then FLAGS="--lzma -xf" |
| 428 | fi |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 429 | # shellcheck disable=SC2086 |
| 430 | $TAR $FLAGS "tarballs/$(basename "$archive")" |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 431 | for patch in patches/${dir}_*.patch; do |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 432 | test -r "$patch" || continue |
| 433 | printf " o $(basename "$patch")\n" |
| 434 | (cd "${dir}" || exit 1; $PATCH -s -N -p1 <"../${patch}") || { |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 435 | printf "\n${RED}Failed $patch.${NC}\n" |
Stefan Reinauer | 916b845 | 2015-06-09 11:54:49 -0700 | [diff] [blame] | 436 | exit 1 |
| 437 | } |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 438 | done |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 439 | touch "${dir}/.unpack_success" |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 440 | ) |
| 441 | } |
| 442 | |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 443 | fn_exists() |
| 444 | { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 445 | # shellcheck disable=SC2039 |
| 446 | type "$1" >/dev/null 2>&1 |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 447 | } |
| 448 | |
Patrick Georgi | f2c15f5 | 2015-06-11 21:07:31 +0200 | [diff] [blame] | 449 | is_package_enabled() |
| 450 | { |
| 451 | echo "$PACKAGES" |grep -q "\<$1\>" |
| 452 | } |
| 453 | |
Martin Roth | 444ece2 | 2016-04-01 18:46:29 -0600 | [diff] [blame] | 454 | package_uses_targetarch() |
| 455 | { |
Patrick Georgi | f32eed1 | 2021-10-16 10:50:00 +0200 | [diff] [blame] | 456 | if [ "$1" = "GCC" ] || [ "$1" = "BINUTILS" ]; then |
Martin Roth | 444ece2 | 2016-04-01 18:46:29 -0600 | [diff] [blame] | 457 | true |
| 458 | else |
| 459 | false |
| 460 | fi |
| 461 | } |
| 462 | |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 463 | generic_build() |
| 464 | { |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 465 | package=$1 |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 466 | host_target=$2 |
| 467 | builddir=$3 |
| 468 | success=$4 |
Martin Roth | c295d5e | 2016-11-14 11:56:11 -0700 | [diff] [blame] | 469 | version=$5 |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 470 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 471 | fn_exists "build_$package" || return |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 472 | |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 473 | mkdir -p "$builddir" |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 474 | |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 475 | if [ -f "$success" ]; then |
Martin Roth | 2c6a806 | 2016-11-14 11:58:39 -0700 | [diff] [blame] | 476 | printf "Skipping $package v$version for $host_target as it is already built\n" |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 477 | else |
Martin Roth | 2c6a806 | 2016-11-14 11:58:39 -0700 | [diff] [blame] | 478 | printf "Building $package v$version for $host_target ... " |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 479 | DIR="$PWD" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 480 | cd "$builddir" || exit 1 |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 481 | rm -f .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 482 | "build_${package}" "$host_target" > build.log 2>&1 |
| 483 | cd "$DIR" || exit 1 |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 484 | if [ ! -f "$builddir/.failed" ]; then |
| 485 | touch "$success"; |
| 486 | else |
Idwer Vollering | e2ef3cf | 2017-08-15 00:53:13 +0200 | [diff] [blame] | 487 | printf "${RED}failed${NC}. Check '$builddir/build.log'.\n" |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 488 | exit 1 |
| 489 | fi |
| 490 | printf "${green}ok${NC}\n" |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 491 | fi |
| 492 | } |
| 493 | |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 494 | build_for_host() |
| 495 | { |
Martin Roth | c295d5e | 2016-11-14 11:56:11 -0700 | [diff] [blame] | 496 | package="$1" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 497 | # shellcheck disable=SC2086 |
Martin Roth | c295d5e | 2016-11-14 11:56:11 -0700 | [diff] [blame] | 498 | version="$(eval echo \$$package"_VERSION")" |
Patrick Georgi | 1b593e5 | 2016-11-25 15:27:41 +0100 | [diff] [blame] | 499 | generic_build "$package" host "build-$package" "${DESTDIR}${TARGETDIR}/.${package}.${version}.success" "$version" |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | build_for_target() |
| 503 | { |
Martin Roth | c295d5e | 2016-11-14 11:56:11 -0700 | [diff] [blame] | 504 | package="$1" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 505 | # shellcheck disable=SC2086 |
Martin Roth | c295d5e | 2016-11-14 11:56:11 -0700 | [diff] [blame] | 506 | version="$(eval echo \$$package"_VERSION")" |
Patrick Georgi | 1b593e5 | 2016-11-25 15:27:41 +0100 | [diff] [blame] | 507 | generic_build "$package" target "build-${TARGETARCH}-$package" "${DESTDIR}${TARGETDIR}/.${TARGETARCH}-${package}.${version}.success" "$version" |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | build() |
| 511 | { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 512 | if package_uses_targetarch "$1"; then |
| 513 | if [ $BOOTSTRAP -eq 1 ] && [ ! -f "${DESTDIR}${TARGETDIR}/.GCC.${GCC_VERSION}.success" ]; then |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 514 | build_for_host GCC |
| 515 | fi |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 516 | build_for_target "$1" |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 517 | else |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 518 | build_for_host "$1" |
Nico Huber | 11ea2b3 | 2016-01-26 16:09:31 +0100 | [diff] [blame] | 519 | fi |
| 520 | } |
| 521 | |
Nico Huber | 18c74d6 | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 522 | exit_handler() |
Zheng Bao | bb003c8 | 2016-08-05 13:41:51 +0800 | [diff] [blame] | 523 | { |
| 524 | printf "${NC}Stop\n" |
| 525 | exit 1 |
| 526 | } |
| 527 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 528 | cleanup() |
| 529 | { |
Stefan Reinauer | 88e83e5 | 2016-04-06 15:39:48 -0700 | [diff] [blame] | 530 | if [ $SAVETEMPS -ne 0 ]; then |
| 531 | printf "Leaving temporary files around... ${green}ok${NC}\n" |
| 532 | return |
| 533 | fi |
| 534 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 535 | printf "Cleaning up temporary files... " |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 536 | for package in $PACKAGES; do |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 537 | # shellcheck disable=SC2086 |
| 538 | rm -rf "build-${TARGETARCH}-$package" "build-$package" "$(eval echo \$$package"_DIR")" |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 539 | done |
zbao | ff3f15c | 2015-08-26 22:00:31 -0400 | [diff] [blame] | 540 | rm -f getopt |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 541 | printf "${green}ok${NC}\n" |
| 542 | } |
| 543 | |
| 544 | myhelp() |
| 545 | { |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 546 | printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-C] [-G] [-S]\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 547 | printf " $0 [-V|--version]\n" |
| 548 | printf " $0 [-h|--help]\n\n" |
| 549 | |
| 550 | printf "Options:\n" |
Felix Singer | 60c56be | 2021-10-17 14:54:12 +0200 | [diff] [blame] | 551 | printf " [-W|--print-version Print machine readable version\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 552 | printf " [-V|--version] print version number and exit\n" |
| 553 | printf " [-h|--help] print this help and exit\n" |
| 554 | printf " [-c|--clean] remove temporary files before build\n" |
| 555 | printf " [-t|--savetemps] don't remove temporary files after build\n" |
Patrick Georgi | c1a75b1 | 2011-11-04 21:37:14 +0100 | [diff] [blame] | 556 | printf " [-y|--ccache] Use ccache when building cross compiler\n" |
Nico Huber | 152e78e | 2016-09-20 15:38:40 +0200 | [diff] [blame] | 557 | printf " [-n|--nocolor] don't print color codes in output\n" |
| 558 | printf " [-u|--urls] print the urls for all packages\n" |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 559 | printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n" |
Martin Roth | 588c79d | 2016-03-20 12:03:20 -0600 | [diff] [blame] | 560 | printf " [-s]--supported <tool> print supported version of a tool\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 561 | printf " [-d|--directory <target dir>] target directory to install cross compiler to\n" |
Martin Roth | 588c79d | 2016-03-20 12:03:20 -0600 | [diff] [blame] | 562 | printf " (defaults to $TARGETDIR)\n\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 563 | printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 564 | printf " (for RPM builds, default unset)\n" |
Patrick Georgi | f32eed1 | 2021-10-16 10:50:00 +0200 | [diff] [blame] | 565 | printf " [-P|--package <package>] Build a specific package: GCC, CLANG, IASL\n" |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 566 | printf " (defaults to $PACKAGE)\n" |
| 567 | printf "GCC specific options:\n" |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 568 | printf " [-b|--bootstrap] bootstrap the host compiler before building\n" |
| 569 | printf " the cross compiler\n" |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 570 | printf " [-p|--platform <platform>] target platform to build cross compiler for\n" |
| 571 | printf " (defaults to $TARGETARCH)\n" |
Nico Huber | bb313bf | 2015-09-08 12:30:27 +0200 | [diff] [blame] | 572 | printf " [-l|--languages <languages>] comma separated list of target languages\n" |
Nico Huber | 66c2c1a | 2016-09-20 13:09:29 +0200 | [diff] [blame] | 573 | printf " (defaults to $DEFAULT_LANGUAGES)\n" |
Patrick Georgi | f32eed1 | 2021-10-16 10:50:00 +0200 | [diff] [blame] | 574 | printf "Platforms for GCC:\n" |
Julius Werner | f96d905 | 2019-08-16 15:35:39 -0700 | [diff] [blame] | 575 | printf " x86_64 i386-elf i386-mingw32 riscv-elf arm aarch64\n" |
Jonathan Neuschäfer | f14f640 | 2016-03-11 20:22:23 +0100 | [diff] [blame] | 576 | printf " powerpc64le-linux-gnu nds32le-elf\n\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 577 | } |
| 578 | |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 579 | printversion() { |
Martin Roth | 7014f82 | 2020-12-21 15:49:33 -0700 | [diff] [blame] | 580 | printf "${blue}Welcome to the ${red}coreboot${blue} cross toolchain builder v$CROSSGCC_VERSION ${NC}\n\n" |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 583 | myversion() |
| 584 | { |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 585 | printversion |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 586 | |
| 587 | cat << EOF |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 588 | Copyright (C) 2008-2010 by coresystems GmbH |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 589 | Copyright (C) 2011 by Sage Electronic Engineering |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 590 | |
| 591 | This program is free software; you can redistribute it and/or modify |
| 592 | it under the terms of the GNU General Public License as published by |
| 593 | the Free Software Foundation; version 2 of the License. |
| 594 | |
| 595 | This program is distributed in the hope that it will be useful, |
| 596 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 597 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 598 | GNU General Public License for more details. |
| 599 | |
| 600 | EOF |
| 601 | } |
| 602 | |
Nico Huber | 5f72f96 | 2016-01-31 23:05:19 +0100 | [diff] [blame] | 603 | have_hostcflags_from_gmp() { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 604 | grep -q __GMP_CFLAGS "$DESTDIR$TARGETDIR/include/gmp.h" >/dev/null 2>&1 |
Nico Huber | 5f72f96 | 2016-01-31 23:05:19 +0100 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | set_hostcflags_from_gmp() { |
| 608 | # Now set CFLAGS to match GMP CFLAGS but strip out -pedantic |
| 609 | # as GCC 4.6.x fails if it's there. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 610 | HOSTCFLAGS="$(grep __GMP_CFLAGS "$DESTDIR$TARGETDIR/include/gmp.h" |cut -d\" -f2 |\ |
Idwer Vollering | ba349ab | 2016-07-24 02:10:19 +0200 | [diff] [blame] | 611 | sed s,-pedantic,,)" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 612 | export HOSTCFLAGS |
Nico Huber | 5f72f96 | 2016-01-31 23:05:19 +0100 | [diff] [blame] | 613 | } |
| 614 | |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 615 | build_GMP() { |
Nico Huber | 8bbd596 | 2016-12-22 16:05:54 +0100 | [diff] [blame] | 616 | # Check if GCC enables `-pie` by default (possible since GCC 6). |
| 617 | # We need PIC in all static libraries then. |
Nico Huber | 2c1c02e | 2017-01-02 20:51:28 +0100 | [diff] [blame] | 618 | if $CC -dumpspecs 2>/dev/null | grep -q '[{;][[:space:]]*:-pie\>' |
Nico Huber | 8bbd596 | 2016-12-22 16:05:54 +0100 | [diff] [blame] | 619 | then |
| 620 | OPTIONS="$OPTIONS --with-pic" |
| 621 | fi |
| 622 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 623 | # shellcheck disable=SC2086 |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 624 | CC="$(hostcc host)" CXX="$(hostcxx host)" \ |
| 625 | ../${GMP_DIR}/configure --disable-shared --enable-fat \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 626 | --prefix="$TARGETDIR" $OPTIONS \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 627 | || touch .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 628 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 629 | $MAKE $JOBS || touch .failed |
| 630 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 631 | |
| 632 | normalize_dirs |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 633 | |
Nico Huber | 5f72f96 | 2016-01-31 23:05:19 +0100 | [diff] [blame] | 634 | set_hostcflags_from_gmp |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | build_MPFR() { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 638 | test "$UNAME" = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 639 | CC="$(hostcc host)" CXX="$(hostcxx host)" \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 640 | ../${MPFR_DIR}/configure --disable-shared --prefix="$TARGETDIR" \ |
| 641 | --infodir="$TARGETDIR/info" \ |
| 642 | --with-gmp="$DESTDIR$TARGETDIR" CFLAGS="$HOSTCFLAGS" || \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 643 | touch .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 644 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 645 | $MAKE $JOBS || touch .failed |
| 646 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 647 | |
| 648 | normalize_dirs |
| 649 | |
| 650 | # work around build problem of libgmp.la |
| 651 | if [ "$DESTDIR" != "" ]; then |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 652 | perl -pi -e "s,$DESTDIR,," "$DESTDIR$TARGETDIR/lib/libgmp.la" |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 653 | fi |
| 654 | } |
| 655 | |
| 656 | build_MPC() { |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 657 | CC="$(hostcc host)" CXX="$(hostcxx host)" \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 658 | ../${MPC_DIR}/configure --disable-shared --prefix="$TARGETDIR" \ |
| 659 | --infodir="$TARGETDIR/info" --with-mpfr="$DESTDIR$TARGETDIR" \ |
| 660 | --with-gmp="$DESTDIR$TARGETDIR" CFLAGS="$HOSTCFLAGS" || \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 661 | touch .failed |
Patrick Georgi | 790aab6 | 2017-04-26 17:35:35 +0200 | [diff] [blame] | 662 | |
| 663 | # work around build problem of libmpfr.la |
| 664 | if [ "$DESTDIR" != "" ]; then |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 665 | perl -pi -e "s,$TARGETDIR/lib/libgmp.la,$DESTDIR\$&," "$DESTDIR$TARGETDIR/lib/libmpfr.la" |
Patrick Georgi | 790aab6 | 2017-04-26 17:35:35 +0200 | [diff] [blame] | 666 | fi |
| 667 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 668 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 669 | $MAKE $JOBS || touch .failed |
| 670 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 671 | |
Patrick Georgi | 790aab6 | 2017-04-26 17:35:35 +0200 | [diff] [blame] | 672 | # work around build problem of libmpfr.la |
| 673 | if [ "$DESTDIR" != "" ]; then |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 674 | perl -pi -e "s,$DESTDIR,," "$DESTDIR$TARGETDIR/lib/libmpfr.la" |
Patrick Georgi | 790aab6 | 2017-04-26 17:35:35 +0200 | [diff] [blame] | 675 | fi |
| 676 | |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 677 | normalize_dirs |
| 678 | } |
| 679 | |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 680 | build_BINUTILS() { |
Nico Huber | ae6187f | 2016-12-22 22:16:39 +0100 | [diff] [blame] | 681 | if [ $TARGETARCH = "x86_64-elf" ]; then |
Stefan Reinauer | 682a90c | 2015-06-09 14:59:58 -0700 | [diff] [blame] | 682 | ADDITIONALTARGET=",i386-elf" |
| 683 | fi |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 684 | CC="$(hostcc target)" CXX="$(hostcxx target)" \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 685 | ../binutils-${BINUTILS_VERSION}/configure --prefix="$TARGETDIR" \ |
Stefan Reinauer | 682a90c | 2015-06-09 14:59:58 -0700 | [diff] [blame] | 686 | --target=${TARGETARCH} --enable-targets=${TARGETARCH}${ADDITIONALTARGET} \ |
| 687 | --disable-werror --disable-nls --enable-lto --enable-gold \ |
Stefan Reinauer | 2fe2d3d | 2016-04-05 02:14:48 -0700 | [diff] [blame] | 688 | --enable-interwork --enable-multilib \ |
Vivia Nikolaidou | 8108436 | 2018-04-28 01:21:44 +0300 | [diff] [blame] | 689 | --enable-plugins --enable-multilibs \ |
Nico Huber | 010ecf80 | 2016-12-22 16:19:37 +0100 | [diff] [blame] | 690 | CFLAGS="$HOSTCFLAGS" \ |
| 691 | CXXFLAGS="$HOSTCFLAGS" \ |
| 692 | || touch .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 693 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 694 | $MAKE $JOBS || touch .failed |
| 695 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 696 | } |
| 697 | |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 698 | bootstrap_GCC() { |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 699 | # shellcheck disable=SC2086 |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 700 | CC="$(hostcc host)" CXX="$(hostcxx host)" \ |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 701 | CFLAGS="$HOSTCFLAGS" \ |
| 702 | CFLAGS_FOR_BUILD="$HOSTCFLAGS" \ |
| 703 | CFLAGS_FOR_TARGET="$HOSTCFLAGS -fPIC" \ |
| 704 | CXXFLAGS="$HOSTCFLAGS" \ |
| 705 | CXXFLAGS_FOR_BUILD="$HOSTCFLAGS" \ |
| 706 | CXXFLAGS_FOR_TARGET="$HOSTCFLAGS -fPIC" \ |
| 707 | ../gcc-${GCC_VERSION}/configure \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 708 | --prefix="$TARGETDIR" --libexecdir="$TARGETDIR/lib" \ |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 709 | --enable-bootstrap \ |
| 710 | --disable-werror --disable-nls \ |
| 711 | --disable-shared --disable-multilib \ |
| 712 | --disable-libssp --disable-libquadmath --disable-libcc1 \ |
Patrick Georgi | 97a9df4 | 2017-04-26 22:18:18 +0200 | [diff] [blame] | 713 | --disable-libsanitizer \ |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 714 | ${GCC_OPTIONS} --enable-languages="${LANGUAGES}" \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 715 | --with-gmp="$DESTDIR$TARGETDIR" --with-mpfr="$DESTDIR$TARGETDIR" \ |
| 716 | --with-mpc="$DESTDIR$TARGETDIR" \ |
Martin Roth | 7014f82 | 2020-12-21 15:49:33 -0700 | [diff] [blame] | 717 | --with-pkgversion="coreboot bootstrap v$CROSSGCC_VERSION" \ |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 718 | && \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 719 | # shellcheck disable=SC2086 |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 720 | $MAKE $JOBS BOOT_CFLAGS="$HOSTCFLAGS" BUILD_CONFIG="" bootstrap && \ |
| 721 | $MAKE install-gcc \ |
| 722 | install-target-libgcc \ |
| 723 | maybe-install-target-libada \ |
| 724 | maybe-install-target-libstdc++-v3 \ |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 725 | DESTDIR=$DESTDIR || touch .failed |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 726 | } |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 727 | |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 728 | build_cross_GCC() { |
Stefan Reinauer | 45f77b8 | 2016-04-03 20:52:01 -0700 | [diff] [blame] | 729 | # Work around crazy code generator in GCC that confuses CLANG. |
Aaron Durbin | b2229dc | 2016-04-07 16:58:10 -0500 | [diff] [blame] | 730 | $CC --version | grep clang >/dev/null 2>&1 && \ |
Patrick Georgi | a7a5a56 | 2017-06-26 07:21:46 +0200 | [diff] [blame] | 731 | CLANGFLAGS="-fbracket-depth=1024" |
Nico Huber | 3f12d93 | 2017-08-31 23:11:18 +0200 | [diff] [blame] | 732 | [ -n "$CXX" ] && $CXX --version | grep clang >/dev/null 2>&1 && \ |
Patrick Georgi | a7a5a56 | 2017-06-26 07:21:46 +0200 | [diff] [blame] | 733 | CLANGCXXFLAGS="-fbracket-depth=1024" |
Stefan Reinauer | 45f77b8 | 2016-04-03 20:52:01 -0700 | [diff] [blame] | 734 | |
Stefan Reinauer | d0f8372 | 2015-06-09 11:52:28 -0700 | [diff] [blame] | 735 | # GCC does not honor HOSTCFLAGS at all. CFLAGS are used for |
| 736 | # both target and host object files. |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 737 | # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET |
| 738 | # but it does not seem to work properly. At least the host library |
| 739 | # libiberty is not compiled with CFLAGS_FOR_BUILD. |
Stefan Reinauer | 45f77b8 | 2016-04-03 20:52:01 -0700 | [diff] [blame] | 740 | # Also set the CXX version of the flags because GCC is now compiled |
| 741 | # using C++. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 742 | # shellcheck disable=SC2086 |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 743 | CC="$(hostcc target)" CXX="$(hostcxx target)" \ |
Nico Huber | 3f12d93 | 2017-08-31 23:11:18 +0200 | [diff] [blame] | 744 | CFLAGS_FOR_TARGET="-O2 -Dinhibit_libc" \ |
Patrick Georgi | a7a5a56 | 2017-06-26 07:21:46 +0200 | [diff] [blame] | 745 | CFLAGS="$HOSTCFLAGS $CLANGFLAGS" \ |
| 746 | CFLAGS_FOR_BUILD="$HOSTCFLAGS $CLANGFLAGS" \ |
| 747 | CXXFLAGS="$HOSTCFLAGS $CLANGCXXFLAGS" \ |
| 748 | CXXFLAGS_FOR_BUILD="$HOSTCFLAGS $CLANGCXXFLAGS" \ |
| 749 | ../gcc-${GCC_VERSION}/configure \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 750 | --prefix="$TARGETDIR" --libexecdir="$TARGETDIR/lib" \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 751 | --target=${TARGETARCH} --disable-werror --disable-shared \ |
Stefan Reinauer | 2f97ebc | 2015-06-09 12:24:54 -0700 | [diff] [blame] | 752 | --enable-lto --enable-plugins --enable-gold --enable-ld=default \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 753 | --disable-libssp --disable-bootstrap --disable-nls \ |
| 754 | --disable-libquadmath --without-headers \ |
Patrick Georgi | 0a97d7e | 2016-01-25 09:51:22 +0100 | [diff] [blame] | 755 | --disable-threads \ |
Patrick Georgi | 1fc02d1 | 2016-03-23 21:44:43 +0100 | [diff] [blame] | 756 | --enable-interwork --enable-multilib --enable-targets=all \ |
Patrick Georgi | 0a97d7e | 2016-01-25 09:51:22 +0100 | [diff] [blame] | 757 | --disable-libatomic --disable-libcc1 --disable-decimal-float \ |
Nico Huber | bb313bf | 2015-09-08 12:30:27 +0200 | [diff] [blame] | 758 | ${GCC_OPTIONS} --enable-languages="${LANGUAGES}" \ |
Ronald G. Minnich | 7ee16b7 | 2016-02-12 21:54:59 +0000 | [diff] [blame] | 759 | --with-system-zlib \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 760 | --with-gmp="$DESTDIR$TARGETDIR" --with-mpfr="$DESTDIR$TARGETDIR" \ |
| 761 | --with-mpc="$DESTDIR$TARGETDIR" \ |
Patrick Georgi | dce4d46 | 2018-09-07 01:00:54 +0200 | [diff] [blame] | 762 | --with-gnu-as --with-gnu-ld \ |
Martin Roth | 7014f82 | 2020-12-21 15:49:33 -0700 | [diff] [blame] | 763 | --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION" \ |
Nico Huber | 659f40b | 2018-05-23 17:06:53 +0200 | [diff] [blame] | 764 | && \ |
Patrick Georgi | 095db33 | 2018-06-26 21:00:58 +0200 | [diff] [blame] | 765 | mkdir -p gcc/$TARGETARCH && \ |
Nico Huber | e87fcd4 | 2020-12-21 00:11:54 +0100 | [diff] [blame] | 766 | rm -f "gcc/$TARGETARCH/$GCC_VERSION" && \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 767 | ln -s "$DESTDIR$TARGETDIR/$TARGETARCH/bin" "gcc/$TARGETARCH/$GCC_VERSION" && \ |
Nico Huber | 659f40b | 2018-05-23 17:06:53 +0200 | [diff] [blame] | 768 | $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc && \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 769 | $MAKE install-gcc DESTDIR="$DESTDIR" || touch .failed |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 770 | |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 771 | if [ ! -f .failed ] && [ "$(echo $TARGETARCH | grep -c -- -mingw32)" -eq 0 ]; then |
| 772 | # shellcheck disable=SC2086 |
Nico Huber | 659f40b | 2018-05-23 17:06:53 +0200 | [diff] [blame] | 773 | $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc && \ |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 774 | $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed |
| 775 | fi |
| 776 | } |
| 777 | |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 778 | build_GCC() { |
| 779 | if [ "$1" = host ]; then |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 780 | bootstrap_GCC "$1" |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 781 | else |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 782 | build_cross_GCC "$1" |
Nico Huber | 234d246 | 2016-01-26 16:10:17 +0100 | [diff] [blame] | 783 | fi |
| 784 | } |
| 785 | |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 786 | build_IASL() { |
| 787 | RDIR=$PWD |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 788 | cd ../$IASL_DIR/generate/unix || exit 1 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 789 | CFLAGS="$HOSTCFLAGS" |
| 790 | HOST="_LINUX" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 791 | test "$UNAME" = "Darwin" && HOST="_APPLE" |
| 792 | test "$UNAME" = "FreeBSD" && HOST="_FreeBSD" |
| 793 | test "$UNAME" = "Cygwin" && HOST="_CYGWIN" |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 794 | HOST="$HOST" CFLAGS="$CFLAGS" \ |
Martin Roth | 7014f82 | 2020-12-21 15:49:33 -0700 | [diff] [blame] | 795 | OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2 -D COREBOOT_TOOLCHAIN_VERSION='\"coreboot toolchain v$CROSSGCC_VERSION\"' " \ |
Elyes HAOUAS | 157851f | 2020-05-29 10:20:14 +0200 | [diff] [blame] | 796 | $MAKE $JOBS CC="$(hostcc host)" iasl acpibin acpidump acpiexec acpihelp acpisrc acpixtract |
Patrick Georgi | 54f86a5 | 2021-05-11 15:06:37 +0200 | [diff] [blame] | 797 | mkdir -p "$DESTDIR$TARGETDIR/bin/" |
| 798 | (cd "$DESTDIR$TARGETDIR/bin" && rm -f iasl acpibin acpidump acpiexec acpihelp acpisrc acpixtract) || touch "$RDIR/.failed" |
| 799 | (cd bin && cp iasl acpibin acpidump acpiexec acpihelp acpisrc acpixtract "$DESTDIR$TARGETDIR/bin") || touch "$RDIR/.failed" |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | build_LLVM() { |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 803 | |
Patrick Georgi | 5a76a53 | 2021-06-03 08:48:26 +0200 | [diff] [blame] | 804 | ln -nsf "$LLVM_DIR" ../llvm |
| 805 | ln -nsf "$CLANG_DIR" ../clang |
| 806 | ln -nsf "$CTE_DIR" ../clang-tools-extra |
| 807 | ln -nsf "$CRT_DIR" ../compiler-rt |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 808 | |
| 809 | $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$DESTDIR$TARGETDIR" \ |
Martin Roth | 7014f82 | 2020-12-21 15:49:33 -0700 | [diff] [blame] | 810 | -DCLANG_VENDOR="coreboot toolchain v$CROSSGCC_VERSION - " \ |
Patrick Georgi | 5a76a53 | 2021-06-03 08:48:26 +0200 | [diff] [blame] | 811 | -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt" \ |
| 812 | -DCMAKE_BUILD_TYPE=Release ../llvm || touch .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 813 | # shellcheck disable=SC2086 |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 814 | $MAKE $JOBS || touch .failed |
| 815 | $MAKE install || touch .failed |
| 816 | |
Patrick Georgi | 5a76a53 | 2021-06-03 08:48:26 +0200 | [diff] [blame] | 817 | rm -f ../llvm ../clang ../clang-tools-extra ../compiler-rt |
| 818 | |
Elyes HAOUAS | 8f1853c | 2020-08-02 09:46:15 +0200 | [diff] [blame] | 819 | cp -a ../$CLANG_DIR/tools/scan-build/* "$DESTDIR$TARGETDIR/bin" |
| 820 | cp -a ../$CLANG_DIR/tools/scan-view/* "$DESTDIR$TARGETDIR/bin" |
Stefan Reinauer | e9e6e3d | 2015-07-07 00:20:42 +0200 | [diff] [blame] | 821 | |
| 822 | # create symlinks to work around broken --print-librt-file-name |
| 823 | # when used with -target. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 824 | cd "$DESTDIR$TARGETDIR/lib/clang/${CLANG_VERSION}/lib" || exit 1 |
Stefan Reinauer | e9e6e3d | 2015-07-07 00:20:42 +0200 | [diff] [blame] | 825 | for i in */libclang_rt.builtins*.a; do |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 826 | ln -s "$i" . |
Stefan Reinauer | e9e6e3d | 2015-07-07 00:20:42 +0200 | [diff] [blame] | 827 | done |
Stefan Reinauer | e7757bd | 2015-06-05 13:59:44 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 830 | build_CMAKE() { |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 831 | CC="$(hostcc host)" CXX="$(hostcxx host)" CFLAGS="$HOSTCFLAGS" \ |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 832 | ../${CMAKE_DIR}/configure --prefix="$TARGETDIR" \ |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 833 | || touch .failed |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 834 | # shellcheck disable=SC2086 |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 835 | $MAKE $JOBS || touch .failed |
| 836 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 837 | } |
| 838 | |
Martin Roth | d70f5fa | 2019-05-26 17:24:19 -0600 | [diff] [blame] | 839 | build_NASM() { |
| 840 | CC="$(hostcc host)" CXX="$(hostcxx host)" CFLAGS="$HOSTCFLAGS" |
| 841 | ../${NASM_DIR}/configure --prefix="$TARGETDIR" \ |
| 842 | || touch .failed |
| 843 | # shellcheck disable=SC2086 |
| 844 | $MAKE $JOBS || touch .failed |
| 845 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 846 | |
| 847 | normalize_dirs |
| 848 | } |
| 849 | |
Stefan Reinauer | c66fd3c | 2017-06-21 14:57:28 -0700 | [diff] [blame] | 850 | print_supported() { |
| 851 | case "$PRINTSUPPORTED" in |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 852 | BINUTILS|binutils) printf "%s\n" "$BINUTILS_VERSION";; |
| 853 | CLANG|clang) printf "%s\n" "$CLANG_VERSION";; |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 854 | GCC|gcc) printf "%s\n" "$GCC_VERSION";; |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 855 | GMP|gmp) printf "%s\n" "$GMP_VERSION";; |
| 856 | IASL|iasl) printf "%s\n" "$IASL_VERSION";; |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 857 | MPC|mpc) printf "%s\n" "$MPC_VERSION";; |
| 858 | MPFR|mpfr) printf "%s\n" "$MPFR_VERSION";; |
Martin Roth | d70f5fa | 2019-05-26 17:24:19 -0600 | [diff] [blame] | 859 | NASM|nasm) printf "%s\n" "${NASM_VERSION}";; |
Stefan Reinauer | c66fd3c | 2017-06-21 14:57:28 -0700 | [diff] [blame] | 860 | *) printf "Unknown tool %s\n" "$PRINTSUPPORTED";; |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 861 | esac |
| 862 | } |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 863 | |
Nico Huber | 18c74d6 | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 864 | trap exit_handler 1 2 3 15 |
Zheng Bao | bb003c8 | 2016-08-05 13:41:51 +0800 | [diff] [blame] | 865 | |
Patrick Georgi | 6bba29f | 2010-01-29 17:40:52 +0000 | [diff] [blame] | 866 | # Look if we have getopt. If not, build it. |
| 867 | export PATH=$PATH:. |
| 868 | getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c |
| 869 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 870 | # parse parameters.. try to find out whether we're running GNU getopt |
Nico Huber | 27e8412b | 2017-12-05 22:02:21 +0100 | [diff] [blame] | 871 | getoptbrand="$(getopt -V 2>/dev/null | sed -e '1!d' -e 's,^\(......\).*,\1,')" |
Peter Stuge | 09377b7 | 2011-08-21 06:24:55 +0200 | [diff] [blame] | 872 | if [ "${getoptbrand}" = "getopt" ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 873 | # Detected GNU getopt that supports long options. |
Felix Singer | 60c56be | 2021-10-17 14:54:12 +0200 | [diff] [blame] | 874 | args=$(getopt -l print-version,version,help,clean,directory:,bootstrap,bootstrap-only,platform:,languages:,package:,jobs:,destdir:,savetemps,scripting,ccache,supported:,urls,nocolor -o WVhcd:bBp:l:P:j:D:tSys:un -- "$@") |
Nico Huber | 78df0bf | 2016-09-20 14:11:53 +0200 | [diff] [blame] | 875 | getopt_ret=$? |
Nico Huber | cc414dd | 2016-09-20 13:59:38 +0200 | [diff] [blame] | 876 | eval set -- "$args" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 877 | else |
| 878 | # Detected non-GNU getopt |
Felix Singer | 60c56be | 2021-10-17 14:54:12 +0200 | [diff] [blame] | 879 | args=$(getopt WVhcd:bBp:l:P:j:D:tSys:un $*) |
Nico Huber | 78df0bf | 2016-09-20 14:11:53 +0200 | [diff] [blame] | 880 | getopt_ret=$? |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 881 | # shellcheck disable=SC2086 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 882 | set -- $args |
| 883 | fi |
| 884 | |
Nico Huber | 78df0bf | 2016-09-20 14:11:53 +0200 | [diff] [blame] | 885 | if [ $getopt_ret != 0 ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 886 | myhelp |
| 887 | exit 1 |
| 888 | fi |
| 889 | |
| 890 | while true ; do |
| 891 | case "$1" in |
Felix Singer | 60c56be | 2021-10-17 14:54:12 +0200 | [diff] [blame] | 892 | -W|--print-version) shift; echo $CROSSGCC_VERSION; exit 0;; |
Patrick Georgi | 9681cdc | 2017-09-22 18:57:10 +0200 | [diff] [blame] | 893 | -V|--version) shift; myversion; exit 0;; |
| 894 | -h|--help) shift; myhelp; exit 0;; |
| 895 | -c|--clean) shift; clean=1;; |
| 896 | -t|--savetemps) shift; SAVETEMPS=1;; |
| 897 | -d|--directory) shift; TARGETDIR="$1"; shift;; |
| 898 | -b|--bootstrap) shift; BOOTSTRAP=1;; |
| 899 | -B|--bootstrap-only) shift; BOOTSTRAPONLY=1; BOOTSTRAP=1;; |
| 900 | -p|--platform) shift; TARGETARCH="$1"; shift;; |
| 901 | -l|--languages) shift; LANGUAGES="$1"; shift;; |
| 902 | -D|--destdir) shift; DESTDIR="$1"; shift;; |
| 903 | -j|--jobs) shift; THREADS="$1"; JOBS="-j $1"; shift;; |
| 904 | -P|--package) shift; PACKAGE="$1"; shift;; |
Patrick Georgi | 9681cdc | 2017-09-22 18:57:10 +0200 | [diff] [blame] | 905 | -y|--ccache) shift; USECCACHE=1;; |
| 906 | -s|--supported) shift; PRINTSUPPORTED="$1"; shift;; |
| 907 | -u|--urls) shift; printf "%s\n" "$ALL_ARCHIVES"; exit 0;; |
| 908 | -n|--nocolor) shift; \ |
Martin Roth | 4a53db0 | 2016-03-01 15:21:07 -0700 | [diff] [blame] | 909 | unset red RED green GREEN blue BLUE cyan CYAN NC;; |
Patrick Georgi | d2e0dd5 | 2013-06-09 08:05:45 +0200 | [diff] [blame] | 910 | --) shift; break;; |
Patrick Georgi | d2e0dd5 | 2013-06-09 08:05:45 +0200 | [diff] [blame] | 911 | *) break;; |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 912 | esac |
| 913 | done |
| 914 | |
Nico Huber | bd74d56 | 2016-09-20 14:16:43 +0200 | [diff] [blame] | 915 | if [ $# -gt 0 ]; then |
| 916 | printf "Excessive arguments: $*\n" |
| 917 | myhelp |
| 918 | exit 1 |
| 919 | fi |
| 920 | |
Stefan Reinauer | c66fd3c | 2017-06-21 14:57:28 -0700 | [diff] [blame] | 921 | if [ -n "$PRINTSUPPORTED" ]; then |
| 922 | print_supported |
Martin Roth | edf965a | 2015-11-25 16:58:33 -0700 | [diff] [blame] | 923 | exit 0 |
| 924 | fi |
| 925 | |
| 926 | #print toolchain builder version string as the header |
| 927 | printversion |
| 928 | |
Martin Roth | 2c6a806 | 2016-11-14 11:58:39 -0700 | [diff] [blame] | 929 | printf "Building toolchain using %d thread(s).\n\n" "$THREADS" |
| 930 | |
Ronald G. Minnich | b460a66 | 2013-05-26 05:33:35 -0700 | [diff] [blame] | 931 | case "$TARGETARCH" in |
Timothy Pearson | a9f6235 | 2015-12-30 18:59:00 -0600 | [diff] [blame] | 932 | x86_64-elf) ;; |
| 933 | x86_64*) TARGETARCH=x86_64-elf;; |
| 934 | i386-elf) ;; |
| 935 | i386-mingw32) ;; |
Iru Cai | ae8e3a0 | 2016-04-02 10:50:59 +0800 | [diff] [blame] | 936 | riscv-elf) TARGETARCH=riscv64-elf;; |
Patrick Georgi | 0a97d7e | 2016-01-25 09:51:22 +0100 | [diff] [blame] | 937 | powerpc64*-linux*) ;; |
Timothy Pearson | a9f6235 | 2015-12-30 18:59:00 -0600 | [diff] [blame] | 938 | i386*) TARGETARCH=i386-elf;; |
Stefan Reinauer | 27522ad | 2016-01-29 17:31:34 -0800 | [diff] [blame] | 939 | arm*) TARGETARCH=arm-eabi;; |
Timothy Pearson | a9f6235 | 2015-12-30 18:59:00 -0600 | [diff] [blame] | 940 | aarch64*) TARGETARCH=aarch64-elf;; |
Martin Roth | 3e0f74d | 2016-03-08 12:07:04 -0700 | [diff] [blame] | 941 | nds32le-elf) ;; |
Timothy Pearson | a9f6235 | 2015-12-30 18:59:00 -0600 | [diff] [blame] | 942 | *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;; |
Ronald G. Minnich | b460a66 | 2013-05-26 05:33:35 -0700 | [diff] [blame] | 943 | esac |
| 944 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 945 | # Figure out which packages to build |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 946 | |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 947 | case "$PACKAGE" in |
| 948 | GCC|gcc) |
Stefan Reinauer | 81693d4 | 2017-06-21 15:25:36 -0700 | [diff] [blame] | 949 | echo "Target architecture is $TARGETARCH" |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 950 | NAME="${TARGETARCH} cross GCC" |
Nico Huber | afda56e | 2017-12-07 17:50:53 +0100 | [diff] [blame] | 951 | PACKAGES="GMP MPFR MPC BINUTILS GCC" |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 952 | ;; |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 953 | CLANG|clang) |
Stefan Reinauer | 81693d4 | 2017-06-21 15:25:36 -0700 | [diff] [blame] | 954 | NAME="LLVM clang" |
| 955 | LLVM_VERSION=${CLANG_VERSION} |
Elyes HAOUAS | 8f1853c | 2020-08-02 09:46:15 +0200 | [diff] [blame] | 956 | PACKAGES="CMAKE LLVM CLANG CRT CTE" |
Stefan Reinauer | ca117e7 | 2017-06-19 17:29:08 -0700 | [diff] [blame] | 957 | CMAKE=${DESTDIR}${TARGETDIR}/bin/cmake |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 958 | ;; |
| 959 | IASL|iasl) |
| 960 | NAME="IASL ACPI compiler" |
| 961 | PACKAGES=IASL |
| 962 | ;; |
Stefan Reinauer | 3b59349 | 2017-06-19 17:28:54 -0700 | [diff] [blame] | 963 | CMAKE|cmake) |
| 964 | NAME="CMake" |
| 965 | PACKAGES=CMAKE |
| 966 | ;; |
Martin Roth | d70f5fa | 2019-05-26 17:24:19 -0600 | [diff] [blame] | 967 | NASM|nasm) |
| 968 | NAME="NASM" |
| 969 | PACKAGES=NASM |
| 970 | ;; |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 971 | *) |
Patrick Georgi | f32eed1 | 2021-10-16 10:50:00 +0200 | [diff] [blame] | 972 | printf "${red}ERROR: Unsupported package $PACKAGE. (Supported packages are GCC, CLANG, IASL, and NASM)${NC}\n\n"; |
Stefan Reinauer | 85b07d6 | 2015-06-09 14:45:14 -0700 | [diff] [blame] | 973 | exit 1 |
| 974 | ;; |
| 975 | esac |
Peter Stuge | ceacd77 | 2011-06-09 04:54:16 +0200 | [diff] [blame] | 976 | |
Stefan Reinauer | 66e9335 | 2015-06-16 22:38:23 +0200 | [diff] [blame] | 977 | # Find all the required tools: |
| 978 | |
| 979 | TAR=$(searchtool tar) || exit $? |
| 980 | PATCH=$(searchtool patch) || exit $? |
| 981 | MAKE=$(searchtool make) || exit $? |
| 982 | SHA1SUM=$(searchtool sha1sum) |
zbao | 5cf758d | 2015-09-01 22:28:57 -0400 | [diff] [blame] | 983 | #SHA512SUM=$(searchtool sha512sum) |
| 984 | #MD5SUM=$(searchtool md5sum) |
Stefan Reinauer | 66e9335 | 2015-06-16 22:38:23 +0200 | [diff] [blame] | 985 | CHECKSUM=$SHA1SUM |
Martin Roth | 95f7b22 | 2016-03-20 12:38:48 -0600 | [diff] [blame] | 986 | LBZIP2=$(searchtool lbzip2 "" nofail) |
| 987 | PIGZ=$(searchtool pigz "" nofail) |
Stefan Reinauer | 66e9335 | 2015-06-16 22:38:23 +0200 | [diff] [blame] | 988 | |
| 989 | searchtool m4 > /dev/null |
| 990 | searchtool bison > /dev/null |
| 991 | searchtool flex flex > /dev/null |
Stefan Reinauer | 66e9335 | 2015-06-16 22:38:23 +0200 | [diff] [blame] | 992 | searchtool bzip2 "bzip2," > /dev/null |
Nico Huber | 0ff3b39 | 2017-03-12 16:07:33 +0100 | [diff] [blame] | 993 | searchtool xz "XZ Utils" "" "xz-utils" > /dev/null |
Stefan Reinauer | 66e9335 | 2015-06-16 22:38:23 +0200 | [diff] [blame] | 994 | |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 995 | if searchtool wget "GNU" nofail > /dev/null; then |
| 996 | download_showing_percentage() { |
| 997 | url=$1 |
Stefan Reinauer | 81693d4 | 2017-06-21 15:25:36 -0700 | [diff] [blame] | 998 | printf "... ${red} 0%%" |
Martin Roth | 82a30a1 | 2020-11-07 15:17:45 -0700 | [diff] [blame] | 999 | wget --tries=3 "$url" 2>&1 | while read -r line; do |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1000 | echo "$line" | grep -o "[0-9]\+%" | awk '{printf("\b\b\b\b%4s", $1)}' |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 1001 | done |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 1002 | printf "${NC}... " |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 1003 | } |
| 1004 | elif searchtool curl "^curl " > /dev/null; then |
| 1005 | download_showing_percentage() { |
| 1006 | url=$1 |
| 1007 | echo |
Idwer Vollering | 5190f42 | 2020-11-24 15:13:16 +0100 | [diff] [blame] | 1008 | curl -O --progress-bar --location --retry 3 "$url" |
Patrick Georgi | df1ff23 | 2017-01-07 09:28:43 +0100 | [diff] [blame] | 1009 | } |
| 1010 | fi |
| 1011 | |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 1012 | # Allow $CC override from the environment. |
| 1013 | if [ -n "$CC" ]; then |
| 1014 | if [ ! -x "$(command -v "$CC" 2>/dev/null)" ]; then |
| 1015 | printf "${RED}ERROR:${red} CC is set to '%s' but wasn't found.${NC}\n" "$CC" |
| 1016 | HALT_FOR_TOOLS=1 |
| 1017 | fi |
| 1018 | else |
Patrick Georgi | 8f2cdad | 2017-07-10 11:48:34 +0200 | [diff] [blame] | 1019 | if searchtool gnatgcc "Free Software Foundation" nofail > /dev/null; then |
| 1020 | CC=gnatgcc |
| 1021 | elif searchtool gcc "Free Software Foundation" nofail > /dev/null; then |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 1022 | CC=gcc |
| 1023 | else |
| 1024 | searchtool cc '^' nofail > /dev/null || please_install gcc |
| 1025 | CC=cc |
| 1026 | fi |
| 1027 | fi |
Martin Roth | 591790f | 2016-03-20 20:39:04 -0600 | [diff] [blame] | 1028 | |
Nico Huber | 08bb837 | 2017-06-24 19:50:35 +0200 | [diff] [blame] | 1029 | # We can leave $CXX empty if it's not set since *buildgcc* never |
| 1030 | # calls it directly. This way configure scripts can search for |
| 1031 | # themselves and we still override it when a bootstrapped g++ is |
| 1032 | # to be used (cf. hostcxx()). |
| 1033 | if [ -n "$CXX" ]; then |
| 1034 | if [ ! -x "$(command -v "$CXX" 2>/dev/null)" ]; then |
| 1035 | printf "${RED}ERROR:${red} CXX is set to '%s' but wasn't found.${NC}\n" "$CXX" |
| 1036 | HALT_FOR_TOOLS=1 |
| 1037 | fi |
| 1038 | else |
| 1039 | searchtool g++ "Free Software Foundation" nofail > /dev/null || \ |
| 1040 | searchtool clang "clang version" nofail > /dev/null || \ |
| 1041 | searchtool clang "LLVM" "" "g++" > /dev/null |
| 1042 | fi |
| 1043 | |
| 1044 | check_for_library "-lz" "zlib (zlib1g-dev or zlib-devel)" |
Nico Huber | 156d87c | 2016-09-20 12:59:53 +0200 | [diff] [blame] | 1045 | |
Martin Roth | 8846382 | 2016-01-07 11:03:36 -0700 | [diff] [blame] | 1046 | if [ "$HALT_FOR_TOOLS" -ne 0 ]; then |
| 1047 | exit 1 |
| 1048 | fi |
| 1049 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1050 | # This initial cleanup is useful when updating the toolchain script. |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 1051 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1052 | if [ "$clean" = "1" ]; then |
| 1053 | cleanup |
| 1054 | fi |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 1055 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1056 | # Set up host compiler and flags needed for various OSes |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 1057 | |
Patrick Georgi | f2c15f5 | 2015-06-11 21:07:31 +0200 | [diff] [blame] | 1058 | if is_package_enabled "GCC"; then |
Patrick Georgi | e8253fe | 2017-07-18 11:35:35 +0200 | [diff] [blame] | 1059 | # sane preset: let the configure script figure out things by itself |
| 1060 | # more importantly, avoid any values that might already linger in the variable |
| 1061 | OPTIONS="ABI=" |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1062 | if [ "$UNAME" = "Darwin" ]; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 1063 | #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix" |
| 1064 | |
| 1065 | # generally the OS X compiler can create x64 binaries. |
| 1066 | # Per default it generated i386 binaries in 10.5 and x64 |
| 1067 | # binaries in 10.6 (even if the kernel is 32bit) |
| 1068 | # For some weird reason, 10.5 autodetects an ABI=64 though |
| 1069 | # so we're setting the ABI explicitly here. |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1070 | if [ "$(sysctl -n hw.optional.x86_64 2>/dev/null)" -eq 1 ] 2>/dev/null; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 1071 | OPTIONS="ABI=64" |
| 1072 | else |
| 1073 | OPTIONS="ABI=32" |
| 1074 | fi |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 1075 | |
Stefan Reinauer | 4266b92 | 2012-12-05 16:18:32 -0800 | [diff] [blame] | 1076 | # In Xcode 4.5.2 the default compiler is clang. |
| 1077 | # However, this compiler fails to compile gcc 4.7.x. As a |
| 1078 | # workaround it's possible to compile gcc with llvm-gcc. |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 1079 | if $CC -v 2>&1 | grep -q LLVM; then |
Stefan Reinauer | 4266b92 | 2012-12-05 16:18:32 -0800 | [diff] [blame] | 1080 | CC=llvm-gcc |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 1081 | fi |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1082 | elif [ "$UNAME" = "Linux" ] || [ "$UNAME" = "Cygwin" ]; then |
Patrick Georgi | ddb8f80 | 2015-07-04 17:45:54 +0200 | [diff] [blame] | 1083 | # gmp is overeager with detecting 64bit CPUs even if they run |
| 1084 | # a 32bit kernel and userland. |
| 1085 | if [ "$(uname -m 2>/dev/null)" = "i686" ]; then |
| 1086 | OPTIONS="ABI=32" |
| 1087 | fi |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1088 | elif [ "$UNAME" = "NetBSD" ]; then |
Nico Huber | de45c59 | 2016-01-20 23:22:33 +0100 | [diff] [blame] | 1089 | # same for NetBSD but this one reports an i386 |
| 1090 | if [ "$(uname -m 2>/dev/null)" = "i386" ]; then |
| 1091 | OPTIONS="ABI=32" |
| 1092 | fi |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 1093 | fi |
Nico Huber | 66c2c1a | 2016-09-20 13:09:29 +0200 | [diff] [blame] | 1094 | if [ -z "${LANGUAGES}" ]; then |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 1095 | if have_gnat; then |
Nico Huber | 66c2c1a | 2016-09-20 13:09:29 +0200 | [diff] [blame] | 1096 | printf "\nFound compatible Ada compiler, enabling Ada support by default.\n\n" |
| 1097 | LANGUAGES="ada,${DEFAULT_LANGUAGES}" |
| 1098 | else |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 1099 | printf "\n${red}WARNING${NC}\n" |
| 1100 | printf "No compatible Ada compiler (GNAT) found. You can continue without\n" |
| 1101 | printf "Ada support, but this will limit the features of ${blue}coreboot${NC} (e.g.\n" |
| 1102 | printf "native graphics initialization won't be available on most Intel\n" |
| 1103 | printf "boards).\n\n" |
| 1104 | |
| 1105 | printf "Usually, you can install GNAT with your package management system\n" |
| 1106 | printf "(the package is called \`gnat\` or \`gcc-ada\`). It has to match the\n" |
| 1107 | printf "\`gcc\` package in version. If there are multiple versions of GCC in-\n" |
| 1108 | printf "stalled, you can point this script to the matching version through\n" |
| 1109 | printf "the \`CC\` and \`CXX\` environment variables.\n\n" |
| 1110 | |
| 1111 | printf "e.g. on Ubuntu 14.04, if \`gcc\` is \`gcc-4.8\`:\n" |
| 1112 | printf " apt-get install gnat-4.8 && make crossgcc\n\n" |
| 1113 | |
| 1114 | printf "on Ubuntu 16.04, if \`gcc\` is \`gcc-5\`:\n" |
| 1115 | printf " apt-get install gnat-5 && make crossgcc\n" |
| 1116 | timeout 30 |
Nico Huber | 66c2c1a | 2016-09-20 13:09:29 +0200 | [diff] [blame] | 1117 | LANGUAGES="${DEFAULT_LANGUAGES}" |
| 1118 | fi |
| 1119 | fi |
Patrick Georgi | f2741aa | 2020-07-06 16:35:56 +0200 | [diff] [blame] | 1120 | if [ "$BOOTSTRAP" != 1 ] && \ |
| 1121 | { [ "$(hostcc_major)" -lt 4 ] || \ |
| 1122 | { [ "$(hostcc_major)" -eq 4 ] && \ |
| 1123 | [ "$(hostcc_minor)" -lt 9 ] ; } ; } |
| 1124 | then |
| 1125 | printf "\n${red}WARNING${NC}\n" |
| 1126 | printf "Building coreboot requires a host compiler newer than 4.9.x while\n" |
| 1127 | printf "yours is $(hostcc_version).\n" |
| 1128 | printf "Enabling bootstrapping to provide a sufficiently new compiler:\n" |
| 1129 | printf "This will take significantly longer than a usual build.\n" |
| 1130 | printf "Alternatively you can abort now and update your host compiler.\n" |
| 1131 | timeout 15 |
| 1132 | BOOTSTRAP=1 |
| 1133 | fi |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 1134 | if ada_requested; then |
Patrick Georgi | f2741aa | 2020-07-06 16:35:56 +0200 | [diff] [blame] | 1135 | if ! have_gnat; then |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 1136 | please_install gnat gcc-ada |
| 1137 | exit 1 |
| 1138 | fi |
Nico Huber | cd87e1b | 2017-06-24 20:35:59 +0200 | [diff] [blame] | 1139 | fi |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 1140 | fi # GCC |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 1141 | |
Nico Huber | 5f72f96 | 2016-01-31 23:05:19 +0100 | [diff] [blame] | 1142 | export HOSTCFLAGS="-Os" |
| 1143 | if have_hostcflags_from_gmp; then |
| 1144 | set_hostcflags_from_gmp |
| 1145 | fi |
| 1146 | |
Patrick Georgi | c1a75b1 | 2011-11-04 21:37:14 +0100 | [diff] [blame] | 1147 | if [ "$USECCACHE" = 1 ]; then |
| 1148 | CC="ccache $CC" |
| 1149 | fi |
| 1150 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1151 | # Prepare target directory for building GCC |
| 1152 | # (dependencies must be in the PATH) |
Martin Roth | 987d42d | 2018-07-22 11:45:29 -0600 | [diff] [blame] | 1153 | mkdir -p "$DESTDIR$TARGETDIR/bin" |
| 1154 | mkdir -p "$DESTDIR$TARGETDIR/share" |
Stefan Reinauer | 16bd789 | 2012-12-07 23:57:01 +0100 | [diff] [blame] | 1155 | export PATH=$DESTDIR$TARGETDIR/bin:$PATH |
| 1156 | |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1157 | # Download, unpack, patch and build all packages |
| 1158 | |
Idwer Vollering | 458e7df | 2020-09-25 12:26:51 +0200 | [diff] [blame] | 1159 | printf "Downloading and verifying tarballs ...\n" |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1160 | mkdir -p tarballs |
| 1161 | for P in $PACKAGES; do |
Jonathan Neuschäfer | 92d483a | 2017-09-26 22:33:53 +0200 | [diff] [blame] | 1162 | download "$P" || exit "$?" |
| 1163 | verify_hash "$P" || exit "$?" |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1164 | done |
Martin Roth | 0362517 | 2016-02-17 14:44:14 -0700 | [diff] [blame] | 1165 | printf "Downloaded tarballs ... ${green}ok${NC}\n" |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1166 | |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 1167 | printf "Unpacking and patching ...\n" |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1168 | for P in $PACKAGES; do |
| 1169 | unpack_and_patch $P || exit 1 |
| 1170 | done |
| 1171 | printf "Unpacked and patched ... ${green}ok${NC}\n" |
| 1172 | |
Patrick Georgi | 9681cdc | 2017-09-22 18:57:10 +0200 | [diff] [blame] | 1173 | if [ -n "$BOOTSTRAPONLY" ]; then |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 1174 | printf "Building bootstrap compiler only ...\n" |
Nico Huber | afda56e | 2017-12-07 17:50:53 +0100 | [diff] [blame] | 1175 | for pkg in GMP MPFR MPC GCC; do |
Patrick Georgi | 9681cdc | 2017-09-22 18:57:10 +0200 | [diff] [blame] | 1176 | build_for_host $pkg |
| 1177 | done |
| 1178 | exit 0 |
| 1179 | fi |
| 1180 | |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 1181 | printf "Building packages ...\n" |
Stefan Reinauer | 1c70e05 | 2015-06-09 11:47:28 -0700 | [diff] [blame] | 1182 | for package in $PACKAGES; do |
| 1183 | build $package |
| 1184 | done |
Stefan Reinauer | 5dd2635 | 2015-06-09 14:52:22 -0700 | [diff] [blame] | 1185 | printf "Packages built ... ${green}ok${NC}\n" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame] | 1186 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 1187 | # Adding git information of current tree to target directory |
| 1188 | # for reproducibility |
Stefan Reinauer | d764912 | 2015-06-09 11:44:25 -0700 | [diff] [blame] | 1189 | PROGNAME=$(basename "$0") |
Stefan Reinauer | 88352d7 | 2016-04-06 15:57:03 -0700 | [diff] [blame] | 1190 | rm -f "$DESTDIR$TARGETDIR/share/$PROGNAME-*" |
Felix Singer | 62fcffb | 2021-10-19 13:25:18 +0200 | [diff] [blame] | 1191 | cp "$PROGNAME" "$DESTDIR$TARGETDIR/share/$PROGNAME-$CROSSGCC_VERSION" |
Zheng Bao | 30b895f | 2013-02-06 18:04:40 +0800 | [diff] [blame] | 1192 | |
Patrick Georgi | 0c2df6f | 2017-11-22 16:14:09 -0500 | [diff] [blame] | 1193 | # Adding edk2 tools template |
| 1194 | mkdir -p "$DESTDIR$TARGETDIR/share/edk2config" |
| 1195 | sed -e "s,@@PREFIX@@,$TARGETDIR,g" edk2tools.txt > "$DESTDIR$TARGETDIR/share/edk2config/tools_def.txt" |
| 1196 | printf "Copied EDK2 tools template ... ${green}ok${NC}\n" |
| 1197 | |
Stefan Reinauer | 88e83e5 | 2016-04-06 15:39:48 -0700 | [diff] [blame] | 1198 | cleanup |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 1199 | |
Stefan Reinauer | 81693d4 | 2017-06-21 15:25:36 -0700 | [diff] [blame] | 1200 | printf "\n${green}You can now run $NAME from $TARGETDIR.${NC}\n" |