Changes in tools/toolchain.sh [ce52c333:e6b4d2d] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/toolchain.sh

    rce52c333 re6b4d2d  
    3131BINUTILS_GDB_GIT="https://github.com/HelenOS/binutils-gdb.git"
    3232
    33 BINUTILS_BRANCH="binutils-2_31_1-helenos"
    34 BINUTILS_VERSION="2.31.1"
    35 
    36 GDB_BRANCH="gdb-8_2-helenos"
    37 GDB_VERSION="8.2"
     33BINUTILS_BRANCH="binutils-2_45-helenos"
     34BINUTILS_VERSION="2.45"
    3835
    3936GCC_GIT="https://github.com/HelenOS/gcc.git"
    40 GCC_BRANCH="8_2_0-helenos"
    41 GCC_VERSION="8.2.0"
    42 
    43 BASEDIR="`pwd`"
     37GCC_BRANCH="15_2_0-helenos"
     38GCC_VERSION="15.2"
     39
     40BASEDIR="$PWD"
    4441SRCDIR="$(readlink -f $(dirname "$0"))"
    4542
    46 REAL_INSTALL=true
    47 USE_HELENOS_TARGET=true
     43# If we install into a temporary directory and copy from there,
     44# we don't have to trust the upstream makefiles respect the prefix for
     45# all files, and we also have a ready-made package for distribution.
     46INSTALL_DIR="${BASEDIR}/PKG"
     47
     48SYSTEM_INSTALL=false
     49
     50BUILD_BINUTILS=true
     51BUILD_GCC=true
     52
     53if [ -z "$JOBS" ] ; then
     54        JOBS="`nproc`"
     55fi
    4856
    4957check_error() {
     
    5765
    5866show_usage() {
    59         echo "Cross-compiler toolchain build script"
     67        echo "HelenOS cross-compiler toolchain build script"
    6068        echo
    6169        echo "Syntax:"
    62         echo " $0 [--no-install] [--non-helenos-target] <platform>"
    63         echo " $0 --test-version [<platform>]"
     70        echo " $0 [--system-wide] --test-version [<platform>]"
    6471        echo
    6572        echo "Possible target platforms are:"
     
    7582        echo " sparc64    SPARC V9"
    7683        echo " all        build all targets"
    77         echo " essential  build only targets currently needed for HelenOS development"
    7884        echo " parallel   same as 'all', but all in parallel"
    7985        echo " 2-way      same as 'all', but 2-way parallel"
    8086        echo
    81         echo "The toolchain is installed into directory specified by the"
    82         echo "CROSS_PREFIX environment variable. If the variable is not"
    83         echo "defined, /usr/local/cross/ is used as default."
    84         echo
    85         echo "If --no-install is present, the toolchain still uses the"
    86         echo "CROSS_PREFIX as the target directory but the installation"
    87         echo "copies the files into PKG/ subdirectory without affecting"
    88         echo "the actual root file system. That is only useful if you do"
    89         echo "not want to run the script under the super user."
    90         echo
    91         echo "The --non-helenos-target will build non-HelenOS-specific toolchain"
    92         echo "(i.e. it will use *-linux-* triplet instead of *-helenos)."
     87        echo "The toolchain target installation directory is determined by matching"
     88        echo "the first of the following conditions:"
     89        echo
     90        echo " (1) If the \$CROSS_PREFIX environment variable is set, then it is"
     91        echo "     used as the target installation directory."
     92        echo " (2) If the --system-wide option is used, then /opt/HelenOS/cross"
     93        echo "     is used as the target installation directory. This usually"
     94        echo "     requires running this script with super user privileges."
     95        echo " (3) In other cases, \$XDG_DATA_HOME/HelenOS/cross is used as the"
     96        echo "     target installation directory. If the \$XDG_DATA_HOME environment"
     97        echo "     variable is not set, then the default value of \$HOME/.local/share"
     98        echo "     is assumed."
     99        echo
     100        echo "The --non-helenos-target option will build non-HelenOS-specific"
     101        echo "toolchain (i.e. it will use *-linux-* triplet instead of *-helenos)."
    93102        echo "Using this toolchain for building HelenOS is not supported."
    94103        echo
     104        echo "The --test-version mode tests the currently installed version of the"
     105        echo "toolchain."
    95106
    96107        exit 3
    97108}
    98109
     110set_cross_prefix() {
     111        if [ -z "$CROSS_PREFIX" ] ; then
     112                if $SYSTEM_INSTALL ; then
     113                        CROSS_PREFIX="/opt/HelenOS/cross"
     114                else
     115                        if [ -z "$XDG_DATA_HOME" ] ; then
     116                                XDG_DATA_HOME="$HOME/.local/share"
     117                        fi
     118                        CROSS_PREFIX="$XDG_DATA_HOME/HelenOS/cross"
     119                fi
     120        fi
     121}
     122
    99123test_version() {
    100         echo "Cross-compiler toolchain build script"
    101         echo
    102         echo "Start testing the version of the installed software"
    103         echo
    104        
     124        set_cross_prefix
     125
     126        echo "HelenOS cross-compiler toolchain build script"
     127        echo
     128        echo "Testing the version of the installed software in $CROSS_PREFIX"
     129        echo
     130
    105131        if [ -z "$1" ] || [ "$1" = "all" ] ; then
    106132                PLATFORMS='amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64'
     
    108134                PLATFORMS="$1"
    109135        fi
    110        
    111        
    112         if [ -z "${CROSS_PREFIX}" ] ; then
    113                 CROSS_PREFIX="/usr/local/cross"
    114         fi
    115 
    116         for i in $PLATFORMS
    117         do
    118                 PLATFORM="$i"
     136
     137        for PLATFORM in $PLATFORMS ; do
    119138                set_target_from_platform "$PLATFORM"
    120                 PREFIX="${CROSS_PREFIX}/bin/${HELENOS_TARGET}"
     139                PREFIX="${CROSS_PREFIX}/bin/${TARGET}"
    121140
    122141                echo "== $PLATFORM =="
    123142                test_app_version "Binutils" "ld" "GNU ld (.*) \([.0-9]*\)" "$BINUTILS_VERSION"
    124143                test_app_version "GCC" "gcc" "gcc version \([.0-9]*\)" "$GCC_VERSION"
    125                 test_app_version "GDB" "gdb" "GNU gdb (.*)[[:space:]]\+\([.0-9]*\)" "$GDB_VERSION"
    126144        done
    127 
    128         exit
    129145}
    130146
     
    135151        INS_VERSION="$4"
    136152
    137 
    138153        APP="${PREFIX}-${APPNAME}"
    139154        if [ ! -e $APP ]; then
     
    148163
    149164                if [ "$INS_VERSION" = "$VERSION" ]; then
    150                         echo "+ $PKGNAME is uptodate ($INS_VERSION)"
     165                        echo "+ $PKGNAME is up-to-date ($INS_VERSION)"
    151166                else
    152167                        echo "- $PKGNAME ($VERSION) is outdated ($INS_VERSION)"
     
    155170}
    156171
    157 
    158 
    159172change_title() {
    160173        printf "\e]0;$1\a"
     174}
     175
     176ring_bell() {
     177        printf '\a'
     178        sleep 0.1
     179        printf '\a'
     180        sleep 0.1
     181        printf '\a'
     182        sleep 0.1
     183        printf '\a'
     184        sleep 0.1
     185        printf '\a'
    161186}
    162187
     
    178203
    179204show_dependencies() {
     205        set_cross_prefix
     206
     207        echo "HelenOS cross-compiler toolchain build script"
     208        echo
     209        echo "Installing software to $CROSS_PREFIX"
     210        echo
     211        echo
    180212        echo "IMPORTANT NOTICE:"
    181213        echo
     
    218250
    219251check_dirs() {
    220         OUTSIDE="$1"
    221         BASE="$2"
    222         ORIGINAL="$PWD"
    223 
    224         cd "${BASE}"
    225         check_error $? "Unable to change directory to ${BASE}."
     252        cd "${BASEDIR}"
     253        check_error $? "Unable to change directory to ${BASEDIR}."
    226254        ABS_BASE="$PWD"
    227         cd "${ORIGINAL}"
    228         check_error $? "Unable to change directory to ${ORIGINAL}."
    229 
    230         mkdir -p "${OUTSIDE}"
    231         cd "${OUTSIDE}"
    232         check_error $? "Unable to change directory to ${OUTSIDE}."
     255
     256        if $SYSTEM_INSTALL && [ ! -d "${CROSS_PREFIX}" ]; then
     257                ring_bell
     258                ( set -x ; sudo -k mkdir -p "${CROSS_PREFIX}" )
     259        else
     260                ( set -x ; mkdir -p "${CROSS_PREFIX}" )
     261        fi
     262
     263        cd "${CROSS_PREFIX}"
     264        check_error $? "Unable to change directory to ${CROSS_PREFIX}."
    233265
    234266        while [ "${#PWD}" -gt "${#ABS_BASE}" ]; do
     
    243275        fi
    244276
    245         cd "${ORIGINAL}"
    246         check_error $? "Unable to change directory to ${ORIGINAL}."
     277        cd "${BASEDIR}"
    247278}
    248279
     
    255286        check_error $? "Change directory failed."
    256287
     288        change_title "Downloading sources"
    257289        echo ">>> Downloading sources"
    258         git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION"
    259         git clone --depth 1 -b "$GDB_BRANCH" "$BINUTILS_GDB_GIT" "gdb-$GDB_VERSION"
    260         git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION"
    261 
    262         # If the directory already existed, pull upstream changes.
    263         git -C "binutils-$BINUTILS_VERSION" pull
    264         git -C "gdb-$GDB_VERSION" pull
    265         git -C "gcc-$GCC_VERSION" pull
    266 
    267         echo ">>> Downloading GCC prerequisites"
    268         cd "gcc-${GCC_VERSION}"
    269         ./contrib/download_prerequisites
    270         cd ..
     290
     291        if $BUILD_BINUTILS ; then
     292                git clone --depth 1 -b "$BINUTILS_BRANCH" "$BINUTILS_GDB_GIT" "binutils-$BINUTILS_VERSION"
     293                # If the directory already existed, pull upstream changes.
     294                git -C "binutils-$BINUTILS_VERSION" pull
     295        fi
     296
     297        if $BUILD_GCC ; then
     298                git clone --depth 1 -b "$GCC_BRANCH" "$GCC_GIT" "gcc-$GCC_VERSION"
     299                git -C "gcc-$GCC_VERSION" pull
     300
     301                change_title "Downloading GCC prerequisites"
     302                echo ">>> Downloading GCC prerequisites"
     303                cd "gcc-${GCC_VERSION}"
     304                ./contrib/download_prerequisites
     305                cd ..
     306        fi
     307
     308        # This sets the CROSS_PREFIX variable
     309        set_cross_prefix
     310
     311        DESTDIR_SPEC="DESTDIR=${INSTALL_DIR}"
     312
     313        check_dirs
    271314}
    272315
     
    296339        esac
    297340
    298         HELENOS_TARGET="${GNU_ARCH}-helenos"
    299 
    300         case "$1" in
    301                 "arm32")
    302                         LINUX_TARGET="${GNU_ARCH}-linux-gnueabi"
    303                         ;;
    304                 *)
    305                         LINUX_TARGET="${GNU_ARCH}-linux-gnu"
    306                         ;;
    307         esac
    308 }
    309 
    310 build_target() {
    311         PLATFORM="$1"
    312 
    313         # This sets the *_TARGET variables
    314         set_target_from_platform "$PLATFORM"
    315         if $USE_HELENOS_TARGET ; then
    316                 TARGET="$HELENOS_TARGET"
    317         else
    318                 TARGET="$LINUX_TARGET"
    319         fi
     341        TARGET="${GNU_ARCH}-helenos"
     342}
     343
     344build_binutils() {
     345        # This sets the TARGET variable
     346        set_target_from_platform "$1"
    320347
    321348        WORKDIR="${BASEDIR}/${TARGET}"
    322         INSTALL_DIR="${BASEDIR}/PKG"
    323349        BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
    324         GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
    325         GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
    326 
    327         if [ -z "${CROSS_PREFIX}" ] ; then
    328                 CROSS_PREFIX="/usr/local/cross"
    329         fi
    330 
    331         if [ -z "$JOBS" ] ; then
    332                 JOBS=`nproc`
    333         fi
    334 
    335         PREFIX="${CROSS_PREFIX}"
    336350
    337351        echo ">>> Removing previous content"
    338352        cleanup_dir "${WORKDIR}"
    339353        mkdir -p "${WORKDIR}"
    340         check_dirs "${PREFIX}" "${WORKDIR}"
    341 
    342         if $USE_HELENOS_TARGET ; then
    343                 echo ">>> Creating build sysroot"
    344                 mkdir -p "${WORKDIR}/sysroot/include"
    345                 mkdir "${WORKDIR}/sysroot/lib"
    346                 ARCH="$PLATFORM"
    347                 if [ "$ARCH" = "mips32eb" ]; then
    348                         ARCH=mips32
    349                 fi
    350 
    351                 cp -r -L -t "${WORKDIR}/sysroot/include" \
    352                         ${SRCDIR}/../abi/include/* \
    353                         ${SRCDIR}/../uspace/lib/c/arch/${ARCH}/include/* \
    354                         ${SRCDIR}/../uspace/lib/c/include/*
    355                 check_error $? "Failed to create build sysroot."
    356         fi
    357 
    358         echo ">>> Processing binutils (${PLATFORM})"
     354
     355        echo ">>> Processing binutils (${TARGET})"
    359356        mkdir -p "${BINUTILSDIR}"
    360357        cd "${BINUTILSDIR}"
    361358        check_error $? "Change directory failed."
    362359
    363         change_title "binutils: configure (${PLATFORM})"
     360        change_title "binutils: configure (${TARGET})"
    364361        CFLAGS="-Wno-error -fcommon" "${BASEDIR}/downloads/binutils-${BINUTILS_VERSION}/configure" \
    365362                "--target=${TARGET}" \
    366                 "--prefix=${PREFIX}" \
     363                "--prefix=${CROSS_PREFIX}" \
    367364                "--program-prefix=${TARGET}-" \
    368365                --disable-nls \
    369366                --disable-werror \
    370                 --enable-gold \
     367                --disable-gold \
    371368                --enable-deterministic-archives \
    372369                --disable-gdb \
     
    374371        check_error $? "Error configuring binutils."
    375372
    376         change_title "binutils: make (${PLATFORM})"
     373        change_title "binutils: make (${TARGET})"
    377374        make all -j$JOBS
    378375        check_error $? "Error compiling binutils."
    379376
    380         change_title "binutils: install (${PLATFORM})"
    381         make install "DESTDIR=${INSTALL_DIR}"
     377        change_title "binutils: install (${TARGET})"
     378        make install $DESTDIR_SPEC
    382379        check_error $? "Error installing binutils."
    383 
    384 
    385         echo ">>> Processing GCC (${PLATFORM})"
     380}
     381
     382build_gcc() {
     383        # This sets the TARGET variable
     384        set_target_from_platform "$1"
     385
     386        WORKDIR="${BASEDIR}/${TARGET}"
     387        GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
     388
     389        echo ">>> Removing previous content"
     390        cleanup_dir "${WORKDIR}"
     391        mkdir -p "${WORKDIR}"
     392
     393        echo ">>> Processing GCC (${TARGET})"
    386394        mkdir -p "${GCCDIR}"
    387395        cd "${GCCDIR}"
    388396        check_error $? "Change directory failed."
    389397
    390         if $USE_HELENOS_TARGET ; then
    391                 SYSROOT=--with-sysroot --with-build-sysroot="${WORKDIR}/sysroot"
    392         else
    393                 SYSROOT=--without-headers
    394         fi
    395 
    396         change_title "GCC: configure (${PLATFORM})"
    397         PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
     398        BUILDPATH="${CROSS_PREFIX}/bin:${PATH}"
     399
     400        change_title "GCC: configure (${TARGET})"
     401        PATH="${BUILDPATH}" "${BASEDIR}/downloads/gcc-${GCC_VERSION}/configure" \
    398402                "--target=${TARGET}" \
    399                 "--prefix=${PREFIX}" \
     403                "--prefix=${CROSS_PREFIX}" \
    400404                "--program-prefix=${TARGET}-" \
    401405                --with-gnu-as \
     
    404408                --enable-languages=c,c++,go \
    405409                --enable-lto \
     410                --enable-obsolete \
    406411                --disable-shared \
    407412                --disable-werror \
    408                 $SYSROOT
     413                --without-headers  # TODO: Replace with proper sysroot so we can build more libs
    409414        check_error $? "Error configuring GCC."
    410415
    411         change_title "GCC: make (${PLATFORM})"
    412         PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc -j$JOBS
     416        change_title "GCC: make (${TARGET})"
     417        PATH="${BUILDPATH}" make all-gcc -j$JOBS
    413418        check_error $? "Error compiling GCC."
    414419
    415         if $USE_HELENOS_TARGET ; then
    416                 PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libgcc -j$JOBS
    417                 check_error $? "Error compiling libgcc."
    418                 # TODO: needs some extra care
    419                 #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libatomic -j$JOBS
    420                 #check_error $? "Error compiling libatomic."
    421                 #PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-target-libstdc++-v3 -j$JOBS
    422                 #check_error $? "Error compiling libstdc++."
    423         fi
    424 
    425         change_title "GCC: install (${PLATFORM})"
    426         PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
    427         if $USE_HELENOS_TARGET ; then
    428                 PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libgcc "DESTDIR=${INSTALL_DIR}"
    429                 #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libatomic "DESTDIR=${INSTALL_DIR}"
    430                 #PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-target-libstdc++-v3 "DESTDIR=${INSTALL_DIR}"
    431         fi
     420        change_title "GCC: install (${TARGET})"
     421        PATH="${BUILDPATH}" make install-gcc $DESTDIR_SPEC
    432422        check_error $? "Error installing GCC."
    433 
    434 
    435         echo ">>> Processing GDB (${PLATFORM})"
    436         mkdir -p "${GDBDIR}"
    437         cd "${GDBDIR}"
     423}
     424
     425build_libgcc() {
     426        # This sets the TARGET variable
     427        set_target_from_platform "$1"
     428
     429        WORKDIR="${BASEDIR}/${TARGET}"
     430        GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
     431
     432        # No removing previous content here, we need the previous GCC build
     433
     434        cd "${GCCDIR}"
    438435        check_error $? "Change directory failed."
    439436
    440         change_title "GDB: configure (${PLATFORM})"
    441         CFLAGS="-fcommon" PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${BASEDIR}/downloads/gdb-${GDB_VERSION}/configure" \
    442                 "--target=${TARGET}" \
    443                 "--prefix=${PREFIX}" \
    444                 "--program-prefix=${TARGET}-" \
    445                 --enable-werror=no
    446         check_error $? "Error configuring GDB."
    447 
    448         change_title "GDB: make (${PLATFORM})"
    449         PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gdb -j$JOBS
    450         check_error $? "Error compiling GDB."
    451 
    452         change_title "GDB: make (${PLATFORM})"
    453         PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gdb "DESTDIR=${INSTALL_DIR}"
    454         check_error $? "Error installing GDB."
    455 
     437        BUILDPATH="${CROSS_PREFIX}/bin:${PATH}"
     438
     439        change_title "libgcc: make (${TARGET})"
     440
     441        PATH="${BUILDPATH}" make all-target-libgcc -j$JOBS
     442        check_error $? "Error compiling libgcc."
     443        # TODO: libatomic and libstdc++ need some extra care
     444        #    PATH="${BUILDPATH}" make all-target-libatomic -j$JOBS
     445        #    check_error $? "Error compiling libatomic."
     446        #    PATH="${BUILDPATH}" make all-target-libstdc++-v3 -j$JOBS
     447        #    check_error $? "Error compiling libstdc++."
     448
     449        change_title "libgcc: install (${TARGET})"
     450
     451        PATH="${BUILDPATH}" make install-target-libgcc $DESTDIR_SPEC
     452        #    PATH="${BUILDPATH}" make install-target-libatomic $DESTDIR_SPEC
     453        #    PATH="${BUILDPATH}" make install-target-libstdc++-v3 $DESTDIR_SPEC
     454        check_error $? "Error installing libgcc."
     455}
     456
     457install_pkg() {
     458        echo ">>> Moving to the destination directory."
     459        if $SYSTEM_INSTALL ; then
     460                ring_bell
     461                ( set -x ; tar -C "${INSTALL_DIR}${CROSS_PREFIX}" -cpf - . | sudo -k tar -C "${CROSS_PREFIX}" -xpf - )
     462        else
     463                ( set -x ; tar -C "${INSTALL_DIR}${CROSS_PREFIX}" -cpf - . | tar -C "${CROSS_PREFIX}" -xpf - )
     464        fi
     465}
     466
     467link_clang() {
    456468        # Symlink clang and lld to the install path.
    457469        CLANG="`which clang 2> /dev/null || echo "/usr/bin/clang"`"
     470        CLANGPP="`which clang++ 2> /dev/null || echo "/usr/bin/clang++"`"
    458471        LLD="`which ld.lld 2> /dev/null || echo "/usr/bin/ld.lld"`"
    459472
    460         ln -s $CLANG "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-clang"
    461         ln -s $LLD "${INSTALL_DIR}/${PREFIX}/bin/${TARGET}-ld.lld"
    462 
    463         if $REAL_INSTALL ; then
    464                 echo ">>> Moving to the destination directory."
    465                 echo cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
    466                 cp -r -t "${PREFIX}" "${INSTALL_DIR}/${PREFIX}/"*
    467         fi
    468 
    469         cd "${BASEDIR}"
    470         check_error $? "Change directory failed."
    471 
    472         echo ">>> Cleaning up"
    473         cleanup_dir "${WORKDIR}"
    474 
    475         echo
    476         echo ">>> Cross-compiler for ${TARGET} installed."
     473        ln -s $CLANG "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-clang"
     474        ln -s $CLANGPP "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-clang++"
     475        ln -s $LLD "${INSTALL_DIR}${CROSS_PREFIX}/bin/${TARGET}-ld.lld"
    477476}
    478477
    479478while [ "$#" -gt 1 ] ; do
    480479        case "$1" in
     480                --system-wide)
     481                        SYSTEM_INSTALL=true
     482                        shift
     483                        ;;
    481484                --test-version)
    482485                        test_version "$2"
    483486                        exit
    484487                        ;;
    485                 --no-install)
    486                         REAL_INSTALL=false
    487                         shift
    488                         ;;
    489                 --non-helenos-target)
    490                         USE_HELENOS_TARGET=false
    491                         shift
    492                         ;;
    493488                *)
    494489                        show_usage
     
    501496fi
    502497
     498PLATFORMS="amd64 arm32 arm64 ia32 ia64 mips32 mips32eb ppc32 riscv64 sparc64"
     499
     500run_one() {
     501        $1 $PLATFORM
     502}
     503
     504run_all() {
     505        for x in $PLATFORMS ; do
     506                $1 $x
     507        done
     508}
     509
     510run_parallel() {
     511        for x in $PLATFORMS ; do
     512                $1 $x &
     513        done
     514        wait
     515}
     516
     517run_2way() {
     518        $1 amd64 &
     519        $1 arm32 &
     520        wait
     521
     522        $1 arm64 &
     523        $1 ia32 &
     524        wait
     525
     526        $1 ia64 &
     527        $1 mips32 &
     528        wait
     529
     530        $1 mips32eb &
     531        $1 ppc32 &
     532        wait
     533
     534        $1 riscv64 &
     535        $1 sparc64 &
     536        wait
     537}
     538
     539everything() {
     540        RUNNER="$1"
     541
     542        prepare
     543
     544        if $BUILD_BINUTILS ; then
     545                $RUNNER build_binutils
     546
     547                if $BUILD_GCC ; then
     548                        # gcc/libgcc may fail to build correctly if binutils is not installed first
     549                        echo ">>> Installing binutils"
     550                        install_pkg
     551                fi
     552        fi
     553
     554        if $BUILD_GCC ; then
     555                $RUNNER build_gcc
     556
     557                # libgcc may fail to build correctly if gcc is not installed first
     558                echo ">>> Installing GCC"
     559                install_pkg
     560
     561                $RUNNER build_libgcc
     562        fi
     563
     564        echo ">>> Installing all files"
     565        install_pkg
     566
     567        link_clang
     568}
     569
    503570case "$1" in
    504571        --test-version)
    505572                test_version
     573                exit
    506574                ;;
    507575        amd64|arm32|arm64|ia32|ia64|mips32|mips32eb|ppc32|riscv64|sparc64)
    508                 prepare
    509                 build_target "$1"
     576                PLATFORM="$1"
     577                everything run_one
    510578                ;;
    511579        "all")
    512                 prepare
    513                 build_target "amd64"
    514                 build_target "arm32"
    515                 build_target "arm64"
    516                 build_target "ia32"
    517                 build_target "ia64"
    518                 build_target "mips32"
    519                 build_target "mips32eb"
    520                 build_target "ppc32"
    521                 build_target "riscv64"
    522                 build_target "sparc64"
    523                 ;;
    524         "essential")
    525                 prepare
    526                 build_target "amd64"
    527                 build_target "arm32"
    528                 build_target "arm64"
    529                 build_target "ia32"
    530                 build_target "ia64"
    531                 build_target "mips32"
    532                 build_target "mips32eb"
    533                 build_target "ppc32"
    534                 build_target "sparc64"
     580                everything run_all
    535581                ;;
    536582        "parallel")
    537                 prepare
    538                 build_target "amd64" &
    539                 build_target "arm32" &
    540                 build_target "arm64" &
    541                 build_target "ia32" &
    542                 build_target "ia64" &
    543                 build_target "mips32" &
    544                 build_target "mips32eb" &
    545                 build_target "ppc32" &
    546                 build_target "riscv64" &
    547                 build_target "sparc64" &
    548                 wait
     583                everything run_parallel
    549584                ;;
    550585        "2-way")
    551                 prepare
    552                 build_target "amd64" &
    553                 build_target "arm32" &
    554                 wait
    555 
    556                 build_target "arm64" &
    557                 build_target "ia32" &
    558                 wait
    559 
    560                 build_target "ia64" &
    561                 build_target "mips32" &
    562                 wait
    563 
    564                 build_target "mips32eb" &
    565                 build_target "ppc32" &
    566                 wait
    567 
    568                 build_target "riscv64" &
    569                 build_target "sparc64" &
    570                 wait
     586                everything run_2way
    571587                ;;
    572588        *)
Note: See TracChangeset for help on using the changeset viewer.