chenyaxing 5 лет назад
Родитель
Сommit
7b9f49877a
100 измененных файлов с 13703 добавлено и 0 удалено
  1. 99 0
      README.md
  2. 1 0
      bin/libcrypt.so.1
  3. BIN
      bin/libcrypt.so.1.1.0
  4. BIN
      bin/libcrypto.so.1.0.0
  5. 1 0
      bin/libexpat.so.1
  6. BIN
      bin/libexpat.so.1.6.7
  7. BIN
      bin/libgcc_s.so.1
  8. 1 0
      bin/libgmp.so.10
  9. BIN
      bin/libgmp.so.10.3.2
  10. 1 0
      bin/libgpm.so.2
  11. BIN
      bin/libgpm.so.2.1.0
  12. 1 0
      bin/libiconv.so.2
  13. BIN
      bin/libiconv.so.2.6.0
  14. 1 0
      bin/liblzma.so.5
  15. BIN
      bin/liblzma.so.5.2.3
  16. 1 0
      bin/libmpfr.so.4
  17. BIN
      bin/libmpfr.so.4.1.6
  18. 1 0
      bin/libncurses.so.6
  19. BIN
      bin/libncurses.so.6.2
  20. BIN
      bin/libpython2.7.so.1.0
  21. BIN
      bin/libpython3.7m.so.1.0
  22. BIN
      bin/libssl.so.1.0.0
  23. 1 0
      bin/libz.so.1
  24. BIN
      bin/libz.so.1.2.8
  25. BIN
      bin/riscv64-unknown-elf-addr2line
  26. BIN
      bin/riscv64-unknown-elf-ar
  27. BIN
      bin/riscv64-unknown-elf-as
  28. BIN
      bin/riscv64-unknown-elf-c++
  29. BIN
      bin/riscv64-unknown-elf-c++filt
  30. BIN
      bin/riscv64-unknown-elf-cpp
  31. BIN
      bin/riscv64-unknown-elf-elfedit
  32. BIN
      bin/riscv64-unknown-elf-g++
  33. BIN
      bin/riscv64-unknown-elf-gcc
  34. BIN
      bin/riscv64-unknown-elf-gcc-8.3.0
  35. BIN
      bin/riscv64-unknown-elf-gcc-ar
  36. BIN
      bin/riscv64-unknown-elf-gcc-nm
  37. BIN
      bin/riscv64-unknown-elf-gcc-ranlib
  38. BIN
      bin/riscv64-unknown-elf-gcov
  39. BIN
      bin/riscv64-unknown-elf-gcov-dump
  40. BIN
      bin/riscv64-unknown-elf-gcov-tool
  41. BIN
      bin/riscv64-unknown-elf-gdb
  42. 116 0
      bin/riscv64-unknown-elf-gdb-add-index
  43. 116 0
      bin/riscv64-unknown-elf-gdb-add-index-py
  44. 116 0
      bin/riscv64-unknown-elf-gdb-add-index-py3
  45. BIN
      bin/riscv64-unknown-elf-gdb-py
  46. BIN
      bin/riscv64-unknown-elf-gdb-py3
  47. BIN
      bin/riscv64-unknown-elf-gprof
  48. BIN
      bin/riscv64-unknown-elf-ld
  49. BIN
      bin/riscv64-unknown-elf-ld.bfd
  50. BIN
      bin/riscv64-unknown-elf-nm
  51. BIN
      bin/riscv64-unknown-elf-objcopy
  52. BIN
      bin/riscv64-unknown-elf-objdump
  53. BIN
      bin/riscv64-unknown-elf-ranlib
  54. BIN
      bin/riscv64-unknown-elf-readelf
  55. BIN
      bin/riscv64-unknown-elf-size
  56. BIN
      bin/riscv64-unknown-elf-strings
  57. BIN
      bin/riscv64-unknown-elf-strip
  58. 112 0
      distro-info/CHANGELOG.md
  59. 10 0
      distro-info/patches/binutils-gdb-2.29.patch
  60. 10 0
      distro-info/patches/binutils-gdb-2.30.patch
  61. 181 0
      distro-info/patches/binutils-gdb-2.32.patch
  62. 680 0
      distro-info/patches/pyconfig-3.7.2.h
  63. 680 0
      distro-info/patches/pyconfig-3.7.6.h
  64. 11 0
      distro-info/patches/python-2.7.13.amd64.patch
  65. 11 0
      distro-info/patches/python-2.7.13.patch
  66. 67 0
      distro-info/patches/python3-config.sh
  67. 100 0
      distro-info/scripts/README-8.2.0-3.1.md
  68. 100 0
      distro-info/scripts/README-8.3.0-1.1.md
  69. 99 0
      distro-info/scripts/README-8.3.0-1.2.md
  70. 1 0
      distro-info/scripts/VERSION
  71. 270 0
      distro-info/scripts/build.sh
  72. 118 0
      distro-info/scripts/common-functions-source.sh
  73. 484 0
      distro-info/scripts/common-versions-source.sh
  74. 1654 0
      distro-info/scripts/container-apps-functions-source.sh
  75. 251 0
      distro-info/scripts/container-build.sh
  76. 14 0
      distro-info/scripts/container-libs-functions-source.sh
  77. 43 0
      distro-info/scripts/defs-source.sh
  78. 3 0
      distro-info/scripts/git-clone-develop.sh
  79. 3 0
      distro-info/scripts/git-clone.sh
  80. 21 0
      distro-info/scripts/helper/LICENSE
  81. 75 0
      distro-info/scripts/helper/README.md
  82. 2508 0
      distro-info/scripts/helper/common-functions-source.sh
  83. 2030 0
      distro-info/scripts/helper/common-libs-functions-source.sh
  84. 175 0
      distro-info/scripts/helper/container-functions-source.sh
  85. 1159 0
      distro-info/scripts/helper/host-functions-source.sh
  86. 77 0
      distro-info/scripts/helper/templates.sh
  87. 1100 0
      distro-info/scripts/helper/test-functions-source.sh
  88. 17 0
      distro-info/scripts/host-defs-source.sh
  89. 70 0
      distro-info/scripts/python-win-config.sh
  90. 346 0
      include/gdb/jit-reader.h
  91. 1 0
      lib/bfd-plugins/liblto_plugin.so
  92. BIN
      lib/gcc/riscv-none-embed/8.3.0/crtbegin.o
  93. BIN
      lib/gcc/riscv-none-embed/8.3.0/crtend.o
  94. BIN
      lib/gcc/riscv-none-embed/8.3.0/crti.o
  95. BIN
      lib/gcc/riscv-none-embed/8.3.0/crtn.o
  96. 14 0
      lib/gcc/riscv-none-embed/8.3.0/include-fixed/README
  97. 197 0
      lib/gcc/riscv-none-embed/8.3.0/include-fixed/limits.h
  98. 8 0
      lib/gcc/riscv-none-embed/8.3.0/include-fixed/syslimits.h
  99. 506 0
      lib/gcc/riscv-none-embed/8.3.0/include/float.h
  100. 41 0
      lib/gcc/riscv-none-embed/8.3.0/include/gcov.h

+ 99 - 0
README.md

@@ -0,0 +1,99 @@
+# xPack GNU RISC-V Embedded GCC
+
+This is the **xPack** version of the
+**GNU RISC-V Embedded GCC** toolchain.
+
+For details, see
+[The xPack GNU RISC-V Embedded GCC](https://xpack.github.io/riscv-none-embed-gcc/) pages.
+
+## Easy install
+
+The **xPack RISC-V Embedded GCC** toolchain is also available as a
+binary [xPack](https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-embed-gcc)
+and can be conveniently installed with [xpm](https://www.npmjs.com/package/xpm):
+
+```console
+$ xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@8.3.0-1.2.1
+```
+
+For more details on how to install the toolchain, please see
+[How to install the RISC-V toolchain?](http://xpack.github.io/toolchain/riscv-bone-embed-gcc/install/) page.
+
+## Compliance
+
+Starting with 8.2.0-2, the xPack GNU RISC-V Embedded GCC (formerly
+GNU MCU Eclipse RISC-V GCC) follows
+the official [SiFive releases](https://github.com/sifive/freedom-tools/releases),
+with as little differences as possible.
+
+This release is based on the
+[v2019.08.0](https://github.com/sifive/freedom-tools/releases/tag/v2019.08.0)
+release, and includes the SiFive extensions (like CLIC interrupts).
+
+The following commits (from [sifive/freedom-tools](https://github.com/sifive/freedom-tools/tree/master/src)) were used:
+
+- the [sifive/riscv-binutils-gdb](https://github.com/sifive/riscv-binutils-gdb)
+project, branch `sifive-binutils-2.32`, commit
+[03d23d5](https://github.com/sifive/riscv-binutils-gdb/tree/03d23d58701bdd425c613b0be2d458bcde46912b)
+from 2 September 2019
+- the [sifive/riscv-gcc](https://github.com/sifive/riscv-gcc) project,
+branch `sifive-gcc-8.3.0`, commit
+[e195042](https://github.com/sifive/riscv-gcc/tree/e195042babe2dc30d9fabb88d336d8c8679b3702)
+from from 7 Aug 2019
+- the [sifive/riscv-newlib](https://github.com/sifive/riscv-newlib) project, the `master` branch,
+commit [0d24a86](https://github.com/sifive/riscv-newlib/tree/0d24a86822a5ee73d6a6aa69e2a0118aa1e35204)
+from 9 July 2019
+
+GDB was upstreamed and does not require SiFive specific patches,
+so the current build uses
+`git://sourceware.org/git/binutils-gdb.git`, the `9b40759` commit from
+28 Feb 2019.
+
+## Changes
+
+Compared to the original SiFive version, the **same architecture and API**
+options are supported, and there are minimal functional changes
+
+- `libgloss` was removed from the list of libraires always linked to the
+  application, since it issues `ECALL`
+  instructions that fail in bare metal environments
+- `march=rv32imaf/mabi=ilp32f` was added to the list of multilibs
+
+## newlib-nano
+
+Support for **newlib-nano** is available using the
+`--specs=nano.specs` option. For better results, this option must be
+added to both compile and link time.
+
+## nosys.specs
+
+If no syscalls are needed, `--specs=nosys.specs` can be used at link
+time to provide empty implementations for the POSIX system calls.
+
+## Compile options
+
+The libraries are compiled with `-O2 -mcmodel=medany`. The nano version is
+compiled with `-Os -mcmodel=medany`.
+
+> Important: It is mandatory for the applications to be compiled with
+`-mcmodel=medany`, otherwise the link will fail.
+
+## Documentation
+
+The original PDF documentation is available in the `share/doc` folder.
+
+## Support
+
+For support, please read the
+[support](https://xpack.github.io/riscv-none-embed-gcc/support/) page.
+
+## More info
+
+For more info, please see the xPack project site:
+
+  http://xpack.github.io/riscv-none-embed-gcc
+
+
+Thank you for using open source software,
+
+Liviu Ionescu

+ 1 - 0
bin/libcrypt.so.1

@@ -0,0 +1 @@
+libcrypt.so.1.1.0

BIN
bin/libcrypt.so.1.1.0


BIN
bin/libcrypto.so.1.0.0


+ 1 - 0
bin/libexpat.so.1

@@ -0,0 +1 @@
+libexpat.so.1.6.7

BIN
bin/libexpat.so.1.6.7


BIN
bin/libgcc_s.so.1


+ 1 - 0
bin/libgmp.so.10

@@ -0,0 +1 @@
+libgmp.so.10.3.2

BIN
bin/libgmp.so.10.3.2


+ 1 - 0
bin/libgpm.so.2

@@ -0,0 +1 @@
+libgpm.so.2.1.0

BIN
bin/libgpm.so.2.1.0


+ 1 - 0
bin/libiconv.so.2

@@ -0,0 +1 @@
+libiconv.so.2.6.0

BIN
bin/libiconv.so.2.6.0


+ 1 - 0
bin/liblzma.so.5

@@ -0,0 +1 @@
+liblzma.so.5.2.3

BIN
bin/liblzma.so.5.2.3


+ 1 - 0
bin/libmpfr.so.4

@@ -0,0 +1 @@
+libmpfr.so.4.1.6

BIN
bin/libmpfr.so.4.1.6


+ 1 - 0
bin/libncurses.so.6

@@ -0,0 +1 @@
+libncurses.so.6.2

BIN
bin/libncurses.so.6.2


BIN
bin/libpython2.7.so.1.0


BIN
bin/libpython3.7m.so.1.0


BIN
bin/libssl.so.1.0.0


+ 1 - 0
bin/libz.so.1

@@ -0,0 +1 @@
+libz.so.1.2.8

BIN
bin/libz.so.1.2.8


BIN
bin/riscv64-unknown-elf-addr2line


BIN
bin/riscv64-unknown-elf-ar


BIN
bin/riscv64-unknown-elf-as


BIN
bin/riscv64-unknown-elf-c++


BIN
bin/riscv64-unknown-elf-c++filt


BIN
bin/riscv64-unknown-elf-cpp


BIN
bin/riscv64-unknown-elf-elfedit


BIN
bin/riscv64-unknown-elf-g++


BIN
bin/riscv64-unknown-elf-gcc


BIN
bin/riscv64-unknown-elf-gcc-8.3.0


BIN
bin/riscv64-unknown-elf-gcc-ar


BIN
bin/riscv64-unknown-elf-gcc-nm


BIN
bin/riscv64-unknown-elf-gcc-ranlib


BIN
bin/riscv64-unknown-elf-gcov


BIN
bin/riscv64-unknown-elf-gcov-dump


BIN
bin/riscv64-unknown-elf-gcov-tool


BIN
bin/riscv64-unknown-elf-gdb


+ 116 - 0
bin/riscv64-unknown-elf-gdb-add-index

@@ -0,0 +1,116 @@
+#! /bin/sh
+
+# Add a .gdb_index section to a file.
+
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This program assumes gdb and objcopy are in $PATH.
+# If not, or you want others, pass the following in the environment
+GDB=${GDB:=gdb}
+OBJCOPY=${OBJCOPY:=objcopy}
+
+myname="${0##*/}"
+
+dwarf5=""
+if [ "$1" = "-dwarf-5" ]; then
+    dwarf5="$1"
+    shift
+fi
+
+if test $# != 1; then
+    echo "usage: $myname [-dwarf-5] FILE" 1>&2
+    exit 1
+fi
+
+file="$1"
+
+if test ! -r "$file"; then
+    echo "$myname: unable to access: $file" 1>&2
+    exit 1
+fi
+
+dir="${file%/*}"
+test "$dir" = "$file" && dir="."
+index4="${file}.gdb-index"
+index5="${file}.debug_names"
+debugstr="${file}.debug_str"
+debugstrmerge="${file}.debug_str.merge"
+debugstrerr="${file}.debug_str.err"
+
+rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
+# Ensure intermediate index file is removed when we exit.
+trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
+
+$GDB --batch -nx -iex 'set auto-load no' \
+    -ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
+    # Just in case.
+    status=$?
+    echo "$myname: gdb error generating index for $file" 1>&2
+    exit $status
+}
+
+# In some situations gdb can exit without creating an index.  This is
+# not an error.
+# E.g., if $file is stripped.  This behaviour is akin to stripping an
+# already stripped binary, it's a no-op.
+status=0
+
+if test -f "$index4" -a -f "$index5"; then
+    echo "$myname: Both index types were created for $file" 1>&2
+    status=1
+elif test -f "$index4" -o -f "$index5"; then
+    if test -f "$index4"; then
+	index="$index4"
+	section=".gdb_index"
+    else
+	index="$index5"
+	section=".debug_names"
+    fi
+    debugstradd=false
+    debugstrupdate=false
+    if test -s "$debugstr"; then
+	if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" /dev/null \
+		 2>$debugstrerr; then
+	    cat >&2 $debugstrerr
+	    exit 1
+	fi
+	if grep -q "can't dump section '.debug_str' - it does not exist" \
+		  $debugstrerr; then
+	    debugstradd=true
+	else
+	    debugstrupdate=true
+	    cat >&2 $debugstrerr
+	fi
+	cat "$debugstr" >>"$debugstrmerge"
+    fi
+
+    $OBJCOPY --add-section $section="$index" \
+	--set-section-flags $section=readonly \
+	$(if $debugstradd; then \
+	      echo --add-section .debug_str="$debugstrmerge"; \
+	      echo --set-section-flags .debug_str=readonly; \
+	  fi; \
+	  if $debugstrupdate; then \
+	      echo --update-section .debug_str="$debugstrmerge"; \
+	  fi) \
+	"$file" "$file"
+
+    status=$?
+else
+    echo "$myname: No index was created for $file" 1>&2
+    echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2
+fi
+
+exit $status

+ 116 - 0
bin/riscv64-unknown-elf-gdb-add-index-py

@@ -0,0 +1,116 @@
+#! /bin/sh
+
+# Add a .gdb_index section to a file.
+
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This program assumes gdb and objcopy are in $PATH.
+# If not, or you want others, pass the following in the environment
+GDB=${GDB:=gdb}
+OBJCOPY=${OBJCOPY:=objcopy}
+
+myname="${0##*/}"
+
+dwarf5=""
+if [ "$1" = "-dwarf-5" ]; then
+    dwarf5="$1"
+    shift
+fi
+
+if test $# != 1; then
+    echo "usage: $myname [-dwarf-5] FILE" 1>&2
+    exit 1
+fi
+
+file="$1"
+
+if test ! -r "$file"; then
+    echo "$myname: unable to access: $file" 1>&2
+    exit 1
+fi
+
+dir="${file%/*}"
+test "$dir" = "$file" && dir="."
+index4="${file}.gdb-index"
+index5="${file}.debug_names"
+debugstr="${file}.debug_str"
+debugstrmerge="${file}.debug_str.merge"
+debugstrerr="${file}.debug_str.err"
+
+rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
+# Ensure intermediate index file is removed when we exit.
+trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
+
+$GDB --batch -nx -iex 'set auto-load no' \
+    -ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
+    # Just in case.
+    status=$?
+    echo "$myname: gdb error generating index for $file" 1>&2
+    exit $status
+}
+
+# In some situations gdb can exit without creating an index.  This is
+# not an error.
+# E.g., if $file is stripped.  This behaviour is akin to stripping an
+# already stripped binary, it's a no-op.
+status=0
+
+if test -f "$index4" -a -f "$index5"; then
+    echo "$myname: Both index types were created for $file" 1>&2
+    status=1
+elif test -f "$index4" -o -f "$index5"; then
+    if test -f "$index4"; then
+	index="$index4"
+	section=".gdb_index"
+    else
+	index="$index5"
+	section=".debug_names"
+    fi
+    debugstradd=false
+    debugstrupdate=false
+    if test -s "$debugstr"; then
+	if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" /dev/null \
+		 2>$debugstrerr; then
+	    cat >&2 $debugstrerr
+	    exit 1
+	fi
+	if grep -q "can't dump section '.debug_str' - it does not exist" \
+		  $debugstrerr; then
+	    debugstradd=true
+	else
+	    debugstrupdate=true
+	    cat >&2 $debugstrerr
+	fi
+	cat "$debugstr" >>"$debugstrmerge"
+    fi
+
+    $OBJCOPY --add-section $section="$index" \
+	--set-section-flags $section=readonly \
+	$(if $debugstradd; then \
+	      echo --add-section .debug_str="$debugstrmerge"; \
+	      echo --set-section-flags .debug_str=readonly; \
+	  fi; \
+	  if $debugstrupdate; then \
+	      echo --update-section .debug_str="$debugstrmerge"; \
+	  fi) \
+	"$file" "$file"
+
+    status=$?
+else
+    echo "$myname: No index was created for $file" 1>&2
+    echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2
+fi
+
+exit $status

+ 116 - 0
bin/riscv64-unknown-elf-gdb-add-index-py3

@@ -0,0 +1,116 @@
+#! /bin/sh
+
+# Add a .gdb_index section to a file.
+
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This program assumes gdb and objcopy are in $PATH.
+# If not, or you want others, pass the following in the environment
+GDB=${GDB:=gdb}
+OBJCOPY=${OBJCOPY:=objcopy}
+
+myname="${0##*/}"
+
+dwarf5=""
+if [ "$1" = "-dwarf-5" ]; then
+    dwarf5="$1"
+    shift
+fi
+
+if test $# != 1; then
+    echo "usage: $myname [-dwarf-5] FILE" 1>&2
+    exit 1
+fi
+
+file="$1"
+
+if test ! -r "$file"; then
+    echo "$myname: unable to access: $file" 1>&2
+    exit 1
+fi
+
+dir="${file%/*}"
+test "$dir" = "$file" && dir="."
+index4="${file}.gdb-index"
+index5="${file}.debug_names"
+debugstr="${file}.debug_str"
+debugstrmerge="${file}.debug_str.merge"
+debugstrerr="${file}.debug_str.err"
+
+rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr
+# Ensure intermediate index file is removed when we exit.
+trap "rm -f $index4 $index5 $debugstr $debugstrmerge $debugstrerr" 0
+
+$GDB --batch -nx -iex 'set auto-load no' \
+    -ex "file $file" -ex "save gdb-index $dwarf5 $dir" || {
+    # Just in case.
+    status=$?
+    echo "$myname: gdb error generating index for $file" 1>&2
+    exit $status
+}
+
+# In some situations gdb can exit without creating an index.  This is
+# not an error.
+# E.g., if $file is stripped.  This behaviour is akin to stripping an
+# already stripped binary, it's a no-op.
+status=0
+
+if test -f "$index4" -a -f "$index5"; then
+    echo "$myname: Both index types were created for $file" 1>&2
+    status=1
+elif test -f "$index4" -o -f "$index5"; then
+    if test -f "$index4"; then
+	index="$index4"
+	section=".gdb_index"
+    else
+	index="$index5"
+	section=".debug_names"
+    fi
+    debugstradd=false
+    debugstrupdate=false
+    if test -s "$debugstr"; then
+	if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" /dev/null \
+		 2>$debugstrerr; then
+	    cat >&2 $debugstrerr
+	    exit 1
+	fi
+	if grep -q "can't dump section '.debug_str' - it does not exist" \
+		  $debugstrerr; then
+	    debugstradd=true
+	else
+	    debugstrupdate=true
+	    cat >&2 $debugstrerr
+	fi
+	cat "$debugstr" >>"$debugstrmerge"
+    fi
+
+    $OBJCOPY --add-section $section="$index" \
+	--set-section-flags $section=readonly \
+	$(if $debugstradd; then \
+	      echo --add-section .debug_str="$debugstrmerge"; \
+	      echo --set-section-flags .debug_str=readonly; \
+	  fi; \
+	  if $debugstrupdate; then \
+	      echo --update-section .debug_str="$debugstrmerge"; \
+	  fi) \
+	"$file" "$file"
+
+    status=$?
+else
+    echo "$myname: No index was created for $file" 1>&2
+    echo "$myname: [Was there no debuginfo? Was there already an index?]" 1>&2
+fi
+
+exit $status

BIN
bin/riscv64-unknown-elf-gdb-py


BIN
bin/riscv64-unknown-elf-gdb-py3


BIN
bin/riscv64-unknown-elf-gprof


BIN
bin/riscv64-unknown-elf-ld


BIN
bin/riscv64-unknown-elf-ld.bfd


BIN
bin/riscv64-unknown-elf-nm


BIN
bin/riscv64-unknown-elf-objcopy


BIN
bin/riscv64-unknown-elf-objdump


BIN
bin/riscv64-unknown-elf-ranlib


BIN
bin/riscv64-unknown-elf-readelf


BIN
bin/riscv64-unknown-elf-size


BIN
bin/riscv64-unknown-elf-strings


BIN
bin/riscv64-unknown-elf-strip


+ 112 - 0
distro-info/CHANGELOG.md

@@ -0,0 +1,112 @@
+
+## Change & release log
+
+Releases in reverse chronological order.
+
+### 2020-07-04
+
+- v8.3.0-1.2 released
+
+### 2019-11-01
+
+- v8.3.0-1.1.1 published on npmjs.com
+- v8.3.0-1.1 released
+
+### 2019-10-30
+
+- v8.3.0-1.1 prepared
+- update to follow SiFive 2019.08.0 release
+
+### 2019-07-31
+
+- v8.2.0-3.1.1 published on npmjs.com
+- v8.2.0-3.1 released
+- update to follow SiFive May 2019.05.0 release
+
+___
+
+## Historical GNU MCU Eclipse change log
+
+### 2019-05-22
+
+- v8.2.0-2.2 released
+- fix GDB build on macOS (use clang)
+- add compiler tests
+- add gdb set language tests
+
+### 2019-04-25
+
+- v8.2.0-2.1 released
+
+### 2019-04-17
+
+- prepare v8.2.0-2 (8.2.0-1 was skipped)
+- update to the latest SiFive commits
+  - `sifive-binutils-2.32`
+  - `sifive-gcc-8.2.0`
+  - `sifive-newlib-3.0.0`
+- for GDB use the FSF c8aa0bb (28 Feb 2019)
+- update for XBB v2.1; no need for static, libs are ok.
+- the defaults were changed to rv32imac/ilp32
+
+### 2018-10-19
+
+- v8.1.0-2-20181019 released
+
+### 2018-10-18
+
+- prepare v8.1.0-2-*
+- update to latest SiFive commits from the following branches:
+  - riscv-binutils-2.30
+  - riscv-gcc-8.1.0
+  - riscv-newlib-3.0.0
+- allow GDB to be built from a separate repo/commit
+
+### 2018-06-06
+
+- v7.2.0-4-20180606 released
+- add -mcmodel=medany, lost during updates
+
+### 2018-05-06
+
+- v7.2.0-3-20180506 released
+- update to latest SiFive commits from the following branches:
+  - riscv-binutils-2.29
+  - riscv-gcc-7.2.0
+  - riscv-newlib-2.5.0
+
+### 2018-05-04
+
+- update the build scripts to follow the ARM XBB structure
+
+### 2018-01-10
+
+- v7.2.0-2-20180110 released
+- update to latest SiFive commits from 2018-01-10
+- dismiss the `data-list-register-names` patch, no longer needed
+
+### 2017-11-09
+
+- v7.2.0-1-20171109 released
+- update to latest SiFive 2017-11-07 released, except newlib, where the
+reference was too old, and a recent commit was used
+- in GDB, the list of registers returned by `data-list-register-names`
+no longer include the 4096 CSRs
+- the tuple was renamed to `riscv-none-embed-`
+
+### 2017-09-12
+
+- v7.1.1-2-20170912 released
+- add multilib support for rv32imaf/ilp32f
+- remove mandatory link of libgloss
+
+### 2017-07-02
+
+- v7.1.1-1-20170702-0625 released
+
+### 2017-06-27
+
+- add support for `--specs=nano.specs`; this translates into a separate
+build for `newlib` with specific configuration options and a separate
+build of the C++ standard libraries with `-Os`.
+

+ 10 - 0
distro-info/patches/binutils-gdb-2.29.patch

@@ -0,0 +1,10 @@
+--- readline/Makefile.in	2015-07-26 16:07:10.000000000 +0000
++++ readline/Makefile-patched.in	2019-07-10 22:17:57.012131564 +0000
+@@ -222,6 +222,7 @@
+ ## so it doesn't depend on us installing it on the system.
+ 
+ install:
++install-strip:
+ 
+ #install:	$(INSTALL_TARGETS)
+ 

+ 10 - 0
distro-info/patches/binutils-gdb-2.30.patch

@@ -0,0 +1,10 @@
+--- readline/Makefile.in	2018-10-17 21:44:52.000000000 +0300
++++ readline/Makefile-patched.in	2019-04-13 23:47:54.000000000 +0300
+@@ -219,6 +219,7 @@
+ ## readline along with GDB. GDB links statically against readline,
+ ## so it doesn't depend on us installing it on the system.
+ 
++install-strip:
+ install:
+ 
+ #install:	$(INSTALL_TARGETS)

+ 181 - 0
distro-info/patches/binutils-gdb-2.32.patch

@@ -0,0 +1,181 @@
+--- readline/Makefile.in	2019-04-16 20:10:40.000000000 +0300
++++ readline/Makefile-patched.in	2019-04-16 20:20:11.000000000 +0300
+@@ -219,6 +219,7 @@
+ ## readline along with GDB. GDB links statically against readline,
+ ## so it doesn't depend on us installing it on the system.
+ 
++install-strip:
+ install:
+ 
+ #install:	$(INSTALL_TARGETS)
+--- gdb/configure	2020-06-14 20:40:38.430076716 +0300
++++ gdb/configure-patched	2020-06-14 20:40:29.175000000 +0300
+@@ -9039,7 +9039,7 @@
+     ac_res=-l$ac_lib
+     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+   fi
+-  if ac_fn_c_try_link "$LINENO"; then :
++  if ac_fn_c_try_run "$LINENO"; then :
+   ac_cv_search_tgetent=$ac_res
+ fi
+ rm -f core conftest.err conftest.$ac_objext \
+diff --git bfd/Makefile.am bfd/Makefile.am
+index a9191555..e0c24d5e 100644
+--- bfd/Makefile.am
++++ bfd/Makefile.am
+@@ -965,7 +965,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
+ 	fi ;\
+ 	$(SED) -e "s,@bfd_version@,$$bfd_version," \
+ 	    -e "s,@bfd_version_string@,$$bfd_version_string," \
+-	    -e "s,@bfd_version_package@,$$bfd_version_package," \
++	    -e "s|@bfd_version_package@|$$bfd_version_package|" \
+ 	    -e "s,@report_bugs_to@,$$report_bugs_to," \
+ 	    < $(srcdir)/version.h > $@; \
+ 	echo "$${bfd_soversion}" > libtool-soversion
+diff --git bfd/Makefile.in bfd/Makefile.in
+index 896df520..8e184d3e 100644
+--- bfd/Makefile.in
++++ bfd/Makefile.in
+@@ -2080,7 +2080,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
+ 	fi ;\
+ 	$(SED) -e "s,@bfd_version@,$$bfd_version," \
+ 	    -e "s,@bfd_version_string@,$$bfd_version_string," \
+-	    -e "s,@bfd_version_package@,$$bfd_version_package," \
++	    -e "s|@bfd_version_package@|$$bfd_version_package|" \
+ 	    -e "s,@report_bugs_to@,$$report_bugs_to," \
+ 	    < $(srcdir)/version.h > $@; \
+ 	echo "$${bfd_soversion}" > libtool-soversion
+diff --git gdb/python/lib/gdb/__init__.py gdb/python/lib/gdb/__init__.py
+index af74df80..afe5b08f 100644
+--- gdb/python/lib/gdb/__init__.py
++++ gdb/python/lib/gdb/__init__.py
+@@ -106,6 +106,32 @@ def execute_unwinders(pending_frame):
+ 
+     return None
+ 
++def _execute_file(filepath):
++    """This function is used to replace Python 2's PyRun_SimpleFile.
++
++    Loads and executes the given file.
++
++    We could use the runpy module, but its documentation says:
++    "Furthermore, any functions and classes defined by the executed code are
++    not guaranteed to work correctly after a runpy function has returned."
++    """
++    globals = sys.modules['__main__'].__dict__
++    set_file = False
++    # Set file (if not set) so that the imported file can use it (e.g. to
++    # access file-relative paths). This matches what PyRun_SimpleFile does.
++    if not hasattr(globals, '__file__'):
++        globals['__file__'] = filepath
++        set_file = True
++    try:
++        with open(filepath, 'rb') as file:
++            # We pass globals also as locals to match what Python does
++            # in PyRun_SimpleFile.
++            compiled = compile(file.read(), filepath, 'exec')
++            exec(compiled, globals, globals)
++    finally:
++        if set_file:
++            del globals['__file__']
++
+ 
+ # Convenience variable to GDB's python directory
+ PYTHONDIR = os.path.dirname(os.path.dirname(__file__))
+diff --git gdb/python/python-config.py gdb/python/python-config.py
+index 3e60b86a..1e04f6cf 100644
+--- gdb/python/python-config.py
++++ gdb/python/python-config.py
+@@ -3,6 +3,7 @@
+ 
+ import sys
+ import os
++import platform
+ import getopt
+ from distutils import sysconfig
+ 
+@@ -45,16 +46,29 @@ def to_unix_path(path):
+ 
+ for opt in opt_flags:
+     if opt == '--prefix':
+-        print (to_unix_path(sysconfig.PREFIX))
++        prefix=os.environ.get('CONFIG_PYTHON_PREFIX')
++        if prefix and prefix.strip():
++            sys.stderr.write ("%s -> [%s]\n" % (opt, prefix.strip()))
++            print (prefix.strip())
++        else:
++            sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(sysconfig.PREFIX)))
++            print (to_unix_path(sysconfig.PREFIX))
+ 
+     elif opt == '--exec-prefix':
+-        print (to_unix_path(sysconfig.EXEC_PREFIX))
++        prefix=os.environ.get('CONFIG_PYTHON_PREFIX')
++        if prefix and prefix.strip():
++            sys.stderr.write ("%s -> [%s]\n" % (opt, prefix.strip()))
++            print (prefix.strip())
++        else:
++            sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(sysconfig.EXEC_PREFIX)))
++            print (to_unix_path(sysconfig.EXEC_PREFIX))
+ 
+     elif opt in ('--includes', '--cflags'):
+         flags = ['-I' + sysconfig.get_python_inc(),
+                  '-I' + sysconfig.get_python_inc(plat_specific=True)]
+         if opt == '--cflags':
+             flags.extend(getvar('CFLAGS').split())
++        sys.stderr.write ("%s -> [%s]\n" % (opt, to_unix_path(' '.join(flags))))
+         print (to_unix_path(' '.join(flags)))
+ 
+     elif opt in ('--libs', '--ldflags'):
+@@ -73,5 +87,7 @@ for opt in opt_flags:
+                     libs.insert(0, '-L' + sysconfig.PREFIX + '/libs')
+             if getvar('LINKFORSHARED') is not None:
+                 libs.extend(getvar('LINKFORSHARED').split())
+-        print (to_unix_path(' '.join(libs)))
++        tmp = to_unix_path(' '.join(libs))
++        sys.stderr.write ("%s -> [%s]\n" % (opt, tmp))
++        print (tmp)
+ 
+diff --git gdb/python/python.c gdb/python/python.c
+index c23db2c1..fe1da107 100644
+--- gdb/python/python.c
++++ gdb/python/python.c
+@@ -323,9 +323,8 @@ python_interactive_command (const char *arg, int from_tty)
+    A FILE * from one runtime does not necessarily operate correctly in
+    the other runtime.
+ 
+-   To work around this potential issue, we create on Windows hosts the
+-   FILE object using Python routines, thus making sure that it is
+-   compatible with the Python library.  */
++   To work around this potential issue, we run code in Python to load
++   the script.  */
+ 
+ static void
+ python_run_simple_file (FILE *file, const char *filename)
+@@ -339,15 +338,21 @@ python_run_simple_file (FILE *file, const char *filename)
+   /* Because we have a string for a filename, and are using Python to
+      open the file, we need to expand any tilde in the path first.  */
+   gdb::unique_xmalloc_ptr<char> full_path (tilde_expand (filename));
+-  gdbpy_ref<> python_file (PyFile_FromString (full_path.get (), (char *) "r"));
+-  if (python_file == NULL)
++
++  if (gdb_python_module == nullptr
++      || ! PyObject_HasAttrString (gdb_python_module, "_execute_file"))
++    error (_("Installation error: gdb._execute_file function is missing"));
++
++  gdbpy_ref<> return_value
++    (PyObject_CallMethod (gdb_python_module, "_execute_file", "s",
++                         full_path.get ()));
++  if (return_value == nullptr)
+     {
+-      gdbpy_print_stack ();
+-      error (_("Error while opening file: %s"), full_path.get ());
++      /* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the
++         behavior of the non-Windows codepath.  */
++      PyErr_PrintEx(0);
+     }
+ 
+-  PyRun_SimpleFile (PyFile_AsFile (python_file.get ()), filename);
+-
+ #endif /* _WIN32 */
+ }
+ 

+ 680 - 0
distro-info/patches/pyconfig-3.7.2.h

@@ -0,0 +1,680 @@
+#ifndef Py_CONFIG_H
+#define Py_CONFIG_H
+
+/* pyconfig.h.  NOT Generated automatically by configure.
+
+This is a manually maintained version used for the Watcom,
+Borland and Microsoft Visual C++ compilers.  It is a
+standard part of the Python distribution.
+
+WINDOWS DEFINES:
+The code specific to Windows should be wrapped around one of
+the following #defines
+
+MS_WIN64 - Code specific to the MS Win64 API
+MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
+MS_WINDOWS - Code specific to Windows, but all versions.
+Py_ENABLE_SHARED - Code if the Python core is built as a DLL.
+
+Also note that neither "_M_IX86" or "_MSC_VER" should be used for
+any purpose other than "Windows Intel x86 specific" and "Microsoft
+compiler specific".  Therefore, these should be very rare.
+
+
+NOTE: The following symbols are deprecated:
+NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
+MS_CORE_DLL.
+
+WIN32 is still required for the locale module.
+
+*/
+
+/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */
+#ifdef USE_DL_EXPORT
+#       define Py_BUILD_CORE
+#endif /* USE_DL_EXPORT */
+
+/* Visual Studio 2005 introduces deprecation warnings for
+   "insecure" and POSIX functions. The insecure functions should
+   be replaced by *_s versions (according to Microsoft); the
+   POSIX functions by _* versions (which, according to Microsoft,
+   would be ISO C conforming). Neither renaming is feasible, so
+   we just silence the warnings. */
+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+#endif
+
+#define HAVE_IO_H
+#define HAVE_SYS_UTIME_H
+#define HAVE_TEMPNAM
+#define HAVE_TMPFILE
+#define HAVE_TMPNAM
+#define HAVE_CLOCK
+#define HAVE_STRERROR
+
+#include <io.h>
+
+#define HAVE_HYPOT
+#define HAVE_STRFTIME
+#define DONT_HAVE_SIG_ALARM
+#define DONT_HAVE_SIG_PAUSE
+#define LONG_BIT        32
+#define WORD_BIT 32
+
+#define MS_WIN32 /* only support win32 and greater. */
+#define MS_WINDOWS
+#ifndef PYTHONPATH
+#       define PYTHONPATH L".\\DLLs;.\\lib"
+#endif
+#define NT_THREADS
+#define WITH_THREAD
+#ifndef NETSCAPE_PI
+#define USE_SOCKET
+#endif
+
+
+/* Compiler specific defines */
+
+/* ------------------------------------------------------------------------*/
+/* Microsoft C defines _MSC_VER */
+#ifdef _MSC_VER
+
+/* We want COMPILER to expand to a string containing _MSC_VER's *value*.
+ * This is horridly tricky, because the stringization operator only works
+ * on macro arguments, and doesn't evaluate macros passed *as* arguments.
+ * Attempts simpler than the following appear doomed to produce "_MSC_VER"
+ * literally in the string.
+ */
+#define _Py_PASTE_VERSION(SUFFIX) \
+        ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]")
+/* e.g., this produces, after compile-time string catenation,
+ *      ("[MSC v.1200 32 bit (Intel)]")
+ *
+ * _Py_STRINGIZE(_MSC_VER) expands to
+ * _Py_STRINGIZE1((_MSC_VER)) expands to
+ * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting
+ *      it's scanned again for macros and so further expands to (under MSVC 6)
+ * _Py_STRINGIZE2(1200) which then expands to
+ * "1200"
+ */
+#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
+#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
+#define _Py_STRINGIZE2(X) #X
+
+/* MSVC defines _WINxx to differentiate the windows platform types
+
+   Note that for compatibility reasons _WIN32 is defined on Win32
+   *and* on Win64. For the same reasons, in Python, MS_WIN32 is
+   defined on Win32 *and* Win64. Win32 only code must therefore be
+   guarded as follows:
+        #if defined(MS_WIN32) && !defined(MS_WIN64)
+*/
+#ifdef _WIN64
+#define MS_WIN64
+#endif
+
+/* set the COMPILER */
+#ifdef MS_WIN64
+#if defined(_M_X64) || defined(_M_AMD64)
+#if defined(__INTEL_COMPILER)
+#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
+#else
+#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
+#endif /* __INTEL_COMPILER */
+#define PYD_PLATFORM_TAG "win_amd64"
+#else
+#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
+#endif
+#endif /* MS_WIN64 */
+
+/* set the version macros for the windows headers */
+/* Python 3.5+ requires Windows Vista or greater */
+#define Py_WINVER 0x0600 /* _WIN32_WINNT_VISTA */
+#define Py_NTDDI NTDDI_VISTA
+
+/* We only set these values when building Python - we don't want to force
+   these values on extensions, as that will affect the prototypes and
+   structures exposed in the Windows headers. Even when building Python, we
+   allow a single source file to override this - they may need access to
+   structures etc so it can optionally use new Windows features if it
+   determines at runtime they are available.
+*/
+#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE)
+#ifndef NTDDI_VERSION
+#define NTDDI_VERSION Py_NTDDI
+#endif
+#ifndef WINVER
+#define WINVER Py_WINVER
+#endif
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT Py_WINVER
+#endif
+#endif
+
+/* _W64 is not defined for VC6 or eVC4 */
+#ifndef _W64
+#define _W64
+#endif
+
+/* Define like size_t, omitting the "unsigned" */
+#ifdef MS_WIN64
+typedef __int64 ssize_t;
+#else
+typedef _W64 int ssize_t;
+#endif
+#define HAVE_SSIZE_T 1
+
+#if defined(MS_WIN32) && !defined(MS_WIN64)
+#if defined(_M_IX86)
+#if defined(__INTEL_COMPILER)
+#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
+#else
+#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
+#endif /* __INTEL_COMPILER */
+#define PYD_PLATFORM_TAG "win32"
+#elif defined(_M_ARM)
+#define COMPILER _Py_PASTE_VERSION("32 bit (Arm)")
+#define PYD_PLATFORM_TAG "win_arm"
+#else
+#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
+#endif
+#endif /* MS_WIN32 && !MS_WIN64 */
+
+typedef int pid_t;
+
+#include <float.h>
+#define Py_IS_NAN _isnan
+#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
+#define Py_IS_FINITE(X) _finite(X)
+#define copysign _copysign
+
+/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
+#if _MSC_VER >= 1400 && _MSC_VER < 1600
+#define HAVE_SXS 1
+#endif
+
+/* define some ANSI types that are not defined in earlier Win headers */
+#if _MSC_VER >= 1200
+/* This file only exists in VC 6.0 or higher */
+#include <basetsd.h>
+#endif
+
+#endif /* _MSC_VER */
+
+/* ------------------------------------------------------------------------*/
+/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */
+#if defined(__GNUC__) && defined(_WIN32)
+/* XXX These defines are likely incomplete, but should be easy to fix.
+   They should be complete enough to build extension modules. */
+/* Suggested by Rene Liebscher <R.Liebscher@gmx.de> to avoid a GCC 2.91.*
+   bug that requires structure imports.  More recent versions of the
+   compiler don't exhibit this bug.
+*/
+#if (__GNUC__==2) && (__GNUC_MINOR__<=91)
+#warning "Please use an up-to-date version of gcc! (>2.91 recommended)"
+#endif
+
+#define COMPILER "[gcc]"
+#define PY_LONG_LONG long long
+#define PY_LLONG_MIN LLONG_MIN
+#define PY_LLONG_MAX LLONG_MAX
+#define PY_ULLONG_MAX ULLONG_MAX
+#endif /* GNUC */
+
+/* ------------------------------------------------------------------------*/
+/* lcc-win32 defines __LCC__ */
+#if defined(__LCC__)
+/* XXX These defines are likely incomplete, but should be easy to fix.
+   They should be complete enough to build extension modules. */
+
+#define COMPILER "[lcc-win32]"
+typedef int pid_t;
+/* __declspec() is supported here too - do nothing to get the defaults */
+
+#endif /* LCC */
+
+/* ------------------------------------------------------------------------*/
+/* End of compilers - finish up */
+
+#ifndef NO_STDIO_H
+#       include <stdio.h>
+#endif
+
+/* 64 bit ints are usually spelt __int64 unless compiler has overridden */
+#ifndef PY_LONG_LONG
+#       define PY_LONG_LONG __int64
+#       define PY_LLONG_MAX _I64_MAX
+#       define PY_LLONG_MIN _I64_MIN
+#       define PY_ULLONG_MAX _UI64_MAX
+#endif
+
+/* For Windows the Python core is in a DLL by default.  Test
+Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
+#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
+#       define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
+#       define MS_COREDLL       /* deprecated old symbol */
+#endif /* !MS_NO_COREDLL && ... */
+
+/*  All windows compilers that use this header support __declspec */
+#define HAVE_DECLSPEC_DLL
+
+/* For an MSVC DLL, we can nominate the .lib files used by extensions */
+#ifdef MS_COREDLL
+#       if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+                /* not building the core - must be an ext */
+#               if defined(_MSC_VER)
+                        /* So MSVC users need not specify the .lib
+                        file in their Makefile (other compilers are
+                        generally taken care of by distutils.) */
+#                       if defined(_DEBUG)
+#                               pragma comment(lib,"python37_d.lib")
+#                       elif defined(Py_LIMITED_API)
+#                               pragma comment(lib,"python3.lib")
+#                       else
+#                               pragma comment(lib,"python37.lib")
+#                       endif /* _DEBUG */
+#               endif /* _MSC_VER */
+#       endif /* Py_BUILD_CORE */
+#endif /* MS_COREDLL */
+
+#if defined(MS_WIN64)
+/* maintain "win32" sys.platform for backward compatibility of Python code,
+   the Win64 API should be close enough to the Win32 API to make this
+   preferable */
+#       define PLATFORM "win32"
+#       define SIZEOF_VOID_P 8
+#       define SIZEOF_TIME_T 8
+#       define SIZEOF_OFF_T 4
+#       define SIZEOF_FPOS_T 8
+#       define SIZEOF_HKEY 8
+#       define SIZEOF_SIZE_T 8
+/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,
+   sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t).
+   On Win64 the second condition is not true, but if fpos_t replaces off_t
+   then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
+   should define this. */
+#       define HAVE_LARGEFILE_SUPPORT
+#elif defined(MS_WIN32)
+#       define PLATFORM "win32"
+#       define HAVE_LARGEFILE_SUPPORT
+#       define SIZEOF_VOID_P 4
+#       define SIZEOF_OFF_T 4
+#       define SIZEOF_FPOS_T 8
+#       define SIZEOF_HKEY 4
+#       define SIZEOF_SIZE_T 4
+        /* MS VS2005 changes time_t to a 64-bit type on all platforms */
+#       if defined(_MSC_VER) && _MSC_VER >= 1400
+#       define SIZEOF_TIME_T 8
+#       else
+#       define SIZEOF_TIME_T 4
+#       endif
+#endif
+
+#ifdef _DEBUG
+#       define Py_DEBUG
+#endif
+
+
+#ifdef MS_WIN32
+
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_DOUBLE 8
+#define SIZEOF_FLOAT 4
+
+/* VC 7.1 has them and VC 6.0 does not.  VC 6.0 has a version number of 1200.
+   Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't
+   define these.
+   If some compiler does not provide them, modify the #if appropriately. */
+#if defined(_MSC_VER)
+#if _MSC_VER > 1300
+#define HAVE_UINTPTR_T 1
+#define HAVE_INTPTR_T 1
+#else
+/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */
+#define Py_LL(x) x##I64
+#endif  /* _MSC_VER > 1300  */
+#endif  /* _MSC_VER */
+
+#endif
+
+/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
+   implementation of Python integers. */
+#define PY_UINT32_T uint32_t
+#define PY_UINT64_T uint64_t
+#define PY_INT32_T int32_t
+#define PY_INT64_T int64_t
+
+/* Fairly standard from here! */
+
+/* Define to 1 if you have the `copysign' function. */
+#define HAVE_COPYSIGN 1
+
+/* Define to 1 if you have the `round' function. */
+#if _MSC_VER >= 1800
+#define HAVE_ROUND 1
+#endif
+
+/* Define to 1 if you have the `isinf' macro. */
+#define HAVE_DECL_ISINF 1
+
+/* Define to 1 if you have the `isnan' function. */
+#define HAVE_DECL_ISNAN 1
+
+/* Define if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
+#ifndef _ALL_SOURCE
+/* #undef _ALL_SOURCE */
+#endif
+
+/* Define to empty if the keyword does not work.  */
+/* #define const  */
+
+/* Define to 1 if you have the <conio.h> header file. */
+#define HAVE_CONIO_H 1
+
+/* Define to 1 if you have the <direct.h> header file. */
+#define HAVE_DIRECT_H 1
+
+/* Define if you have dirent.h.  */
+/* #define DIRENT 1 */
+
+/* Define to the type of elements in the array set by `getgroups'.
+   Usually this is either `int' or `gid_t'.  */
+/* #undef GETGROUPS_T */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef gid_t */
+
+/* Define if your struct tm has tm_zone.  */
+/* #undef HAVE_TM_ZONE */
+
+/* Define if you don't have tm_zone but do have the external array
+   tzname.  */
+#define HAVE_TZNAME
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef mode_t */
+
+/* Define if you don't have dirent.h, but have ndir.h.  */
+/* #undef NDIR */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define if the system does not provide POSIX.1 features except
+   with this defined.  */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if you don't have dirent.h, but have sys/dir.h.  */
+/* #undef SYSDIR */
+
+/* Define if you don't have dirent.h, but have sys/ndir.h.  */
+/* #undef SYSNDIR */
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+/* #undef TIME_WITH_SYS_TIME */
+
+/* Define if your <sys/time.h> declares struct tm.  */
+/* #define TM_IN_SYS_TIME 1 */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef uid_t */
+
+/* Define if the closedir function returns void instead of int.  */
+/* #undef VOID_CLOSEDIR */
+
+/* Define if getpgrp() must be called as getpgrp(0)
+   and (consequently) setpgrp() as setpgrp(0, 0). */
+/* #undef GETPGRP_HAVE_ARGS */
+
+/* Define this if your time.h defines altzone */
+/* #define HAVE_ALTZONE */
+
+/* Define if you have the putenv function.  */
+#define HAVE_PUTENV
+
+/* Define if your compiler supports function prototypes */
+#define HAVE_PROTOTYPES
+
+/* Define if  you can safely include both <sys/select.h> and <sys/time.h>
+   (which you can't on SCO ODT 3.0). */
+/* #undef SYS_SELECT_WITH_SYS_TIME */
+
+/* Define if you want documentation strings in extension modules */
+#define WITH_DOC_STRINGS 1
+
+/* Define if you want to compile in rudimentary thread support */
+/* #undef WITH_THREAD */
+
+/* Define if you want to use the GNU readline library */
+/* #define WITH_READLINE 1 */
+
+/* Use Python's own small-block memory-allocator. */
+#define WITH_PYMALLOC 1
+
+/* Define if you have clock.  */
+/* #define HAVE_CLOCK */
+
+/* Define when any dynamic module loading is enabled */
+#define HAVE_DYNAMIC_LOADING
+
+/* Define if you have ftime.  */
+#define HAVE_FTIME
+
+/* Define if you have getpeername.  */
+#define HAVE_GETPEERNAME
+
+/* Define if you have getpgrp.  */
+/* #undef HAVE_GETPGRP */
+
+/* Define if you have getpid.  */
+#define HAVE_GETPID
+
+/* Define if you have gettimeofday.  */
+/* #undef HAVE_GETTIMEOFDAY */
+
+/* Define if you have getwd.  */
+/* #undef HAVE_GETWD */
+
+/* Define if you have lstat.  */
+/* #undef HAVE_LSTAT */
+
+/* Define if you have the mktime function.  */
+#define HAVE_MKTIME
+
+/* Define if you have nice.  */
+/* #undef HAVE_NICE */
+
+/* Define if you have readlink.  */
+/* #undef HAVE_READLINK */
+
+/* Define if you have setpgid.  */
+/* #undef HAVE_SETPGID */
+
+/* Define if you have setpgrp.  */
+/* #undef HAVE_SETPGRP */
+
+/* Define if you have setsid.  */
+/* #undef HAVE_SETSID */
+
+/* Define if you have setvbuf.  */
+#define HAVE_SETVBUF
+
+/* Define if you have siginterrupt.  */
+/* #undef HAVE_SIGINTERRUPT */
+
+/* Define if you have symlink.  */
+/* #undef HAVE_SYMLINK */
+
+/* Define if you have tcgetpgrp.  */
+/* #undef HAVE_TCGETPGRP */
+
+/* Define if you have tcsetpgrp.  */
+/* #undef HAVE_TCSETPGRP */
+
+/* Define if you have times.  */
+/* #undef HAVE_TIMES */
+
+/* Define if you have uname.  */
+/* #undef HAVE_UNAME */
+
+/* Define if you have waitpid.  */
+/* #undef HAVE_WAITPID */
+
+/* Define to 1 if you have the `wcsftime' function. */
+#if defined(_MSC_VER) && _MSC_VER >= 1310
+#define HAVE_WCSFTIME 1
+#endif
+
+/* Define to 1 if you have the `wcscoll' function. */
+#define HAVE_WCSCOLL 1
+
+/* Define to 1 if you have the `wcsxfrm' function. */
+#define HAVE_WCSXFRM 1
+
+/* Define if the zlib library has inflateCopy */
+#define HAVE_ZLIB_COPY 1
+
+/* Define if you have the <dlfcn.h> header file.  */
+/* #undef HAVE_DLFCN_H */
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <process.h> header file. */
+#define HAVE_PROCESS_H 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define if you have the <stdarg.h> prototypes.  */
+#define HAVE_STDARG_PROTOTYPES
+
+/* Define if you have the <stddef.h> header file.  */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <sys/audioio.h> header file.  */
+/* #undef HAVE_SYS_AUDIOIO_H */
+
+/* Define if you have the <sys/param.h> header file.  */
+/* #define HAVE_SYS_PARAM_H 1 */
+
+/* Define if you have the <sys/select.h> header file.  */
+/* #define HAVE_SYS_SELECT_H 1 */
+
+/* Define to 1 if you have the <sys/stat.h> header file.  */
+#define HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/time.h> header file.  */
+/* #define HAVE_SYS_TIME_H 1 */
+
+/* Define if you have the <sys/times.h> header file.  */
+/* #define HAVE_SYS_TIMES_H 1 */
+
+/* Define to 1 if you have the <sys/types.h> header file.  */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/un.h> header file.  */
+/* #define HAVE_SYS_UN_H 1 */
+
+/* Define if you have the <sys/utime.h> header file.  */
+/* #define HAVE_SYS_UTIME_H 1 */
+
+/* Define if you have the <sys/utsname.h> header file.  */
+/* #define HAVE_SYS_UTSNAME_H 1 */
+
+/* Define if you have the <unistd.h> header file.  */
+/* #define HAVE_UNISTD_H 1 */
+
+/* Define if you have the <utime.h> header file.  */
+/* #define HAVE_UTIME_H 1 */
+
+/* Define if the compiler provides a wchar.h header file. */
+#define HAVE_WCHAR_H 1
+
+/* The size of `wchar_t', as computed by sizeof. */
+#define SIZEOF_WCHAR_T 2
+
+/* The size of `_Bool', as computed by sizeof. */
+#define SIZEOF__BOOL 1
+
+/* The size of `pid_t', as computed by sizeof. */
+#define SIZEOF_PID_T SIZEOF_INT
+
+/* Define if you have the dl library (-ldl).  */
+/* #undef HAVE_LIBDL */
+
+/* Define if you have the mpc library (-lmpc).  */
+/* #undef HAVE_LIBMPC */
+
+/* Define if you have the nsl library (-lnsl).  */
+#define HAVE_LIBNSL 1
+
+/* Define if you have the seq library (-lseq).  */
+/* #undef HAVE_LIBSEQ */
+
+/* Define if you have the socket library (-lsocket).  */
+#define HAVE_LIBSOCKET 1
+
+/* Define if you have the sun library (-lsun).  */
+/* #undef HAVE_LIBSUN */
+
+/* Define if you have the termcap library (-ltermcap).  */
+/* #undef HAVE_LIBTERMCAP */
+
+/* Define if you have the termlib library (-ltermlib).  */
+/* #undef HAVE_LIBTERMLIB */
+
+/* Define if you have the thread library (-lthread).  */
+/* #undef HAVE_LIBTHREAD */
+
+/* WinSock does not use a bitmask in select, and uses
+   socket handles greater than FD_SETSIZE */
+#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
+
+/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
+   least significant byte first */
+#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
+
+/* Define to 1 if you have the `erf' function. */
+#define HAVE_ERF 1
+
+/* Define to 1 if you have the `erfc' function. */
+#define HAVE_ERFC 1
+
+/* Define if you have the 'inet_pton' function. */
+#define HAVE_INET_PTON 1
+
+/* framework name */
+#define _PYTHONFRAMEWORK ""
+
+/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
+#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
+
+#endif /* !Py_CONFIG_H */

+ 680 - 0
distro-info/patches/pyconfig-3.7.6.h

@@ -0,0 +1,680 @@
+#ifndef Py_CONFIG_H
+#define Py_CONFIG_H
+
+/* pyconfig.h.  NOT Generated automatically by configure.
+
+This is a manually maintained version used for the Watcom,
+Borland and Microsoft Visual C++ compilers.  It is a
+standard part of the Python distribution.
+
+WINDOWS DEFINES:
+The code specific to Windows should be wrapped around one of
+the following #defines
+
+MS_WIN64 - Code specific to the MS Win64 API
+MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
+MS_WINDOWS - Code specific to Windows, but all versions.
+Py_ENABLE_SHARED - Code if the Python core is built as a DLL.
+
+Also note that neither "_M_IX86" or "_MSC_VER" should be used for
+any purpose other than "Windows Intel x86 specific" and "Microsoft
+compiler specific".  Therefore, these should be very rare.
+
+
+NOTE: The following symbols are deprecated:
+NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
+MS_CORE_DLL.
+
+WIN32 is still required for the locale module.
+
+*/
+
+/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */
+#ifdef USE_DL_EXPORT
+#       define Py_BUILD_CORE
+#endif /* USE_DL_EXPORT */
+
+/* Visual Studio 2005 introduces deprecation warnings for
+   "insecure" and POSIX functions. The insecure functions should
+   be replaced by *_s versions (according to Microsoft); the
+   POSIX functions by _* versions (which, according to Microsoft,
+   would be ISO C conforming). Neither renaming is feasible, so
+   we just silence the warnings. */
+
+#ifndef _CRT_SECURE_NO_DEPRECATE
+#define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+#define _CRT_NONSTDC_NO_DEPRECATE 1
+#endif
+
+#define HAVE_IO_H
+#define HAVE_SYS_UTIME_H
+#define HAVE_TEMPNAM
+#define HAVE_TMPFILE
+#define HAVE_TMPNAM
+#define HAVE_CLOCK
+#define HAVE_STRERROR
+
+#include <io.h>
+
+#define HAVE_HYPOT
+#define HAVE_STRFTIME
+#define DONT_HAVE_SIG_ALARM
+#define DONT_HAVE_SIG_PAUSE
+#define LONG_BIT        32
+#define WORD_BIT 32
+
+#define MS_WIN32 /* only support win32 and greater. */
+#define MS_WINDOWS
+#ifndef PYTHONPATH
+#       define PYTHONPATH L".\\DLLs;.\\lib"
+#endif
+#define NT_THREADS
+#define WITH_THREAD
+#ifndef NETSCAPE_PI
+#define USE_SOCKET
+#endif
+
+
+/* Compiler specific defines */
+
+/* ------------------------------------------------------------------------*/
+/* Microsoft C defines _MSC_VER */
+#ifdef _MSC_VER
+
+/* We want COMPILER to expand to a string containing _MSC_VER's *value*.
+ * This is horridly tricky, because the stringization operator only works
+ * on macro arguments, and doesn't evaluate macros passed *as* arguments.
+ * Attempts simpler than the following appear doomed to produce "_MSC_VER"
+ * literally in the string.
+ */
+#define _Py_PASTE_VERSION(SUFFIX) \
+        ("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]")
+/* e.g., this produces, after compile-time string catenation,
+ *      ("[MSC v.1200 32 bit (Intel)]")
+ *
+ * _Py_STRINGIZE(_MSC_VER) expands to
+ * _Py_STRINGIZE1((_MSC_VER)) expands to
+ * _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting
+ *      it's scanned again for macros and so further expands to (under MSVC 6)
+ * _Py_STRINGIZE2(1200) which then expands to
+ * "1200"
+ */
+#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
+#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
+#define _Py_STRINGIZE2(X) #X
+
+/* MSVC defines _WINxx to differentiate the windows platform types
+
+   Note that for compatibility reasons _WIN32 is defined on Win32
+   *and* on Win64. For the same reasons, in Python, MS_WIN32 is
+   defined on Win32 *and* Win64. Win32 only code must therefore be
+   guarded as follows:
+        #if defined(MS_WIN32) && !defined(MS_WIN64)
+*/
+#ifdef _WIN64
+#define MS_WIN64
+#endif
+
+/* set the COMPILER */
+#ifdef MS_WIN64
+#if defined(_M_X64) || defined(_M_AMD64)
+#if defined(__INTEL_COMPILER)
+#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
+#else
+#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
+#endif /* __INTEL_COMPILER */
+#define PYD_PLATFORM_TAG "win_amd64"
+#else
+#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
+#endif
+#endif /* MS_WIN64 */
+
+/* set the version macros for the windows headers */
+/* Python 3.5+ requires Windows Vista or greater */
+#define Py_WINVER 0x0600 /* _WIN32_WINNT_VISTA */
+#define Py_NTDDI NTDDI_VISTA
+
+/* We only set these values when building Python - we don't want to force
+   these values on extensions, as that will affect the prototypes and
+   structures exposed in the Windows headers. Even when building Python, we
+   allow a single source file to override this - they may need access to
+   structures etc so it can optionally use new Windows features if it
+   determines at runtime they are available.
+*/
+#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE)
+#ifndef NTDDI_VERSION
+#define NTDDI_VERSION Py_NTDDI
+#endif
+#ifndef WINVER
+#define WINVER Py_WINVER
+#endif
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT Py_WINVER
+#endif
+#endif
+
+/* _W64 is not defined for VC6 or eVC4 */
+#ifndef _W64
+#define _W64
+#endif
+
+/* Define like size_t, omitting the "unsigned" */
+#ifdef MS_WIN64
+typedef __int64 ssize_t;
+#else
+typedef _W64 int ssize_t;
+#endif
+#define HAVE_SSIZE_T 1
+
+#if defined(MS_WIN32) && !defined(MS_WIN64)
+#if defined(_M_IX86)
+#if defined(__INTEL_COMPILER)
+#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
+#else
+#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
+#endif /* __INTEL_COMPILER */
+#define PYD_PLATFORM_TAG "win32"
+#elif defined(_M_ARM)
+#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
+#define PYD_PLATFORM_TAG "win_arm"
+#else
+#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
+#endif
+#endif /* MS_WIN32 && !MS_WIN64 */
+
+typedef int pid_t;
+
+#include <float.h>
+#define Py_IS_NAN _isnan
+#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
+#define Py_IS_FINITE(X) _finite(X)
+#define copysign _copysign
+
+/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
+#if _MSC_VER >= 1400 && _MSC_VER < 1600
+#define HAVE_SXS 1
+#endif
+
+/* define some ANSI types that are not defined in earlier Win headers */
+#if _MSC_VER >= 1200
+/* This file only exists in VC 6.0 or higher */
+#include <basetsd.h>
+#endif
+
+#endif /* _MSC_VER */
+
+/* ------------------------------------------------------------------------*/
+/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */
+#if defined(__GNUC__) && defined(_WIN32)
+/* XXX These defines are likely incomplete, but should be easy to fix.
+   They should be complete enough to build extension modules. */
+/* Suggested by Rene Liebscher <R.Liebscher@gmx.de> to avoid a GCC 2.91.*
+   bug that requires structure imports.  More recent versions of the
+   compiler don't exhibit this bug.
+*/
+#if (__GNUC__==2) && (__GNUC_MINOR__<=91)
+#warning "Please use an up-to-date version of gcc! (>2.91 recommended)"
+#endif
+
+#define COMPILER "[gcc]"
+#define PY_LONG_LONG long long
+#define PY_LLONG_MIN LLONG_MIN
+#define PY_LLONG_MAX LLONG_MAX
+#define PY_ULLONG_MAX ULLONG_MAX
+#endif /* GNUC */
+
+/* ------------------------------------------------------------------------*/
+/* lcc-win32 defines __LCC__ */
+#if defined(__LCC__)
+/* XXX These defines are likely incomplete, but should be easy to fix.
+   They should be complete enough to build extension modules. */
+
+#define COMPILER "[lcc-win32]"
+typedef int pid_t;
+/* __declspec() is supported here too - do nothing to get the defaults */
+
+#endif /* LCC */
+
+/* ------------------------------------------------------------------------*/
+/* End of compilers - finish up */
+
+#ifndef NO_STDIO_H
+#       include <stdio.h>
+#endif
+
+/* 64 bit ints are usually spelt __int64 unless compiler has overridden */
+#ifndef PY_LONG_LONG
+#       define PY_LONG_LONG __int64
+#       define PY_LLONG_MAX _I64_MAX
+#       define PY_LLONG_MIN _I64_MIN
+#       define PY_ULLONG_MAX _UI64_MAX
+#endif
+
+/* For Windows the Python core is in a DLL by default.  Test
+Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
+#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
+#       define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
+#       define MS_COREDLL       /* deprecated old symbol */
+#endif /* !MS_NO_COREDLL && ... */
+
+/*  All windows compilers that use this header support __declspec */
+#define HAVE_DECLSPEC_DLL
+
+/* For an MSVC DLL, we can nominate the .lib files used by extensions */
+#ifdef MS_COREDLL
+#       if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+                /* not building the core - must be an ext */
+#               if defined(_MSC_VER)
+                        /* So MSVC users need not specify the .lib
+                        file in their Makefile (other compilers are
+                        generally taken care of by distutils.) */
+#                       if defined(_DEBUG)
+#                               pragma comment(lib,"python37_d.lib")
+#                       elif defined(Py_LIMITED_API)
+#                               pragma comment(lib,"python3.lib")
+#                       else
+#                               pragma comment(lib,"python37.lib")
+#                       endif /* _DEBUG */
+#               endif /* _MSC_VER */
+#       endif /* Py_BUILD_CORE */
+#endif /* MS_COREDLL */
+
+#if defined(MS_WIN64)
+/* maintain "win32" sys.platform for backward compatibility of Python code,
+   the Win64 API should be close enough to the Win32 API to make this
+   preferable */
+#       define PLATFORM "win32"
+#       define SIZEOF_VOID_P 8
+#       define SIZEOF_TIME_T 8
+#       define SIZEOF_OFF_T 4
+#       define SIZEOF_FPOS_T 8
+#       define SIZEOF_HKEY 8
+#       define SIZEOF_SIZE_T 8
+/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff
+   sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t).
+   On Win64 the second condition is not true, but if fpos_t replaces off_t
+   then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
+   should define this. */
+#       define HAVE_LARGEFILE_SUPPORT
+#elif defined(MS_WIN32)
+#       define PLATFORM "win32"
+#       define HAVE_LARGEFILE_SUPPORT
+#       define SIZEOF_VOID_P 4
+#       define SIZEOF_OFF_T 4
+#       define SIZEOF_FPOS_T 8
+#       define SIZEOF_HKEY 4
+#       define SIZEOF_SIZE_T 4
+        /* MS VS2005 changes time_t to a 64-bit type on all platforms */
+#       if defined(_MSC_VER) && _MSC_VER >= 1400
+#       define SIZEOF_TIME_T 8
+#       else
+#       define SIZEOF_TIME_T 4
+#       endif
+#endif
+
+#ifdef _DEBUG
+#       define Py_DEBUG
+#endif
+
+
+#ifdef MS_WIN32
+
+#define SIZEOF_SHORT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_DOUBLE 8
+#define SIZEOF_FLOAT 4
+
+/* VC 7.1 has them and VC 6.0 does not.  VC 6.0 has a version number of 1200.
+   Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't
+   define these.
+   If some compiler does not provide them, modify the #if appropriately. */
+#if defined(_MSC_VER)
+#if _MSC_VER > 1300
+#define HAVE_UINTPTR_T 1
+#define HAVE_INTPTR_T 1
+#else
+/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */
+#define Py_LL(x) x##I64
+#endif  /* _MSC_VER > 1300  */
+#endif  /* _MSC_VER */
+
+#endif
+
+/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
+   implementation of Python integers. */
+#define PY_UINT32_T uint32_t
+#define PY_UINT64_T uint64_t
+#define PY_INT32_T int32_t
+#define PY_INT64_T int64_t
+
+/* Fairly standard from here! */
+
+/* Define to 1 if you have the `copysign' function. */
+#define HAVE_COPYSIGN 1
+
+/* Define to 1 if you have the `round' function. */
+#if _MSC_VER >= 1800
+#define HAVE_ROUND 1
+#endif
+
+/* Define to 1 if you have the `isinf' macro. */
+#define HAVE_DECL_ISINF 1
+
+/* Define to 1 if you have the `isnan' function. */
+#define HAVE_DECL_ISNAN 1
+
+/* Define if on AIX 3.
+   System headers sometimes define this.
+   We just want to avoid a redefinition error message.  */
+#ifndef _ALL_SOURCE
+/* #undef _ALL_SOURCE */
+#endif
+
+/* Define to empty if the keyword does not work.  */
+/* #define const  */
+
+/* Define to 1 if you have the <conio.h> header file. */
+#define HAVE_CONIO_H 1
+
+/* Define to 1 if you have the <direct.h> header file. */
+#define HAVE_DIRECT_H 1
+
+/* Define if you have dirent.h.  */
+/* #define DIRENT 1 */
+
+/* Define to the type of elements in the array set by `getgroups'.
+   Usually this is either `int' or `gid_t'.  */
+/* #undef GETGROUPS_T */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef gid_t */
+
+/* Define if your struct tm has tm_zone.  */
+/* #undef HAVE_TM_ZONE */
+
+/* Define if you don't have tm_zone but do have the external array
+   tzname.  */
+#define HAVE_TZNAME
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef mode_t */
+
+/* Define if you don't have dirent.h, but have ndir.h.  */
+/* #undef NDIR */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef pid_t */
+
+/* Define if the system does not provide POSIX.1 features except
+   with this defined.  */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+/* Define if you don't have dirent.h, but have sys/dir.h.  */
+/* #undef SYSDIR */
+
+/* Define if you don't have dirent.h, but have sys/ndir.h.  */
+/* #undef SYSNDIR */
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+/* #undef TIME_WITH_SYS_TIME */
+
+/* Define if your <sys/time.h> declares struct tm.  */
+/* #define TM_IN_SYS_TIME 1 */
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+/* #undef uid_t */
+
+/* Define if the closedir function returns void instead of int.  */
+/* #undef VOID_CLOSEDIR */
+
+/* Define if getpgrp() must be called as getpgrp(0)
+   and (consequently) setpgrp() as setpgrp(0, 0). */
+/* #undef GETPGRP_HAVE_ARGS */
+
+/* Define this if your time.h defines altzone */
+/* #define HAVE_ALTZONE */
+
+/* Define if you have the putenv function.  */
+#define HAVE_PUTENV
+
+/* Define if your compiler supports function prototypes */
+#define HAVE_PROTOTYPES
+
+/* Define if  you can safely include both <sys/select.h> and <sys/time.h>
+   (which you can't on SCO ODT 3.0). */
+/* #undef SYS_SELECT_WITH_SYS_TIME */
+
+/* Define if you want documentation strings in extension modules */
+#define WITH_DOC_STRINGS 1
+
+/* Define if you want to compile in rudimentary thread support */
+/* #undef WITH_THREAD */
+
+/* Define if you want to use the GNU readline library */
+/* #define WITH_READLINE 1 */
+
+/* Use Python's own small-block memory-allocator. */
+#define WITH_PYMALLOC 1
+
+/* Define if you have clock.  */
+/* #define HAVE_CLOCK */
+
+/* Define when any dynamic module loading is enabled */
+#define HAVE_DYNAMIC_LOADING
+
+/* Define if you have ftime.  */
+#define HAVE_FTIME
+
+/* Define if you have getpeername.  */
+#define HAVE_GETPEERNAME
+
+/* Define if you have getpgrp.  */
+/* #undef HAVE_GETPGRP */
+
+/* Define if you have getpid.  */
+#define HAVE_GETPID
+
+/* Define if you have gettimeofday.  */
+/* #undef HAVE_GETTIMEOFDAY */
+
+/* Define if you have getwd.  */
+/* #undef HAVE_GETWD */
+
+/* Define if you have lstat.  */
+/* #undef HAVE_LSTAT */
+
+/* Define if you have the mktime function.  */
+#define HAVE_MKTIME
+
+/* Define if you have nice.  */
+/* #undef HAVE_NICE */
+
+/* Define if you have readlink.  */
+/* #undef HAVE_READLINK */
+
+/* Define if you have setpgid.  */
+/* #undef HAVE_SETPGID */
+
+/* Define if you have setpgrp.  */
+/* #undef HAVE_SETPGRP */
+
+/* Define if you have setsid.  */
+/* #undef HAVE_SETSID */
+
+/* Define if you have setvbuf.  */
+#define HAVE_SETVBUF
+
+/* Define if you have siginterrupt.  */
+/* #undef HAVE_SIGINTERRUPT */
+
+/* Define if you have symlink.  */
+/* #undef HAVE_SYMLINK */
+
+/* Define if you have tcgetpgrp.  */
+/* #undef HAVE_TCGETPGRP */
+
+/* Define if you have tcsetpgrp.  */
+/* #undef HAVE_TCSETPGRP */
+
+/* Define if you have times.  */
+/* #undef HAVE_TIMES */
+
+/* Define if you have uname.  */
+/* #undef HAVE_UNAME */
+
+/* Define if you have waitpid.  */
+/* #undef HAVE_WAITPID */
+
+/* Define to 1 if you have the `wcsftime' function. */
+#if defined(_MSC_VER) && _MSC_VER >= 1310
+#define HAVE_WCSFTIME 1
+#endif
+
+/* Define to 1 if you have the `wcscoll' function. */
+#define HAVE_WCSCOLL 1
+
+/* Define to 1 if you have the `wcsxfrm' function. */
+#define HAVE_WCSXFRM 1
+
+/* Define if the zlib library has inflateCopy */
+#define HAVE_ZLIB_COPY 1
+
+/* Define if you have the <dlfcn.h> header file.  */
+/* #undef HAVE_DLFCN_H */
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <process.h> header file. */
+#define HAVE_PROCESS_H 1
+
+/* Define to 1 if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define if you have the <stdarg.h> prototypes.  */
+#define HAVE_STDARG_PROTOTYPES
+
+/* Define if you have the <stddef.h> header file.  */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <sys/audioio.h> header file.  */
+/* #undef HAVE_SYS_AUDIOIO_H */
+
+/* Define if you have the <sys/param.h> header file.  */
+/* #define HAVE_SYS_PARAM_H 1 */
+
+/* Define if you have the <sys/select.h> header file.  */
+/* #define HAVE_SYS_SELECT_H 1 */
+
+/* Define to 1 if you have the <sys/stat.h> header file.  */
+#define HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/time.h> header file.  */
+/* #define HAVE_SYS_TIME_H 1 */
+
+/* Define if you have the <sys/times.h> header file.  */
+/* #define HAVE_SYS_TIMES_H 1 */
+
+/* Define to 1 if you have the <sys/types.h> header file.  */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/un.h> header file.  */
+/* #define HAVE_SYS_UN_H 1 */
+
+/* Define if you have the <sys/utime.h> header file.  */
+/* #define HAVE_SYS_UTIME_H 1 */
+
+/* Define if you have the <sys/utsname.h> header file.  */
+/* #define HAVE_SYS_UTSNAME_H 1 */
+
+/* Define if you have the <unistd.h> header file.  */
+/* #define HAVE_UNISTD_H 1 */
+
+/* Define if you have the <utime.h> header file.  */
+/* #define HAVE_UTIME_H 1 */
+
+/* Define if the compiler provides a wchar.h header file. */
+#define HAVE_WCHAR_H 1
+
+/* The size of `wchar_t', as computed by sizeof. */
+#define SIZEOF_WCHAR_T 2
+
+/* The size of `_Bool', as computed by sizeof. */
+#define SIZEOF__BOOL 1
+
+/* The size of `pid_t', as computed by sizeof. */
+#define SIZEOF_PID_T SIZEOF_INT
+
+/* Define if you have the dl library (-ldl).  */
+/* #undef HAVE_LIBDL */
+
+/* Define if you have the mpc library (-lmpc).  */
+/* #undef HAVE_LIBMPC */
+
+/* Define if you have the nsl library (-lnsl).  */
+#define HAVE_LIBNSL 1
+
+/* Define if you have the seq library (-lseq).  */
+/* #undef HAVE_LIBSEQ */
+
+/* Define if you have the socket library (-lsocket).  */
+#define HAVE_LIBSOCKET 1
+
+/* Define if you have the sun library (-lsun).  */
+/* #undef HAVE_LIBSUN */
+
+/* Define if you have the termcap library (-ltermcap).  */
+/* #undef HAVE_LIBTERMCAP */
+
+/* Define if you have the termlib library (-ltermlib).  */
+/* #undef HAVE_LIBTERMLIB */
+
+/* Define if you have the thread library (-lthread).  */
+/* #undef HAVE_LIBTHREAD */
+
+/* WinSock does not use a bitmask in select, and uses
+   socket handles greater than FD_SETSIZE */
+#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
+
+/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
+   least significant byte first */
+#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
+
+/* Define to 1 if you have the `erf' function. */
+#define HAVE_ERF 1
+
+/* Define to 1 if you have the `erfc' function. */
+#define HAVE_ERFC 1
+
+/* Define if you have the 'inet_pton' function. */
+#define HAVE_INET_PTON 1
+
+/* framework name */
+#define _PYTHONFRAMEWORK ""
+
+/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
+#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
+
+#endif /* !Py_CONFIG_H */

+ 11 - 0
distro-info/patches/python-2.7.13.amd64.patch

@@ -0,0 +1,11 @@
+--- pyconfig.h	2016-06-26 02:46:30.000000000 +0300
++++ pyconfig.h.new	2018-02-14 13:35:21.000000000 +0200
+@@ -282,7 +282,7 @@
+ #endif
+ 
+ #define COMPILER "[gcc]"
+-#define hypot _hypot
++// #define hypot _hypot
+ #define PY_LONG_LONG long long
+ #define PY_LLONG_MIN LLONG_MIN
+ #define PY_LLONG_MAX LLONG_MAX

+ 11 - 0
distro-info/patches/python-2.7.13.patch

@@ -0,0 +1,11 @@
+--- pyconfig.h	2018-02-13 20:36:06.000000000 +0200
++++ pyconfig.h.new	2018-02-13 20:39:17.000000000 +0200
+@@ -282,7 +282,7 @@
+ #endif
+ 
+ #define COMPILER "[gcc]"
+-#define hypot _hypot
++// #define hypot _hypot
+ #define PY_LONG_LONG long long
+ #define PY_LLONG_MIN LLONG_MIN
+ #define PY_LLONG_MAX LLONG_MAX

+ 67 - 0
distro-info/patches/python3-config.sh

@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+# Windows Python3 configuration script
+#
+# As per comment regarding --with-python in gdb/configure.ac, this script
+# follows the interface of gdb/python/python-config.py but return path
+# related to Windows Python3.
+
+set -o errexit # Exit if command failed.
+set -o pipefail # Exit if pipe failed.
+set -o nounset # Exit if variable not set.
+
+if [ ! -d "${SOURCES_FOLDER_PATH}/${PYTHON3_SRC_FOLDER_NAME}" ]
+then
+  exit 1
+fi
+
+if [ ! -d "${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}" ]
+then
+  exit 1
+fi
+
+while [ $# -ge 1 ]
+do
+  opt="$1"
+  case ${opt} in
+
+    --prefix|--exec-prefix)
+      prefix="${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}"
+      echo "${opt} -> [${prefix}]" >&2
+      echo "${prefix}"
+      ;;
+
+    --includes|--cflags)
+      cflags="-I${SOURCES_FOLDER_PATH}/${PYTHON3_SRC_FOLDER_NAME}/Include"
+
+      if [ "${opt}" == "--cflags" ]
+      then
+        cflags+=" ${CFLAGS}"
+      fi
+      echo "${opt} -> [${cflags}]" >&2
+      echo "${cflags}"
+      ;;
+
+    --libs|--ldflags)
+      # Options to link to static libpython2.7 archive so as to avoid  an
+      # external dependency on python
+      libs="-L${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME} -lpython37"
+      echo "${opt} -> [${libs}]" >&2
+      echo "${libs}"
+      ;;
+
+    --*)
+      echo "Unknown option: ${opt}" >&2
+      exit 1
+      ;;
+
+    *)
+      # Ignore non options since we are called with gdb provided
+      # python-config.py as first parameter
+      ;;
+
+  esac
+  shift
+done
+
+exit 0

+ 100 - 0
distro-info/scripts/README-8.2.0-3.1.md

@@ -0,0 +1,100 @@
+# xPack GNU RISC-V Embedded GCC
+
+This is the **xPack** version of the
+**GNU RISC-V Embedded GCC** toolchain.
+
+For details, see
+[The xPack GNU RISC-V Embedded GCC](https://xpack.github.io/riscv-none-embed-gcc/) pages.
+
+## Easy install
+
+The **xPack RISC-V Embedded GCC** toolchain is also available as a
+binary [xPack](https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-embed-gcc)
+and can be conveniently installed with [xpm](https://www.npmjs.com/package/xpm):
+
+```console
+$ xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@8.2.0-3.1.1
+```
+
+For more details on how to install the toolchain, please see
+[How to install the RISC-V toolchain?](http://xpack.github.io/toolchain/riscv-bone-embed-gcc/install/) page.
+
+## Compliance
+
+Starting with 8.2.0-2, the xPack GNU RISC-V Embedded GCC (formerly
+GNU MCU Eclipse RISC-V GCC) follows
+the official [SiFive releases](https://github.com/sifive/freedom-tools/releases),
+with as little differences as possible.
+
+This release is based on the
+[v2019.05.0](https://github.com/sifive/freedom-tools/releases/tag/v2019.05.0)
+release, and includes the SiFive extensions (like CLIC interrupts).
+
+The following commits (from [sifive/freedom-tools](https://github.com/sifive/freedom-tools/tree/master/src)) were used:
+
+- the [sifive/riscv-gcc](https://github.com/sifive/riscv-gcc) project,
+branch `sifive-gcc-8.2.0`, commit
+[242abcaff6](https://github.com/sifive/riscv-gcc/tree/242abcaff697d0a1ea12dccc975465e1bfeb8331)
+from from 5 April 2019
+- the [sifive/riscv-binutils-gdb](https://github.com/sifive/riscv-binutils-gdb)
+project, branch `sifive-binutils-2.32`, commit
+[164267155c](https://github.com/sifive/riscv-binutils-gdb/tree/164267155c96f91472a539ca78ac919993bc5b4e)
+from 28 February 2019
+- the [sifive/riscv-newlib](https://github.com/sifive/riscv-newlib) project,
+commit [42c2e3fb9f](https://github.com/sifive/riscv-newlib/tree/42c2e3fb9f557d59b76d1a64bb6fb32707ff4530)
+from 17 November 2018
+
+GDB was upstreamed and does not require SiFive specific patches,
+so the current build uses
+`git://sourceware.org/git/binutils-gdb.git`, the `9b40759` commit from
+28 Feb 2019.
+
+## Changes
+
+Compared to the original SiFive version, the **same architecture and API**
+options are supported, and there are minimal functional changes
+
+- `libgloss` was removed from the list of libraires always linked to the
+  application, since it issues `ECALL`
+  instructions that fail in bare metal environments
+- `march=rv32imaf/mabi=ilp32f` was added to the list of multilibs
+
+## newlib-nano
+
+Support for **newlib-nano** is available using the
+`--specs=nano.specs` option. For better results, this option must be
+added to both compile and link time.
+
+## nosys.specs
+
+If no syscalls are needed, `--specs=nosys.specs` can be used at link
+time to provide empty implementations for the POSIX system calls.
+
+## Compile options
+
+The libraries are compiled with `-O2 -mcmodel=medany`. The nano version is
+compiled with `-Os -mcmodel=medany`.
+
+> Important: It is mandatory for the applications to be compiled with
+`-mcmodel=medany`, otherwise the link will fail.
+
+## Documentation
+
+The original PDF documentation is available in the `share/doc` folder.
+
+## Support
+
+For support, please read the
+[support](https://xpack.github.io/riscv-none-embed-gcc/support/) page.
+
+## More info
+
+For more info, please see the xPack project site:
+
+  http://xpack.github.io/riscv-none-embed-gcc
+
+
+Thank you for using open source software,
+
+Liviu Ionescu
+

+ 100 - 0
distro-info/scripts/README-8.3.0-1.1.md

@@ -0,0 +1,100 @@
+# xPack GNU RISC-V Embedded GCC
+
+This is the **xPack** version of the
+**GNU RISC-V Embedded GCC** toolchain.
+
+For details, see
+[The xPack GNU RISC-V Embedded GCC](https://xpack.github.io/riscv-none-embed-gcc/) pages.
+
+## Easy install
+
+The **xPack RISC-V Embedded GCC** toolchain is also available as a
+binary [xPack](https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-embed-gcc)
+and can be conveniently installed with [xpm](https://www.npmjs.com/package/xpm):
+
+```console
+$ xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@8.3.0-1.1.1
+```
+
+For more details on how to install the toolchain, please see
+[How to install the RISC-V toolchain?](http://xpack.github.io/toolchain/riscv-bone-embed-gcc/install/) page.
+
+## Compliance
+
+Starting with 8.2.0-2, the xPack GNU RISC-V Embedded GCC (formerly
+GNU MCU Eclipse RISC-V GCC) follows
+the official [SiFive releases](https://github.com/sifive/freedom-tools/releases),
+with as little differences as possible.
+
+This release is based on the
+[v2019.08.0](https://github.com/sifive/freedom-tools/releases/tag/v2019.08.0)
+release, and includes the SiFive extensions (like CLIC interrupts).
+
+The following commits (from [sifive/freedom-tools](https://github.com/sifive/freedom-tools/tree/master/src)) were used:
+
+- the [sifive/riscv-binutils-gdb](https://github.com/sifive/riscv-binutils-gdb)
+project, branch `sifive-binutils-2.32`, commit
+[03d23d5](https://github.com/sifive/riscv-binutils-gdb/tree/03d23d58701bdd425c613b0be2d458bcde46912b)
+from 2 September 2019
+- the [sifive/riscv-gcc](https://github.com/sifive/riscv-gcc) project,
+branch `sifive-gcc-8.3.0`, commit
+[e195042](https://github.com/sifive/riscv-gcc/tree/e195042babe2dc30d9fabb88d336d8c8679b3702)
+from from 7 Aug 2019
+- the [sifive/riscv-newlib](https://github.com/sifive/riscv-newlib) project, the `master` branch,
+commit [0d24a86](https://github.com/sifive/riscv-newlib/tree/0d24a86822a5ee73d6a6aa69e2a0118aa1e35204)
+from 9 July 2019
+
+GDB was upstreamed and does not require SiFive specific patches,
+so the current build uses
+`git://sourceware.org/git/binutils-gdb.git`, the `9b40759` commit from
+28 Feb 2019.
+
+## Changes
+
+Compared to the original SiFive version, the **same architecture and API**
+options are supported, and there are minimal functional changes
+
+- `libgloss` was removed from the list of libraires always linked to the
+  application, since it issues `ECALL`
+  instructions that fail in bare metal environments
+- `march=rv32imaf/mabi=ilp32f` was added to the list of multilibs
+
+## newlib-nano
+
+Support for **newlib-nano** is available using the
+`--specs=nano.specs` option. For better results, this option must be
+added to both compile and link time.
+
+## nosys.specs
+
+If no syscalls are needed, `--specs=nosys.specs` can be used at link
+time to provide empty implementations for the POSIX system calls.
+
+## Compile options
+
+The libraries are compiled with `-O2 -mcmodel=medany`. The nano version is
+compiled with `-Os -mcmodel=medany`.
+
+> Important: It is mandatory for the applications to be compiled with
+`-mcmodel=medany`, otherwise the link will fail.
+
+## Documentation
+
+The original PDF documentation is available in the `share/doc` folder.
+
+## Support
+
+For support, please read the
+[support](https://xpack.github.io/riscv-none-embed-gcc/support/) page.
+
+## More info
+
+For more info, please see the xPack project site:
+
+  http://xpack.github.io/riscv-none-embed-gcc
+
+
+Thank you for using open source software,
+
+Liviu Ionescu
+

+ 99 - 0
distro-info/scripts/README-8.3.0-1.2.md

@@ -0,0 +1,99 @@
+# xPack GNU RISC-V Embedded GCC
+
+This is the **xPack** version of the
+**GNU RISC-V Embedded GCC** toolchain.
+
+For details, see
+[The xPack GNU RISC-V Embedded GCC](https://xpack.github.io/riscv-none-embed-gcc/) pages.
+
+## Easy install
+
+The **xPack RISC-V Embedded GCC** toolchain is also available as a
+binary [xPack](https://www.npmjs.com/package/@xpack-dev-tools/riscv-none-embed-gcc)
+and can be conveniently installed with [xpm](https://www.npmjs.com/package/xpm):
+
+```console
+$ xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@8.3.0-1.2.1
+```
+
+For more details on how to install the toolchain, please see
+[How to install the RISC-V toolchain?](http://xpack.github.io/toolchain/riscv-bone-embed-gcc/install/) page.
+
+## Compliance
+
+Starting with 8.2.0-2, the xPack GNU RISC-V Embedded GCC (formerly
+GNU MCU Eclipse RISC-V GCC) follows
+the official [SiFive releases](https://github.com/sifive/freedom-tools/releases),
+with as little differences as possible.
+
+This release is based on the
+[v2019.08.0](https://github.com/sifive/freedom-tools/releases/tag/v2019.08.0)
+release, and includes the SiFive extensions (like CLIC interrupts).
+
+The following commits (from [sifive/freedom-tools](https://github.com/sifive/freedom-tools/tree/master/src)) were used:
+
+- the [sifive/riscv-binutils-gdb](https://github.com/sifive/riscv-binutils-gdb)
+project, branch `sifive-binutils-2.32`, commit
+[03d23d5](https://github.com/sifive/riscv-binutils-gdb/tree/03d23d58701bdd425c613b0be2d458bcde46912b)
+from 2 September 2019
+- the [sifive/riscv-gcc](https://github.com/sifive/riscv-gcc) project,
+branch `sifive-gcc-8.3.0`, commit
+[e195042](https://github.com/sifive/riscv-gcc/tree/e195042babe2dc30d9fabb88d336d8c8679b3702)
+from from 7 Aug 2019
+- the [sifive/riscv-newlib](https://github.com/sifive/riscv-newlib) project, the `master` branch,
+commit [0d24a86](https://github.com/sifive/riscv-newlib/tree/0d24a86822a5ee73d6a6aa69e2a0118aa1e35204)
+from 9 July 2019
+
+GDB was upstreamed and does not require SiFive specific patches,
+so the current build uses
+`git://sourceware.org/git/binutils-gdb.git`, the `9b40759` commit from
+28 Feb 2019.
+
+## Changes
+
+Compared to the original SiFive version, the **same architecture and API**
+options are supported, and there are minimal functional changes
+
+- `libgloss` was removed from the list of libraires always linked to the
+  application, since it issues `ECALL`
+  instructions that fail in bare metal environments
+- `march=rv32imaf/mabi=ilp32f` was added to the list of multilibs
+
+## newlib-nano
+
+Support for **newlib-nano** is available using the
+`--specs=nano.specs` option. For better results, this option must be
+added to both compile and link time.
+
+## nosys.specs
+
+If no syscalls are needed, `--specs=nosys.specs` can be used at link
+time to provide empty implementations for the POSIX system calls.
+
+## Compile options
+
+The libraries are compiled with `-O2 -mcmodel=medany`. The nano version is
+compiled with `-Os -mcmodel=medany`.
+
+> Important: It is mandatory for the applications to be compiled with
+`-mcmodel=medany`, otherwise the link will fail.
+
+## Documentation
+
+The original PDF documentation is available in the `share/doc` folder.
+
+## Support
+
+For support, please read the
+[support](https://xpack.github.io/riscv-none-embed-gcc/support/) page.
+
+## More info
+
+For more info, please see the xPack project site:
+
+  http://xpack.github.io/riscv-none-embed-gcc
+
+
+Thank you for using open source software,
+
+Liviu Ionescu

+ 1 - 0
distro-info/scripts/VERSION

@@ -0,0 +1 @@
+8.3.0-1.2

+ 270 - 0
distro-info/scripts/build.sh

@@ -0,0 +1,270 @@
+#!/usr/bin/env bash
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2019 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
+# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
+
+if [[ ! -z ${DEBUG} ]]
+then
+  set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
+else
+  DEBUG=""
+fi
+
+set -o errexit # Exit if command failed.
+set -o pipefail # Exit if pipe failed.
+set -o nounset # Exit if variable not set.
+
+# Remove the initial space and instead use '\n'.
+IFS=$'\n\t'
+
+# -----------------------------------------------------------------------------
+# Identify the script location, to reach, for example, the helper scripts.
+
+build_script_path="$0"
+if [[ "${build_script_path}" != /* ]]
+then
+  # Make relative path absolute.
+  build_script_path="$(pwd)/$0"
+fi
+
+script_folder_path="$(dirname "${build_script_path}")"
+script_folder_name="$(basename "${script_folder_path}")"
+
+# =============================================================================
+
+# Script to build the xPack GNU RISC-V Embeded GCC distribution packages.
+#
+# Developed on macOS 10.13 High Sierra, but intended to run on
+# macOS 10.10 Yosemite and CentOS 6 XBB. 
+
+# -----------------------------------------------------------------------------
+
+echo
+echo "xPack GNU RISC-V Embedded GCC distribution build script."
+
+host_functions_script_path="${script_folder_path}/helper/host-functions-source.sh"
+source "${host_functions_script_path}"
+
+common_functions_script_path="${script_folder_path}/common-functions-source.sh"
+source "${common_functions_script_path}"
+
+defines_script_path="${script_folder_path}/defs-source.sh"
+source "${defines_script_path}"
+
+host_detect
+
+# For clarity, explicitly define the docker images here.
+docker_linux64_image=${docker_linux64_image:-"ilegeul/ubuntu:amd64-12.04-xbb-v3.2"}
+docker_linux32_image=${docker_linux32_image:-"ilegeul/ubuntu:i386-12.04-xbb-v3.2"}
+docker_linux_arm64_image=${docker_linux_arm64_image:-"ilegeul/ubuntu:arm64v8-16.04-xbb-v3.2"}
+docker_linux_arm32_image=${docker_linux_arm32_image:-"ilegeul/ubuntu:arm32v7-16.04-xbb-v3.2"}
+
+# -----------------------------------------------------------------------------
+
+# Array where the remaining args will be stored.
+declare -a rest
+
+help_message="    bash $0 [--win32] [--win64] [--linux32] [--linux64] [--arm32] [--arm64] [--osx] [--all] [clean|cleanlibs|cleanall|preload-images] [--env-file file] [--disable-strip] [--without-pdf] [--with-html] [--disable-multilib] [--develop] [--debug] [--use-gits] [--jobs N] [--help]"
+host_options "${help_message}" "$@"
+
+# Intentionally moved after option parsing.
+echo
+echo "Host helper functions source script: \"${host_functions_script_path}\"."
+echo "Common functions source script: \"${common_functions_script_path}\"."
+echo "Definitions source script: \"${defines_script_path}\"."
+
+host_common
+
+# -----------------------------------------------------------------------------
+
+if [ -n "${DO_BUILD_WIN32}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX64}" ]
+then
+  host_prepare_docker
+fi
+
+# ----- Build the native distribution. ----------------------------------------
+
+if [ -z "${DO_BUILD_OSX}${DO_BUILD_LINUX64}${DO_BUILD_LINUX_ARM64}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX_ARM32}${DO_BUILD_WIN32}" ]
+then
+
+  host_build_target "Creating the native distribution..." \
+    --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+    --env-file "${ENV_FILE}" \
+    -- \
+    ${rest[@]-}
+
+else
+
+  # ----- Build the OS X distribution. ----------------------------------------
+
+  if [ "${DO_BUILD_OSX}" == "y" ]
+  then
+    if [ "${HOST_UNAME}" == "Darwin" ]
+    then
+      host_build_target "Creating the OS X distribution..." \
+        --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "darwin" \
+        -- \
+        ${rest[@]-}
+    else
+      echo "Building the macOS image is not possible on this platform."
+      exit 1
+    fi
+  fi
+
+  # ----- Build the GNU/Linux 64-bit distribution. ---------------------------
+
+  if [ "${DO_BUILD_LINUX64}" == "y" ]
+  then
+    host_build_target "Creating the GNU/Linux 64-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "linux" \
+      --target-arch "x64" \
+      --target-bits 64 \
+      --docker-image "${docker_linux64_image}" \
+      -- \
+      ${rest[@]-}
+  fi
+
+  # ----- Build the Windows 64-bit distribution. -----------------------------
+
+  if [ "${DO_BUILD_WIN64}" == "y" ]
+  then
+    linux_install_relative_path="linux-x64/install/${APP_LC_NAME}"
+    if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
+    then
+      host_build_target "Creating the GNU/Linux 64-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "x64" \
+        --target-bits 64 \
+        --docker-image "${docker_linux64_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
+    then
+      echo "Mandatory GNU/Linux binaries missing."
+      exit 1
+    fi
+
+    host_build_target "Creating the Windows 64-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "win32" \
+      --target-arch "x64" \
+      --target-bits 64 \
+      --docker-image "${docker_linux64_image}" \
+      -- \
+      --linux-install-path "${linux_install_relative_path}" \
+      ${rest[@]-}
+  fi
+
+  # ----- Build the GNU/Linux 32-bit distribution. ---------------------------
+
+  if [ "${DO_BUILD_LINUX32}" == "y" ]
+  then
+    host_build_target "Creating the GNU/Linux 32-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "linux" \
+      --target-arch "x32" \
+      --target-bits 32 \
+      --docker-image "${docker_linux32_image}" \
+      -- \
+      ${rest[@]-}
+  fi
+
+  # ----- Build the Windows 32-bit distribution. -----------------------------
+
+  # Since the actual container is a 32-bit, use the debian32 binaries.
+  if [ "${DO_BUILD_WIN32}" == "y" ]
+  then
+    linux_install_relative_path="linux-x32/install/${APP_LC_NAME}"
+    if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
+    then
+      host_build_target "Creating the GNU/Linux 32-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "x32" \
+        --target-bits 32 \
+        --docker-image "${docker_linux32_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    if [ ! -f "${HOST_WORK_FOLDER_PATH}/${linux_install_relative_path}/bin/${GCC_TARGET}-gcc" ]
+    then
+      echo "Mandatory GNU/Linux binaries missing."
+      exit 1
+    fi
+
+    host_build_target "Creating the Windows 32-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "win32" \
+      --target-arch "x32" \
+      --target-bits 32 \
+      --docker-image "${docker_linux32_image}" \
+      -- \
+      --linux-install-path "${linux_install_relative_path}" \
+      ${rest[@]-}
+  fi
+
+  # ----- Build the GNU/Linux Arm 64-bit distribution. ---------------------------
+
+  if [ "${DO_BUILD_LINUX_ARM64}" == "y" ]
+  then
+    host_build_target "Creating the GNU/Linux Arm 64-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "linux" \
+      --target-arch "arm64" \
+      --target-bits 64 \
+      --docker-image "${docker_linux_arm64_image}" \
+      -- \
+      ${rest[@]-}
+  fi
+
+  # ----- Build the GNU/Linux Arm 32-bit distribution. ---------------------------
+
+  if [ "${DO_BUILD_LINUX_ARM32}" == "y" ]
+  then
+    host_build_target "Creating the GNU/Linux Arm 32-bit distribution..." \
+      --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      --target-platform "linux" \
+      --target-arch "arm" \
+      --target-bits 32 \
+      --docker-image "${docker_linux_arm32_image}" \
+      -- \
+      ${rest[@]-}
+  fi
+
+fi
+
+host_show_sha
+
+# -----------------------------------------------------------------------------
+
+host_stop_timer
+
+host_notify_completed
+
+# Completed successfully.
+exit 0
+
+# -----------------------------------------------------------------------------

+ 118 - 0
distro-info/scripts/common-functions-source.sh

@@ -0,0 +1,118 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the GNU MCU Eclipse build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the container build scripts.
+
+# -----------------------------------------------------------------------------
+
+function prepare_variables()
+{
+  if [ "${USE_GITS}" != "y" ]
+  then
+
+    # -------------------------------------------------------------------------
+
+    BINUTILS_SRC_FOLDER_NAME=${BINUTILS_SRC_FOLDER_NAME:-"${BINUTILS_PROJECT_NAME}-${BINUTILS_GH_RELEASE}"}
+    BINUTILS_ARCHIVE_NAME=${BINUTILS_ARCHIVE_NAME:-"${BINUTILS_SRC_FOLDER_NAME}.tar.gz"}
+
+    BINUTILS_ARCHIVE_URL=${BINUTILS_ARCHIVE_URL:-"https://github.com/xpack-dev-tools/${BINUTILS_PROJECT_NAME}/archive/v${BINUTILS_GH_RELEASE}.tar.gz"}
+
+    BINUTILS_GIT_URL=""
+
+    # -------------------------------------------------------------------------
+
+    GCC_SRC_FOLDER_NAME=${GCC_SRC_FOLDER_NAME:-"${GCC_PROJECT_NAME}-${GCC_GH_RELEASE}"}
+    GCC_ARCHIVE_NAME=${GCC_ARCHIVE_NAME:-"${GCC_SRC_FOLDER_NAME}.tar.gz"}
+
+    GCC_ARCHIVE_URL=${GCC_ARCHIVE_URL:-"https://github.com/xpack-dev-tools/${GCC_PROJECT_NAME}/archive/v${GCC_GH_RELEASE}.tar.gz"}
+
+    GCC_GIT_URL=""
+
+    # -------------------------------------------------------------------------
+
+    NEWLIB_SRC_FOLDER_NAME=${NEWLIB_SRC_FOLDER_NAME:-"${NEWLIB_PROJECT_NAME}-${NEWLIB_GH_RELEASE}"}
+    NEWLIB_ARCHIVE_NAME=${NEWLIB_ARCHIVE_NAME:-"${NEWLIB_SRC_FOLDER_NAME}.tar.gz"}
+
+    NEWLIB_ARCHIVE_URL=${NEWLIB_ARCHIVE_URL:-"https://github.com/xpack-dev-tools/${NEWLIB_PROJECT_NAME}/archive/v${NEWLIB_GH_RELEASE}.tar.gz"}
+
+    NEWLIB_GIT_URL=""
+
+    # -------------------------------------------------------------------------
+
+    GDB_SRC_FOLDER_NAME=${GDB_SRC_FOLDER_NAME:-"${GDB_PROJECT_NAME}-${GDB_GH_RELEASE}"}
+    GDB_ARCHIVE_NAME=${GDB_ARCHIVE_NAME:-"${GDB_SRC_FOLDER_NAME}.tar.gz"}
+
+    GDB_ARCHIVE_URL=${GDB_ARCHIVE_URL:-"https://github.com/xpack-dev-tools/${GDB_PROJECT_NAME}/archive/v${GDB_GH_RELEASE}.tar.gz"}
+
+    GDB_GIT_URL=""
+
+    # -------------------------------------------------------------------------
+  else
+    # -------------------------------------------------------------------------
+
+    BINUTILS_SRC_FOLDER_NAME=${BINUTILS_SRC_FOLDER_NAME:-"${BINUTILS_PROJECT_NAME}.git"}
+
+    BINUTILS_GIT_URL=${BINUTILS_GIT_URL:-"https://github.com/xpack-dev-tools/${BINUTILS_PROJECT_NAME}.git"}
+
+    BINUTILS_ARCHIVE_URL=""
+
+    # -------------------------------------------------------------------------
+
+    GCC_SRC_FOLDER_NAME=${GCC_SRC_FOLDER_NAME:-"${GCC_PROJECT_NAME}.git"}
+
+    GCC_GIT_URL=${GCC_GIT_URL:-"https://github.com/xpack-dev-tools/${GCC_PROJECT_NAME}.git"}
+
+    GCC_ARCHIVE_URL=""
+
+    # -------------------------------------------------------------------------
+
+    NEWLIB_SRC_FOLDER_NAME=${NEWLIB_SRC_FOLDER_NAME:-"${NEWLIB_PROJECT_NAME}.git"}
+      
+    NEWLIB_GIT_URL=${NEWLIB_GIT_URL:-"https://github.com/xpack-dev-tools/${NEWLIB_PROJECT_NAME}.git"}
+
+    NEWLIB_ARCHIVE_URL=""
+
+    # -------------------------------------------------------------------------
+
+    # Pre 8.x builds define it to reuse the binutils repo.
+    GDB_SRC_FOLDER_NAME=${GDB_SRC_FOLDER_NAME:-"binutils-gdb.git"}
+
+    GDB_GIT_URL=${GDB_GIT_URL:-"https://github.com/xpack-dev-tools/${GDB_PROJECT_NAME}.git"}
+
+    GDB_ARCHIVE_URL=""
+
+    # -------------------------------------------------------------------------
+  fi
+
+  # ---------------------------------------------------------------------------
+
+  BINUTILS_FOLDER_NAME="binutils-${BINUTILS_VERSION}"
+  GCC_FOLDER_NAME="gcc-${GCC_VERSION}"
+  NEWLIB_FOLDER_NAME="newlib-${NEWLIB_VERSION}"
+  GDB_FOLDER_NAME="gdb-${GDB_VERSION}"
+
+}
+
+# -----------------------------------------------------------------------------
+
+function add_linux_install_path()
+{
+  # Verify that the compiler is there.
+  "${WORK_FOLDER_PATH}/${LINUX_INSTALL_PATH}/bin/${GCC_TARGET}-gcc" --version
+
+  export PATH="${WORK_FOLDER_PATH}/${LINUX_INSTALL_PATH}/bin:${PATH}"
+  echo ${PATH}
+
+  export LD_LIBRARY_PATH="${WORK_FOLDER_PATH}/${LINUX_INSTALL_PATH}/bin:${LD_LIBRARY_PATH}"
+  echo ${LD_LIBRARY_PATH}
+}
+
+# -----------------------------------------------------------------------------

+ 484 - 0
distro-info/scripts/common-versions-source.sh

@@ -0,0 +1,484 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the GNU MCU Eclipse build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the container build scripts.
+
+# -----------------------------------------------------------------------------
+
+function build_versions()
+{
+
+  APP_PREFIX_NANO="${INSTALL_FOLDER_PATH}/${APP_LC_NAME}-nano"
+
+  # The \x2C is a comma in hex; without this trick the regular expression
+  # that processes this string in the Makefile, silently fails and the 
+  # bfdver.h file remains empty.
+  BRANDING="${BRANDING}\x2C ${TARGET_BITS}-bit"
+
+  CFLAGS_OPTIMIZATIONS_FOR_TARGET="-ffunction-sections -fdata-sections -O2"
+  # Cannot use medlow with 64 bits, so all must be medany.
+  CFLAGS_OPTIMIZATIONS_FOR_TARGET+=" -mcmodel=medany"
+
+  BINUTILS_PROJECT_NAME="riscv-binutils-gdb"
+  GCC_PROJECT_NAME="riscv-gcc"
+  NEWLIB_PROJECT_NAME="riscv-newlib"
+  GDB_PROJECT_NAME="riscv-binutils-gdb"
+
+  # ---------------------------------------------------------------------------
+  # Defaults. Must be present.
+
+  BINUTILS_PATCH=""
+  GDB_PATCH=""
+
+  WITH_GDB_PY2=""
+  WITH_GDB_PY3=""
+  USE_PLATFORM_PYTHON2=""
+  USE_PLATFORM_PYTHON3=""
+
+  if [ "${WITHOUT_MULTILIB}" == "y" ]
+  then
+    MULTILIB_FLAGS="--disable-multilib"
+  else
+    # By default it searches the definitions in "t-elf-multilib"
+    MULTILIB_FLAGS=""
+  fi
+
+  # ---------------------------------------------------------------------------
+
+  # Redefine to "y" to create the LTO plugin links.
+  FIX_LTO_PLUGIN=""
+  if [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+    LTO_PLUGIN_ORIGINAL_NAME="liblto_plugin.0.so"
+    LTO_PLUGIN_BFD_PATH="lib/bfd-plugins/liblto_plugin.so"
+  elif [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    LTO_PLUGIN_ORIGINAL_NAME="liblto_plugin.so.0.0.0"
+    LTO_PLUGIN_BFD_PATH="lib/bfd-plugins/liblto_plugin.so"
+  elif [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+    LTO_PLUGIN_ORIGINAL_NAME="liblto_plugin-0.dll"
+    LTO_PLUGIN_BFD_PATH="lib/bfd-plugins/liblto_plugin-0.dll"
+  fi
+
+  FIX_LTO_PLUGIN="y"
+
+  # ---------------------------------------------------------------------------
+
+  README_OUT_FILE_NAME="README-${RELEASE_VERSION}.md"
+
+  # In reverse chronological order.
+  # Keep them in sync with https://github.com/sifive/freedom-tools/releases.
+  if [[ "${RELEASE_VERSION}" =~ 8\.3\.0-* ]]
+  then
+    # This is similar to SiFive 2019.08.0 release.
+    # https://github.com/sifive/freedom-tools/releases
+
+    # Binutils 2.32 with SiFive CLIC patches
+    # https://github.com/sifive/riscv-binutils-gdb/tree/03d23d58701bdd425c613b0be2d458bcde46912b
+
+    # GCC 8.3.0 with SiFive CLIC patches
+    # https://github.com/sifive/riscv-gcc/tree/e195042babe2dc30d9fabb88d336d8c8679b3702
+
+    # Newlib 3.1.0 from SiFive branch
+    # https://github.com/sifive/riscv-newlib/tree/0d24a86822a5ee73d6a6aa69e2a0118aa1e35204
+
+    # GDB 8.3 from FSF gdb-8.3-release branch
+    # riscv-gdb @ 9b40759 (11 May 2019)
+    # https://sourceware.org/git/?p=binutils-gdb.git
+    # git://sourceware.org/git/binutils-gdb.git
+
+
+    # -------------------------------------------------------------------------
+
+    # Inspired from SiFive
+    # MULTILIBS_GEN :=            rv32e-ilp32e--c rv32em-ilp32e--c rv32eac-ilp32e-- rv32emac-ilp32e-- rv32i-ilp32--c rv32im-ilp32--c rv32imf-ilp32f--c rv32iac-ilp32-- rv32imac-ilp32-- rv32imafc-ilp32f-rv32imafdc- rv32imafdc-ilp32d-- rv64i-lp64--c rv64im-lp64--c rv64imf-lp64f--c rv64iac-lp64-- rv64imac-lp64-- rv64imafc-lp64f-rv64imafdc- rv64imafdc-lp64d--
+
+    # Minimal list, for tests only. Pass it via the environment.
+    # GCC_MULTILIB=${GCC_MULTILIB:-"rv32imac-ilp32-- rv64imac-lp64--"}
+
+    # New extended list, based on SiFive list.
+    # Added: rv32imaf-ilp32f--
+    GCC_MULTILIB=${GCC_MULTILIB:-"\
+    rv32e-ilp32e--c \
+    rv32ea-ilp32e--m \
+    rv32em-ilp32e--c \
+    rv32eac-ilp32e-- \
+    rv32emac-ilp32e-- \
+    rv32i-ilp32--c \
+    rv32ia-ilp32--m \
+    rv32im-ilp32--c \
+    rv32if-ilp32f-rv32ifd-c \
+    rv32iaf-ilp32f-rv32imaf,rv32iafc-d \
+    rv32imf-ilp32f-rv32imfd-c \
+    rv32imaf-ilp32f-- \
+    rv32iac-ilp32-- \
+    rv32imac-ilp32-- \
+    rv32imafc-ilp32f-rv32imafdc- \
+    rv32ifd-ilp32d--c \
+    rv32imfd-ilp32d--c \
+    rv32iafd-ilp32d-rv32imafd,rv32iafdc- \
+    rv32imafdc-ilp32d-- \
+    rv64i-lp64--c \
+    rv64ia-lp64--m \
+    rv64im-lp64--c \
+    rv64if-lp64f-rv64ifd-c \
+    rv64iaf-lp64f-rv64iafc-d \
+    rv64imf-lp64f-rv64imfd-c \
+    rv64imaf-lp64f-- \
+    rv64iac-lp64-- \
+    rv64imac-lp64-- \
+    rv64imafc-lp64f-rv64imafdc- \
+    rv64ifd-lp64d--m,c \
+    rv64iafd-lp64d-rv64imafd,rv64iafdc- \
+    rv64imafdc-lp64d-- \
+    "}
+
+    GCC_MULTILIB_FILE=${GCC_MULTILIB_FILE:-"t-elf-multilib"}
+
+    # -------------------------------------------------------------------------
+
+    BINUTILS_VERSION="2.32"
+    # From gcc/BASE_VER
+    GCC_VERSION="8.3.0"
+    # From newlib/configure, VERSION=
+    NEWLIB_VERSION="3.1.0"
+    # From gdb/VERSION.in
+    GDB_VERSION="8.3"
+
+    # -------------------------------------------------------------------------
+
+    if [ "${USE_GITS}" != "y" ]
+    then
+
+      # Be sure there is no `v`, it is added in the URL.
+      GH_RELEASE="8.3.0-1.1"
+      BINUTILS_GH_RELEASE=${BINUTILS_GH_RELEASE:-"${GH_RELEASE}"}
+      GCC_GH_RELEASE=${GCC_GH_RELEASE:-"${GH_RELEASE}"}
+      NEWLIB_GH_RELEASE=${NEWLIB_GH_RELEASE:-"${GH_RELEASE}"}
+      # Same, with a `-gdb` suffix added.
+      GDB_GH_RELEASE=${GDB_GH_RELEASE:-"${GH_RELEASE}-gdb"}
+
+    else
+
+      BINUTILS_GIT_BRANCH=${BINUTILS_GIT_BRANCH:-"sifive-binutils-2.32-xpack"}
+      # 16 April 2019
+      BINUTILS_GIT_COMMIT=${BINUTILS_GIT_COMMIT:-"03d23d58701bdd425c613b0be2d458bcde46912b"}
+
+      GCC_GIT_BRANCH=${GCC_GIT_BRANCH:-"sifive-gcc-8.3.0-xpack"}
+      GCC_GIT_COMMIT=${GCC_GIT_COMMIT:-"e195042babe2dc30d9fabb88d336d8c8679b3702"}
+
+      NEWLIB_GIT_BRANCH=${NEWLIB_GIT_BRANCH:-"sifive-master-xpack"}
+      NEWLIB_GIT_COMMIT=${NEWLIB_GIT_COMMIT:-"0d24a86822a5ee73d6a6aa69e2a0118aa1e35204"}
+
+      GDB_SRC_FOLDER_NAME=${GDB_SRC_FOLDER_NAME:-"binutils-gdb.git"}
+      GDB_GIT_BRANCH=${GDB_GIT_BRANCH:-"sifive-gdb-8.3-xpack"}
+      GDB_GIT_COMMIT=${GDB_GIT_COMMIT:-"9b8cecd18313807ac0cc4d2b1871603279b94244"}
+
+    fi
+    
+    # -------------------------------------------------------------------------
+
+    ZLIB_VERSION="1.2.8"
+    GMP_VERSION="6.1.2"
+    MPFR_VERSION="3.1.6"
+    MPC_VERSION="1.0.3"
+    ISL_VERSION="0.18"
+    LIBELF_VERSION="0.8.13"
+    EXPAT_VERSION="2.2.5"
+    LIBICONV_VERSION="1.15"
+    XZ_VERSION="5.2.3"
+
+    # -------------------------------------------------------------------------
+
+    if [ "${RELEASE_VERSION}" == "8.3.0-1.1" ]
+    then
+
+      PYTHON2_WIN_VERSION="2.7.13"
+
+      if [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        USE_PLATFORM_PYTHON2="y"
+      fi
+
+      WITH_GDB_PY2="y"
+
+    elif [ "${RELEASE_VERSION}" == "8.3.0-1.2" ]
+    then
+
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        # On Windows if fails with 
+        # "The procedure entry point ClearCommBreak could not be located
+        # in the dynamic link library." 
+        # It looks like an incompatibility between Python2 and mingw-w64.
+        # Given that Python2 is end-of-life, it is not worth to further
+        # investigate, disable it for now.
+        WITH_GDB_PY2=""
+      elif [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        # ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/operator.so, 2): Symbol not found: __PyUnicodeUCS2_AsDefaultEncodedString
+        #  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/operator.so
+        #  Expected in: flat namespace
+        # in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/operator.so
+        WITH_GDB_PY2=""
+      else
+        WITH_GDB_PY2="y"
+      fi
+
+      PYTHON2_WIN_VERSION="2.7.18"
+
+      WITH_GDB_PY3="y" 
+      PYTHON3_WIN_VERSION="3.7.6"
+
+    else
+      echo "Unsupported version ${RELEASE_VERSION}."
+      exit 1
+    fi
+
+    BINUTILS_PATCH="binutils-gdb-${BINUTILS_VERSION}.patch"
+    GDB_PATCH="binutils-gdb-${BINUTILS_VERSION}.patch"
+
+    # -------------------------------------------------------------------------
+  elif [[ "${RELEASE_VERSION}" =~ 8\.2\.0-3\.* ]]
+  then
+    # This is similar to SiFive 2019.05.0 release.
+    # https://github.com/sifive/freedom-tools/releases
+
+    # Binutils 2.32 with SiFive CLIC patches
+    # https://github.com/sifive/riscv-binutils-gdb/tree/164267155c96f91472a539ca78ac919993bc5b4e
+
+    # GCC 8.2.0 with SiFive CLIC patches
+    # https://github.com/sifive/riscv-gcc/tree/242abcaff697d0a1ea12dccc975465e1bfeb8331
+
+    # GDB 8.3 from FSF gdb-8.3-release branch
+    # riscv-gdb @ 9b40759 (11 May 2019)
+    # https://sourceware.org/git/?p=binutils-gdb.git
+    # git://sourceware.org/git/binutils-gdb.git
+
+    # Newlib 3.0.0 from SiFive branch
+    # https://github.com/sifive/riscv-newlib/tree/42c2e3fb9f557d59b76d1a64bb6fb32707ff4530
+
+    # -------------------------------------------------------------------------
+
+    # Inspired from SiFive
+    # MULTILIBS_GEN :=            rv32e-ilp32e--c rv32em-ilp32e--c rv32eac-ilp32e-- rv32emac-ilp32e-- rv32i-ilp32--c rv32im-ilp32--c rv32imf-ilp32f--c rv32iac-ilp32-- rv32imac-ilp32-- rv32imafc-ilp32f-rv32imafdc- rv32imafdc-ilp32d-- rv64i-lp64--c rv64im-lp64--c rv64imf-lp64f--c rv64iac-lp64-- rv64imac-lp64-- rv64imafc-lp64f-rv64imafdc- rv64imafdc-lp64d--
+
+    # Minimal list, for tests only. Pass it via the environment.
+    # GCC_MULTILIB=${GCC_MULTILIB:-"rv32imac-ilp32-- rv64imac-lp64--"}
+
+    # New extended list, based on SiFive list.
+    # Added: rv32imaf-ilp32f--
+    GCC_MULTILIB=${GCC_MULTILIB:-"rv32e-ilp32e--c rv32em-ilp32e--c rv32eac-ilp32e-- rv32emac-ilp32e-- rv32i-ilp32--c rv32im-ilp32--c rv32imf-ilp32f--c rv32imaf-ilp32f-- rv32iac-ilp32-- rv32imac-ilp32-- rv32imafc-ilp32f-rv32imafdc- rv32imafdc-ilp32d-- rv64i-lp64--c rv64im-lp64--c rv64imf-lp64f--c rv64iac-lp64-- rv64imac-lp64-- rv64imafc-lp64f-rv64imafdc- rv64imafdc-lp64d--"}
+
+    GCC_MULTILIB_FILE=${GCC_MULTILIB_FILE:-"t-elf-multilib"}
+
+    # -------------------------------------------------------------------------
+
+    BINUTILS_VERSION="2.32"
+    # From gcc/BASE_VER
+    GCC_VERSION="8.2.0"
+    # From newlib/configure, VERSION=
+    NEWLIB_VERSION="3.0.0"
+    # From gdb/VERSION.in
+    GDB_VERSION="8.3"
+
+    # -------------------------------------------------------------------------
+
+    if [ "${USE_GITS}" != "y" ]
+    then
+
+      # Be sure there is no `v`, it is added in the URL.
+      GH_RELEASE="8.2.0-3.1"
+      BINUTILS_GH_RELEASE=${BINUTILS_GH_RELEASE:-"${GH_RELEASE}"}
+      GCC_GH_RELEASE=${GCC_GH_RELEASE:-"${GH_RELEASE}"}
+      NEWLIB_GH_RELEASE=${NEWLIB_GH_RELEASE:-"${GH_RELEASE}"}
+      # Same, with a `-gdb` suffix added.
+      GDB_GH_RELEASE=${GDB_GH_RELEASE:-"${GH_RELEASE}-gdb"}
+
+    else
+
+      BINUTILS_GIT_BRANCH=${BINUTILS_GIT_BRANCH:-"sifive-binutils-2.32-xpack"}
+      # 16 April 2019
+      BINUTILS_GIT_COMMIT=${BINUTILS_GIT_COMMIT:-"82b51c7b5087ddb77988287cd7a2dd8921331bfd"}
+
+      GCC_GIT_BRANCH=${GCC_GIT_BRANCH:-"sifive-gcc-8.2.0-xpack"}
+      GCC_GIT_COMMIT=${GCC_GIT_COMMIT:-"0c7a874f0b6f452eeafde57731646e5f460187e4"}
+
+      NEWLIB_GIT_BRANCH=${NEWLIB_GIT_BRANCH:-"sifive-newlib-3.0.0-xpack"}
+      NEWLIB_GIT_COMMIT=${NEWLIB_GIT_COMMIT:-"1975c561730cbd4b93c491eaadeb6c3b01a89447"}
+
+      GDB_SRC_FOLDER_NAME=${GDB_SRC_FOLDER_NAME:-"binutils-gdb.git"}
+      GDB_GIT_BRANCH=${GDB_GIT_BRANCH:-"sifive-gdb-8.3-xpack"}
+      GDB_GIT_COMMIT=${GDB_GIT_COMMIT:-"9b8cecd18313807ac0cc4d2b1871603279b94244"}
+
+    fi
+    
+    # -------------------------------------------------------------------------
+
+    ZLIB_VERSION="1.2.8"
+    GMP_VERSION="6.1.2"
+    MPFR_VERSION="3.1.6"
+    MPC_VERSION="1.0.3"
+    ISL_VERSION="0.18"
+    LIBELF_VERSION="0.8.13"
+    EXPAT_VERSION="2.2.5"
+    LIBICONV_VERSION="1.15"
+    XZ_VERSION="5.2.3"
+
+    WITH_GDB_PY2="y"
+    PYTHON2_WIN_VERSION="2.7.13"
+
+    BINUTILS_PATCH="binutils-gdb-${BINUTILS_VERSION}.patch"
+    GDB_PATCH="binutils-gdb-${BINUTILS_VERSION}.patch"
+
+    # -------------------------------------------------------------------------
+  else
+    echo "Unsupported version ${RELEASE_VERSION}."
+    exit 1
+  fi
+
+  prepare_variables
+
+  # ---------------------------------------------------------------------------
+  # Build dependent libraries.
+
+  # For better control, without it some components pick the lib packed 
+  # inside the archive.
+  build_zlib "${ZLIB_VERSION}"
+
+  # The classical GCC libraries.
+  build_gmp "${GMP_VERSION}"
+  build_mpfr "${MPFR_VERSION}"
+  build_mpc "${MPC_VERSION}"
+  build_isl "${ISL_VERSION}"
+
+  # More libraries.
+  # Fails on mingw
+  ## do_libelf
+  build_expat "${EXPAT_VERSION}"
+  build_libiconv "${LIBICONV_VERSION}"
+  build_xz "${XZ_VERSION}"
+
+  build_gettext "0.19.8.1"
+
+  if [ "${TARGET_PLATFORM}" != "win32" ]
+  then
+    # Used by ncurses. Fails on macOS.
+    if [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+      build_gpm "1.20.7"
+    fi
+
+    build_ncurses "6.2"
+  fi
+
+  # ---------------------------------------------------------------------------
+
+  # The task descriptions are from the ARM build script.
+
+  # Task [III-0] /$HOST_NATIVE/binutils/
+  # Task [IV-1] /$HOST_MINGW/binutils/
+  build_binutils
+  # copy_dir to libs included above
+
+  if [ "${TARGET_PLATFORM}" != "win32" ]
+  then
+
+    # Task [III-1] /$HOST_NATIVE/gcc-first/
+    build_gcc_first
+
+    # Task [III-2] /$HOST_NATIVE/newlib/
+    build_newlib ""
+    # Task [III-3] /$HOST_NATIVE/newlib-nano/
+    build_newlib "-nano"
+
+    # Task [III-4] /$HOST_NATIVE/gcc-final/
+    build_gcc_final ""
+
+    # Task [III-5] /$HOST_NATIVE/gcc-size-libstdcxx/
+    build_gcc_final "-nano"
+
+  else
+
+    # Task [IV-2] /$HOST_MINGW/copy_libs/
+    copy_linux_libs
+
+    # Task [IV-3] /$HOST_MINGW/gcc-final/
+    build_gcc_final ""
+
+  fi
+
+  # Task [III-6] /$HOST_NATIVE/gdb/
+  # Task [IV-4] /$HOST_MINGW/gdb/
+  build_gdb ""
+
+  if [ "${WITH_GDB_PY2}" == "y" ]
+  then
+    # The Windows GDB needs some headers from the Python distribution.
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      download_python2_win "${PYTHON2_WIN_VERSION}"
+    fi
+
+    build_gdb "-py"
+  fi
+
+  if [ "${WITH_GDB_PY3}" == "y" ]
+  then
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      download_python3_win "${PYTHON3_WIN_VERSION}"
+    fi
+
+    build_gdb "-py3"
+  fi
+
+  # Task [III-7] /$HOST_NATIVE/build-manual
+  # Nope, the build process is different.
+
+  # ---------------------------------------------------------------------------
+
+  # Task [III-8] /$HOST_NATIVE/pretidy/
+  # Task [IV-5] /$HOST_MINGW/pretidy/
+  tidy_up
+
+  # Task [III-9] /$HOST_NATIVE/strip_host_objects/
+  # Task [IV-6] /$HOST_MINGW/strip_host_objects/
+  if [ "${WITH_STRIP}" == "y" ]
+  then
+    strip_binaries
+  fi
+
+  # Must be done after gcc 2 make install, otherwise some wrong links
+  # are created in libexec.
+  # Must also be done after strip binaries, since strip after patchelf
+  # damages the binaries.
+  prepare_app_folder_libraries
+
+  if [ "${WITH_STRIP}" == "y" -a "${TARGET_PLATFORM}" != "win32" ]
+  then
+    # Task [III-10] /$HOST_NATIVE/strip_target_objects/
+    strip_libs
+  fi
+
+  final_tunings
+
+  # Task [IV-7] /$HOST_MINGW/installation/
+  # Nope, no setup.exe.
+
+  # Task [III-11] /$HOST_NATIVE/package_tbz2/
+  # Task [IV-8] /Package toolchain in zip format/
+
+  check_binaries
+}
+
+# -----------------------------------------------------------------------------

+ 1654 - 0
distro-info/scripts/container-apps-functions-source.sh

@@ -0,0 +1,1654 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2019 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the container build scripts.
+
+# -----------------------------------------------------------------------------
+
+function download_binutils() 
+{
+  if [ ! -d "${SOURCES_FOLDER_PATH}/${BINUTILS_SRC_FOLDER_NAME}" ]
+  then
+    (
+      cd "${SOURCES_FOLDER_PATH}"
+      if [ -n "${BINUTILS_GIT_URL}" ]
+      then
+        git_clone "${BINUTILS_GIT_URL}" "${BINUTILS_GIT_BRANCH}" \
+          "${BINUTILS_GIT_COMMIT}" "${BINUTILS_SRC_FOLDER_NAME}"
+        cd "${BINUTILS_SRC_FOLDER_NAME}"
+        do_patch "${BINUTILS_PATCH}"
+      elif [ -n "${BINUTILS_ARCHIVE_URL}" ]
+      then
+        download_and_extract "${BINUTILS_ARCHIVE_URL}" \
+          "${BINUTILS_ARCHIVE_NAME}" "${BINUTILS_SRC_FOLDER_NAME}" \
+          "${BINUTILS_PATCH}"
+      fi
+    )
+  fi
+}
+
+function download_gcc() 
+{
+  if [ ! -d "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}" ]
+  then
+    (
+      cd "${SOURCES_FOLDER_PATH}"
+      if [ -n "${GCC_GIT_URL}" ]
+      then
+        git_clone "${GCC_GIT_URL}" "${GCC_GIT_BRANCH}" \
+          "${GCC_GIT_COMMIT}" "${GCC_SRC_FOLDER_NAME}"
+      elif [ -n "${GCC_ARCHIVE_URL}" ]
+      then
+        download_and_extract "${GCC_ARCHIVE_URL}" \
+          "${GCC_ARCHIVE_NAME}" "${GCC_SRC_FOLDER_NAME}"
+      fi
+    )
+  fi
+}
+
+function download_newlib() 
+{
+  if [ ! -d "${SOURCES_FOLDER_PATH}/${NEWLIB_SRC_FOLDER_NAME}" ]
+  then
+    (
+      cd "${SOURCES_FOLDER_PATH}"
+      if [ -n "${NEWLIB_GIT_URL}" ]
+      then
+        git_clone "${NEWLIB_GIT_URL}" "${NEWLIB_GIT_BRANCH}" \
+          "${NEWLIB_GIT_COMMIT}" "${NEWLIB_SRC_FOLDER_NAME}"
+      elif [ -n "${NEWLIB_ARCHIVE_URL}" ]
+      then
+        download_and_extract "${NEWLIB_ARCHIVE_URL}" \
+          "${NEWLIB_ARCHIVE_NAME}" "${NEWLIB_SRC_FOLDER_NAME}" 
+      fi
+    )
+  fi
+}
+
+function download_gdb() 
+{
+  # Same package as binutils.
+  if [ ! -d "${SOURCES_FOLDER_PATH}/${GDB_SRC_FOLDER_NAME}" ]
+  then
+    (
+      cd "${SOURCES_FOLDER_PATH}"
+      if [ -n "${GDB_GIT_URL}" ]
+      then
+        git_clone "${GDB_GIT_URL}" "${GDB_GIT_BRANCH}" \
+          "${GDB_GIT_COMMIT}" "${GDB_SRC_FOLDER_NAME}"
+        cd "${GDB_SRC_FOLDER_NAME}"
+        do_patch "${GDB_PATCH}"
+      elif [ -n "${GDB_ARCHIVE_URL}" ]
+      then
+        download_and_extract "${GDB_ARCHIVE_URL}" \
+          "${GDB_ARCHIVE_NAME}" "${GDB_SRC_FOLDER_NAME}" \
+          "${GDB_PATCH}"
+      fi
+    )
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_binutils()
+{
+  # https://ftp.gnu.org/gnu/binutils/
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=binutils-git
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gdb-git
+
+  local binutils_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${BINUTILS_FOLDER_NAME}-installed"
+
+  if [ ! -f "${binutils_stamp_file_path}" ]
+  then
+
+    download_binutils
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}"
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}"
+      cd "${BUILD_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+
+      LDFLAGS="${XBB_LDFLAGS_APP}" 
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        LDFLAGS+=" -Wl,${XBB_FOLDER_PATH}/mingw/lib/CRT_glob.o"
+      fi
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then
+        (
+          echo
+          echo "Running binutils configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${BINUTILS_SRC_FOLDER_NAME}/configure" --help
+
+          # ? --without-python --without-curses, --with-expat
+          # Note that GDB is disabled here, will be build later, possibly from 
+          # different sources.
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${BINUTILS_SRC_FOLDER_NAME}/configure" \
+            --prefix="${APP_PREFIX}" \
+            --infodir="${APP_PREFIX_DOC}/info" \
+            --mandir="${APP_PREFIX_DOC}/man" \
+            --htmldir="${APP_PREFIX_DOC}/html" \
+            --pdfdir="${APP_PREFIX_DOC}/pdf" \
+            \
+            --build=${BUILD} \
+            --host=${HOST} \
+            --target=${GCC_TARGET} \
+            \
+            --with-pkgversion="${BRANDING}" \
+            --with-bugurl="${BUGURL}" \
+            \
+            --disable-nls \
+            --disable-werror \
+            --disable-sim \
+            --disable-gdb \
+            --enable-interwork \
+            --enable-plugins \
+            --disable-libdecnumber \
+            --disable-libreadline \
+            --with-sysroot="${APP_PREFIX}/${GCC_TARGET}" \
+            \
+            --enable-build-warnings=no \
+            --disable-rpath \
+            --with-system-zlib \
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running binutils make..."
+      
+        # Build.
+        run_verbose make -j ${JOBS} 
+
+        if false # [ "${WITH_STRIP}" == "y" ]
+        then
+          # For -strip, readline needs a patch.
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+        (
+          xbb_activate_tex
+
+          if [ "${WITH_PDF}" == "y" ]
+          then
+            run_verbose make pdf
+            run_verbose make install-pdf
+          fi
+
+          if [ "${WITH_HTML}" == "y" ]
+          then
+            run_verbose make html
+            run_verbose make install-html
+          fi
+        )
+
+        # Without this copy, the build for the nano version of the GCC second 
+        # step fails with unexpected errors, like "cannot compute suffix of 
+        # object files: cannot compile".
+        copy_dir "${APP_PREFIX}" "${APP_PREFIX_NANO}"
+
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ar"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-as"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ld"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-nm"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-objcopy"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-objdump"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ranlib"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-size"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-strings"
+        show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-strip"
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${BINUTILS_FOLDER_NAME}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${BINUTILS_SRC_FOLDER_NAME}" \
+        "${BINUTILS_FOLDER_NAME}"
+
+    )
+
+    touch "${binutils_stamp_file_path}"
+  else
+    echo "Component binutils already installed."
+  fi
+
+  tests_add "test_binutils"
+}
+
+function test_binutils()
+{
+  (
+    xbb_activate_installed_bin
+
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ar"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-as"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ld"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-nm"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-objcopy"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-objdump"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-ranlib"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-size"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-strings"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-strip"
+
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-ar" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-as" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-ld" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-nm" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-objcopy" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-objdump" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-ranlib" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-size" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-strings" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-strip" --version
+
+  )
+}
+
+function build_gcc_first()
+{
+  local gcc_first_folder_name="${GCC_FOLDER_NAME}-first"
+  local gcc_first_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${gcc_first_folder_name}-installed"
+
+  if [ ! -f "${gcc_first_stamp_file_path}" ]
+  then
+
+    download_gcc
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gcc_first_folder_name}"
+
+    if [ -n "${GCC_MULTILIB}" ]
+    then
+      (
+        echo
+        echo "Running the multilib generator..."
+
+        cd "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/gcc/config/riscv"
+
+        xbb_activate
+        xbb_activate_installed_dev
+
+        # Be sure the ${GCC_MULTILIB} has no quotes, since it defines 
+        # multiple strings.
+
+        # Change IFS temporarily so that we can pass a simple string of
+        # whitespace delimited multilib tokens to multilib-generator
+        local IFS=$' '
+        ./multilib-generator ${GCC_MULTILIB} > "${GCC_MULTILIB_FILE}"
+        cat "${GCC_MULTILIB_FILE}"
+      )
+    fi
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${gcc_first_folder_name}"
+      cd "${BUILD_FOLDER_PATH}/${gcc_first_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_APP}" 
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      CFLAGS_FOR_TARGET="${CFLAGS_OPTIMIZATIONS_FOR_TARGET}" 
+      CXXFLAGS_FOR_TARGET="${CFLAGS_OPTIMIZATIONS_FOR_TARGET}" 
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      export CFLAGS_FOR_TARGET 
+      export CXXFLAGS_FOR_TARGET
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then
+        (
+          echo
+          echo "Running gcc first stage configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/configure" --help
+
+          # https://gcc.gnu.org/install/configure.html
+          # --enable-shared[=package[,…]] build shared versions of libraries
+          # --enable-tls specify that the target supports TLS (Thread Local Storage). 
+          # --enable-nls enables Native Language Support (NLS)
+          # --enable-checking=list the compiler is built to perform internal consistency checks of the requested complexity. ‘yes’ (most common checks)
+          # --with-headers=dir specify that target headers are available when building a cross compiler
+          # --with-newlib Specifies that ‘newlib’ is being used as the target C library. This causes `__eprintf`` to be omitted from `libgcc.a`` on the assumption that it will be provided by newlib.
+          # --enable-languages=c newlib does not use C++, so C should be enough
+
+          # --enable-checking=no ???
+
+          # --with-native-system-header-dir="/include" \
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/configure" \
+            --prefix="${APP_PREFIX}"  \
+            --infodir="${APP_PREFIX_DOC}/info" \
+            --mandir="${APP_PREFIX_DOC}/man" \
+            --htmldir="${APP_PREFIX_DOC}/html" \
+            --pdfdir="${APP_PREFIX_DOC}/pdf" \
+            \
+            --build=${BUILD} \
+            --host=${HOST} \
+            --target=${GCC_TARGET} \
+            \
+            --with-pkgversion="${BRANDING}" \
+            --with-bugurl="${BUGURL}" \
+            \
+            --enable-languages=c \
+            --enable-lto \
+            --disable-decimal-float \
+            --disable-libffi \
+            --disable-libgomp \
+            --disable-libmudflap \
+            --disable-libquadmath \
+            --disable-libssp \
+            --disable-libstdcxx-pch \
+            --disable-nls \
+            --disable-threads \
+            --disable-tls \
+            --enable-checking=yes \
+            --with-newlib \
+            --without-headers \
+            --with-gnu-as \
+            --with-gnu-ld \
+            --with-python-dir=share/gcc-${GCC_TARGET} \
+            --with-sysroot="${APP_PREFIX}/${GCC_TARGET}" \
+            \
+            ${MULTILIB_FLAGS} \
+            --with-abi="${GCC_ABI}" \
+            --with-arch="${GCC_ARCH}" \
+            \
+            --disable-rpath \
+            --disable-build-format-warnings \
+            --with-system-zlib 
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gcc_first_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gcc_first_folder_name}/configure-output.txt"
+      fi
+
+      (
+        # Partial build, without documentation.
+        echo
+        echo "Running gcc first stage make..."
+
+        # Build.
+        # No need to make 'all', 'all-gcc' is enough to compile the libraries.
+        run_verbose make -j ${JOBS} all-gcc
+        
+        # No -strip available here.
+        run_verbose make install-gcc
+
+        # Strip?
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gcc_first_folder_name}/make-output.txt"
+    )
+
+    touch "${gcc_first_stamp_file_path}"
+  else
+    echo "Component gcc first stage already installed."
+  fi
+}
+
+# For the nano build, call it with "-nano".
+# $1="" or $1="-nano"
+function build_newlib()
+{
+  local newlib_folder_name="${NEWLIB_FOLDER_NAME}$1"
+  local newlib_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${newlib_folder_name}-installed"
+
+  if [ ! -f "${newlib_stamp_file_path}" ]
+  then
+
+    download_newlib
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${newlib_folder_name}"
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${newlib_folder_name}"
+      cd "${BUILD_FOLDER_PATH}/${newlib_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      # Add the gcc first stage binaries to the path.
+      PATH="${APP_PREFIX}/bin:${PATH}"
+
+      local optimize="${CFLAGS_OPTIMIZATIONS_FOR_TARGET}"
+      if [ "$1" == "-nano" ]
+      then
+        # For newlib-nano optimize for size.
+        optimize="$(echo ${optimize} | sed -e 's/-O[123]/-Os/')"
+      fi
+
+      CPPFLAGS="${XBB_CPPFLAGS}" 
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+
+      # Note the intentional `-g`.
+      CFLAGS_FOR_TARGET="${optimize} -g" 
+      CXXFLAGS_FOR_TARGET="${optimize} -g" 
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+
+      export CFLAGS_FOR_TARGET
+      export CXXFLAGS_FOR_TARGET
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then
+        (
+          # --disable-nls do not use Native Language Support
+          # --enable-newlib-io-long-double   enable long double type support in IO functions printf/scanf
+          # --enable-newlib-io-long-long   enable long long type support in IO functions like printf/scanf
+          # --enable-newlib-io-c99-formats   enable C99 support in IO functions like printf/scanf
+          # --enable-newlib-register-fini   enable finalization function registration using atexit
+          # --disable-newlib-supplied-syscalls disable newlib from supplying syscalls (__NO_SYSCALLS__)
+
+          # --disable-newlib-fvwrite-in-streamio    disable iov in streamio
+          # --disable-newlib-fseek-optimization    disable fseek optimization
+          # --disable-newlib-wide-orient    Turn off wide orientation in streamio
+          # --disable-newlib-unbuf-stream-opt    disable unbuffered stream optimization in streamio
+          # --enable-newlib-nano-malloc    use small-footprint nano-malloc implementation
+          # --enable-lite-exit	enable light weight exit
+          # --enable-newlib-global-atexit	enable atexit data structure as global
+          # --enable-newlib-nano-formatted-io    Use nano version formatted IO
+          # --enable-newlib-reent-small
+
+          # --enable-newlib-retargetable-locking ???
+
+          echo
+          echo "Running newlib$1 configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${NEWLIB_SRC_FOLDER_NAME}/configure" --help
+
+          # I still did not figure out how to define a variable with
+          # the list of options, such that it can be extended, so the
+          # brute force approach is to duplicate the entire call.
+
+          if [ "$1" == "" ]
+          then
+
+            # Extra options to ARM distribution:
+            # --enable-newlib-io-long-long
+            # --enable-newlib-io-c99-formats
+            # --enable-newlib-reent-check-verify
+            run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${NEWLIB_SRC_FOLDER_NAME}/configure" \
+              --prefix="${APP_PREFIX}"  \
+              --infodir="${APP_PREFIX_DOC}/info" \
+              --mandir="${APP_PREFIX_DOC}/man" \
+              --htmldir="${APP_PREFIX_DOC}/html" \
+              --pdfdir="${APP_PREFIX_DOC}/pdf" \
+              \
+              --build=${BUILD} \
+              --host=${HOST} \
+              --target="${GCC_TARGET}" \
+              \
+              --enable-newlib-io-long-double \
+              --enable-newlib-register-fini \
+              --enable-newlib-retargetable-locking \
+              --disable-newlib-supplied-syscalls \
+              --disable-nls \
+              \
+              --enable-newlib-io-long-long \
+              --enable-newlib-io-c99-formats 
+
+          elif [ "$1" == "-nano" ]
+          then
+
+            # --enable-newlib-io-long-long and --enable-newlib-io-c99-formats
+            # are currently ignored if --enable-newlib-nano-formatted-io.
+            # --enable-newlib-register-fini is debatable, was removed.
+            # --enable-newlib-reent-check-verify
+            run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${NEWLIB_SRC_FOLDER_NAME}/configure" \
+              --prefix="${APP_PREFIX_NANO}"  \
+              \
+              --build=${BUILD} \
+              --host=${HOST} \
+              --target="${GCC_TARGET}" \
+              \
+              --disable-newlib-supplied-syscalls \
+              --enable-newlib-reent-small \
+              --disable-newlib-fvwrite-in-streamio \
+              --disable-newlib-fseek-optimization \
+              --disable-newlib-wide-orient \
+              --enable-newlib-nano-malloc \
+              --disable-newlib-unbuf-stream-opt \
+              --enable-lite-exit \
+              --enable-newlib-global-atexit \
+              --enable-newlib-nano-formatted-io \
+              --disable-nls \
+              --enable-newlib-register-fini
+
+          else
+            echo "Unsupported build_newlib arg $1"
+            exit 1
+          fi
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${newlib_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${newlib_folder_name}/configure-output.txt"
+      fi
+
+      (
+        # Partial build, without documentation.
+        echo
+        echo "Running newlib$1 make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+        # make
+
+        # Top make fails with install-strip due to libgloss make.
+        run_verbose make install
+
+        if [ "$1" == "" ]
+        then
+
+          if [ "${WITH_PDF}" == "y" ]
+          then
+
+            # Warning, parallel build failed on Debian 32-bit.
+
+            (
+              if [[ "${RELEASE_VERSION}" =~ 5\.4\.1-* ]]
+              then
+                hack_pdfetex
+              fi
+
+              xbb_activate_tex
+
+              run_verbose make pdf
+            )
+
+            install -v -d "${APP_PREFIX_DOC}/pdf"
+
+            install -v -c -m 644 \
+              "${GCC_TARGET}/libgloss/doc/porting.pdf" "${APP_PREFIX_DOC}/pdf"
+            install -v -c -m 644 \
+              "${GCC_TARGET}/newlib/libc/libc.pdf" "${APP_PREFIX_DOC}/pdf"
+            install -v -c -m 644 \
+              "${GCC_TARGET}/newlib/libm/libm.pdf" "${APP_PREFIX_DOC}/pdf"
+
+          fi
+
+          if [ "${WITH_HTML}" == "y" ]
+          then
+
+            run_verbose make html
+
+            install -v -d "${APP_PREFIX_DOC}/html"
+
+            copy_dir "${GCC_TARGET}/newlib/libc/libc.html" "${APP_PREFIX_DOC}/html/libc"
+            copy_dir "${GCC_TARGET}/newlib/libm/libm.html" "${APP_PREFIX_DOC}/html/libm"
+
+          fi
+
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${newlib_folder_name}/make-output.txt"
+
+      if [ "$1" == "" ]
+      then
+        copy_license \
+          "${SOURCES_FOLDER_PATH}/${NEWLIB_SRC_FOLDER_NAME}" \
+          "${NEWLIB_FOLDER_NAME}"
+      fi
+
+    )
+
+    touch "${newlib_stamp_file_path}"
+  else
+    echo "Component newlib$1 already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function copy_nano_libs() 
+{
+  local src_folder="$1"
+  local dst_folder="$2"
+
+  if [ -f "${src_folder}/libstdc++.a" ]
+  then
+    cp -v -f "${src_folder}/libstdc++.a" "${dst_folder}/libstdc++_nano.a"
+  fi
+  if [ -f "${src_folder}/libsupc++.a" ]
+  then
+    cp -v -f "${src_folder}/libsupc++.a" "${dst_folder}/libsupc++_nano.a"
+  fi
+  cp -v -f "${src_folder}/libc.a" "${dst_folder}/libc_nano.a"
+  cp -v -f "${src_folder}/libg.a" "${dst_folder}/libg_nano.a"
+  if [ -f "${src_folder}/librdimon.a" ]
+  then
+    cp -v -f "${src_folder}/librdimon.a" "${dst_folder}/librdimon_nano.a"
+  fi
+
+  cp -v -f "${src_folder}/nano.specs" "${dst_folder}/"
+  if [ -f "${src_folder}/rdimon.specs" ]
+  then
+    cp -v -f "${src_folder}/rdimon.specs" "${dst_folder}/"
+  fi
+  cp -v -f "${src_folder}/nosys.specs" "${dst_folder}/"
+  cp -v -f "${src_folder}"/*crt0.o "${dst_folder}/"
+}
+
+# Copy target libraries from each multilib folders.
+# $1=source
+# $2=destination
+# $3=target gcc
+function copy_multi_libs()
+{
+  local -a multilibs
+  local multilib
+  local multi_folder
+  local src_folder="$1"
+  local dst_folder="$2"
+  local gcc_target="$3"
+
+  echo ${gcc_target}
+  multilibs=( $("${gcc_target}" -print-multi-lib 2>/dev/null) )
+  if [ ${#multilibs[@]} -gt 0 ]
+  then
+    for multilib in "${multilibs[@]}"
+    do
+      multi_folder="${multilib%%;*}"
+      copy_nano_libs "${src_folder}/${multi_folder}" \
+        "${dst_folder}/${multi_folder}"
+    done
+  else
+    copy_nano_libs "${src_folder}" "${dst_folder}"
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function copy_linux_libs()
+{
+  local copy_linux_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-copy-linux-completed"
+  if [ ! -f "${copy_linux_stamp_file_path}" ]
+  then
+
+    local linux_path="${LINUX_INSTALL_PATH}"
+
+    (
+      cd "${WORK_FOLDER_PATH}"
+
+      copy_dir "${linux_path}/${GCC_TARGET}/lib" "${APP_PREFIX}/${GCC_TARGET}/lib"
+      copy_dir "${linux_path}/${GCC_TARGET}/include" "${APP_PREFIX}/${GCC_TARGET}/include"
+      copy_dir "${linux_path}/include" "${APP_PREFIX}/include"
+      copy_dir "${linux_path}/lib" "${APP_PREFIX}/lib"
+      copy_dir "${linux_path}/share" "${APP_PREFIX}/share"
+    ) 
+
+    (
+      cd "${APP_PREFIX}"
+      find "${GCC_TARGET}/lib" "${GCC_TARGET}/include" "include" "lib" "share" \
+        -perm /111 -and ! -type d \
+        -exec rm '{}' ';'
+    )
+    touch "${copy_linux_stamp_file_path}"
+
+  else
+    echo "Component copy-linux-libs already processed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# For the nano build, call it with "-nano".
+# $1="" or $1="-nano"
+function build_gcc_final()
+{
+  local gcc_final_folder_name="${GCC_FOLDER_NAME}-final$1"
+  local gcc_final_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${gcc_final_folder_name}-installed"
+
+  if [ ! -f "${gcc_final_stamp_file_path}" ]
+  then
+
+    download_gcc
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gcc_final_folder_name}"
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${gcc_final_folder_name}"
+      cd "${BUILD_FOLDER_PATH}/${gcc_final_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}" 
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+
+      LDFLAGS="${XBB_LDFLAGS_APP}" 
+      # Do not add CRT_glob.o here, it will fail with already defined,
+      # since it is already handled by --enable-mingw-wildcard.
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      local optimize="${CFLAGS_OPTIMIZATIONS_FOR_TARGET}"
+      if [ "$1" == "-nano" ]
+      then
+        # For newlib-nano optimize for size.
+        optimize="$(echo ${optimize} | sed -e 's/-O[123]/-Os/')"
+      fi
+
+      # Note the intentional `-g`.
+      CFLAGS_FOR_TARGET="${optimize} -g" 
+      CXXFLAGS_FOR_TARGET="${optimize} -fno-exceptions -g" 
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS 
+      export LDFLAGS        
+
+      export CFLAGS_FOR_TARGET
+      export CXXFLAGS_FOR_TARGET
+
+      local mingw_wildcard="--disable-mingw-wildcard"
+
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        add_linux_install_path
+
+        mingw_wildcard="--enable-mingw-wildcard"
+
+        export AR_FOR_TARGET="${GCC_TARGET}-ar"
+        export NM_FOR_TARGET="${GCC_TARGET}-nm"
+        export OBJDUMP_FOR_TARET="${GCC_TARGET}-objdump"
+        export STRIP_FOR_TARGET="${GCC_TARGET}-strip"
+        export CC_FOR_TARGET="${GCC_TARGET}-gcc"
+        export GCC_FOR_TARGET="${GCC_TARGET}-gcc"
+        export CXX_FOR_TARGET="${GCC_TARGET}-g++"
+      fi
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then
+        (
+          echo
+          echo "Running gcc$1 final stage configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/configure" --help
+
+          # https://gcc.gnu.org/install/configure.html
+          # --enable-shared[=package[,…]] build shared versions of libraries
+          # --enable-tls specify that the target supports TLS (Thread Local Storage). 
+          # --enable-nls enables Native Language Support (NLS)
+          # --enable-checking=list the compiler is built to perform internal consistency checks of the requested complexity. ‘yes’ (most common checks)
+          # --with-headers=dir specify that target headers are available when building a cross compiler
+          # --with-newlib Specifies that ‘newlib’ is being used as the target C library. This causes `__eprintf`` to be omitted from `libgcc.a`` on the assumption that it will be provided by newlib.
+          # --enable-languages=c,c++ Support only C/C++, ignore all other.
+
+          if [ "$1" == "" ]
+          then
+
+            run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/configure" \
+              --prefix="${APP_PREFIX}"  \
+              --infodir="${APP_PREFIX_DOC}/info" \
+              --mandir="${APP_PREFIX_DOC}/man" \
+              --htmldir="${APP_PREFIX_DOC}/html" \
+              --pdfdir="${APP_PREFIX_DOC}/pdf" \
+              \
+              --build=${BUILD} \
+              --host=${HOST} \
+              --target=${GCC_TARGET} \
+              \
+              --with-pkgversion="${BRANDING}" \
+              --with-bugurl="${BUGURL}" \
+              \
+              --enable-languages=c,c++ \
+              ${mingw_wildcard} \
+              --enable-plugins \
+              --enable-lto \
+              --disable-decimal-float \
+              --disable-libffi \
+              --disable-libgomp \
+              --disable-libmudflap \
+              --disable-libquadmath \
+              --disable-libssp \
+              --disable-libstdcxx-pch \
+              --disable-nls \
+              --disable-threads \
+              --disable-tls \
+              --enable-checking=yes \
+              --with-gnu-as \
+              --with-gnu-ld \
+              --with-newlib \
+              --with-headers=yes \
+              --with-python-dir="share/gcc-${GCC_TARGET}" \
+              --with-sysroot="${APP_PREFIX}/${GCC_TARGET}" \
+              --with-native-system-header-dir="/include" \
+              \
+              ${MULTILIB_FLAGS} \
+              --with-abi="${GCC_ABI}" \
+              --with-arch="${GCC_ARCH}" \
+              \
+              --disable-rpath \
+              --disable-build-format-warnings \
+              --with-system-zlib
+
+          elif [ "$1" == "-nano" ]
+          then
+
+            run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}/configure" \
+              --prefix="${APP_PREFIX_NANO}"  \
+              \
+              --build=${BUILD} \
+              --host=${HOST} \
+              --target=${GCC_TARGET} \
+              \
+              --with-pkgversion="${BRANDING}" \
+              --with-bugurl="${BUGURL}" \
+              \
+              --enable-languages=c,c++ \
+              --disable-decimal-float \
+              --disable-libffi \
+              --disable-libgomp \
+              --disable-libmudflap \
+              --disable-libquadmath \
+              --disable-libssp \
+              --disable-libstdcxx-pch \
+              --disable-libstdcxx-verbose \
+              --disable-nls \
+              --disable-threads \
+              --disable-tls \
+              --with-gnu-as \
+              --with-gnu-ld \
+              --with-newlib \
+              --with-headers=yes \
+              --with-python-dir="share/gcc-${GCC_TARGET}" \
+              --with-sysroot="${APP_PREFIX_NANO}/${GCC_TARGET}" \
+              --with-native-system-header-dir="/include" \
+              ${MULTILIB_FLAGS} \
+              \
+              --disable-rpath \
+              --disable-build-format-warnings \
+              --with-system-zlib
+
+          fi
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gcc_final_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gcc_final_folder_name}/configure-output.txt"
+      fi
+
+      (
+        # Partial build, without documentation.
+        echo
+        echo "Running gcc$1 final stage make..."
+
+        if [ "${TARGET_PLATFORM}" != "win32" ]
+        then
+
+          # Passing USE_TM_CLONE_REGISTRY=0 via INHIBIT_LIBC_CFLAGS to disable
+          # transactional memory related code in crtbegin.o.
+          # This is a workaround. Better approach is have a t-* to set this flag via
+          # CRTSTUFF_T_CFLAGS
+
+          # Parallel builds may fail.
+          run_verbose make -j ${JOBS} INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
+          # make INHIBIT_LIBC_CFLAGS="-DUSE_TM_CLONE_REGISTRY=0"
+
+          if [ "${WITH_STRIP}" == "y" ]
+          then
+            run_verbose make install-strip
+          else
+            run_verbose make install
+          fi
+
+          if [ "$1" == "-nano" ]
+          then
+
+            local target_gcc=""
+            if [ "${TARGET_PLATFORM}" == "win32" ]
+            then
+              target_gcc="${GCC_TARGET}-gcc"
+            else
+              target_gcc="${APP_PREFIX_NANO}/bin/${GCC_TARGET}-gcc"
+            fi
+
+            # Copy the libraries after appending the `_nano` suffix.
+            # Iterate through all multilib names.
+            copy_multi_libs \
+              "${APP_PREFIX_NANO}/${GCC_TARGET}/lib" \
+              "${APP_PREFIX}/${GCC_TARGET}/lib" \
+              "${target_gcc}"
+
+            # Copy the nano configured newlib.h file into the location that nano.specs
+            # expects it to be.
+            mkdir -pv "${APP_PREFIX}/${GCC_TARGET}/include/newlib-nano"
+            cp -v -f "${APP_PREFIX_NANO}/${GCC_TARGET}/include/newlib.h" \
+              "${APP_PREFIX}/${GCC_TARGET}/include/newlib-nano/newlib.h"
+
+          fi
+
+        else
+
+          # Build.
+          # For Windows build only the GCC binaries, the libraries were copied 
+          # from the Linux build.
+          run_verbose make -j ${JOBS} all-gcc
+          # make all-gcc
+
+          # No -strip here.
+          run_verbose make install-gcc
+
+          # Strip?
+
+        fi
+
+        if [ "$1" == "" ]
+        then
+          (
+            xbb_activate_tex
+
+            # Full build, with documentation.
+            if [ "${WITH_PDF}" == "y" ]
+            then
+              run_verbose make pdf
+              run_verbose make install-pdf
+            fi
+
+            if [ "${WITH_HTML}" == "y" ]
+            then
+              run_verbose make html
+              run_verbose make install-html
+            fi
+          )
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gcc_final_folder_name}/make-output.txt"
+
+      if [ "$1" == "" ]
+      then
+        copy_license \
+          "${SOURCES_FOLDER_PATH}/${GCC_SRC_FOLDER_NAME}" \
+          "${GCC_FOLDER_NAME}"
+      fi
+    )
+
+    touch "${gcc_final_stamp_file_path}"
+  else
+    echo "Component gcc$1 final stage already installed."
+  fi
+
+  if [ "$1" == "" ]
+  then
+    tests_add "test_gcc"
+  fi
+}
+
+function test_gcc()
+{
+  (
+    xbb_activate_installed_bin
+
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-gcc"
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-g++"
+    show_libs "${APP_PREFIX}/libexec/gcc/${GCC_TARGET}/${GCC_VERSION}/cc1"
+    show_libs "${APP_PREFIX}/libexec/gcc/${GCC_TARGET}/${GCC_VERSION}/cc1plus"
+    show_libs "${APP_PREFIX}/libexec/gcc/${GCC_TARGET}/${GCC_VERSION}/collect2"
+    show_libs "${APP_PREFIX}/libexec/gcc/${GCC_TARGET}/${GCC_VERSION}/lto-wrapper"
+    show_libs "${APP_PREFIX}/libexec/gcc/${GCC_TARGET}/${GCC_VERSION}/lto1"
+
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" --help
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -dumpversion
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -dumpmachine
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -print-multi-lib
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -dumpspecs | wc -l
+
+    local tmp=$(mktemp /tmp/gcc-test.XXXXX)
+    rm -rf "${tmp}"
+
+    mkdir -pv "${tmp}"
+    cd "${tmp}"
+
+    # Note: __EOF__ is quoted to prevent substitutions here.
+    cat <<'__EOF__' > hello.c
+#include <stdio.h>
+
+int
+main(int argc, char* argv[])
+{
+  printf("Hello World\n");
+}
+__EOF__
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -o hello-c.elf -specs=nosys.specs hello.c
+
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -o hello.c.o -c -flto hello.c
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gcc" -o hello-c-lto.elf -specs=nosys.specs -flto -v hello.c.o
+
+    # Note: __EOF__ is quoted to prevent substitutions here.
+    cat <<'__EOF__' > hello.cpp
+#include <iostream>
+
+int
+main(int argc, char* argv[])
+{
+  std::cout << "Hello World" << std::endl;
+}
+
+extern "C" void __sync_synchronize();
+
+void 
+__sync_synchronize()
+{
+}
+__EOF__
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-g++" -o hello-cpp.elf -specs=nosys.specs hello.cpp
+
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-g++" -o hello.cpp.o -c -flto hello.cpp
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-g++" -o hello-cpp-lto.elf -specs=nosys.specs -flto -v hello.cpp.o
+
+    cd ..
+    rm -rf "${tmp}"
+  )
+}
+
+# Called multile times, with and without python support.
+# $1="" or $1="-py" or $1="-py3"
+function build_gdb()
+{  
+  local gdb_folder_name="${GDB_FOLDER_NAME}$1"
+  local gdb_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${gdb_folder_name}-installed"
+
+  if [ ! -f "${gdb_stamp_file_path}" ]
+  then
+
+    download_gdb
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gdb_folder_name}"
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${gdb_folder_name}"
+      cd "${BUILD_FOLDER_PATH}/${gdb_folder_name}"
+
+      local platform_python2
+      if [ -x "/Library/Frameworks/Python.framework/Versions/2.7/bin/python" ]
+      then
+        platform_python2="/Library/Frameworks/Python.framework/Versions/2.7/bin/python2"
+      elif [ -x "/usr/bin/python2.7" ]
+      then
+        platform_python2="/usr/bin/python2.7"
+      elif [ -x "/usr/bin/python2.6" ]
+      then
+        platform_python2="/usr/bin/python2.6"
+      else
+        set +e
+        platform_python2="$(which python)"
+        set -e
+      fi
+
+      local platform_python3
+      if [ -x "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3" ]
+      then
+        platform_python3="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"
+      elif [ -x "/usr/bin/python3.7" ]
+      then
+        platform_python3="/usr/bin/python3.7"
+      elif [ -x "/usr/bin/python3.6" ]
+      then
+        platform_python3="/usr/bin/python3.6"
+      else
+        set +e
+        platform_python3="$(which python3)"
+        set -e
+      fi
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      if false # [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        # When compiled with GCC-7 it fails to run, due to
+        # some problems with exceptions unwind.
+        export CC=clang
+        export CXX=clang++
+        unset AR
+        unset LD
+        unset NM
+        unset RANLIB
+      fi
+
+      CPPFLAGS="${XBB_CPPFLAGS}" 
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+          
+      # libiconv is used by Python3.
+      # export LIBS="-liconv"
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        # https://stackoverflow.com/questions/44150871/embeded-python3-6-with-mingw-in-c-fail-on-linking
+        # ???
+        CPPFLAGS+=" -DPy_BUILD_CORE_BUILTIN=1"
+
+        if [ "$1" == "-py" ]
+        then
+          # Definition required by python-config.sh.
+          export GNURM_PYTHON_WIN_DIR="${SOURCES_FOLDER_PATH}/${PYTHON2_SRC_FOLDER_NAME}"
+        fi
+
+        # From Arm script.
+        LDFLAGS="${XBB_LDFLAGS_APP} -Wl,${XBB_FOLDER_PATH}/mingw/lib/CRT_glob.o"
+        # Workaround for undefined reference to `__strcpy_chk' in GCC 9.
+        # https://sourceforge.net/p/mingw-w64/bugs/818/
+        LIBS="-lssp -liconv"
+      elif [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        # This makes gdb-py fail!
+        # Pick some system libraries from XBB, to avoid rebuilding them here.
+        #        CPPFLAGS+=" -I${XBB_FOLDER_PATH}/include" 
+        #        LDFLAGS+=" -L${XBB_FOLDER_PATH}/lib"
+        LDFLAGS="${XBB_LDFLAGS_APP}"
+        LIBS="-liconv -lncurses"
+      elif [ "${TARGET_PLATFORM}" == "linux" ]
+      then
+        LDFLAGS="${XBB_LDFLAGS_APP}"
+        LIBS=""
+      fi
+
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      if [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        # Pick some system libraries from XBB, to avoid rebuilding them here.
+        # Otherwise configure will not identify that Python is present.
+        CPPFLAGS+=" -I${XBB_FOLDER_PATH}/include" 
+        LDFLAGS+=" -L${XBB_FOLDER_PATH}/lib"
+      fi
+
+      # Not yet used, requires patching the python-config.py.
+      # See the arm-none-eabi script.
+      CONFIG_PYTHON_PREFIX=""
+
+      local extra_python_opts="--with-python=no"
+      if [ "$1" == "-py" ]
+      then
+        if [ "${TARGET_PLATFORM}" == "win32" ]
+        then
+          extra_python_opts="--with-python=${SOURCES_FOLDER_PATH}/${GCC_COMBO_FOLDER_NAME}/python-config.sh"
+        else
+          if [ "${USE_PLATFORM_PYTHON2}" == "y" ]
+          then
+            extra_python_opts="--with-python=${platform_python2}"
+          else
+            extra_python_opts="--with-python=$(which python2)"
+          fi
+          
+          if [ "${TARGET_PLATFORM}" == "darwin" ]
+          then
+            # Use the custom path, 2.7 will be removed from future macOS.
+            CONFIG_PYTHON_PREFIX="/Library/Frameworks/Python.framework/Versions/2.7"
+          elif [ "${TARGET_PLATFORM}" == "linux" ]
+          then
+            CONFIG_PYTHON_PREFIX="/usr/local"
+          fi
+        fi
+      elif [ "$1" == "-py3" ]
+      then
+        if [ "${TARGET_PLATFORM}" == "win32" ]
+        then
+          extra_python_opts="--with-python=${BUILD_GIT_PATH}/patches/python3-config.sh"
+        else
+          if [ "${USE_PLATFORM_PYTHON3}" == "y" ]
+          then
+            extra_python_opts="--with-python=${platform_python3}"
+          else
+            extra_python_opts="--with-python=$(which python3)"
+          fi
+
+          if [ "${TARGET_PLATFORM}" == "darwin" ]
+          then
+            CONFIG_PYTHON_PREFIX="/Library/Frameworks/Python.framework/Versions/3.7"
+          elif [ "${TARGET_PLATFORM}" == "linux" ]
+          then
+            CONFIG_PYTHON_PREFIX="/usr/local"
+          fi
+        fi
+      fi
+
+      local tui_option
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        tui_option="--disable-tui"
+      else
+        tui_option="--enable-tui"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+          
+      export LDFLAGS
+      export LIBS
+
+      export CONFIG_PYTHON_PREFIX
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then
+        (
+          echo
+          echo "Running gdb$1 configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${GDB_SRC_FOLDER_NAME}/configure" --help
+
+          # Note that all components are disabled, except GDB.
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${GDB_SRC_FOLDER_NAME}/configure" \
+            --prefix="${APP_PREFIX}"  \
+            --infodir="${APP_PREFIX_DOC}/info" \
+            --mandir="${APP_PREFIX_DOC}/man" \
+            --htmldir="${APP_PREFIX_DOC}/html" \
+            --pdfdir="${APP_PREFIX_DOC}/pdf" \
+            \
+            --build=${BUILD} \
+            --host=${HOST} \
+            --target=${GCC_TARGET} \
+            \
+            --with-pkgversion="${BRANDING}" \
+            --with-bugurl="${BUGURL}" \
+            \
+            --enable-gdb \
+            --disable-nls \
+            --disable-sim \
+            --disable-gas \
+            --disable-binutils \
+            --disable-ld \
+            --disable-gold \
+            --disable-gprof \
+            --with-expat \
+            --with-lzma=yes \
+            --with-system-gdbinit="${APP_PREFIX}/${GCC_TARGET}/lib/gdbinit" \
+            --with-gdb-datadir="${APP_PREFIX}/${GCC_TARGET}/share/gdb" \
+            \
+            ${extra_python_opts} \
+            --program-prefix="${GCC_TARGET}-" \
+            --program-suffix="$1" \
+            \
+            --disable-werror \
+            --enable-build-warnings=no \
+            --disable-rpath \
+            --with-system-zlib \
+            --without-guile \
+            --without-babeltrace \
+            --without-libunwind-ia64 \
+            ${tui_option} \
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gdb_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gdb_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running gdb$1 make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+        # make 
+
+        # install-strip fails, not only because of readline has no install-strip
+        # but even after patching it tries to strip a non elf file
+        # strip:.../install/riscv-none-gcc/bin/_inst.672_: file format not recognized
+        run_verbose make install
+
+        if [ "$1" == "" ]
+        then
+          (
+            xbb_activate_tex
+
+            if [ "${WITH_PDF}" == "y" ]
+            then
+              run_verbose make pdf
+              run_verbose make install-pdf
+            fi
+
+            if [ "${WITH_HTML}" == "y" ]
+            then
+              run_verbose make html 
+              run_verbose make install-html 
+            fi
+          )
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gdb_folder_name}/make-output.txt"
+
+      if [ "$1" == "" ]
+      then
+        copy_license \
+          "${SOURCES_FOLDER_PATH}/${GDB_SRC_FOLDER_NAME}/gdb" \
+          "${GDB_FOLDER_NAME}"
+      fi
+
+    )
+
+    touch "${gdb_stamp_file_path}"
+  else
+    echo "Component gdb$1 already installed."
+  fi
+
+  tests_add "test_gdb$1"
+}
+
+function test_gdb_py()
+{
+  test_gdb "-py"
+}
+
+function test_gdb_py3()
+{
+  test_gdb "-py3"
+}
+
+function test_gdb()
+{
+  local suffix=""
+  if [ $# -ge 1 ]
+  then
+    suffix="$1"
+  fi
+
+  if [ "${suffix}" != "" -a "${TARGET_PLATFORM}" == "win32" ]
+  then
+    (
+      xbb_activate
+
+      show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}"
+
+      # Fails on Wine
+      # ImportError: No module named site
+      # 007b:fixme:msvcrt:__clean_type_info_names_internal (0x1e31e2e8) stub
+      run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}" --version || true
+    )
+    return 0
+  fi
+
+  # error while loading shared libraries: /Host/home/ilg/Work/arm-none-eabi-gcc-8.2.1-1.5/linux-x32/install/arm-none-eabi-gcc/bin/libpython3.7m.so.1.0: unsupported version 0 of Verneed record
+  if [ "${suffix}" == "-py3" -a "${TARGET_PLATFORM}" == "linux" -a "${TARGET_ARCH}" == "x32" ]
+  then
+    return 0
+  fi
+
+  (
+    # Required by gdb-py to access the python shared library.
+    xbb_activate_installed_bin
+
+    show_libs "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}"
+
+    # The original Python in Ubunutu XBB is too old and the test fails.
+    # Use the XBB modern Python.
+    if [ "${suffix}" == "-py" ]
+    then
+      echo
+      python2 --version
+
+      if [ "${TARGET_PLATFORM}" == "linux" ]
+      then
+        export PYTHONHOME="${XBB_FOLDER_PATH}"
+      elif [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        # export PYTHONHOME="${XBB_FOLDER_PATH}"
+        export PYTHONPATH="${XBB_FOLDER_PATH}/lib/python2.7"
+      fi
+    elif [ "${suffix}" == "-py3" ]
+    then
+      echo
+      python3 --version
+
+      if [ "${TARGET_PLATFORM}" == "linux" ]
+      then
+        export PYTHONHOME="${XBB_FOLDER_PATH}"
+      fi
+    fi
+
+    set +u
+    echo "PYTHONHOME=${PYTHONHOME}"
+    echo "PYTHONPATH=${PYTHONPATH}"
+    set -u
+
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}" --version
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}" --config
+
+    # This command is known to fail with 'Abort trap: 6' (SIGABRT)
+    run_app "${APP_PREFIX}/bin/${GCC_TARGET}-gdb${suffix}" \
+      --nh \
+      --nx \
+      -ex='show language' \
+      -ex='set language auto' \
+      -ex='quit'
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+function tidy_up() 
+{
+  (
+    xbb_activate
+
+    echo
+    echo "Tidying up..."
+
+    cd "${WORK_FOLDER_PATH}"
+
+    find "${APP_PREFIX}" -name "libiberty.a" -exec rm -v '{}' ';'
+    find "${APP_PREFIX}" -name '*.la' -exec rm -v '{}' ';'
+
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      find "${APP_PREFIX}" -name "liblto_plugin.a" -exec rm -v '{}' ';'
+      find "${APP_PREFIX}" -name "liblto_plugin.dll.a" -exec rm -v '{}' ';'
+    fi
+  )
+}
+
+function strip_binaries()
+{
+  local folder_path="${APP_PREFIX}"
+  if [ $# -ge 1 ]
+  then
+    folder_path="$1"
+  fi
+
+  if [ "${WITH_STRIP}" == "y" ]
+  then
+    (
+      xbb_activate
+
+      echo
+      echo "Stripping binaries..."
+
+      # Otherwise `find` may fail.
+      cd "${WORK_FOLDER_PATH}"
+
+      local binaries
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+
+        which "${CROSS_COMPILE_PREFIX}-strip"
+
+        binaries=$(find "${folder_path}" -name \*.exe)
+        for bin in ${binaries} 
+        do
+          strip_binary2 "${CROSS_COMPILE_PREFIX}-strip" "${bin}"
+        done
+
+      elif [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+
+        which strip
+
+        binaries=$(find "${folder_path}" -name \* -perm +111 -and ! -type d)
+        for bin in ${binaries} 
+        do
+          if is_elf "${bin}"
+          then
+            strip_binary2 strip "${bin}"
+          fi
+        done
+
+      elif [ "${TARGET_PLATFORM}" == "linux" ]
+      then
+
+        which strip
+
+        binaries=$(find "${folder_path}" -name \* -perm /111 -and ! -type d)
+        for bin in ${binaries} 
+        do
+          if is_elf "${bin}"
+          then
+            strip_binary2 strip "${bin}"
+          fi
+        done
+
+      fi
+    )
+  fi
+}
+
+function strip_libs()
+{
+  if [ "${WITH_STRIP}" == "y" ]
+  then
+    (
+      xbb_activate
+
+      PATH="${APP_PREFIX}/bin:${PATH}"
+
+      echo
+      echo "Stripping libraries..."
+
+      cd "${WORK_FOLDER_PATH}"
+
+      # which "${GCC_TARGET}-objcopy"
+
+      local libs=$(find "${APP_PREFIX}" -name '*.[ao]')
+      for lib in ${libs}
+      do
+        echo "${GCC_TARGET}-objcopy -R ... ${lib}"
+        "${APP_PREFIX}/bin/${GCC_TARGET}-objcopy" -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc "${lib}" || true
+      done
+    )
+  fi
+}
+
+function copy_distro_files()
+{
+  (
+    xbb_activate
+
+    rm -rf "${APP_PREFIX}/${DISTRO_INFO_NAME}"
+    mkdir -pv "${APP_PREFIX}/${DISTRO_INFO_NAME}"
+
+    copy_build_files
+
+    echo
+    echo "Copying distro files..."
+
+    cd "${BUILD_GIT_PATH}"
+    install -v -c -m 644 "scripts/${README_OUT_FILE_NAME}" \
+      "${APP_PREFIX}/README.md"
+  )
+}
+
+function final_tunings()
+{
+  # Create the missing LTO plugin links.
+  # For `ar` to work with LTO objects, it needs the plugin in lib/bfd-plugins,
+  # but the build leaves it where `ld` needs it. On POSIX, make a soft link.
+  if [ "${FIX_LTO_PLUGIN}" == "y" ]
+  then
+    (
+      cd "${APP_PREFIX}"
+
+      echo
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        echo
+        echo "Copying ${LTO_PLUGIN_ORIGINAL_NAME}..."
+
+        mkdir -pv "$(dirname ${LTO_PLUGIN_BFD_PATH})"
+
+        if [ ! -f "${LTO_PLUGIN_BFD_PATH}" ]
+        then
+          local plugin_path="$(find * -type f -name ${LTO_PLUGIN_ORIGINAL_NAME})"
+          if [ ! -z "${plugin_path}" ]
+          then
+            cp -v "${plugin_path}" "${LTO_PLUGIN_BFD_PATH}"
+          else
+            echo "${LTO_PLUGIN_ORIGINAL_NAME} not found."
+            exit 1
+          fi
+        fi
+      else
+        echo
+        echo "Creating ${LTO_PLUGIN_ORIGINAL_NAME} link..."
+
+        mkdir -pv "$(dirname ${LTO_PLUGIN_BFD_PATH})"
+        if [ ! -f "${LTO_PLUGIN_BFD_PATH}" ]
+        then
+          local plugin_path="$(find * -type f -name ${LTO_PLUGIN_ORIGINAL_NAME})"
+          if [ ! -z "${plugin_path}" ]
+          then
+            ln -s -v "../../${plugin_path}" "${LTO_PLUGIN_BFD_PATH}"
+          else
+            echo "${LTO_PLUGIN_ORIGINAL_NAME} not found."
+            exit 1
+          fi
+        fi
+      fi
+    )
+  fi
+}
+
+# -----------------------------------------------------------------------------

+ 251 - 0
distro-info/scripts/container-build.sh

@@ -0,0 +1,251 @@
+#!/usr/bin/env bash
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2019 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
+# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
+
+if [[ ! -z ${DEBUG} ]]
+then
+  set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
+else
+  DEBUG=""
+fi
+
+set -o errexit # Exit if command failed.
+set -o pipefail # Exit if pipe failed.
+set -o nounset # Exit if variable not set.
+
+# Remove the initial space and instead use '\n'.
+IFS=$'\n\t'
+
+# -----------------------------------------------------------------------------
+# Identify the script location, to reach, for example, the helper scripts.
+
+build_script_path="$0"
+if [[ "${build_script_path}" != /* ]]
+then
+  # Make relative path absolute.
+  build_script_path="$(pwd)/$0"
+fi
+
+script_folder_path="$(dirname "${build_script_path}")"
+script_folder_name="$(basename "${script_folder_path}")"
+
+# =============================================================================
+
+# Inner script to run inside Docker containers to build the 
+# xPack GNU RISC-V Embedded GCC distribution packages.
+
+# For native builds, it runs on the host (macOS build cases,
+# and development builds for GNU/Linux).
+
+# -----------------------------------------------------------------------------
+
+defines_script_path="${script_folder_path}/defs-source.sh"
+echo "Definitions source script: \"${defines_script_path}\"."
+source "${defines_script_path}"
+
+# This file is generated by the host build script.
+host_defines_script_path="${script_folder_path}/host-defs-source.sh"
+echo "Host definitions source script: \"${host_defines_script_path}\"."
+source "${host_defines_script_path}"
+
+common_helper_functions_script_path="${script_folder_path}/helper/common-functions-source.sh"
+echo "Common helper functions source script: \"${common_helper_functions_script_path}\"."
+source "${common_helper_functions_script_path}"
+
+common_helper_libs_functions_script_path="${script_folder_path}/helper/common-libs-functions-source.sh"
+echo "Common helper libs functions source script: \"${common_helper_libs_functions_script_path}\"."
+source "${common_helper_libs_functions_script_path}"
+
+common_functions_script_path="${script_folder_path}/common-functions-source.sh"
+echo "Common functions source script: \"${common_functions_script_path}\"."
+source "${common_functions_script_path}"
+
+container_functions_script_path="${script_folder_path}/helper/container-functions-source.sh"
+echo "Container helper functions source script: \"${container_functions_script_path}\"."
+source "${container_functions_script_path}"
+
+common_versions_script_path="${script_folder_path}/common-versions-source.sh"
+echo "Common versions source script: \"${common_versions_script_path}\"."
+source "${common_versions_script_path}"
+
+container_libs_functions_script_path="${script_folder_path}/${CONTAINER_LIBS_FUNCTIONS_SCRIPT_NAME}"
+echo "Container libs functions source script: \"${container_libs_functions_script_path}\"."
+source "${container_libs_functions_script_path}"
+
+container_app_functions_script_path="${script_folder_path}/${CONTAINER_APP_FUNCTIONS_SCRIPT_NAME}"
+echo "Container app functions source script: \"${container_app_functions_script_path}\"."
+source "${container_app_functions_script_path}"
+
+# -----------------------------------------------------------------------------
+
+if [ ! -z "#{DEBUG}" ]
+then
+  echo $@
+fi
+
+WITH_STRIP="y"
+WITHOUT_MULTILIB=""
+WITH_PDF="y"
+WITH_HTML="n"
+WITH_TESTS="y"
+
+IS_DEVELOP=""
+IS_DEBUG=""
+
+LINUX_INSTALL_PATH=""
+USE_GITS=""
+
+if [ "$(uname)" == "Linux" ]
+then
+  JOBS="$(nproc)"
+elif [ "$(uname)" == "Darwin" ]
+then
+  JOBS="$(sysctl hw.ncpu | sed 's/hw.ncpu: //')"
+else
+  JOBS="1"
+fi
+
+while [ $# -gt 0 ]
+do
+
+  case "$1" in
+
+    --disable-strip)
+      WITH_STRIP="n"
+      shift
+      ;;
+
+    --disable-tests)
+      WITH_TESTS="n"
+      shift
+      ;;
+
+    --without-pdf)
+      WITH_PDF="n"
+      shift
+      ;;
+
+    --with-pdf)
+      WITH_PDF="y"
+      shift
+      ;;
+
+    --without-html)
+      WITH_HTML="n"
+      shift
+      ;;
+
+    --with-html)
+      WITH_HTML="y"
+      shift
+      ;;
+
+    --jobs)
+      JOBS=$2
+      shift 2
+      ;;
+
+    --develop)
+      IS_DEVELOP="y"
+      shift
+      ;;
+
+    --debug)
+      IS_DEBUG="y"
+      WITH_STRIP="n"
+      shift
+      ;;
+
+    # --- specific
+
+    --linux-install-path)
+      LINUX_INSTALL_PATH="$2"
+      shift 2
+      ;;
+
+    --disable-multilib)
+      WITHOUT_MULTILIB="y"
+      shift
+      ;;
+
+    --use-gits)
+      USE_GITS="y"
+      shift
+      ;;
+
+    *)
+      echo "Unknown action/option $1"
+      exit 1
+      ;;
+
+  esac
+
+done
+
+if [ "${IS_DEBUG}" == "y" ]
+then
+  WITH_STRIP="n"
+fi
+
+if [ "${TARGET_PLATFORM}" == "win32" ]
+then
+  export WITH_TESTS="n"
+fi
+
+env | sort
+
+# -----------------------------------------------------------------------------
+
+start_timer
+
+detect_container
+
+prepare_xbb_env
+
+prepare_xbb_extras
+
+tests_initialize
+
+# -----------------------------------------------------------------------------
+
+echo
+echo "Here we go..."
+echo
+
+build_versions
+
+# -----------------------------------------------------------------------------
+
+copy_distro_files
+
+create_archive
+
+# Change ownership to non-root Linux user.
+fix_ownership
+
+# -----------------------------------------------------------------------------
+
+# Final checks.
+# To keep everything as pristine as possible, run tests
+# only after the archive is packed.
+
+prime_wine
+
+tests_run
+
+# -----------------------------------------------------------------------------
+
+stop_timer
+
+exit 0
+
+# -----------------------------------------------------------------------------

+ 14 - 0
distro-info/scripts/container-libs-functions-source.sh

@@ -0,0 +1,14 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2019 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the container build scripts.
+
+# -----------------------------------------------------------------------------

+ 43 - 0
distro-info/scripts/defs-source.sh

@@ -0,0 +1,43 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPacks distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2019 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the build scripts.
+# As the name implies, it should contain only definitions and should
+# be included with 'source' by the host and container scripts.
+
+# Warning: MUST NOT depend on $HOME or other environment variables.
+
+# -----------------------------------------------------------------------------
+
+# Used to display the application name.
+APP_NAME=${APP_NAME:-"GNU RISC-V Embedded GCC"}
+
+# Used as part of file/folder paths.
+APP_UC_NAME=${APP_UC_NAME:-"RISC-V Embedded GCC"}
+APP_LC_NAME=${APP_LC_NAME:-"riscv-none-embed-gcc"}
+
+DISTRO_UC_NAME=${DISTRO_UC_NAME:-"xPack"}
+DISTRO_LC_NAME=${DISTRO_LC_NAME:-"xpack"}
+DISTRO_TOP_FOLDER=${DISTRO_TOP_FOLDER:-"xPacks"}
+
+# Use the new xPack naming convention.
+HAS_NAME_ARCH="y"
+
+BRANDING=${BRANDING:-"${DISTRO_UC_NAME} ${APP_NAME}"}
+BUGURL=${BUGURL:-"https://github.com/sifive/freedom-tools/issues"}
+
+GCC_TARGET=${GCC_TARGET:-"riscv-none-embed"}
+GCC_ARCH=${GCC_ARCH:-"rv32imac"}
+GCC_ABI=${GCC_ABI:-"ilp32"}
+
+CONTAINER_SCRIPT_NAME=${CONTAINER_SCRIPT_NAME:-"container-build.sh"}
+CONTAINER_LIBS_FUNCTIONS_SCRIPT_NAME=${CONTAINER_LIBS_FUNCTIONS_SCRIPT_NAME:-"container-libs-functions-source.sh"}
+CONTAINER_APP_FUNCTIONS_SCRIPT_NAME=${CONTAINER_APP_FUNCTIONS_SCRIPT_NAME:-"container-apps-functions-source.sh"}
+
+# -----------------------------------------------------------------------------

+ 3 - 0
distro-info/scripts/git-clone-develop.sh

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+rm -rf "${HOME}/Downloads/riscv-none-embed-gcc-xpack.git"
+git clone --branch develop --recurse-submodules https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack.git "${HOME}/Downloads/riscv-none-embed-gcc-xpack.git"

+ 3 - 0
distro-info/scripts/git-clone.sh

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+rm -rf "${HOME}/Downloads/riscv-none-embed-gcc-xpack.git"
+git clone --recurse-submodules https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack.git "${HOME}/Downloads/riscv-none-embed-gcc-xpack.git"

+ 21 - 0
distro-info/scripts/helper/LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Liviu Ionescu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 75 - 0
distro-info/scripts/helper/README.md

@@ -0,0 +1,75 @@
+# build-helper
+
+Common script used in other build scripts.
+
+- `host-functions-source.sh`: to be included with `source` in the host build script
+- `container-functions-source.sh`: to be included with `source` in the container build script
+
+Deprecated:
+
+- `builder-helper.sh`: used in the first generation of build scripts.
+
+# Patches
+
+The code used to download and extract archives can also be used
+to post-patch the downloaded files. For this a patch file must be
+placed in the `patches` folder, and the name must be passed as the
+third param to `extract()`.
+
+## Memo
+
+The code to apply the patch (`common-functions-source.sh:extract()`) does 
+the following:
+
+```console
+$ cd sources/binutils
+$ patch -p0 < "binutils-2.31.patch"
+```
+
+The patch is applied from the library source folder, so it must be created
+with the library relative path.
+
+For example, to create a binutils patch, use:
+
+```console
+$ cd sources/binutils
+$ cp bfd/ihex.c bfd/ihex-patched.c
+$ vi bfd/ihex-patched.c
+$ diff -u bfd/ihex.c bfd/ihex-patched.c > patches/binutils-2.31.patch
+```
+
+Alternatively, multiple changes can be generated by Git:
+
+```console
+$ git init
+$ git add -A
+$ git commit -m all
+```
+
+Perform changes as usual.
+
+To create a patch with the uncommitted changes that will be consumed
+with `patch`:
+
+```console
+$ git diff --no-prefix -u > file.patch
+```
+
+For completeness, to create a patch with the uncommitted changes that
+will be consumeed with `git apply file.git-patch`.
+
+```console
+$ git diff > file.git-patch
+```
+
+It is also possible to create patches with git and consume them with patch
+
+```console
+$ git diff --no-prefix -u > file.patch
+```
+
+Links:
+
+- https://git-scm.com/docs/git-diff
+- https://git-scm.com/docs/git-apply
+

+ 2508 - 0
distro-info/scripts/helper/common-functions-source.sh

@@ -0,0 +1,2508 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPack distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the build scripts (both native
+# and container).
+
+# -----------------------------------------------------------------------------
+
+# Default empty definition, if XBB is available, it should
+# redefine it.
+function xbb_activate()
+{
+  :
+}
+
+function xbb_activate_dev()
+{
+  # Add XBB include in front of XBB_CPPFLAGS.
+  XBB_CPPFLAGS="-I${XBB_FOLDER_PATH}/include ${XBB_CPPFLAGS}"
+
+  if [ -d "${XBB_FOLDER_PATH}/lib" ]
+  then
+    # Add XBB lib in front of XBB_LDFLAGS.
+    XBB_LDFLAGS="-L${XBB_FOLDER_PATH}/lib ${XBB_LDFLAGS}"
+    XBB_LDFLAGS_LIB="-L${XBB_FOLDER_PATH}/lib ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_APP="-L${XBB_FOLDER_PATH}/lib ${XBB_LDFLAGS_APP}"
+    XBB_LDFLAGS_APP_STATIC_GCC="-L${XBB_FOLDER_PATH}/lib ${XBB_LDFLAGS_APP_STATIC_GCC}"
+
+    # Add XBB lib in front of PKG_CONFIG_PATH.
+    if [ -d "${XBB_FOLDER_PATH}/lib/pkgconfig" ]
+    then
+      if [ -z "${PKG_CONFIG_PATH}" ]
+      then
+        PKG_CONFIG_PATH="${XBB_FOLDER_PATH}/lib/pkgconfig"
+      else
+        PKG_CONFIG_PATH="${XBB_FOLDER_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}"
+      fi
+    fi
+  fi
+
+  if [ -d "${XBB_FOLDER_PATH}/lib64" ]
+  then
+    # For 64-bit systems, add XBB lib64 in front of paths.
+    XBB_LDFLAGS="-L${XBB_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_LIB="-L${XBB_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_APP="-L${XBB_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_APP}"
+    XBB_LDFLAGS_APP_STATIC_GCC="-L${XBB_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_APP_STATIC_GCC}"
+
+    if [ -d "${XBB_FOLDER_PATH}/lib64/pkgconfig" ]
+    then
+      if [ -z "${PKG_CONFIG_PATH}" ]
+      then
+        PKG_CONFIG_PATH="${XBB_FOLDER_PATH}/lib64/pkgconfig"
+      else
+        PKG_CONFIG_PATH="${XBB_FOLDER_PATH}/lib64/pkgconfig:${PKG_CONFIG_PATH}"
+      fi
+    fi
+  fi
+
+  export XBB_CPPFLAGS
+
+  export XBB_LDFLAGS
+  export XBB_LDFLAGS_LIB
+  export XBB_LDFLAGS_APP
+  export XBB_LDFLAGS_APP_STATIC_GCC
+
+  export PKG_CONFIG_PATH
+}
+
+function xbb_activate_libs()
+{
+  LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-""}
+
+  if [ -d "${XBB_FOLDER_PATH}/lib" ]
+  then
+    if [ -z "${LD_LIBRARY_PATH}" ]
+    then
+      LD_LIBRARY_PATH="${XBB_FOLDER_PATH}/lib"
+    else
+      LD_LIBRARY_PATH="${XBB_FOLDER_PATH}/lib:${LD_LIBRARY_PATH}"
+    fi
+  fi
+
+  if [ -d "${XBB_FOLDER_PATH}/lib64" ]
+  then
+    if [ -z "${LD_LIBRARY_PATH}" ]
+    then
+      LD_LIBRARY_PATH="${XBB_FOLDER_PATH}/lib64"
+    else
+      LD_LIBRARY_PATH="${XBB_FOLDER_PATH}/lib64:${LD_LIBRARY_PATH}"
+    fi
+  fi
+
+  export LD_LIBRARY_PATH
+}
+
+# Add the freshly built binaries.
+function xbb_activate_installed_bin()
+{
+  # Add the XBB bin to the PATH.
+  PATH="${LIBS_INSTALL_FOLDER_PATH}/bin:${PATH}"
+
+  export PATH
+}
+
+# Add the freshly built headrs and libraries.
+function xbb_activate_installed_dev()
+{
+  # Add XBB include in front of XBB_CPPFLAGS.
+  XBB_CPPFLAGS="-I${LIBS_INSTALL_FOLDER_PATH}/include ${XBB_CPPFLAGS}"
+
+  if [ -d "${LIBS_INSTALL_FOLDER_PATH}/lib" ]
+  then
+    # Add XBB lib in front of XBB_LDFLAGS.
+    XBB_LDFLAGS="-L${LIBS_INSTALL_FOLDER_PATH}/lib ${XBB_LDFLAGS}"
+    XBB_LDFLAGS_LIB="-L${LIBS_INSTALL_FOLDER_PATH}/lib ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_APP="-L${LIBS_INSTALL_FOLDER_PATH}/lib ${XBB_LDFLAGS_APP}"
+    XBB_LDFLAGS_APP_STATIC_GCC="-L${LIBS_INSTALL_FOLDER_PATH}/lib ${XBB_LDFLAGS_APP_STATIC_GCC}"
+
+    # Add XBB lib in front of PKG_CONFIG_PATH.
+    PKG_CONFIG_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}"
+
+    # Needed by internal binaries, like the bootstrap compiler, which do not
+    # have a rpath.
+    if [ -z "${LD_LIBRARY_PATH}" ]
+    then
+      LD_LIBRARY_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib"
+    else
+      LD_LIBRARY_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib:${LD_LIBRARY_PATH}"
+    fi
+  fi
+
+  # For just in case, apparently not used.
+  if [ -d "${LIBS_INSTALL_FOLDER_PATH}/lib64" ]
+  then
+    # For 64-bit systems, add XBB lib64 in front of paths.
+    XBB_LDFLAGS="-L${LIBS_INSTALL_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_LIB="-L${LIBS_INSTALL_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_LIB}"
+    XBB_LDFLAGS_APP="-L${LIBS_INSTALL_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_APP}"
+    XBB_LDFLAGS_APP_STATIC_GCC="-L${LIBS_INSTALL_FOLDER_PATH}/lib64 ${XBB_LDFLAGS_APP_STATIC_GCC}"
+
+    PKG_CONFIG_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib64/pkgconfig:${PKG_CONFIG_PATH}"
+
+    if [ -z "${LD_LIBRARY_PATH}" ]
+    then
+      LD_LIBRARY_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib64"
+    else
+      LD_LIBRARY_PATH="${LIBS_INSTALL_FOLDER_PATH}/lib64:${LD_LIBRARY_PATH}"
+    fi
+  fi
+
+  export XBB_CPPFLAGS
+
+  export XBB_LDFLAGS
+  export XBB_LDFLAGS_LIB
+  export XBB_LDFLAGS_APP
+  export XBB_LDFLAGS_APP_STATIC_GCC
+
+  export PKG_CONFIG_PATH
+  export LD_LIBRARY_PATH
+
+  echo
+  env | sort
+}
+
+function xbb_activate_tex()
+{
+  :
+}
+
+# -----------------------------------------------------------------------------
+
+function do_config_guess() 
+{
+  if [ -f "${XBB_FOLDER_PATH}/share/libtool/build-aux/config.guess" ]
+  then
+    BUILD="$(${XBB_FOLDER_PATH}/share/libtool/build-aux/config.guess)"
+  elif [ -f "/usr/share/libtool/build-aux/config.guess" ]
+  then
+    BUILD="$(/usr/share/libtool/build-aux/config.guess)"
+  elif [ -f "/usr/share/misc/config.guess" ]
+  then
+    BUILD="$(/usr/share/misc/config.guess)"
+  else
+    echo "Could not find config.guess."
+    exit 1
+  fi
+}
+
+function prepare_xbb_env() 
+{
+  # Defaults, to ensure the variables are defined.
+  PATH="${PATH:-""}"
+  LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-""}"
+
+  if [ -f "${HOME}/opt/xbb/xbb-source.sh" ]
+  then
+    XBB_FOLDER_PATH="${HOME}/opt/xbb"
+    echo
+    echo "Sourcing ${HOME}/opt/xbb/xbb-source.sh..."
+    source "${HOME}/opt/xbb/xbb-source.sh"
+  elif [ -f "${HOME}/opt/homebrew/xbb/xbb-source.sh" ]
+  then
+    XBB_FOLDER_PATH="${HOME}/opt/homebrew/xbb"
+    # Deprecated, on macOS it was moved to HOME/opt/xbb
+    echo
+    echo "Sourcing ${HOME}/opt/homebrew/xbb/xbb-source.sh..."
+    source "${HOME}/opt/homebrew/xbb/xbb-source.sh"
+  elif [ -f "/opt/xbb/xbb-source.sh" ]
+  then
+    XBB_FOLDER_PATH="/opt/xbb"
+    echo
+    echo "Sourcing /opt/xbb/xbb-source.sh..."
+    source "/opt/xbb/xbb-source.sh"
+  else
+    XBB_FOLDER_PATH=""
+  fi
+
+  TARGET_FOLDER_NAME="${TARGET_PLATFORM}-${TARGET_ARCH}"
+
+  # Compute the BUILD/HOST/TARGET for configure.
+  CROSS_COMPILE_PREFIX=""
+  if [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+
+    # Disable test when cross compiling for Windows.
+    WITH_TESTS="n"
+
+    # For Windows targets, decide which cross toolchain to use.
+    if [ ${TARGET_ARCH} == "x32" ]
+    then
+      CROSS_COMPILE_PREFIX="i686-w64-mingw32"
+    elif [ ${TARGET_ARCH} == "x64" ]
+    then
+      CROSS_COMPILE_PREFIX="x86_64-w64-mingw32"
+    else
+      echo "Oops! Unsupported ${TARGET_ARCH}."
+      exit 1
+    fi
+
+    do_config_guess
+
+    HOST="${CROSS_COMPILE_PREFIX}"
+    TARGET="${HOST}"
+
+  elif [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+
+    do_config_guess
+
+    HOST="${BUILD}"
+    TARGET="${HOST}"
+
+  elif [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+
+    do_config_guess
+
+    HOST="${BUILD}"
+    TARGET="${HOST}"
+
+  else
+    echo "Oops! Unsupported ${TARGET_PLATFORM}."
+    exit 1
+  fi
+
+  if [ -f "/.dockerenv" ]
+  then
+    WORK_FOLDER_PATH="${CONTAINER_WORK_FOLDER_PATH}"
+    DOWNLOAD_FOLDER_PATH="${CONTAINER_CACHE_FOLDER_PATH}"
+  else
+    WORK_FOLDER_PATH="${HOST_WORK_FOLDER_PATH}"
+    DOWNLOAD_FOLDER_PATH="${HOST_CACHE_FOLDER_PATH}"
+  fi
+
+  # Develop builds use the host folder.
+  BUILD_FOLDER_PATH="${WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/build"
+  if [ -f "/.dockerenv" ]
+  then 
+    if [ "${IS_DEVELOP}" != "y" ]
+    then
+      # Docker builds use a temporary folder.
+      BUILD_FOLDER_PATH="/tmp/${TARGET_FOLDER_NAME}/build"
+    fi
+  fi
+
+  LIBS_BUILD_FOLDER_PATH="${BUILD_FOLDER_PATH}/libs"
+  mkdir -pv "${LIBS_BUILD_FOLDER_PATH}"
+
+  APP_BUILD_FOLDER_PATH="${BUILD_FOLDER_PATH}/${APP_LC_NAME}"
+  # Do it later, only if needed.
+  # mkdir -pv "${APP_BUILD_FOLDER_PATH}"
+
+  INSTALL_FOLDER_PATH="${WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/install"
+  STAMPS_FOLDER_PATH="${INSTALL_FOLDER_PATH}"
+
+  LIBS_INSTALL_FOLDER_PATH="${INSTALL_FOLDER_PATH}/libs"
+  # Use explicit include & especially lib, to prevent compiler complaining
+  # for missing folders.
+  mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/include"
+  mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/lib"
+
+  APP_INSTALL_FOLDER_PATH="${INSTALL_FOLDER_PATH}/${APP_LC_NAME}"
+  mkdir -pv "${APP_INSTALL_FOLDER_PATH}"
+
+  LOGS_FOLDER_NAME=${LOGS_FOLDER_NAME:-"logs"}
+  LOGS_FOLDER_PATH="${WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/${LOGS_FOLDER_NAME}"
+  mkdir -pv "${LOGS_FOLDER_PATH}"
+
+  DEPLOY_FOLDER_NAME=${DEPLOY_FOLDER_NAME:-"deploy"}
+  DEPLOY_FOLDER_PATH="${WORK_FOLDER_PATH}/${DEPLOY_FOLDER_NAME}"
+  # Do it later, only if needed.
+  # mkdir -pv "${DEPLOY_FOLDER_PATH}"
+
+  DISTRO_INFO_NAME=${DISTRO_INFO_NAME:-"distro-info"}
+  
+  BUILD_GIT_PATH="${WORK_FOLDER_PATH}/build.git"
+
+  # ---------------------------------------------------------------------------
+
+  APP_PREFIX="${INSTALL_FOLDER_PATH}/${APP_LC_NAME}"
+  # The documentation location is now the same on all platforms.
+  APP_PREFIX_DOC="${APP_PREFIX}/share/doc"
+
+  # ---------------------------------------------------------------------------
+
+  SOURCES_FOLDER_PATH=${SOURCES_FOLDER_PATH:-"${WORK_FOLDER_PATH}/sources"}
+  mkdir -pv "${SOURCES_FOLDER_PATH}"
+
+  # Empty defaults.
+  IS_DEVELOP=${IS_DEVELOP:-""}
+  IS_DEBUG=${IS_DEBUG:-""}
+  WITH_PDF=${WITH_PDF:-""}
+  WITH_HTML=${WITH_HTML:-""}
+  WITH_TESTS=${WITH_TESTS:-""}
+
+  # Redefine this to "y" to create files that include the architecture.
+  HAS_NAME_ARCH=${HAS_NAME_ARCH:-""}
+
+  USE_TAR_GZ=${USE_TAR_GZ:-"y"}
+  USE_SINGLE_FOLDER_PATH=${USE_SINGLE_FOLDER_PATH:-"y"}
+
+  # ---------------------------------------------------------------------------
+
+  export LANGUAGE="en_US:en"
+  export LANG="en_US.UTF-8"
+  export LC_ALL="en_US.UTF-8"
+  export LC_COLLATE="en_US.UTF-8"
+  export LC_CTYPE="UTF-8"
+  export LC_MESSAGES="en_US.UTF-8"
+  export LC_MONETARY="en_US.UTF-8"
+  export LC_NUMERIC="en_US.UTF-8"
+  export LC_TIME="en_US.UTF-8"
+
+  export PATH
+  export LD_LIBRARY_PATH
+
+  export SOURCES_FOLDER_PATH
+
+  # libtool fails with the Ubuntu /bin/sh.
+  export SHELL="/bin/bash"
+  export CONFIG_SHELL="/bin/bash"
+
+  echo
+  env | sort
+}
+
+function prepare_xbb_extras()
+{
+  # ---------------------------------------------------------------------------
+
+  XBB_CPPFLAGS=""
+
+  XBB_CFLAGS="-ffunction-sections -fdata-sections -pipe"
+  XBB_CXXFLAGS="-ffunction-sections -fdata-sections -pipe"
+
+  if [ "${TARGET_ARCH}" == "x64" -o "${TARGET_ARCH}" == "x32" ]
+  then
+    XBB_CFLAGS+=" -m${TARGET_BITS}"
+    XBB_CXXFLAGS+=" -m${TARGET_BITS}"
+  fi
+
+  XBB_LDFLAGS=""
+
+  if [ "${IS_DEBUG}" == "y" ]
+  then
+    XBB_CFLAGS+=" -g -O0"
+    XBB_CXXFLAGS+=" -g -O0"
+    XBB_LDFLAGS+=" -g -O0"
+  else
+    XBB_CFLAGS+=" -O2"
+    XBB_CXXFLAGS+=" -O2"
+    XBB_LDFLAGS+=" -O2"
+  fi
+
+  if [ ! -z "$(xbb_activate; which "g++-xbb")" ]
+  then
+    prepare_gcc_env "" "-xbb"
+  elif [ ! -z "$(xbb_activate; which "g++-9")" ]
+  then
+    prepare_gcc_env "" "-9"
+  elif [ ! -z "$(xbb_activate; which "g++-8")" ]
+  then
+    prepare_gcc_env "" "-8"
+  elif [ ! -z "$(xbb_activate; which "g++-7")" ]
+  then
+    prepare_gcc_env "" "-7"
+  else
+    prepare_gcc_env "" ""
+  fi
+
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    # Do not add -static here, it fails.
+    # Do not try to link pthread statically, it must match the system glibc.
+    XBB_LDFLAGS_LIB="${XBB_LDFLAGS}"
+    XBB_LDFLAGS_APP="${XBB_LDFLAGS} -Wl,--gc-sections"
+    XBB_LDFLAGS_APP_STATIC_GCC="${XBB_LDFLAGS_APP} -static-libgcc -static-libstdc++"
+  elif [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+    # Note: macOS linker ignores -static-libstdc++, so 
+    # libstdc++.6.dylib should be handled.
+    XBB_LDFLAGS+=" -Wl,-macosx_version_min,10.10"
+    XBB_LDFLAGS_LIB="${XBB_LDFLAGS}"
+    XBB_LDFLAGS_APP="${XBB_LDFLAGS} -Wl,-dead_strip"
+    XBB_LDFLAGS_APP_STATIC_GCC="${XBB_LDFLAGS_APP}"
+  elif [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+    export NATIVE_CC=${CC}
+    export NATIVE_CXX=${CXX}
+    
+    prepare_gcc_env "${CROSS_COMPILE_PREFIX}-"
+
+    # CRT_glob is from Arm script
+    # -static avoids libwinpthread-1.dll 
+    # -static-libgcc avoids libgcc_s_sjlj-1.dll 
+    XBB_LDFLAGS_LIB="${XBB_LDFLAGS}"
+    XBB_LDFLAGS_APP="${XBB_LDFLAGS} -Wl,--gc-sections"
+    XBB_LDFLAGS_APP_STATIC_GCC="${XBB_LDFLAGS_APP} -static-libgcc -static-libstdc++"
+  else
+    echo "Oops! Unsupported ${TARGET_PLATFORM}."
+    exit 1
+  fi
+
+  XBB_CFLAGS_NO_W="${XBB_CFLAGS} -w"
+  XBB_CXXFLAGS_NO_W="${XBB_CXXFLAGS} -w"
+
+  set +u
+  if [ ! -z "${XBB_FOLDER_PATH}" -a -x "${XBB_FOLDER_PATH}/bin/pkg-config-verbose" ]
+  then
+    PKG_CONFIG="${XBB_FOLDER_PATH}/bin/pkg-config-verbose"
+  else
+    PKG_CONFIG="$(which pkg-config)"
+  fi
+  set -u
+
+  # Hopefully defining it empty would be enough...
+  PKG_CONFIG_PATH=${PKG_CONFIG_PATH:-""}
+
+  # Prevent pkg-config to search the system folders (configured in the
+  # pkg-config at build time).
+  PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-""}
+
+  set +u
+  echo
+  echo "CC=${CC}"
+  echo "CXX=${CXX}"
+  echo "XBB_CPPFLAGS=${XBB_CPPFLAGS}"
+  echo "XBB_CFLAGS=${XBB_CFLAGS}"
+  echo "XBB_CXXFLAGS=${XBB_CXXFLAGS}"
+
+  echo "XBB_LDFLAGS_LIB=${XBB_LDFLAGS_LIB}"
+  echo "XBB_LDFLAGS_APP=${XBB_LDFLAGS_APP}"
+  echo "XBB_LDFLAGS_APP_STATIC_GCC=${XBB_LDFLAGS_APP_STATIC_GCC}"
+
+  echo "PKG_CONFIG=${PKG_CONFIG}"
+  echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}"
+  echo "PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}"
+  set -u
+
+  (
+    xbb_activate
+
+    which ${CC}
+    ${CC} --version
+
+    which make
+    make --version
+  )
+
+  # ---------------------------------------------------------------------------
+
+  # CC & co were exported by prepare_gcc_env.
+  export XBB_CPPFLAGS
+
+  export XBB_CFLAGS
+  export XBB_CXXFLAGS
+
+  export XBB_CFLAGS_NO_W
+  export XBB_CXXFLAGS_NO_W
+
+  export XBB_LDFLAGS
+  export XBB_LDFLAGS_LIB
+  export XBB_LDFLAGS_APP
+  export XBB_LDFLAGS_APP_STATIC_GCC
+
+  export PKG_CONFIG
+  export PKG_CONFIG_PATH
+  export PKG_CONFIG_LIBDIR
+}
+
+function prepare_gcc_env()
+{
+  local prefix="$1"
+
+  local suffix
+  if [ $# -ge 2 ]
+  then
+    suffix="$2"
+  else
+    suffix=""
+  fi
+
+  export CC="${prefix}gcc${suffix}"
+  export CXX="${prefix}g++${suffix}"
+
+  export AR="${prefix}gcc-ar${suffix}"
+  export AS="${prefix}as"
+  export DLLTOOL="${prefix}dlltool"
+  export LD="${prefix}ld"
+  export NM="${prefix}gcc-nm${suffix}"
+  export OBJCOPY="${prefix}objcopy"
+  export OBJDUMP="${prefix}objdump"
+  export RANLIB="${prefix}gcc-ranlib${suffix}"
+  export READELF="${prefix}readelf"
+  export SIZE="${prefix}size"
+  export STRIP="${prefix}strip"
+  export WINDRES="${prefix}windres"
+  export WINDMC="${prefix}windmc"
+  export RC="${prefix}windres"
+}
+
+function unset_gcc_env()
+{
+  unset CC
+  unset CXX
+  unset AR
+  unset AS
+  unset DLLTOOL
+  unset LD
+  unset NM
+  unset OBJCOPY
+  unset OBJDUMP
+  unset RANLIB
+  unset READELF
+  unset SIZE
+  unset STRIP
+  unset WINDRES
+  unset WINDMC
+  unset RC
+}
+
+# -----------------------------------------------------------------------------
+
+function do_actions()
+{
+  if [ "${ACTION}" == "clean" ]
+  then
+    echo
+
+    if [ "${IS_NATIVE}" == "y" ]
+    then
+      echo "Removing the ${TARGET_FOLDER_NAME} build and install ${APP_LC_NAME} folders..."
+
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/build/${APP_LC_NAME}"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/install/${APP_LC_NAME}"
+    elif [ ! -z "${DO_BUILD_WIN32}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX64}${DO_BUILD_OSX}" ]
+    then
+      if [ "${DO_BUILD_WIN32}" == "y" ]
+      then
+        echo "Removing the win32-x32 build and install ${APP_LC_NAME} folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32/build/${APP_LC_NAME}"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32/install/${APP_LC_NAME}"
+      fi
+      if [ "${DO_BUILD_WIN64}" == "y" ]
+      then
+        echo "Removing the win32-x64 build and install ${APP_LC_NAME} folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64/build/${APP_LC_NAME}"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64/install/${APP_LC_NAME}"
+      fi
+      if [ "${DO_BUILD_LINUX32}" == "y" ]
+      then
+        echo "Removing the linux-x32 build and install ${APP_LC_NAME} folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32/build/${APP_LC_NAME}"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32/install/${APP_LC_NAME}"
+      fi
+      if [ "${DO_BUILD_LINUX64}" == "y" ]
+      then
+        echo "Removing the linux-x64 build and install ${APP_LC_NAME} folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64/build/${APP_LC_NAME}"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64/install/${APP_LC_NAME}"
+      fi
+      if [ "${DO_BUILD_OSX}" == "y" ]
+      then
+        echo "Removing the darwin-x64 build and install ${APP_LC_NAME} folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64/build/${APP_LC_NAME}"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64/install/${APP_LC_NAME}"
+      fi
+    else
+      echo "Removing the ${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH} build and install ${APP_LC_NAME} folders..."
+
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}/build/${APP_LC_NAME}"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}/install/${APP_LC_NAME}"
+    fi
+  fi
+
+  if [ "${ACTION}" == "cleanlibs" ]
+  then
+    echo
+
+    if [ "${IS_NATIVE}" == "y" ]
+    then
+      echo "Removing the ${TARGET_FOLDER_NAME} build and install libs folders..."
+
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/build/libs"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/install/libs"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}/install"/stamp-*-installed
+    elif [ ! -z "${DO_BUILD_WIN32}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX64}${DO_BUILD_OSX}" ]
+    then
+      if [ "${DO_BUILD_WIN32}" == "y" ]
+      then
+        echo "Removing the win32-x32 build and install libs folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32/build/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32/install/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32/install"/stamp-*-installed
+      fi
+      if [ "${DO_BUILD_WIN64}" == "y" ]
+      then
+        echo "Removing the win32-x64 build and install libs folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64/build/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64/install/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64/install"/stamp-*-installed
+      fi
+      if [ "${DO_BUILD_LINUX32}" == "y" ]
+      then
+        echo "Removing the linux-x32 build and install libs folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32/build/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32/install/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32/install"/stamp-*-installed
+      fi
+      if [ "${DO_BUILD_LINUX64}" == "y" ]
+      then
+        echo "Removing the linux-x64 build and install libs folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64/build/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64/install/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64/install"/stamp-*-installed
+      fi
+      if [ "${DO_BUILD_OSX}" == "y" ]
+      then
+        echo "Removing the darwin-x64 build and install libs folders..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64/build/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64/install/libs"
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64/install"/stamp-*-installed
+      fi
+    else
+      echo "Removing the ${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH} build and install libs folders..."
+
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}/build/libs"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}/install/libs"
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}/install"/stamp-*-installed
+    fi
+  fi
+
+  if [ "${ACTION}" == "cleanall" ]
+  then
+    echo
+    if [ "${IS_NATIVE}" == "y" ]
+    then
+      echo "Removing the ${TARGET_FOLDER_NAME} folder..."
+  
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${TARGET_FOLDER_NAME}"
+    elif [ ! -z "${DO_BUILD_WIN32}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX64}${DO_BUILD_OSX}" ]
+    then
+      if [ "${DO_BUILD_WIN32}" == "y" ]
+      then
+        echo "Removing the win32-x32 folder..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x32"
+      fi
+      if [ "${DO_BUILD_WIN64}" == "y" ]
+      then
+        echo "Removing the win32-x64 folder..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/win32-x64"
+      fi
+      if [ "${DO_BUILD_LINUX32}" == "y" ]
+      then
+        echo "Removing the linux-x32 folder..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x32"
+      fi
+      if [ "${DO_BUILD_LINUX64}" == "y" ]
+      then
+        echo "Removing the linux-x64 folder..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/linux-x64"
+      fi
+      if [ "${DO_BUILD_OSX}" == "y" ]
+      then
+        echo "Removing the darwin-x64 folder..."
+
+        rm -rf "${HOST_WORK_FOLDER_PATH}/darwin-x64"
+      fi
+    else
+      echo "Removing the ${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH} folder..."
+
+      rm -rf "${HOST_WORK_FOLDER_PATH}/${HOST_NODE_PLATFORM}-${HOST_NODE_ARCH}"
+    fi
+  fi
+
+  if [ "${ACTION}" == "clean" -o "${ACTION}" == "cleanlibs" -o "${ACTION}" == "cleanall" ]
+  then
+    echo
+    echo "Clean completed. Proceed with a regular build."
+
+    exit 0
+  fi
+
+  # Not used for native buils. Otherwise the names of the docker images
+  # must be set.
+  if [ "${ACTION}" == "preload-images" ]
+  then
+    host_start_timer
+
+    host_prepare_docker
+
+    echo
+    echo "Check/Preload Docker images..."
+
+    if [ "${HOST_MACHINE}" == "aarch64" -o "${HOST_MACHINE}" == "armv7l" -o "${HOST_MACHINE}" == "armv8l" ]
+    then
+      echo
+      docker run --interactive --tty "${docker_linux_arm64_image}" \
+        lsb_release --description --short
+
+      echo
+      docker run --interactive --tty "${docker_linux_arm32_image}" \
+        lsb_release --description --short
+    else
+      echo
+      docker run --interactive --tty "${docker_linux64_image}" \
+        lsb_release --description --short
+
+      echo
+      docker run --interactive --tty "${docker_linux32_image}" \
+        lsb_release --description --short
+    fi
+
+    echo
+    docker images
+
+    host_stop_timer
+
+    exit 0
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function run_verbose()
+{
+  # Does not include the .exe extension.
+  local app_path=$1
+  shift
+
+  echo
+  echo "[${app_path} $@]"
+  "${app_path}" "$@" 2>&1
+}
+
+function run_app()
+{
+  # Does not include the .exe extension.
+  local app_path=$1
+  shift
+
+  echo
+  echo "${app_path} $@"
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    "${app_path}" "$@"
+  elif [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+    "${app_path}" "$@"
+  elif [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+    local wsl_path=$(which wsl.exe)
+    if [ ! -z "${wsl_path}" ]
+    then
+      "${app_path}.exe" "$@"
+    else 
+      (
+        xbb_activate
+        
+        local wine_path=$(which wine)
+        if [ ! -z "${wine_path}" ]
+        then
+          wine "${app_path}.exe" "$@"
+        else
+          echo "Install wine if you want to run the .exe binaries on Linux."
+        fi
+      )
+    fi
+  else
+    echo "Oops! Unsupported ${TARGET_PLATFORM}."
+    exit 1
+  fi
+}
+
+function show_libs()
+{
+  # Does not include the .exe extension.
+  local app_path=$1
+  shift
+
+  (
+    xbb_activate
+
+    if [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+      echo
+      echo "readelf -d ${app_path} | grep 'ibrary'"
+      # Ignore errors in case it is not using shared libraries.
+      set +e 
+      readelf -d "${app_path}" | grep 'ibrary'
+      echo "ldd -v ${app_path}"
+      ldd -v "${app_path}"
+      set -e
+    elif [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+      echo
+      echo "otool -L ${app_path}"
+      otool -L "${app_path}"
+    elif [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      echo
+      echo ${CROSS_COMPILE_PREFIX}-objdump -x ${app_path}.exe
+      ${CROSS_COMPILE_PREFIX}-objdump -x ${app_path}.exe | grep -i 'DLL Name' 
+    else
+      echo "Oops! Unsupported ${TARGET_PLATFORM}."
+      exit 1
+    fi
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+function do_patch()
+{
+  if [ ! -z "$1" ]
+  then
+    local patch_file_name="$1"
+    local patch_path="${BUILD_GIT_PATH}/patches/${patch_file_name}"
+    if [ -f "${patch_path}" ]
+    then
+      echo "Patching..."
+      patch -p0 < "${patch_path}"
+    fi
+  fi
+}
+
+function extract()
+{
+  local archive_name="$1"
+  local folder_name="$2"
+  # local patch_file_name="$3"
+  local pwd="$(pwd)"
+
+  if [ ! -d "${folder_name}" ]
+  then
+    (
+      xbb_activate
+
+      echo
+      echo "Extracting \"${archive_name}\" -> \"${pwd}/${folder_name}\"..."
+      if [[ "${archive_name}" == *zip ]]
+      then
+        unzip "${archive_name}" 
+      else
+        if [ ! -z "${DEBUG}" ]
+        then
+          tar -x -v -f "${archive_name}"
+        else
+          tar -x -f "${archive_name}"
+        fi
+      fi
+
+      if [ $# -ge 3 ]
+      then
+        cd "${folder_name}"
+        do_patch "$3"
+      fi
+    )
+  else
+    echo "Folder \"${pwd}/${folder_name}\" already present."
+  fi
+}
+
+
+function download()
+{
+  local url="$1"
+  local archive_name="$2"
+
+  if [ ! -f "${DOWNLOAD_FOLDER_PATH}/${archive_name}" ]
+  then
+    (
+      xbb_activate
+
+      echo
+      echo "Downloading \"${archive_name}\" from \"${url}\"..."
+      rm -f "${DOWNLOAD_FOLDER_PATH}/${archive_name}.download"
+      mkdir -pv "${DOWNLOAD_FOLDER_PATH}"
+      curl --fail -L -o "${DOWNLOAD_FOLDER_PATH}/${archive_name}.download" "${url}"
+      mv "${DOWNLOAD_FOLDER_PATH}/${archive_name}.download" "${DOWNLOAD_FOLDER_PATH}/${archive_name}"
+    )
+  else
+    echo "File \"${DOWNLOAD_FOLDER_PATH}/${archive_name}\" already downloaded."
+  fi
+}
+
+# $4 is the patch file name
+function download_and_extract()
+{
+  local url="$1"
+  local archive_name="$2"
+  local folder_name="$3"
+
+  download "${url}" "${archive_name}"
+  if [ $# -ge 4 ]
+  then
+    extract "${DOWNLOAD_FOLDER_PATH}/${archive_name}" "${folder_name}" "$4"
+  else
+    extract "${DOWNLOAD_FOLDER_PATH}/${archive_name}" "${folder_name}"
+  fi
+}
+
+function git_clone()
+{
+  local url="$1"
+  local branch="$2"
+  local commit="$3"
+  local folder_name="$4"
+
+  (
+    echo
+    echo "Cloning \"${folder_name}\" from \"${url}\"..."
+    git clone --branch="${branch}" "${url}" "${folder_name}"
+    if [ -n "${commit}" ]
+    then
+      cd "${folder_name}"
+      git checkout -qf "${commit}"
+    fi
+  )
+}
+
+# Copy the build files to the Work area, to make them easily available. 
+function copy_build_git()
+{
+  rm -rf "${HOST_WORK_FOLDER_PATH}/build.git"
+  mkdir -pv "${HOST_WORK_FOLDER_PATH}/build.git"
+  cp -r "$(dirname ${script_folder_path})"/* "${HOST_WORK_FOLDER_PATH}/build.git"
+  rm -rf "${HOST_WORK_FOLDER_PATH}/build.git/scripts/helper/.git"
+  rm -rf "${HOST_WORK_FOLDER_PATH}/build.git/scripts/helper/build-helper.sh"
+}
+
+# -----------------------------------------------------------------------------
+
+function check_binary()
+{
+  local file_path="$1"
+
+  if [ ! -x "${file_path}" ]
+  then
+    return 0
+  fi
+
+  if file --mime "${file_path}" | grep -q text
+  then
+    return 0
+  fi
+
+  check_binary_for_libraries "$1"
+}
+
+function check_binary_for_libraries()
+{
+  local file_path="$1"
+  local file_name="$(basename ${file_path})"
+  local folder_path="$(dirname ${file_path})"
+
+  (
+    xbb_activate
+
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      echo
+      echo "${file_name} (${file_path})"
+      set +e
+      ${CROSS_COMPILE_PREFIX}-objdump -x "${file_path}" | grep -i 'DLL Name'
+
+      local dll_names=$(${CROSS_COMPILE_PREFIX}-objdump -x "${file_path}" \
+        | grep -i 'DLL Name' \
+        | sed -e 's/.*DLL Name: \(.*\)/\1/' \
+      )
+
+      local n
+      for n in ${dll_names}
+      do
+        if [ ! -f "${folder_path}/${n}" ] 
+        then
+          if is_win_sys_dll "${n}"
+          then
+            :
+          elif [ "${n}${HAS_WINPTHREAD}" == "libwinpthread-1.dlly" ]
+          then
+            :
+          elif [[ ${n} == python*.dll ]] && [[ ${file_name} == *-gdb-py.exe ]]
+          then
+            :
+          else
+            echo "Unexpected |${n}|"
+            exit 1
+          fi
+        fi
+      done
+      set -e
+    elif [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+      echo
+      (
+        set +e
+        cd ${folder_path}
+        otool -L "${file_name}"
+        set -e
+      )
+
+      # Skip the first line which is the binary itself.
+      local libs
+      if [[ "${file_name}" == *\.dylib ]]
+      then
+        # Skip the second line too, which is the library again.
+        lib_names=$(otool -L "${file_path}" \
+              | sed '1d' \
+              | sed '1d' \
+              | sed -e 's|[[:space:]]*\(.*\) (.*)|\1|' \
+            )
+      else
+        lib_names=$(otool -L "${file_path}" \
+              | sed '1d' \
+              | sed -e 's|[[:space:]]*\(.*\) (.*)|\1|' \
+            )
+      fi
+      for lib_name in ${lib_names}
+      do
+        if [ "${lib_name:0:1}" != "@" ]
+        then
+          if ! is_darwin_allowed_sys_dylib "${lib_name}"
+          then
+            echo ">>> \"${lib_name}\" is not expected here"
+            exit 1
+          fi
+        fi
+      done
+
+      # More or less deprecated by the above.
+      set +e
+      local unxp
+      if [[ "${file_name}" == *\.dylib ]]
+      then
+        unxp=$(otool -L "${file_path}" | sed '1d' | sed '1d' | grep -v "${file_name}" | egrep -e "(macports|homebrew|opt|install)/")
+      else
+        unxp=$(otool -L "${file_path}" | sed '1d' | grep -v "${file_name}" | egrep -e "(macports|homebrew|opt|install)/")
+      fi
+      set -e
+
+      # echo "|${unxp}|"
+      if [ ! -z "$unxp" ]
+      then
+        echo "Unexpected |${unxp}|"
+        exit 1
+      fi
+    elif [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+      echo
+      echo "${file_name} (${file_path})"
+      set +e
+      readelf -d "${file_path}" | egrep -i '(SONAME)'
+      readelf -d "${file_path}" | egrep -i '(RUNPATH|RPATH)'
+      readelf -d "${file_path}" | egrep -i '(NEEDED)'
+
+      local so_names=$(readelf -d "${file_path}" \
+        | grep -i 'Shared library' \
+        | sed -e 's/.*Shared library: \[\(.*\)\]/\1/' \
+      )
+
+      local relative_path=$(readelf -d "${file_path}" | egrep -i '(RUNPATH|RPATH)' | sed -e 's/.*\[\$ORIGIN//' | sed -e 's/\].*//')
+      # echo $relative_path
+
+      for so_name in ${so_names}
+      do
+        if [ ! -f "${folder_path}${relative_path}/${so_name}" ] 
+        then
+          if is_linux_sys_so "${so_name}"
+          then
+            :
+          elif [[ ${so_name} == libpython* ]] && [[ ${file_name} == *-gdb-py ]]
+          then
+            :
+          else
+            echo "Unexpected |${so_name}|"
+            exit 1
+          fi
+        fi
+      done
+      set -e
+    else
+      echo "Oops! Unsupported ${TARGET_PLATFORM}."
+      exit 1
+    fi
+  )
+}
+
+function is_win_sys_dll() 
+{
+  local dll_name="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
+
+  # DLLs that are expected to be present on any Windows.
+  # Be sure all names are lower case!
+  local sys_dlls=( \
+    advapi32.dll \
+    cfgmgr32.dll \
+    crypt32.dll \
+    dnsapi.dll \
+    gdi32.dll \
+    imm32.dll \
+    imm32.dll \
+    iphlpapi.dll \
+    iphlpapi.dll \
+    kernel32.dll \
+    msvcr90.dll \
+    oleaut32.dll \
+    psapi.dll \
+    rpcrt4.dll \
+    setupapi.dll \
+    shell32.dll \
+    shlwapi.dll \
+    user32.dll \
+    userenv.dll \
+    vcruntime140.dll \
+    version.dll \
+    winmm.dll \
+    winmm.dll \
+    ws2_32.dll \
+    \
+    msvcrt.dll \
+    ole32.dll \
+    api-ms-win-crt-runtime-l1-1-0.dll \
+    api-ms-win-crt-math-l1-1-0.dll \
+    api-ms-win-crt-locale-l1-1-0.dll \
+    api-ms-win-crt-string-l1-1-0.dll \
+    api-ms-win-crt-stdio-l1-1-0.dll \
+    api-ms-win-crt-convert-l1-1-0.dll \
+    api-ms-win-crt-time-l1-1-0.dll \
+    api-ms-win-crt-environment-l1-1-0.dll \
+    api-ms-win-crt-process-l1-1-0.dll \
+    api-ms-win-crt-heap-l1-1-0.dll \
+    api-ms-win-crt-conio-l1-1-0.dll \
+    api-ms-win-crt-filesystem-l1-1-0.dll \
+  )
+
+  # The Python DLL were a permanent source of trouble.
+  # python27.dll \
+  # The latest Python 2.7.18 has no DLL at all, so it cannot be skipped.
+  # python37.dll \
+  # The Python 3 seems better, allow to copy it in the archive,
+  # to be sure it matches the version used during build.
+
+  local dll
+  for dll in "${sys_dlls[@]}"
+  do
+    if [ "${dll}" == "${dll_name}" ]
+    then
+      return 0 # True
+    fi
+  done
+  return 1 # False
+}
+
+function is_linux_sys_so() 
+{
+  local lib_name="$1"
+
+  # Do not add these two, they are present if the toolchain is installed, 
+  # but this is not guaranteed, so better copy them from the xbb toolchain.
+  # libstdc++.so.6 
+  # libgcc_s.so.1 
+
+  # Shared libraries that are expected to be present on any Linux.
+  # Note the X11 libraries.
+  local sys_lib_names=(\
+    librt.so.1 \
+    libm.so.6 \
+    libc.so.6 \
+    libutil.so.1 \
+    libpthread.so.0 \
+    libdl.so.2 \
+    ld-linux.so.2 \
+    ld-linux.so.3 \
+    ld-linux-x86-64.so.2 \
+    ld-linux-armhf.so.3 \
+    ld-linux-arm64.so.1 \
+    ld-linux-aarch64.so.1 \
+    libX11.so.6 \
+    libXau.so.6 \
+    libxcb.so.1 \
+  )
+
+  local sys_lib_name
+  for sys_lib_name in "${sys_lib_names[@]}"
+  do
+    if [ "${lib_name}" == "${sys_lib_name}" ]
+    then
+      return 0 # True
+    fi
+  done
+  return 1 # False
+}
+
+function is_darwin_sys_dylib() 
+{
+  local lib_name="$1"
+
+  if [[ ${lib_name} == /usr/lib* ]]
+  then
+    return 0 # True
+  fi
+  if [[ ${lib_name} == /System/Library/Frameworks/* ]]
+  then
+    return 0 # True
+  fi
+  if [[ ${lib_name} == /Library/Frameworks/* ]]
+  then
+    return 0 # True
+  fi
+
+  return 1 # False
+}
+
+function is_darwin_allowed_sys_dylib() 
+{
+  local lib_name="$1"
+
+  # Since there is no -static-libc++, the first attempt was to not 
+  # define these here and have the 10.10 ones copied to the application. 
+  # Building CMake proved that this is ok with 10.11 and 10.12, but 
+  # failes on 10.13 and 10.14 with:
+  # dyld: Symbol not found: __ZNSt3__118shared_timed_mutex13unlock_sharedEv
+  # Referenced from: /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
+  # Expected in: /Users/travis/test-cmake/xpack-cmake-3.17.1-1/bin/libc++.1.dylib
+  # in /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
+  #
+  # /usr/lib/libc++.dylib \
+  # /usr/lib/libc++.1.dylib \
+  # /usr/lib/libc++abi.dylib \
+
+  # Same for -static-libgcc; there were no cases which failed on later releases,
+  # but for consistency, they are also included here.
+  #
+  # /usr/lib/libgcc_s.1.dylib \
+
+  local sys_libs=(\
+    /usr/lib/libgcc_s.1.dylib \
+    /
+    /usr/lib/libc++.dylib \
+    /usr/lib/libc++.1.dylib \
+    /usr/lib/libc++abi.dylib \
+    /
+    /usr/lib/libSystem.B.dylib \
+    /usr/lib/libobjc.A.dylib \
+  )
+
+  if [[ ${lib_name} == /System/Library/Frameworks/* ]]
+  then
+    # Allow all system frameworks.
+    return 0 # True
+  fi
+
+  local lib
+  for lib in "${sys_libs[@]}"
+  do
+    if [ "${lib}" == "${lib_name}" ]
+    then
+      return 0 # True
+    fi
+  done
+  return 1 # False
+}
+
+# -----------------------------------------------------------------------------
+
+function has_origin()
+{
+  if [ $# -lt 1 ]
+  then
+    warning "has_origin: Missing file argument"
+    exit 1
+  fi
+
+  local bin="$1"
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    local origin=$(readelf -d ${bin} | grep 'Library runpath: \[$ORIGIN\]')
+    if [ ! -z "${origin}" ]
+    then
+      return 0 # true
+    fi
+  fi
+  return 1 # false
+}
+
+# Strip binary files as in "strip binary" form, for both native
+# (linux/mac) and mingw.
+function strip_binary2() 
+{
+  (
+    set +e
+    if [ $# -lt 2 ]
+    then
+        warning "strip_binary: Missing arguments"
+        exit 1
+    fi
+
+    local strip="$1"
+    local bin="$2"
+
+    if is_elf "${bin}"
+    then
+      if has_origin "${bin}"
+      then
+        echo "${strip} ${bin} skipped (patched)"
+      else
+        echo "${strip} ${bin}"
+        # ${strip} ${bin} 2>/dev/null || true
+        "${strip}" -S "${bin}" || true
+      fi
+    else
+      echo $(file "${bin}")
+    fi
+
+    set -e
+  )
+}
+
+function strip_binary() 
+{
+  if [ $# -lt 1 ]
+  then
+    warning "strip_binary: Missing file argument"
+    exit 1
+  fi
+
+  local file_path="$1"
+
+  if ! is_elf "${file_path}"
+  then
+    echo $(file "${file_path}")
+    return
+  fi  
+
+  local strip="strip"
+  if [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+    strip="${CROSS_COMPILE_PREFIX}-strip"
+    if [[ "${file_path}" != *.exe ]] && [[ "${file_path}" != *.dll ]]
+    then
+      bin="${file_path}.exe"
+    fi
+  fi
+
+  if has_origin "${file_path}"
+  then
+    # If the file was patched, skip strip, otherwise
+    # we may damage the binary due to a bug in strip.
+    echo "${strip} ${file_path} skipped (patched)"
+    return
+  fi
+
+  echo "${strip} ${file_path}"
+  "${strip}" -S "${file_path}" || true
+}
+
+function is_elf()
+{
+  if [ $# -lt 1 ]
+  then
+    warning "is_elf: Missing arguments"
+    exit 1
+  fi
+
+  local bin_path="$1"
+
+  # Symlinks do not match.
+  if [ -L "${bin_path}" ]
+  then
+    return 1
+  fi
+
+  if [ -f "${bin_path}" ]
+  then
+    # Return 0 (true) if found.
+    file ${bin_path} | egrep -q "( ELF )|( PE )|( PE32 )|( PE32\+ )|( Mach-O )"
+  else
+    return 1
+  fi
+}
+
+function is_ar()
+{
+  if [ $# -lt 1 ]
+  then
+    warning "is_ar: Missing arguments"
+    exit 1
+  fi
+
+  local bin_path="$1"
+
+  # Symlinks do not match.
+  if [ -L "${bin_path}" ]
+  then
+    return 1
+  fi
+
+  if [ -f "${bin_path}" ]
+  then
+    # Return 0 (true) if found.
+    file ${bin_path} | egrep -q "ar archive"
+  else
+    return 1
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# Deprecated, use copy_dependencies_recursive().
+function copy_win_gcc_dll() 
+{
+  local dll_name="$1"
+
+  # Identify the current cross gcc version, to locate the specific dll folder.
+  local cross_gcc_version=$(${CROSS_COMPILE_PREFIX}-gcc --version | grep 'gcc' | sed -e 's/.*\s\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\).*/\1.\2.\3/')
+  local cross_gcc_version_short=$(echo ${cross_gcc_version} | sed -e 's/\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\).*/\1.\2/')
+  local SUBLOCATION="-win32"
+
+  # First try Ubuntu specific locations,
+  # then do a long full search.
+
+  if [ -f "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/lib/${dll_name}" ]
+  then
+    cp -v "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/lib/${dll_name}" \
+      "${APP_PREFIX}/bin"
+  elif [ -f "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version}/${dll_name}" ]
+  then
+    cp -v "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version}/${dll_name}" \
+      "${APP_PREFIX}/bin"
+  elif [ -f "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version_short}/${dll_name}" ]
+  then
+    cp -v "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version_short}/${dll_name}" \
+      "${APP_PREFIX}/bin"
+  elif [ -f "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version_short}${SUBLOCATION}/${dll_name}" ]
+  then
+    cp -v "/usr/lib/gcc/${CROSS_COMPILE_PREFIX}/${cross_gcc_version_short}${SUBLOCATION}/${dll_name}" \
+      "${APP_PREFIX}/bin"
+  else
+    echo "Searching /usr for ${dll_name}..."
+    SJLJ_PATH=$(find "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}" /usr \! -readable -prune -o -name ${dll_name} -print | grep ${CROSS_COMPILE_PREFIX})
+    cp -v ${SJLJ_PATH} "${APP_PREFIX}/bin"
+  fi
+}
+
+# Deprecated, use copy_dependencies_recursive().
+function copy_win_libwinpthread_dll() 
+{
+  if [ -f "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/bin/libwinpthread-1.dll" ]
+  then
+    cp "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/bin/libwinpthread-1.dll" \
+      "${APP_PREFIX}/bin"
+  else
+    echo "No libwinpthread-1.dll"
+    exit 1
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function change_dylib()
+{
+  local dylib_name="$1"
+  local file_path="$2"
+
+  local dylib_path="$(otool -L "${file_path}" | sed '1d' | sed -e 's|[[:space:]]*\(.*\)[[:space:]][(].*[)]|\1|' | grep "${dylib_name}")"
+
+  if [ -z "${dylib_path}" ]
+  then
+    echo "Dylib ${dylib_name} may not used in binary ${file_path}..."
+    # for example libftdi1.2.4.0.dylib has the name libftdi1.2.dylib.
+    # exit 1
+  elif [ $(printf "${dylib_path}" | wc -l) -gt 1 ]
+  then
+    echo "${file_path} has multiple ${dylib_name} libraries..."
+    exit 1
+  fi
+
+  # Hack to bring Python library name in line with the other libraries.
+  if [ "${dylib_name}" == "Python" ]
+  then
+    local version="$(otool -L "${file_path}" | grep "${dylib_name}" | sed -e 's|.*current version \([0-9][0-9]*\.[0-9][0-9]*\).*|\1|')"
+    dylib_name="libpython${version}.dylib"
+    rm -rf "$(dirname ${file_path})/Python"
+  fi
+
+  chmod +w "${file_path}"
+  install_name_tool \
+    -change "${dylib_path}" \
+    "@executable_path/${dylib_name}" \
+    "${file_path}"
+
+  if [ ! -f "$(dirname ${file_path})/${dylib_name}" ]
+  then
+    install -v -c -m 644 "${dylib_path}" "$(dirname ${file_path})/${dylib_name}"
+  fi
+}
+
+# Workaround to Docker error on 32-bit image:
+# stat: Value too large for defined data type (requires -D_FILE_OFFSET_BITS=64)
+function patch_linux_elf_origin()
+{
+  if [ $# -lt 1 ]
+  then 
+    echo "patch_linux_elf_origin requires 1 args." 
+    exit 1
+  fi
+
+  local file_path="$1"
+  local libexec_path
+  if [ $# -ge 2 ]
+  then
+    libexec_path="$2"
+  else
+    libexec_path="$(dirname "${file_path}")"
+  fi
+
+  local tmp_path=$(mktemp)
+  rm -rf "${tmp_path}"
+  cp "${file_path}" "${tmp_path}"
+  if false
+  then
+    local relative_path="$(realpath --relative-to="$(dirname ${file_path})" "${libexec_path}")"
+    if [ "${IS_DEVELOP}" == "y" ]
+    then
+      echo "\$ORIGIN/${relative_path}" "${file_path}"
+    fi
+    patchelf --set-rpath "\$ORIGIN/${relative_path}" "${tmp_path}"
+  else
+    if file "${tmp_path}" | grep statically
+    then
+      file "${file_path}"
+    else
+      patchelf --set-rpath "\$ORIGIN" "${tmp_path}"
+    fi
+  fi
+  cp "${tmp_path}" "${file_path}"
+  rm -rf "${tmp_path}"
+}
+
+# $1 - absolute path to executable
+# Note: must pass libexec path
+# For single apps, otherwise use prepare_app_folder_libraries
+# Does not use libexec.
+function prepare_app_libraries()
+{
+  local app_path="$1"
+  shift
+
+  (
+    xbb_activate
+
+    local app_folder_path="$(dirname "${app_path}")"
+
+    if [ "${WITH_STRIP}" == "y" ]
+    then
+      strip_binary "${app_path}"
+    fi
+
+    if [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+      echo
+      echo "Shared libraries:"
+      echo "${app_path}"
+      set +e
+      readelf -d "${app_path}" | grep 'Shared library:'
+      set -e
+
+      echo
+      echo "Preparing libraries..."
+      patch_linux_elf_origin "${app_path}"
+
+      echo
+      copy_dependencies_recursive "${app_path}" "${app_folder_path}"
+
+      echo
+      echo "Updated shared libraries:"
+      echo ldd -v "${app_path}"
+      ldd -v "${app_path}"
+    elif [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+      echo
+      echo "Initial dynamic libraries:"
+      otool -L "${app_path}"
+
+      echo
+      echo "Preparing libraries..."
+      copy_dependencies_recursive "${app_path}" "${app_folder_path}"
+
+      echo
+      echo "Updated dynamic libraries:"
+      otool -L "${app_path}"
+    elif [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      echo
+      echo "Dynamic libraries:"
+      echo "${app_path}.exe"
+      ${CROSS_COMPILE_PREFIX}-objdump -x "${app_path}.exe" | grep -i 'DLL Name'
+
+      echo
+      echo "Preparing libraries..."
+      copy_dependencies_recursive "${app_path}.exe" "${app_folder_path}"
+    else
+      echo "Oops! Unsupported ${TARGET_PLATFORM}."
+      exit 1
+    fi
+  )
+}
+
+# Process all executables and shared libraries.
+function prepare_app_folder_libraries()
+{
+  local folder_path
+  if [ $# -ge 1 ]
+  then
+    folder_path="$1"
+  else
+    folder_path="${APP_PREFIX}"
+  fi
+
+  local libexec_folder_path
+  if [ $# -ge 2 ]
+  then
+    libexec_folder_path="$2"
+  else
+    libexec_folder_path="${APP_PREFIX}/libexec"
+  fi
+
+  (
+    xbb_activate
+
+    echo
+    echo "Preparing ${folder_path} libraries..."
+
+    # Otherwise `find` may fail.
+    cd "${WORK_FOLDER_PATH}"
+
+    local binaries
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \*.exe)
+      for bin in ${binaries} 
+      do
+        echo
+        echo "Preparing $(basename "${bin}") ${bin} libraries..."
+        # On Windows the DLLs are copied in the same folder.
+        copy_dependencies_recursive "${bin}" "$(dirname "${bin}")"
+      done
+
+    elif [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \* -perm +111 -and ! -type d)
+      for bin in ${binaries} 
+      do
+        if is_elf "${bin}"
+        then
+          echo
+          echo "Preparing $(basename "${bin}") ${bin} libraries..."
+          if true
+          then
+            copy_dependencies_recursive "${bin}" \
+              "$(dirname "${bin}")"
+          else
+            # On macOS the dynamic libraries can be copied in the libexec folder.
+            copy_dependencies_recursive "${bin}" \
+              "$(dirname "${bin}")" "${libexec_folder_path}"
+          fi
+        fi
+      done
+
+    elif [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \* -perm /111 -and ! -type d)
+      for bin_path in ${binaries} 
+      do
+        if is_elf "${bin_path}"
+        then
+          echo
+          echo "Preparing $(basename "${bin_path}") (${bin_path}) libraries..."
+          # On Linux the shared libraries can be copied in the libexec folder,
+          # and links be kept in the current folder, but not for 32-bit
+          # Intel distros.
+          # For consistency reasons, do the same on all platforms.
+          if true # [ "${TARGET_ARCH}" == "x32" ]
+          then
+            copy_dependencies_recursive "${bin_path}" \
+              "$(dirname "${bin_path}")"
+          else
+            copy_dependencies_recursive "${bin_path}" \
+              "$(dirname "${bin_path}")" "${libexec_folder_path}"
+          fi
+
+          # echo $(basename "${bin_path}") $(readelf -d "${bin_path}" | egrep -i '(RUNPATH|RPATH)')
+        fi
+      done
+
+    else
+      echo "Oops! Unsupported ${TARGET_PLATFORM}."
+      exit 1
+    fi
+  )
+}
+
+function copy_dependencies_recursive()
+{
+  if [ $# -lt 2 ]
+  then 
+    echo "copy_dependencies_recursive requires at least 2 arg." 
+    exit 1
+  fi
+
+  local source_file_path="$1"
+  local dest_folder_path="$2"
+
+  local libexec_folder_path
+  if [ $# -ge 3 ]
+  then 
+    libexec_folder_path="$3"
+  else
+    libexec_folder_path="${dest_folder_path}"
+  fi
+
+  # The first step is to copy the file to libexec and link it.
+
+
+  local source_file_name="$(basename "${source_file_path}")"
+  local source_folder_path="$(dirname "${source_file_path}")"
+
+  local actual_source_file_path=""
+  local copied_file_path="${dest_folder_path}/${source_file_name}"
+
+  # echo "I. Processing ${source_file_path} itself..."
+
+  if [ ! -f "${dest_folder_path}/${source_file_name}" ]
+  then
+
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      # On Windows don't bother with sym links, simply copy the file
+      # to the destination.
+
+      actual_source_file_path="$(readlink -f "${source_file_path}")"
+      copied_file_path="${dest_folder_path}/${source_file_name}"
+
+    else
+      # On POSIX copy to libexec and place a symlink at destination.
+      
+      if [ -L "${source_file_path}" ]
+      then
+        #
+        # Compute the final absolute path of the link, regardless
+        # how many links there are on the way.
+        actual_source_file_path="$(readlink -f "${source_file_path}")"
+        copied_file_path="${libexec_folder_path}/$(basename "${actual_source_file_path}")"
+        
+      elif is_elf "${source_file_path}"
+      then
+
+        if [ "${IS_DEVELOP}" == "y" ]
+        then
+          # The file is definitelly an elf, not a link.
+          echo "is_elf ${source_file_name}"
+        fi
+
+        actual_source_file_path="${source_file_path}"
+        copied_file_path="${libexec_folder_path}/${source_file_name}"
+
+      else
+        # Not a symlink and not an elf. Ignore it.
+        echo "!!!!!!!!!!!!!!"
+        return
+      fi
+    fi
+
+  else
+    : #echo "${dest_folder_path}/${source_file_name} already there"
+  fi
+
+  if [ ! -z "${actual_source_file_path}" ]
+  then
+    if [ ! -f "${copied_file_path}" ]
+    then
+      install -v -c -m 644 "${actual_source_file_path}" "${copied_file_path}"
+    fi
+  else
+    actual_source_file_path="${source_file_path}"
+  fi
+
+  if [ "${WITH_STRIP}" == "y" ]
+  then
+    strip_binary "${copied_file_path}"
+  fi
+
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    patch_linux_elf_origin "${copied_file_path}"
+  fi
+  
+  # If libexec is the destination, there is no need to link.
+  if [ ! -f "${dest_folder_path}/${source_file_name}" ]
+  then
+    (
+      cd "${dest_folder_path}"
+
+      local link_relative_path="$(realpath --relative-to="${dest_folder_path}" "${copied_file_path}")"
+      ln -sv "${link_relative_path}" "${source_file_name}" 
+    )
+  fi
+
+  local actual_dest_file_path="$(realpath "${dest_folder_path}/${source_file_name}")"
+  local actual_dest_folder_path="$(dirname "${actual_dest_file_path}")"
+
+  # echo "II. Processing ${source_file_path} dependencies..."
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+    # The file must be an elf. Get its shared libraries.
+    local lib_names=$(readelf -d "${dest_folder_path}/${source_file_name}" \
+          | grep -i 'Shared library' \
+          | sed -e 's/.*Shared library: \[\(.*\)\]/\1/')
+    local lib_name
+    for lib_name in ${lib_names}
+    do
+      if is_linux_sys_so "${lib_name}"
+      then
+        continue # System library, no need to copy it.
+      else
+        
+        if [ -f "$(dirname "${actual_source_file_path}")/${lib_name}" ]
+        then
+          copy_dependencies_recursive "$(dirname "${actual_source_file_path}")/${lib_name}" \
+            "${actual_dest_folder_path}" "${libexec_folder_path}" 
+        elif [ -f "${LIBS_INSTALL_FOLDER_PATH}/lib64/${lib_name}" ]
+        then
+          copy_dependencies_recursive "${LIBS_INSTALL_FOLDER_PATH}/lib64/${lib_name}" \
+            "${actual_dest_folder_path}" "${libexec_folder_path}" 
+        elif [ -f "${LIBS_INSTALL_FOLDER_PATH}/lib/${lib_name}" ]
+        then
+          copy_dependencies_recursive "${LIBS_INSTALL_FOLDER_PATH}/lib/${lib_name}" \
+            "${actual_dest_folder_path}" "${libexec_folder_path}"
+        else
+          # Not a compiled dependency, perhas a compiler dependency.
+          local full_path=$(${CC} -print-file-name=${lib_name})
+          # -print-file-name outputs back the requested name if not found.
+          if [ "${full_path}" != "${lib_name}" ]
+          then
+            copy_dependencies_recursive "${full_path}" \
+              "${actual_dest_folder_path}" "${libexec_folder_path}"
+          else
+            # If no toolchain library either, last chance is the XBB libraries.
+            if [ -f "${XBB_FOLDER_PATH}/lib64/${lib_name}" ]
+            then
+              copy_dependencies_recursive "${XBB_FOLDER_PATH}/lib64/${lib_name}" \
+                "${actual_dest_folder_path}" "${libexec_folder_path}"
+            elif [ -f "${XBB_FOLDER_PATH}/lib/${lib_name}" ]
+            then
+              copy_dependencies_recursive "${XBB_FOLDER_PATH}/lib/${lib_name}" \
+                "${actual_dest_folder_path}" "${libexec_folder_path}"
+            else
+              echo "${lib_name} not found in the compiled or XBB libraries."
+              exit 1
+            fi
+          fi
+        fi
+
+        if [ ! -f "${actual_dest_folder_path}/${lib_name}" ]
+        then
+          echo "Oops! Dependency ${actual_dest_folder_path}/${lib_name} of ${source_file_name} not found"
+          exit 1
+        fi
+      fi
+    done
+    # echo "iterate ${dest_folder_path}/${source_file_name} done"
+  elif [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+    echo
+    otool -L "${dest_folder_path}/${source_file_name}"
+    local lib_names
+    if [[ "${source_file_name}" == *\.dylib ]]
+    then
+      lib_names=$(otool -L "${dest_folder_path}/${source_file_name}" \
+            | sed '1d' \
+            | sed '1d' \
+            | sed -e 's|[[:space:]]*\(.*\) (.*)|\1|' \
+          )
+    else
+      lib_names=$(otool -L "${dest_folder_path}/${source_file_name}" \
+            | sed '1d' \
+            | sed -e 's|[[:space:]]*\(.*\) (.*)|\1|' \
+          )
+    fi
+    local exec_prefix="@executable_path/"
+    local loader_path="@loader_path/"
+    local lib_name
+    for lib_name in ${lib_names}
+    do
+      local lib_link_base=""
+      if [ "${lib_name:0:1}" != "@" ]
+      then
+        lib_link_base="$(basename $(readlink -f ${lib_name}))"
+      fi
+
+      if [ "${lib_name}" == "${exec_prefix}${source_file_name}" ]
+      then
+        :
+      elif [ "${lib_name}" == "${loader_path}${source_file_name}" ]
+      then
+        :
+      elif [ "${lib_link_base}" == "${source_file_name}" ]
+      then
+        : # Libraries return a line with their own name.
+      else
+        if is_darwin_sys_dylib "${lib_name}"
+        then
+          : # System library, no need to copy it.
+          if ! is_darwin_allowed_sys_dylib "${lib_name}"
+          then
+            echo "Oops! \"${lib_name}\" should not be there!"
+          fi
+        else
+          # The libs can be relative to @executable_path or absolute.
+          if [ "${lib_name:0:${#exec_prefix}}" == "${exec_prefix}" ]
+          then
+            : 
+          else
+            if [ -f "${lib_name}" ]
+            then
+              copy_dependencies_recursive "${lib_name}" \
+                "${dest_folder_path}" "${libexec_folder_path}"
+            elif [ -f "${LIBS_INSTALL_FOLDER_PATH}/lib/${lib_name}" ]
+            then
+              copy_dependencies_recursive "${LIBS_INSTALL_FOLDER_PATH}/lib/${lib_name}" \
+                "${dest_folder_path}" "${libexec_folder_path}"
+            else
+              echo "${lib_name} not found"
+              exit 1
+            fi
+            # Change library path to '@executable_path' inside the lib or app.
+            change_dylib "$(basename "${lib_name}")" \
+              "${dest_folder_path}/${source_file_name}"
+          fi
+        fi
+      fi
+    done
+  elif [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+    local libs=$(${CROSS_COMPILE_PREFIX}-objdump -x "${dest_folder_path}/${source_file_name}" \
+          | grep -i 'DLL Name' \
+          | sed -e 's/.*DLL Name: \(.*\)/\1/' \
+        )
+    local lib_name
+    for lib_name in ${libs}
+    do
+      if is_win_sys_dll "${lib_name}"
+      then
+        : # System DLL, no need to copy it.
+      else
+        if [ -f "${LIBS_INSTALL_FOLDER_PATH}/bin/${lib_name}" ]
+        then
+          copy_dependencies_recursive "${LIBS_INSTALL_FOLDER_PATH}/bin/${lib_name}" \
+            "${dest_folder_path}"
+        elif [ -f "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/bin/${lib_name}" ]
+        then
+          copy_dependencies_recursive "${XBB_FOLDER_PATH}/${CROSS_COMPILE_PREFIX}/bin/${lib_name}" \
+            "${dest_folder_path}"
+        elif [ -f "${XBB_FOLDER_PATH}/mingw/bin/${lib_name}" ]
+        then
+          # Mainly to get libwinpthread-1.dll.
+          copy_dependencies_recursive "${XBB_FOLDER_PATH}/mingw/bin/${lib_name}" \
+            "${dest_folder_path}"
+        else
+          local full_path=$(${CROSS_COMPILE_PREFIX}-gcc -print-file-name=${lib_name})
+          # -print-file-name outputs back the requested name if not found.
+          if [ "${full_path}" != "${lib_name}" ]
+          then
+            copy_dependencies_recursive "${full_path}" "${dest_folder_path}"
+          else
+            echo "${lib_name} required by ${source_file_name}, not found"
+            exit 1
+          fi
+        fi
+      fi
+    done
+  else
+    echo "Oops! Unsupported ${TARGET_PLATFORM}."
+    exit 1
+  fi
+
+  if [ "${IS_DEVELOP}" == "y" ]
+  then
+    echo "dependency ${source_file_path} done"
+  fi
+}
+
+function check_binaries()
+{
+  local folder_path="${APP_PREFIX}"
+  if [ $# -ge 1 ]
+  then
+    folder_path="$1"
+  fi
+
+  (
+    xbb_activate
+    
+    echo
+    echo "Checking binaries for unwanted libraries..."
+
+    # Otherwise `find` may fail.
+    cd "${WORK_FOLDER_PATH}"
+
+    local binaries
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \*.exe)
+      for bin in ${binaries} 
+      do
+        check_binary "${bin}"
+      done
+
+    elif [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \* -perm +111 -and ! -type d)
+      for bin in ${binaries} 
+      do
+        if is_elf "${bin}"
+        then
+          check_binary "${bin}"
+        fi
+      done
+
+    elif [ "${TARGET_PLATFORM}" == "linux" ]
+    then
+
+      binaries=$(find "${folder_path}" -name \* -perm /111 -and ! -type d)
+      for bin in ${binaries} 
+      do
+        if is_elf "${bin}"
+        then
+          check_binary "${bin}"
+        fi
+      done
+
+    else
+      echo "Oops! Unsupported ${TARGET_PLATFORM}."
+      exit 1
+    fi
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+# $1 - absolute path to input folder
+# $2 - name of output folder below INSTALL_FOLDER
+function copy_license() 
+{
+  # Iterate all files in a folder and install some of them in the
+  # destination folder
+  (
+    if [ -z "$2" ]
+    then
+      return
+    fi
+
+    echo
+    echo "Copying license files for $2..."
+
+    cd "$1"
+    local f
+    for f in *
+    do
+      if [ -f "$f" ]
+      then
+        if [[ "$f" =~ AUTHORS.*|NEWS.*|COPYING.*|README.*|LICENSE.*|Copyright.*|COPYRIGHT.*|FAQ.*|DEPENDENCIES.*|THANKS.*|CHANGES.* ]]
+        then
+          install -d -m 0755 \
+            "${APP_PREFIX}/${DISTRO_INFO_NAME}/licenses/$2"
+          install -v -c -m 644 "$f" \
+            "${APP_PREFIX}/${DISTRO_INFO_NAME}/licenses/$2"
+        fi
+      elif [ -d "$f" ] && [[ "$f" =~ [Ll][Ii][Cc][Ee][Nn][Ss][Ee]* ]]
+      then
+        install -d -m 0755 \
+          "${APP_PREFIX}/${DISTRO_INFO_NAME}/licenses/$2"
+        install -v -c -m 644 "$f"/* \
+          "${APP_PREFIX}/${DISTRO_INFO_NAME}/licenses/$2"
+      fi
+    done
+  )
+  (
+    xbb_activate
+
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+      find "${APP_PREFIX}/${DISTRO_INFO_NAME}/licenses" \
+        -type f \
+        -exec unix2dos '{}' ';'
+    fi
+  )
+}
+
+function copy_build_files()
+{
+  echo
+  echo "Copying build files..."
+
+  (
+    cd "${BUILD_GIT_PATH}"
+
+    mkdir -pv patches
+
+    find scripts patches -type d \
+      -exec install -d -m 0755 \
+        "${APP_PREFIX}/${DISTRO_INFO_NAME}"/'{}' ';'
+
+    find scripts patches -type f \
+      -exec install -v -c -m 644 \
+        '{}' "${APP_PREFIX}/${DISTRO_INFO_NAME}"/'{}' ';'
+
+    if [ -f CHANGELOG.txt ]
+    then
+      install -v -c -m 644 \
+          CHANGELOG.txt "${APP_PREFIX}/${DISTRO_INFO_NAME}"
+    fi
+    if [ -f CHANGELOG.md ]
+    then
+      install -v -c -m 644 \
+          CHANGELOG.md "${APP_PREFIX}/${DISTRO_INFO_NAME}"
+    fi
+  )
+}
+
+# Must be called in the build folder, like 
+# cd "${LIBS_BUILD_FOLDER_PATH}"
+# cd "${UILD_FOLDER_PATH}"
+
+function copy_cmake_logs()
+{
+  local folder_name="$1"
+
+  echo
+  echo "Preserving CMake log files..."
+  rm -rf "${LOGS_FOLDER_PATH}/${folder_name}"
+  mkdir -pv "${LOGS_FOLDER_PATH}/${folder_name}/CMakeFiles"
+
+  (
+    cd "${folder_name}"
+    cp -v "CMakeCache.txt" "${LOGS_FOLDER_PATH}/${folder_name}"
+
+    cp -v "CMakeFiles"/*.log "${LOGS_FOLDER_PATH}/${folder_name}/CMakeFiles"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+# Copy one folder to another
+function copy_dir() 
+{
+  local from_path="$1"
+  local to_path="$2"
+
+  set +u
+  # rm -rf "${to_path}"
+  mkdir -pv "${to_path}"
+
+  (
+    cd "${from_path}"
+    if [ "${TARGET_PLATFORM}" == "darwin" ]
+    then
+      find . -xdev -print0 | cpio -oa0 | (cd "${to_path}" && cpio -im)
+    else
+      find . -xdev -print0 | cpio -oa0V | (cd "${to_path}" && cpio -imuV)
+    fi
+  )
+
+  set -u
+}
+
+# -----------------------------------------------------------------------------
+
+function create_archive()
+{
+  (
+    xbb_activate
+
+    local distribution_file_version="${RELEASE_VERSION}"
+
+    local target_folder_name=${TARGET_FOLDER_NAME}
+
+    if [ "${HAS_NAME_ARCH}" != "y" ]
+    then
+      # Pre xPack distributions use the old file name convention.
+      distribution_file_version="${RELEASE_VERSION}-${DISTRIBUTION_FILE_DATE}"
+
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        target_folder_name="win${TARGET_BITS}"
+      elif [ "${TARGET_PLATFORM}" == "darwin" ]
+      then
+        target_folder_name="macos"
+      elif [ "${TARGET_PLATFORM}" == "linux" ]
+      then
+        target_folder_name="${CONTAINER_DISTRO_LC_NAME}${TARGET_BITS}"
+      else
+        echo "Oops! Unsupported ${TARGET_PLATFORM}."
+        exit 1
+      fi
+    fi
+
+    local distribution_file="${DEPLOY_FOLDER_PATH}/${DISTRO_LC_NAME}-${APP_LC_NAME}-${distribution_file_version}-${target_folder_name}"
+
+    local archive_version_path
+    archive_version_path="${INSTALL_FOLDER_PATH}/archive/${DISTRO_LC_NAME}-${APP_LC_NAME}-${distribution_file_version}"
+
+    cd "${APP_PREFIX}"
+    find . -name '.DS_Store' -exec rm '{}' ';'
+
+    echo
+    echo "Creating distribution..."
+
+    mkdir -pv "${DEPLOY_FOLDER_PATH}"
+
+    # The folder is temprarily moved into a versioned folder like
+    # xpack-<app-name>-<version>, or, in previous versions, 
+    # in a more elaborate hierarchy like
+    # xPacks/<app-name>/<version>.
+    # After the archive is created, the folders are moved back.
+    # The atempt to transform the tar path fails, since symlinks were
+    # also transformed, which is bad.
+    if [ "${TARGET_PLATFORM}" == "win32" ]
+    then
+
+      local distribution_file="${distribution_file}.zip"
+
+      if [ "${USE_SINGLE_FOLDER_PATH}" != "y" ]
+      then
+        # DEPRECATED!
+        archive_version_path="${INSTALL_FOLDER_PATH}/archive/${DISTRO_UC_NAME}/${APP_UC_NAME}/${distribution_file_version}"
+      fi
+
+      echo
+      echo "ZIP file: \"${distribution_file}\"."
+
+      rm -rf "${INSTALL_FOLDER_PATH}/archive"
+      mkdir -pv "${archive_version_path}"
+      mv "${APP_PREFIX}"/* "${archive_version_path}"
+
+      cd "${INSTALL_FOLDER_PATH}/archive"
+      zip -r9 -q "${distribution_file}" *
+
+      # Put folders back.
+      mv "${archive_version_path}"/* "${APP_PREFIX}"
+
+    else
+
+      # Unfortunately on node.js, xz & bz2 require native modules, which
+      # proved unsafe, some xz versions failed to compile on node.js v9.x,
+      # so use the good old .tar.gz.
+      local distribution_file
+      if [ "${USE_TAR_GZ}" == "y" ]
+      then
+        # Some platforms (like Arduino) accept only this explicit path.
+        distribution_file="${distribution_file}.tar.gz"
+      else
+        distribution_file="${distribution_file}.tgz"
+      fi
+
+      local archive_version_path
+      if [ "${USE_SINGLE_FOLDER_PATH}" != "y" ]
+      then
+        # DEPRECATED!
+        archive_version_path="${INSTALL_FOLDER_PATH}/archive/${DISTRO_TOP_FOLDER_PATH}/${APP_LC_NAME}/${distribution_file_version}"
+      fi
+
+      echo "Compressed tarball: \"${distribution_file}\"."
+
+      rm -rf "${INSTALL_FOLDER_PATH}/archive"
+      mkdir -pv "${archive_version_path}"
+      mv -v "${APP_PREFIX}"/* "${archive_version_path}"
+
+      # Without --hard-dereference the hard links may be turned into
+      # broken soft links on macOS.
+      cd "${INSTALL_FOLDER_PATH}"/archive
+      # -J uses xz for compression; best compression ratio.
+      # -j uses bz2 for compression; good compression ratio.
+      # -z uses gzip for compression; fair compression ratio.
+      tar -c -z -f "${distribution_file}" \
+        --owner=0 \
+        --group=0 \
+        --format=posix \
+        --hard-dereference \
+        *
+
+      # Put folders back.
+      mv -v "${archive_version_path}"/* "${APP_PREFIX}"
+
+    fi
+
+    cd "${DEPLOY_FOLDER_PATH}"
+    compute_sha shasum -a 256 "$(basename ${distribution_file})"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+# $1 = application name
+function check_application()
+{
+  local app_name=$1
+
+  if [ "${TARGET_PLATFORM}" == "linux" ]
+  then
+
+    echo
+    echo "Checking binaries for unwanted shared libraries..."
+
+    check_binary "${APP_PREFIX}/bin/${app_name}"
+
+    local libs=$(find "${APP_PREFIX}/bin" -name \*.so.\* -type f)
+    local lib
+    for lib in ${libs} 
+    do
+      check_binary_for_libraries "${lib}"
+    done
+
+  elif [ "${TARGET_PLATFORM}" == "darwin" ]
+  then
+
+    echo
+    echo "Checking binaries for unwanted dynamic libraries..."
+
+    check_binary "${APP_PREFIX}/bin/${app_name}"
+
+    local libs=$(find "${APP_PREFIX}/bin" -name \*.dylib -type f)
+    local lib
+    for lib in ${libs} 
+    do
+      check_binary_for_libraries "${lib}"
+    done
+
+  elif [ "${TARGET_PLATFORM}" == "win32" ]
+  then
+
+    echo
+    echo "Checking binaries for unwanted DLLs..."
+
+    check_binary "${APP_PREFIX}/bin/${app_name}.exe"
+
+    local libs=$(find "${APP_PREFIX}/bin" -name \*.dll -type f)
+    local lib
+    for lib in ${libs} 
+    do
+      check_binary_for_libraries "${lib}"
+    done
+
+  else
+    echo "Oops! Unsupported ${TARGET_PLATFORM}."
+    exit 1
+  fi
+
+  echo
+}
+
+# -----------------------------------------------------------------------------
+
+function compute_sha() 
+{
+  # $1 shasum program
+  # $2.. options
+  # ${!#} file
+
+  file=${!#}
+  sha_file="${file}.sha"
+  "$@" >"${sha_file}"
+  echo "SHA: $(cat ${sha_file})"
+}
+
+# -----------------------------------------------------------------------------
+
+function prime_wine()
+{
+  if [  "${TARGET_PLATFORM}" == "win32" ]
+  then
+    (
+      xbb_activate
+
+      echo
+      winecfg &>/dev/null
+      echo "wine primed, testing..."
+    )
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function copy_distro_files()
+{
+  (
+    xbb_activate
+
+    mkdir -pv "${APP_PREFIX}/${DISTRO_INFO_NAME}"
+
+    copy_build_files
+
+    echo
+    echo "Copying xPack files..."
+
+    cd "${WORK_FOLDER_PATH}/build.git"
+    README_OUT_FILE_NAME="${README_OUT_FILE_NAME:-README-OUT.md}"
+    install -v -c -m 644 "scripts/${README_OUT_FILE_NAME}" \
+      "${APP_PREFIX}/README.md"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+function tests_initialize()
+{
+  test_functions=()
+}
+
+function tests_add()
+{
+  test_functions+=("$1")
+}
+
+function tests_run()
+{
+  echo
+  echo "Runnng final tests..."
+
+  for test_function in ${test_functions[@]}
+  do
+    echo
+    local func=$(echo ${test_function} | sed -e 's|-|_|g')
+    echo "Running ${func}..."
+    ${func}
+  done
+}
+
+# -----------------------------------------------------------------------------

+ 2030 - 0
distro-info/scripts/helper/common-libs-functions-source.sh

@@ -0,0 +1,2030 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPack distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the build scripts (both native
+# and container).
+
+# -----------------------------------------------------------------------------
+
+function build_zlib() 
+{
+  # http://zlib.net
+  # http://zlib.net/fossils/
+
+  # https://archlinuxarm.org/packages/aarch64/zlib/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=zlib-static
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=zlib-git
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mingw-w64-zlib
+
+  # 2013-04-28 "1.2.8"
+  # 2017-01-15 "1.2.11"
+
+  local zlib_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local zlib_src_folder_name="zlib-${zlib_version}"
+
+  local zlib_archive="${zlib_src_folder_name}.tar.gz"
+  local zlib_url="http://zlib.net/fossils/${zlib_archive}"
+
+  # The folder name for build, licenses, etc.
+  local zlib_folder_name="${zlib_src_folder_name}"
+
+  local zlib_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${zlib_folder_name}-installed"
+  if [ ! -f "${zlib_stamp_file_path}" ]
+  then
+
+    # In-source build.
+
+    if [ ! -d "${LIBS_BUILD_FOLDER_PATH}/${zlib_folder_name}" ]
+    then
+      cd "${LIBS_BUILD_FOLDER_PATH}"
+
+      download_and_extract "${zlib_url}" "${zlib_archive}" \
+        "${zlib_src_folder_name}"
+
+      if [ "${zlib_src_folder_name}" != "${zlib_folder_name}" ]
+      then
+        mv -v "${zlib_src_folder_name}" "${zlib_folder_name}"
+      fi
+    fi
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${zlib_folder_name}"
+
+    (
+      cd "${LIBS_BUILD_FOLDER_PATH}/${zlib_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      if [ "${TARGET_PLATFORM}" == "win32" ]
+      then
+        (
+          echo
+          echo "Running zlib make..."
+
+          # Build.
+          run_verbose make -f win32/Makefile.gcc \
+            PREFIX=${CROSS_COMPILE_PREFIX}- \
+            prefix="${LIBS_INSTALL_FOLDER_PATH}" \
+            CFLAGS="${XBB_CFLAGS_NO_W} -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4"
+          
+          run_verbose make -f win32/Makefile.gcc install \
+            DESTDIR="${LIBS_INSTALL_FOLDER_PATH}/" \
+            INCLUDE_PATH="include" \
+            LIBRARY_PATH="lib" \
+            BINARY_PATH="bin"
+
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${zlib_folder_name}/make-output.txt"
+      else
+
+        CPPFLAGS="${XBB_CPPFLAGS}"
+        CFLAGS="${XBB_CFLAGS_NO_W}"
+        CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+        LDFLAGS="${XBB_LDFLAGS_LIB}"
+        if [ "${IS_DEVELOP}" == "y" ]
+        then
+          LDFLAGS+=" -v"
+        fi
+
+        export CPPFLAGS
+        export CFLAGS
+        export CXXFLAGS
+        export LDFLAGS
+
+        env | sort
+
+        # No config.status left, use the library.
+        if [ ! -f "libz.a" ]
+        then
+          (
+            echo
+            echo "Running zlib configure..."
+
+            bash "configure" --help
+
+            run_verbose bash ${DEBUG} "configure" \
+              --prefix="${LIBS_INSTALL_FOLDER_PATH}" 
+            
+            cp "configure.log" "${LOGS_FOLDER_PATH}/${zlib_folder_name}/configure-log.txt"
+          ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${zlib_folder_name}/configure-output.txt"
+        fi
+
+        (
+          echo
+          echo "Running zlib make..."
+
+          # Build.
+          run_verbose make -j ${JOBS}
+
+          if [ "${WITH_TESTS}" == "y" ]
+          then
+            run_verbose make test
+          fi
+
+          run_verbose make install
+
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${zlib_folder_name}/make-output.txt"
+      fi
+
+      copy_license \
+        "${LIBS_BUILD_FOLDER_PATH}/${zlib_folder_name}" \
+        "${zlib_folder_name}"
+
+    )
+
+    touch "${zlib_stamp_file_path}"
+
+  else
+    echo "Library zlib already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_gmp() 
+{
+  # https://gmplib.org
+  # https://gmplib.org/download/gmp/
+
+  # https://archlinuxarm.org/packages/aarch64/gmp/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gmp-hg
+
+  # 01-Nov-2015 "6.1.0"
+  # 16-Dec-2016 "6.1.2"
+  # 17-Jan-2020 "6.2.0"
+
+  local gmp_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local gmp_src_folder_name="gmp-${gmp_version}"
+
+  local gmp_archive="${gmp_src_folder_name}.tar.xz"
+  local gmp_url="https://gmplib.org/download/gmp/${gmp_archive}"
+
+  # The folder name for build, licenses, etc.
+  local gmp_folder_name="${gmp_src_folder_name}"
+
+  local gmp_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${gmp_folder_name}-installed"
+  if [ ! -f "${gmp_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${gmp_url}" "${gmp_archive}" \
+      "${gmp_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gmp_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${gmp_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${gmp_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      # ABI is mandatory, otherwise configure fails on 32-bit.
+      # (see https://gmplib.org/manual/ABI-and-ISA.html)
+      if [ "${TARGET_ARCH}" == "x64" -o "${TARGET_ARCH}" == "x32" ]
+      then
+        export ABI="${TARGET_BITS}"
+      fi
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running gmp configure..."
+
+          # ABI is mandatory, otherwise configure fails on 32-bit.
+          # (see https://gmplib.org/manual/ABI-and-ISA.html)
+
+          bash "${SOURCES_FOLDER_PATH}/${gmp_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+            
+          config_options+=("--enable-cxx")
+
+          if [ "${TARGET_PLATFORM}" == "win32" ]
+          then
+            # mpfr asks for this explicitly during configure.
+            # (although the message is confusing)
+            config_options+=("--enable-shared")
+            config_options+=("--disable-static")
+          fi
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${gmp_src_folder_name}/configure" \
+            ${config_options[@]}
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gmp_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gmp_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running gmp make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gmp_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${gmp_src_folder_name}" \
+        "${gmp_folder_name}"
+
+    )
+
+    touch "${gmp_stamp_file_path}"
+
+  else
+    echo "Library gmp already installed."
+  fi
+}
+
+function build_mpfr()
+{
+  # http://www.mpfr.org
+  # http://www.mpfr.org/history.html
+
+  # https://archlinuxarm.org/packages/aarch64/mpfr/files/PKGBUILD
+  # https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/mpfr
+
+  # 6 March 2016 "3.1.4"
+  # 7 September 2017 "3.1.6"
+  # 31 January 2019 "4.0.2"
+
+  local mpfr_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local mpfr_src_folder_name="mpfr-${mpfr_version}"
+
+  local mpfr_archive="${mpfr_src_folder_name}.tar.xz"
+  local mpfr_url="http://www.mpfr.org/${mpfr_src_folder_name}/${mpfr_archive}"
+
+  # The folder name for build, licenses, etc.
+  local mpfr_folder_name="${mpfr_src_folder_name}"
+
+  local mpfr_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${mpfr_folder_name}-installed"
+  if [ ! -f "${mpfr_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${mpfr_url}" "${mpfr_archive}" \
+      "${mpfr_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${mpfr_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${mpfr_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${mpfr_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running mpfr configure..."
+
+          bash "${SOURCES_FOLDER_PATH}/${mpfr_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          config_options+=("--disable-warnings")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${mpfr_src_folder_name}/configure" \
+            ${config_options[@]}
+             
+          cp "config.log" "${LOGS_FOLDER_PATH}/${mpfr_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${mpfr_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running mpfr make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${mpfr_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${mpfr_src_folder_name}" \
+        "${mpfr_folder_name}"
+
+    )
+    touch "${mpfr_stamp_file_path}"
+
+  else
+    echo "Library mpfr already installed."
+  fi
+}
+
+function build_mpc()
+{
+  # http://www.multiprecision.org/
+  # ftp://ftp.gnu.org/gnu/mpc
+
+  # https://archlinuxarm.org/packages/aarch64/mpc/files/PKGBUILD
+  # https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/libmpc
+
+  # 20 Feb 2015 "1.0.3"
+  # 2018-01-11 "1.1.0"
+
+  local mpc_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local mpc_src_folder_name="mpc-${mpc_version}"
+
+  local mpc_archive="${mpc_src_folder_name}.tar.gz"
+  local mpc_url="ftp://ftp.gnu.org/gnu/mpc/${mpc_archive}"
+  if [[ "${mpc_version}" =~ 0\.* ]]
+  then
+    mpc_url="http://www.multiprecision.org/downloads/${mpc_archive}"
+  fi
+
+  # The folder name for build, licenses, etc.
+  local mpc_folder_name="${mpc_src_folder_name}"
+
+  local mpc_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${mpc_folder_name}-installed"
+  if [ ! -f "${mpc_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${mpc_url}" "${mpc_archive}" \
+      "${mpc_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${mpc_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${mpc_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${mpc_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running mpc configure..."
+        
+          bash "${SOURCES_FOLDER_PATH}/${mpc_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${mpc_src_folder_name}/configure" \
+            ${config_options[@]}
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${mpc_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${mpc_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running mpc make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${mpc_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${mpc_src_folder_name}" \
+        "${mpc_folder_name}"
+
+    )
+    touch "${mpc_stamp_file_path}"
+
+  else
+    echo "Library mpc already installed."
+  fi
+}
+
+function build_isl()
+{
+  # http://isl.gforge.inria.fr
+
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=isl
+
+  # 2015-06-12 "0.15"
+  # 2016-01-15 "0.16.1"
+  # 2016-12-20 "0.18"
+  # 2019-03-26 "0.21"
+  # 2020-01-16 "0.22"
+
+  local isl_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local isl_src_folder_name="isl-${isl_version}"
+
+  local isl_archive="${isl_src_folder_name}.tar.xz"
+  if [[ "${isl_version}" =~ 0\.12\.* ]]
+  then
+    isl_archive="${isl_src_folder_name}.tar.gz"
+  fi
+
+  local isl_url="http://isl.gforge.inria.fr/${isl_archive}"
+
+  # The folder name for build, licenses, etc.
+  local isl_folder_name="${isl_src_folder_name}"
+
+  local isl_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${isl_folder_name}-installed"
+  if [ ! -f "${isl_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${isl_url}" "${isl_archive}" \
+      "${isl_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${isl_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${isl_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${isl_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running isl configure..."
+
+          bash "${SOURCES_FOLDER_PATH}/${isl_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${isl_src_folder_name}/configure" \
+            ${config_options[@]}
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${isl_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${isl_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running isl make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          if [ "${TARGET_PLATFORM}" == "linux" -a \
+            \( "${TARGET_ARCH}" == "x64" -o "${TARGET_ARCH}" == "x32" \) ] 
+          then
+            # /Host/Users/ilg/Work/gcc-8.4.0-1/linux-x64/build/libs/isl-0.22/.libs/lt-isl_test_cpp: relocation error: /Host/Users/ilg/Work/gcc-8.4.0-1/linux-x64/build/libs/isl-0.22/.libs/lt-isl_test_cpp: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
+            # FAIL isl_test_cpp (exit status: 127)
+            # /Host/Users/ilg/Work/gcc-8.4.0-1/linux-x32/build/libs/isl-0.22/.libs/lt-isl_test_cpp: relocation error: /Host/Users/ilg/Work/gcc-8.4.0-1/linux-x32/build/libs/isl-0.22/.libs/lt-isl_test_cpp: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference
+            # FAIL isl_test_cpp (exit status: 127)
+
+            run_verbose make check || true
+          else
+            run_verbose make check
+          fi
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${isl_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${isl_src_folder_name}" \
+        "${isl_folder_name}"
+
+    )
+    touch "${isl_stamp_file_path}"
+
+  else
+    echo "Library isl already installed."
+  fi
+}
+
+function build_zstd()
+{
+  # https://facebook.github.io/zstd/
+  # https://github.com/facebook/zstd/releases
+  # https://github.com/facebook/zstd/archive/v1.4.4.tar.gz
+
+  # https://archlinuxarm.org/packages/aarch64/zstd/files/PKGBUILD
+
+  # 5 Nov 2019 "1.4.4"
+
+  local zstd_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local zstd_src_folder_name="zstd-${zstd_version}"
+
+  local zstd_archive="${zstd_src_folder_name}.tar.gz"
+
+  # GitHub release archive.
+  local zstd_github_archive="v${zstd_version}.tar.gz"
+
+  local zstd_url="https://github.com/facebook/zstd/archive/${zstd_github_archive}"
+
+  # The folder name for build, licenses, etc.
+  local zstd_folder_name="${zstd_src_folder_name}"
+
+  local zstd_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${zstd_folder_name}-installed"
+  if [ ! -f "${zstd_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${zstd_url}" "${zstd_archive}" \
+      "${zstd_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${zstd_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${zstd_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${zstd_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      local build_type
+      if [ "${IS_DEBUG}" == "y" ]
+      then
+        build_type=Debug
+      else
+        build_type=Release
+      fi
+
+      env | sort
+
+      if [ ! -f "CMakeCache.txt" ]
+      then 
+        (
+          echo
+          echo "Running zstd cmake..."
+        
+          config_options=()
+
+          config_options+=("-LH")
+          config_options+=("-G" "Ninja")
+
+          config_options+=("-DCMAKE_INSTALL_PREFIX=${LIBS_INSTALL_FOLDER_PATH}")
+          config_options+=("-DZSTD_BUILD_PROGRAMS=OFF")
+
+          if [ "${WITH_TESTS}" == "y" ]
+          then
+            config_options+=("-DZSTD_BUILD_TESTS=ON")
+          fi
+
+          run_verbose cmake \
+            ${config_options[@]} \
+            \
+            "${SOURCES_FOLDER_PATH}/${zstd_src_folder_name}/build/cmake"
+            
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${zstd_folder_name}/zstd-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running zstd build..."
+
+        run_verbose cmake \
+          --build . \
+          --parallel ${JOBS} \
+          --config "${build_type}" \
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose ctest \
+            -V \
+
+        fi
+
+        (
+          # The install procedure runs some resulted exxecutables, which require
+          # the libssl and libcrypt libraries from XBB.
+          # xbb_activate_libs
+
+          echo
+          echo "Running zstd install..."
+
+          run_verbose cmake \
+            --build . \
+            --config "${build_type}" \
+            -- \
+            install
+
+        )
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${zstd_folder_name}/build-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${zstd_src_folder_name}" \
+        "${zstd_folder_name}"
+
+      (
+        cd "${LIBS_BUILD_FOLDER_PATH}"
+
+        copy_cmake_logs "${zstd_folder_name}"
+      )
+
+    )
+    touch "${zstd_stamp_file_path}"
+
+  else
+    echo "Library zstd already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_libiconv()
+{
+  # https://www.gnu.org/software/libiconv/
+  # https://ftp.gnu.org/pub/gnu/libiconv/
+
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libiconv
+
+  # 2011-08-07 1.14"
+  # 2017-02-02 "1.15"
+  # 2019-04-26 "1.16"
+
+  local libiconv_version="$1"
+
+  local libiconv_src_folder_name="libiconv-${libiconv_version}"
+
+  local libiconv_archive="${libiconv_src_folder_name}.tar.gz"
+  local libiconv_url="https://ftp.gnu.org/pub/gnu/libiconv/${libiconv_archive}"
+
+  local libiconv_folder_name="${libiconv_src_folder_name}"
+
+  local libiconv_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${libiconv_folder_name}-installed"
+  if [ ! -f "${libiconv_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${libiconv_url}" "${libiconv_archive}" \
+      "${libiconv_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${libiconv_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${libiconv_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${libiconv_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      # -fgnu89-inline fixes "undefined reference to `aliases2_lookup'"
+      #  https://savannah.gnu.org/bugs/?47953
+      CFLAGS="${XBB_CFLAGS_NO_W} -fgnu89-inline"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running libiconv configure..."
+
+          bash "${SOURCES_FOLDER_PATH}/${libiconv_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${libiconv_src_folder_name}/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${libiconv_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libiconv_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running libiconv make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libiconv_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${libiconv_src_folder_name}" \
+        "${libiconv_folder_name}"
+
+    )
+
+    touch "${libiconv_stamp_file_path}"
+
+  else
+    echo "Library libiconv already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# Could not make it work on Windows.
+function build_ncurses()
+{
+  # https://invisible-island.net/ncurses/
+  # ftp://ftp.invisible-island.net/pub/ncurses
+  # ftp://ftp.invisible-island.net/pub/ncurses/ncurses-6.2.tar.gz
+
+  # depends=(glibc gcc-libs)
+  # https://archlinuxarm.org/packages/aarch64/ncurses/files/PKGBUILD
+  # http://deb.debian.org/debian/pool/main/n/ncurses/ncurses_6.1+20181013.orig.tar.gz.asc
+
+  # https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-ncurses/PKGBUILD
+  # https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-ncurses/001-use-libsystre.patch
+  # https://github.com/msys2/MSYS2-packages/blob/master/ncurses/PKGBUILD
+
+  # _4421.c:1364:15: error: expected ‘)’ before ‘int’
+  # ../include/curses.h:1906:56: note: in definition of macro ‘mouse_trafo’
+  # 1906 | #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
+
+  # 26 Feb 2011, "5.8" # build fails
+  # 27 Jan 2018, "5.9" # build fails
+  # 27 Jan 2018, "6.1"
+  # 12 Feb 2020, "6.2"
+
+  local ncurses_version="$1"
+
+  # The folder name as resulted after being extracted from the archive.
+  local ncurses_src_folder_name="ncurses-${ncurses_version}"
+
+  local ncurses_archive="${ncurses_src_folder_name}.tar.gz"
+  local ncurses_url="ftp://ftp.invisible-island.net//pub/ncurses/${ncurses_archive}"
+
+  # The folder name  for build, licenses, etc.
+  local ncurses_folder_name="${ncurses_src_folder_name}"
+
+  # local ncurses_version_major="$(echo ${ncurses_version} | sed -e 's|\([0-9][0-9]*\)\.\([0-9][0-9]*\)|\1|')"
+  # local ncurses_version_minor="$(echo ${ncurses_version} | sed -e 's|\([0-9][0-9]*\)\.\([0-9][0-9]*\)|\2|')"
+
+  local ncurses_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-${ncurses_folder_name}-installed"
+  if [ ! -f "${ncurses_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${ncurses_url}" "${ncurses_archive}" \
+      "${ncurses_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${ncurses_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${ncurses_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${ncurses_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running ncurses configure..."
+
+          bash "${SOURCES_FOLDER_PATH}/${ncurses_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          # Not yet functional on windows.
+          if [ "${TARGET_PLATFORM}" == "win32" ]
+          then
+
+            # The build passes, but generally it is not expected to be
+            # used on Windows.
+
+            # export PATH_SEPARATOR=";"
+
+            # --with-libtool \
+            # /opt/xbb/bin/libtool: line 10548: gcc-8bs: command not found
+
+            # Without --with-pkg-config-libdir= it'll try to write the .pc files in the
+            # xbb folder, probbaly by using the dirname of pkg-config.
+
+            config_options+=("--with-build-cc=${NATIVE_CC}")
+            config_options+=("--with-build-cflags=${CFLAGS}")
+            config_options+=("--with-build-cppflags=${CPPFLAGS}")
+            config_options+=("--with-build-ldflags=${LDFLAGS}")
+               
+            config_options+=("--without-progs")
+
+            # Only for the MinGW port, it provides a way to substitute
+            # the low-level terminfo library with different terminal drivers.
+            config_options+=("--enable-term-driver")
+            
+            config_options+=("--disable-termcap")
+            config_options+=("--disable-home-terminfo")
+            config_options+=("--disable-db-install")
+
+          else
+
+            # Without --with-pkg-config-libdir= it'll try to write the .pc files in the
+            # xbb folder, probbaly by using the dirname of pkg-config.
+
+            config_options+=("--with-terminfo-dirs=/etc/terminfo")
+            config_options+=("--with-default-terminfo-dir=/etc/terminfo:/lib/terminfo:/usr/share/terminfo")
+            config_options+=("--with-gpm")
+            config_options+=("--with-versioned-syms")
+            config_options+=("--with-xterm-kbs=del")
+
+            config_options+=("--enable-termcap")
+            config_options+=("--enable-const")
+            config_options+=("--enable-symlinks")
+
+          fi
+
+          config_options+=("--with-shared")
+          config_options+=("--with-normal")
+          config_options+=("--with-cxx")
+          config_options+=("--with-cxx-binding")
+          config_options+=("--with-cxx-shared")
+          config_options+=("--with-pkg-config-libdir=${LIBS_INSTALL_FOLDER_PATH}/lib/pkgconfig")
+          
+          # Fails on Linux, with missing _nc_cur_term, which is there.
+          config_options+=("--without-pthread")
+
+          config_options+=("--without-ada")
+          config_options+=("--without-debug")
+          config_options+=("--without-manpages")
+          config_options+=("--without-tack")
+          config_options+=("--without-tests")
+
+          config_options+=("--enable-pc-files")
+          config_options+=("--enable-sp-funcs")
+          config_options+=("--enable-ext-colors")
+          config_options+=("--enable-interop")
+
+          config_options+=("--disable-lib-suffixes")
+          config_options+=("--disable-overwrite")
+
+          NCURSES_DISABLE_WIDEC=${NCURSES_DISABLE_WIDEC:-""}
+
+          if [ "${NCURSES_DISABLE_WIDEC}" == "y" ]
+          then
+            config_options+=("--disable-widec")
+          fi
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${ncurses_src_folder_name}/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${ncurses_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${ncurses_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running ncurses make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        # The test-programs are interactive
+
+        # make install-strip
+        run_verbose make install
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${ncurses_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${ncurses_src_folder_name}" \
+        "${ncurses_folder_name}"
+
+    )
+
+    touch "${ncurses_stamp_file_path}"
+
+  else
+    echo "Library ncurses already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_libffi() 
+{
+  # http://www.sourceware.org/libffi/
+  # ftp://sourceware.org/pub/libffi/
+  # https://github.com/libffi/libffi/archive/v3.2.1.tar.gz
+
+  # https://archlinuxarm.org/packages/aarch64/libffi/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=libffi-git
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mingw-w64-libffi
+
+  # 12-Nov-2014, "3.2.1"
+  # 23 Nov 2019, "3.3"
+
+  local libffi_version="$1"
+
+  local libffi_src_folder_name="libffi-${libffi_version}"
+
+  local libffi_archive="${libffi_src_folder_name}.tar.gz"
+  # local libffi_url="ftp://sourceware.org/pub/libffi/${libffi_archive}"
+  # GitHub release archive.
+  local libffi_url="https://github.com/libffi/libffi/archive/v${libffi_version}.tar.gz"
+
+  local libffi_folder_name="${libffi_src_folder_name}"
+
+  local libffi_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${libffi_folder_name}-installed"
+  if [ ! -f "${libffi_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${libffi_url}" "${libffi_archive}" \
+      "${libffi_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${libffi_folder_name}"
+
+    (
+      if [ ! -x "${SOURCES_FOLDER_PATH}/${libffi_src_folder_name}/configure" ]
+      then
+
+        cd "${SOURCES_FOLDER_PATH}/${libffi_src_folder_name}"
+        
+        xbb_activate
+        xbb_activate_installed_dev
+
+        run_verbose bash ${DEBUG} "autogen.sh"
+
+      fi
+    ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libffi_folder_name}/autogen-output.txt"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${libffi_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${libffi_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+
+        (
+          echo
+          echo "Running libffi configure..."
+
+          bash "${SOURCES_FOLDER_PATH}/${libffi_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          config_options+=("--enable-pax_emutramp")
+
+          # --enable-pax_emutramp is inspired by AUR
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${libffi_src_folder_name}/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${libffi_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libffi_folder_name}/configure-output.txt"
+
+      fi
+
+      (
+        echo
+        echo "Running libffi make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libffi_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${libffi_src_folder_name}" \
+        "${libffi_folder_name}"
+
+    )
+
+    touch "${libffi_stamp_file_path}"
+
+  else
+    echo "Library libffi already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_gettext() 
+{
+  # https://www.gnu.org/software/gettext/
+  # http://ftp.gnu.org/pub/gnu/gettext/
+
+  # https://archlinuxarm.org/packages/aarch64/gettext/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gettext-git
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mingw-w64-gettext
+
+  # gettext_version="0.19.5.1"
+  # gettext_version="0.19.8.1" # 2016-06-11
+
+  local gettext_version="$1"
+
+  local gettext_src_folder_name="gettext-${gettext_version}"
+
+  local gettext_archive="${gettext_src_folder_name}.tar.gz"
+  local gettext_url="http://ftp.gnu.org/pub/gnu/gettext/${gettext_archive}"
+
+  local gettext_folder_name="${gettext_src_folder_name}"
+  local gettext_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${gettext_folder_name}-installed"
+  if [ ! -f "${gettext_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${gettext_url}" "${gettext_archive}" \
+      "${gettext_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gettext_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${gettext_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${gettext_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"      
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+
+        (
+          echo
+          echo "Running gettext configure..."
+
+          # Build only the /gettext-runtime folder, attempts to build
+          # the full package fail with a CXX='no' problem.
+          bash "${SOURCES_FOLDER_PATH}/${gettext_src_folder_name}/gettext-runtime/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          if [ "${TARGET_PLATFORM}" == "win32" ]
+          then
+            config_options+=("--enable-threads=windows")
+            config_options+=("--with-gnu-ld")
+          elif [ "${TARGET_PLATFORM}" == "linux" ]
+          then
+            config_options+=("--enable-threads=posix")
+            config_options+=("--with-gnu-ld")
+          elif [ "${TARGET_PLATFORM}" == "darwin" ]
+          then
+            config_options+=("--enable-threads=posix")
+          fi
+
+          config_options+=("--disable-installed-tests")
+          config_options+=("--disable-always-build-tests")
+          # config_options+=("--enable-nls")
+          config_options+=("--disable-rpath")
+          config_options+=("--disable-java")
+          config_options+=("--disable-native-java")
+          config_options+=("--disable-c++")
+          config_options+=("--disable-libasprintf")
+
+          #  --enable-nls needed to include libintl
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${gettext_src_folder_name}/gettext-runtime/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gettext_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gettext_folder_name}/configure-output.txt"
+
+      fi
+
+      (
+        echo
+        echo "Running gettext make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          make check # || true
+        fi
+
+        # Avoid strip here, it may interfere with patchelf.
+        # make install-strip
+        if false # [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gettext_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${gettext_src_folder_name}" \
+        "${gettext_folder_name}"
+
+    )
+
+    touch "${gettext_stamp_file_path}"
+
+  else
+    echo "Library gettext already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_libelf()
+{
+  # http://www.mr511.de/ (?Deprecated?)
+  # http://www.mr511.de/software/
+  # https://sourceware.org/elfutils/
+  # ftp://sourceware.org/pub/elfutils//0.178/elfutils-0.178.tar.bz2
+
+  # https://archlinuxarm.org/packages/aarch64/libelf/files/PKGBUILD
+
+  # libelf_version="0.8.13" (deprecated)
+  # 26 Nov 2019, 0.178
+  # 2020-03-30, 0.179
+  # 2020-06-11, 0.180
+
+  local libelf_version="$1"
+
+  local libelf_src_folder_name="libelf-${libelf_version}"
+  local libelf_archive="${libelf_src_folder_name}.tar.gz"
+
+  # local libelf_url="http://www.mr511.de/software/${libelf_archive}"
+  # The original site seems unavailable, use a mirror.
+  local libelf_url="https://fossies.org/linux/misc/old/${libelf_archive}"
+
+  local libelf_folder_name="${libelf_src_folder_name}"
+
+  local libelf_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${libelf_folder_name}-installed"
+  if [ ! -f "${libelf_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${libelf_url}" "${libelf_archive}" \
+      "${libelf_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${libelf_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${libelf_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${libelf_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running libelf configure..."
+
+          run_verbose bash "${SOURCES_FOLDER_PATH}/${libelf_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          # config_options+=("--disable-nls")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${libelf_src_folder_name}/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${libelf_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libelf_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running libelf make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        run_verbose make install
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${libelf_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${libelf_src_folder_name}" \
+        "${libelf_folder_name}"
+
+    )
+
+    touch "${libelf_stamp_file_path}"
+
+  else
+    echo "Library libelf already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_expat()
+{
+  # https://libexpat.github.io
+  # https://github.com/libexpat/libexpat/releases
+
+  # https://archlinuxarm.org/packages/aarch64/expat/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=expat-git
+
+  # Oct 21, 2017 "2.1.1"
+  # Nov 1, 2017 "2.2.5"
+  # 26 Sep 2019 "2.2.9"
+
+  local expat_version="$1"
+
+  local expat_src_folder_name="expat-${expat_version}"
+  local expat_archive="${expat_src_folder_name}.tar.bz2"
+  if [[ "${expat_version}" =~ 2\.0\.* ]]
+  then
+    expat_archive="${expat_src_folder_name}.tar.gz"
+  fi
+  
+  local expat_release="R_$(echo ${expat_version} | sed -e 's|[.]|_|g')"
+  local expat_url="https://github.com/libexpat/libexpat/releases/download/${expat_release}/${expat_archive}"
+
+  local expat_folder_name="${expat_src_folder_name}"
+
+  local expat_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${expat_folder_name}-installed"
+  if [ ! -f "${expat_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${expat_url}" "${expat_archive}" \
+      "${expat_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${expat_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${expat_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${expat_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running expat configure..."
+
+          run_verbose bash "${SOURCES_FOLDER_PATH}/${expat_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${expat_src_folder_name}/configure" \
+            ${config_options[@]}
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${expat_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${expat_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running expat make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        run_verbose make install
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${expat_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${expat_src_folder_name}" \
+        "${expat_folder_name}"
+
+    )
+
+    touch "${expat_stamp_file_path}"
+
+  else
+    echo "Library expat already installed."
+  fi
+}
+
+
+# -----------------------------------------------------------------------------
+
+function build_xz()
+{
+  # https://tukaani.org/xz/
+  # https://sourceforge.net/projects/lzmautils/files/
+
+  # https://archlinuxarm.org/packages/aarch64/xz/files/PKGBUILD
+  # https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=xz-git
+
+  # 2016-12-30 "5.2.3"
+  # 2018-04-29 "5.2.4"
+
+  local xz_version="$1"
+
+  local xz_src_folder_name="xz-${xz_version}"
+  local xz_archive="${xz_src_folder_name}.tar.xz"
+  local xz_url="https://sourceforge.net/projects/lzmautils/files/${xz_archive}"
+
+  local xz_folder_name="${xz_src_folder_name}"
+
+  local xz_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${xz_folder_name}-installed"
+  if [ ! -f "${xz_stamp_file_path}" ]
+  then
+
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${xz_url}" "${xz_archive}" \
+      "${xz_src_folder_name}"
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${xz_folder_name}"
+
+    (
+      mkdir -pv "${LIBS_BUILD_FOLDER_PATH}/${xz_folder_name}"
+      cd "${LIBS_BUILD_FOLDER_PATH}/${xz_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS}"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running xz configure..."
+
+          run_verbose bash "${SOURCES_FOLDER_PATH}/${xz_src_folder_name}/configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          # config_options+=("--disable-rpath")
+          # config_options+=("--disable-nls")
+
+          run_verbose bash ${DEBUG} "${SOURCES_FOLDER_PATH}/${xz_src_folder_name}/configure" \
+            ${config_options[@]}
+
+          cp "config.log" "${LOGS_FOLDER_PATH}/${xz_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${xz_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running xz make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          run_verbose make install-strip
+        else
+          run_verbose make install
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${xz_folder_name}/make-output.txt"
+
+      copy_license \
+        "${SOURCES_FOLDER_PATH}/${xz_src_folder_name}" \
+        "${xz_folder_name}"
+
+    )
+
+    touch "${xz_stamp_file_path}"
+
+  else
+    echo "Library xz already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function build_gpm()
+{
+  # General purpose mouse. Used by ncurses.
+  # https://www.nico.schottelius.org/software/gpm/
+  # https://github.com/telmich/gpm
+  # https://github.com/telmich/gpm/releases/tag/1.20.7
+  # https://github.com/telmich/gpm/archive/1.20.7.tar.gz
+
+  # https://archlinuxarm.org/packages/aarch64/gpm/files/PKGBUILD
+
+  # 27 Oct 2012 "1.20.7"
+
+  local gpm_version="$1"
+
+  local gpm_src_folder_name="gpm-${gpm_version}"
+  local gpm_archive="${gpm_src_folder_name}.tar.gz"
+  local gpm_github_archive="${gpm_version}.tar.gz"
+  
+  local gpm_url="https://github.com/telmich/gpm/archive/${gpm_github_archive}"
+
+  local gpm_folder_name="${gpm_src_folder_name}"
+
+  local gpm_stamp_file_path="${INSTALL_FOLDER_PATH}/stamp-${gpm_folder_name}-installed"
+  if [ ! -f "${gpm_stamp_file_path}" ]
+  then
+
+    # In-source build.
+
+    cd "${LIBS_BUILD_FOLDER_PATH}"
+
+    if [ ! -d "${LIBS_BUILD_FOLDER_PATH}/${gpm_folder_name}" ]
+    then
+      cd "${LIBS_BUILD_FOLDER_PATH}"
+
+      download_and_extract "${gpm_url}" "${gpm_archive}" \
+        "${gpm_src_folder_name}"
+
+      if [ "${gpm_src_folder_name}" != "${gpm_folder_name}" ]
+      then
+        mv -v "${gpm_src_folder_name}" "${gpm_folder_name}"
+      fi
+    fi
+
+    mkdir -pv "${LOGS_FOLDER_PATH}/${gpm_folder_name}"
+
+    (
+      cd "${LIBS_BUILD_FOLDER_PATH}/${gpm_folder_name}"
+      if [ ! -f "stamp-autogen" ]
+      then
+
+        xbb_activate
+        
+        run_app bash ${DEBUG} "autogen.sh"
+
+        touch "stamp-autogen"
+      fi
+    ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gpm_folder_name}/autogen-output.txt"
+
+    (
+      cd "${LIBS_BUILD_FOLDER_PATH}/${gpm_folder_name}"
+
+      xbb_activate
+      xbb_activate_installed_dev
+
+      CPPFLAGS="${XBB_CPPFLAGS} -I${LIBS_BUILD_FOLDER_PATH}/${gpm_folder_name}/src/headers"
+      CFLAGS="${XBB_CFLAGS_NO_W}"
+      CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
+      LDFLAGS="${XBB_LDFLAGS_LIB}"
+      if [ "${IS_DEVELOP}" == "y" ]
+      then
+        LDFLAGS+=" -v"
+      fi
+
+      export CPPFLAGS
+      export CFLAGS
+      export CXXFLAGS
+      export LDFLAGS
+
+      env | sort
+
+      if [ ! -f "config.status" ]
+      then 
+        (
+          echo
+          echo "Running gpm configure..."
+
+          run_verbose bash "configure" --help
+
+          config_options=()
+
+          config_options+=("--prefix=${LIBS_INSTALL_FOLDER_PATH}")
+            
+          config_options+=("--build=${BUILD}")
+          config_options+=("--host=${HOST}")
+          config_options+=("--target=${TARGET}")
+
+          # config_options+=("--with-pic")
+
+          run_verbose bash ${DEBUG} "configure" \
+            ${config_options[@]}
+            
+          cp "config.log" "${LOGS_FOLDER_PATH}/${gpm_folder_name}/config-log.txt"
+        ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gpm_folder_name}/configure-output.txt"
+      fi
+
+      (
+        echo
+        echo "Running gpm make..."
+
+        # Build.
+        run_verbose make -j ${JOBS}
+
+        if [ "${WITH_TESTS}" == "y" ]
+        then
+          run_verbose make check
+        fi
+
+        run_verbose make install
+
+        if [ "${TARGET_PLATFORM}" == "linux" ]
+        then
+          (
+            mkdir -pv "${APP_PREFIX}/bin"
+            cd "${APP_PREFIX}/bin"
+
+            # Manual copy, since it is not refered in the elf.
+            cp -v "${LIBS_INSTALL_FOLDER_PATH}/lib/libgpm.so.2.1.0" .
+            rm -f "libgpm.so.2"
+            ln -s -v "libgpm.so.2.1.0" "libgpm.so.2"
+          )
+        fi
+
+      ) 2>&1 | tee "${LOGS_FOLDER_PATH}/${gpm_folder_name}/make-output.txt"
+
+      copy_license \
+        "${LIBS_BUILD_FOLDER_PATH}/${gpm_folder_name}" \
+        "${gpm_folder_name}"
+    )
+
+    touch "${gpm_stamp_file_path}"
+
+  else
+    echo "Library gpm already installed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# Download the Windows Python 2 libraries and headers.
+function download_python2_win() 
+{
+  # https://www.python.org/downloads/release/python-2714/
+  # https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi
+  # https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi
+
+  local python2_version="$1"
+
+  local python2_version_major=$(echo ${python2_version} | sed -e 's|\([0-9]\)\..*|\1|')
+  local python2_version_minor=$(echo ${python2_version} | sed -e 's|\([0-9]\)\.\([0-9][0-9]*\)\..*|\2|')
+
+  if [ "${TARGET_BITS}" == "32" ]
+  then
+    PYTHON2_SRC_FOLDER_NAME=python-"${python2_version}"
+  else
+    PYTHON2_SRC_FOLDER_NAME=python-"${python2_version}".amd64
+  fi
+
+  # Used to compute GNURM_PYTHON_WIN_DIR.
+  export PYTHON2_SRC_FOLDER_NAME
+
+  local python2_win_pack="${PYTHON2_SRC_FOLDER_NAME}.msi"
+  local python2_win_url="https://www.python.org/ftp/python/${python2_version}/${python2_win_pack}"
+
+  cd "${SOURCES_FOLDER_PATH}"
+
+  download "${python2_win_url}" "${python2_win_pack}"
+
+  (
+    xbb_activate
+
+    if [ ! -d "${PYTHON2_SRC_FOLDER_NAME}" ]
+    then
+      cd "${SOURCES_FOLDER_PATH}"
+
+      # Include only the headers and the python library and executable.
+      echo '*.h' >"/tmp/included"
+      echo 'python*.dll' >>"/tmp/included"
+      echo 'python*.lib' >>"/tmp/included"
+      7za x -o"${PYTHON2_SRC_FOLDER_NAME}" "${DOWNLOAD_FOLDER_PATH}/${python2_win_pack}" -i@"/tmp/included"
+
+      # Patch to disable the macro that renames hypot.
+      local patch_path="${BUILD_GIT_PATH}/patches/${PYTHON2_SRC_FOLDER_NAME}.patch"
+      if [ -f "${patch_path}" ]
+      then
+        (
+          cd "${PYTHON2_SRC_FOLDER_NAME}"
+          patch -p0 <"${patch_path}" 
+        )
+      fi
+    else
+      echo "Folder ${PYTHON2_SRC_FOLDER_NAME} already present."
+    fi
+
+    echo "Copying python${python2_version_major}${python2_version_minor}.dll..."
+    # From here it'll be copied as dependency.
+    mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/bin/"
+    install -v -c -m 644 "${PYTHON2_SRC_FOLDER_NAME}/python${python2_version_major}${python2_version_minor}.dll" \
+      "${LIBS_INSTALL_FOLDER_PATH}/bin/"
+
+    mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/lib/"
+    install -v -c -m 644 "${PYTHON2_SRC_FOLDER_NAME}/python${python2_version_major}${python2_version_minor}.lib" \
+      "${LIBS_INSTALL_FOLDER_PATH}/lib/"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+# Download the Windows Python 3 libraries and headers.
+function download_python3_win() 
+{
+  # https://www.python.org/downloads/windows/
+  # https://www.python.org/downloads/release/python-372/
+  # https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-win32.zip
+  # https://www.python.org/ftp/python/3.7.2/python-3.7.2.post1-embed-amd64.zip
+  # https://www.python.org/ftp/python/3.7.2/python-3.7.2.exe
+  # https://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe
+  # https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
+  # https://www.python.org/ftp/python/3.7.6/
+  # https://www.python.org/ftp/python/3.7.6/python-3.7.6-embed-amd64.zip
+  # https://www.python.org/ftp/python/3.7.6/python-3.7.6-embed-win32.zip
+
+  local python3_version="$1"
+  
+  local python3_version_major=$(echo ${python3_version} | sed -e 's|\([0-9]\)\..*|\1|')
+  local python3_version_minor=$(echo ${python3_version} | sed -e 's|\([0-9]\)\.\([0-9][0-9]*\)\..*|\2|')
+
+  # Version 3.7.2 uses a longer name, like python-3.7.2.post1-embed-amd64.zip.
+  if [ "${TARGET_BITS}" == "32" ]
+  then
+    PYTHON3_WIN_EMBED_FOLDER_NAME=python-"${python3_version}-embed-win32"
+  else
+    PYTHON3_WIN_EMBED_FOLDER_NAME=python-"${python3_version}-embed-amd64"
+  fi
+
+  # Used in python3-config.sh
+  export PYTHON3_WIN_EMBED_FOLDER_NAME
+  export PYTHON3_SRC_FOLDER_NAME="Python-${python3_version}"
+
+  local python3_win_embed_pack="${PYTHON3_WIN_EMBED_FOLDER_NAME}.zip"
+  local python3_win_embed_url="https://www.python.org/ftp/python/${python3_version}/${python3_win_embed_pack}"
+
+  (
+    xbb_activate
+
+    if [ ! -d "${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}" ]
+    then
+      mkdir -pv "${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}"
+      cd "${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}"
+
+      download_and_extract "${python3_win_embed_url}" "${python3_win_embed_pack}" "${PYTHON3_WIN_EMBED_FOLDER_NAME}"
+    else
+      echo "Folder ${PYTHON3_WIN_EMBED_FOLDER_NAME} already present."
+    fi
+      
+    cd "${SOURCES_FOLDER_PATH}/${PYTHON3_WIN_EMBED_FOLDER_NAME}"
+    echo "Copying python${python3_version_major}${python3_version_minor}.dll..."
+    # From here it'll be copied as dependency.
+    mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/bin/"
+    install -v -c -m 644 "python${python3_version_major}.dll" \
+      "${LIBS_INSTALL_FOLDER_PATH}/bin/"
+    install -v -c -m 644 "python${python3_version_major}${python3_version_minor}.dll" \
+      "${LIBS_INSTALL_FOLDER_PATH}/bin/"
+
+    mkdir -pv "${LIBS_INSTALL_FOLDER_PATH}/lib/"
+    install -v -c -m 644 "python${python3_version_major}.dll" \
+      "${LIBS_INSTALL_FOLDER_PATH}/lib/"
+    install -v -c -m 644 "python${python3_version_major}${python3_version_minor}.dll" \
+      "${LIBS_INSTALL_FOLDER_PATH}/lib/"
+  )
+
+  local python3_archive="${PYTHON3_SRC_FOLDER_NAME}.tar.xz"
+  local python3_url="https://www.python.org/ftp/python/${python3_version}/${python3_archive}"
+
+  # local python3_folder_name="python-${python3_version}"
+
+  if [ ! -d "${SOURCES_FOLDER_PATH}/${PYTHON3_SRC_FOLDER_NAME}" ]
+  then
+    cd "${SOURCES_FOLDER_PATH}"
+
+    download_and_extract "${python3_url}" "${python3_archive}" \
+      "${PYTHON3_SRC_FOLDER_NAME}"
+  fi
+
+  # The source archive includes only the pyconfig.h.in, which needs
+  # to be configured, which is not an easy task. Thus add the file copied 
+  # from a Windows install.
+  cp -v "${BUILD_GIT_PATH}/patches/pyconfig-${python3_version}.h" \
+    "${SOURCES_FOLDER_PATH}/${PYTHON3_SRC_FOLDER_NAME}/Include/pyconfig.h"
+}
+
+# -----------------------------------------------------------------------------
+

+ 175 - 0
distro-info/scripts/helper/container-functions-source.sh

@@ -0,0 +1,175 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPack distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the container build scripts.
+
+# -----------------------------------------------------------------------------
+
+function start_timer() 
+{
+  CONTAINER_BEGIN_SECOND=$(date +%s)
+  echo
+  echo "Container script \"$0\" started at $(date)."
+}
+
+function stop_timer() 
+{
+  local end_second=$(date +%s)
+  echo
+  echo "Container script \"$0\" completed at $(date)."
+  local delta_seconds=$((end_second-CONTAINER_BEGIN_SECOND))
+  if [ ${delta_seconds} -lt 100 ]
+  then
+    echo "Duration: ${delta_seconds} seconds."
+  else
+    local delta_minutes=$(((delta_seconds+30)/60))
+    echo "Duration: ${delta_minutes} minutes."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function detect_container() 
+{
+  echo
+  uname -a
+
+  CONTAINER_DISTRO_NAME=""
+  CONTAINER_UNAME="$(uname)"
+  CONTAINER_NODE_PLATFORM=""
+  CONTAINER_NODE_ARCH=""
+
+  if [ "${CONTAINER_UNAME}" == "Darwin" ]
+  then
+
+    CONTAINER_BITS="64"
+    CONTAINER_MACHINE="x86_64"
+
+    CONTAINER_NODE_PLATFORM="darwin"
+    CONTAINER_NODE_ARCH="x64"
+
+    CONTAINER_DISTRO_NAME=Darwin
+    CONTAINER_DISTRO_LC_NAME=darwin
+
+  elif [ "${CONTAINER_UNAME}" == "Linux" ]
+  then
+    # ----- Determine distribution name and word size -----
+
+    set +e
+    CONTAINER_DISTRO_NAME=$(lsb_release -si)
+    set -e
+
+    CONTAINER_NODE_PLATFORM="linux"
+
+    if [ -z "${CONTAINER_DISTRO_NAME}" ]
+    then
+      echo "Please install the lsb core package and rerun."
+      CONTAINER_DISTRO_NAME="Linux"
+    fi
+
+    CONTAINER_MACHINE="$(uname -m)"
+    if [ "${CONTAINER_MACHINE}" == "x86_64" ]
+    then
+      CONTAINER_BITS="64"
+      CONTAINER_NODE_ARCH="x64"
+    elif [ "${CONTAINER_MACHINE}" == "i686" ]
+    then
+      CONTAINER_BITS="32"
+      CONTAINER_NODE_ARCH="x32"
+    elif [ "${CONTAINER_MACHINE}" == "aarch64" ]
+    then
+      CONTAINER_BITS="64"
+      CONTAINER_NODE_ARCH="arm64"
+    elif [ "${CONTAINER_MACHINE}" == "armv7l" \
+      -o "${CONTAINER_MACHINE}" == "armv8l" ]
+    then
+      CONTAINER_BITS="32"
+      CONTAINER_NODE_ARCH="arm"
+    else
+      echo "Unknown uname -m ${CONTAINER_MACHINE}"
+      exit 1
+    fi
+
+    CONTAINER_DISTRO_LC_NAME=$(echo ${CONTAINER_DISTRO_NAME} | tr "[:upper:]" "[:lower:]")
+
+  else
+    echo "Unknown uname ${CONTAINER_UNAME}"
+    exit 1
+  fi
+
+  echo
+  echo "Container script running on ${CONTAINER_DISTRO_NAME} ${CONTAINER_NODE_ARCH} (${CONTAINER_BITS}-bit)."
+  echo "User $(whoami), in '${HOME}'"
+
+  HAS_WINPTHREAD=${HAS_WINPTHREAD:-""}
+  CONTAINER_ROOT_UMASK=${CONTAINER_ROOT_UMASK:-"000"}
+
+  if [ -f "/.dockerenv" -a "$(whoami)" == "root" ]
+  then
+    umask ${CONTAINER_ROOT_UMASK}
+  fi
+}
+
+
+# -----------------------------------------------------------------------------
+
+function fix_ownership()
+{
+  if [ -f "/.dockerenv" -a "${CONTAINER_RUN_AS_ROOT}" == "y" ]
+  then
+    (
+      xbb_activate
+      
+      # Set the owner of the folder and files created by the docker CentOS 
+      # container to match the user running the build script on the host. 
+      # When running on linux host, these folders and their content remain  
+      # owned by root if this is not done. However, on macOS  
+      # the owner used by Docker is the same as the macOS user, so an 
+      # ownership change is not realy necessary. 
+      echo
+      echo "Changing ownership to non-root GNU/Linux user..."
+
+      if [ -d "${BUILD_FOLDER_PATH}" ]
+      then
+        chown -R ${USER_ID}:${GROUP_ID} "${BUILD_FOLDER_PATH}"
+      fi
+      if [ -d "${INSTALL_FOLDER_PATH}" ]
+      then
+        chown -R ${USER_ID}:${GROUP_ID} "${INSTALL_FOLDER_PATH}"
+      fi
+      chown -R ${USER_ID}:${GROUP_ID} "${DEPLOY_FOLDER_PATH}"
+    )
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# Hack to make pdftex ignore errors.
+# Used for newlib manuals, which issue some errors, but the
+# pdf file is generated anyway.
+function hack_pdfetex()
+{
+  local bin=$(which pdfetex)
+  local hacked_pdfetex="hack/pdfetex"
+
+  mkdir -pv "$(dirname "${hacked_pdfetex}")"
+  rm -rf "${hacked_pdfetex}"
+  echo '#!/usr/bin/env bash' >"${hacked_pdfetex}"
+  echo 'set -x' >>"${hacked_pdfetex}"
+  echo 'set +e' >>"${hacked_pdfetex}"
+  echo "${bin}" '$@' >>"${hacked_pdfetex}"
+  echo 'set -e' >>"${hacked_pdfetex}"
+  echo 'true' >>"${hacked_pdfetex}"
+  chmod +x "${hacked_pdfetex}"
+
+  export PATH="$(pwd)/$(dirname "${hacked_pdfetex}"):${PATH}"
+}
+

+ 1159 - 0
distro-info/scripts/helper/host-functions-source.sh

@@ -0,0 +1,1159 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPack distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the second edition of the xPack build 
+# scripts. As the name implies, it should contain only functions and 
+# should be included with 'source' by the host build scripts.
+
+# -----------------------------------------------------------------------------
+
+function host_get_current_date() 
+{
+  # Use the UTC date as version in the name of the distribution file.
+  DISTRIBUTION_FILE_DATE=${DISTRIBUTION_FILE_DATE:-$(date -u +%Y%m%d-%H%M)}
+
+  # Leave a track of the start date, in case of resume needed.
+  mkdir -pv "${HOST_WORK_FOLDER_PATH}"
+  touch "${HOST_WORK_FOLDER_PATH}/${DISTRIBUTION_FILE_DATE}"
+  echo
+  echo "DISTRIBUTION_FILE_DATE=\"${DISTRIBUTION_FILE_DATE}\""
+}
+
+function host_start_timer() 
+{
+  HOST_BEGIN_SECOND=$(date +%s)
+  echo
+  echo "Script \"$0\" started at $(date)."
+}
+
+function host_stop_timer() 
+{
+  local host_end_second=$(date +%s)
+  echo
+  echo "Script \"$0\" completed at $(date)."
+  local delta_seconds=$((host_end_second-HOST_BEGIN_SECOND))
+  if [ ${delta_seconds} -lt 100 ]
+  then
+    echo "Duration: ${delta_seconds} seconds."
+  else
+    local delta_minutes=$(((delta_seconds+30)/60))
+    echo "Duration: ${delta_minutes} minutes."
+  fi
+}
+
+function host_notify_completed()
+{
+  if [ "${HOST_UNAME}" == "Darwin" ]
+  then
+    say "Wake up, the build completed successfully"
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+# Detect the machine the build runs on.
+function host_detect() 
+{
+  echo
+  uname -a
+
+  HOST_UNAME="$(uname)"
+  HOST_MACHINE="$(uname -m)"
+
+  HOST_DISTRO_NAME="?" # Linux distribution name (Ubuntu|CentOS|...)
+  HOST_DISTRO_LC_NAME="?" # Same, in lower case.
+
+  HOST_NODE_ARCH="?" # Node.js process.arch (x32|x64|arm|arm64)
+  HOST_NODE_PLATFORM="?" # Node.js process.platform (darwin|linux|win32)
+
+  if [ "${HOST_UNAME}" == "Darwin" ]
+  then
+    # uname -p -> i386
+    # uname -m -> x86_64
+
+    HOST_BITS="64"
+
+    HOST_DISTRO_NAME=Darwin
+    HOST_DISTRO_LC_NAME=darwin
+
+    HOST_NODE_ARCH="x64" # For now.
+    HOST_NODE_PLATFORM="darwin"
+
+  elif [ "${HOST_UNAME}" == "Linux" ]
+  then
+    # ----- Determine distribution name and word size -----
+
+    # uname -p -> x86_64|i686 (unknown in recent versions, use -m)
+    # uname -m -> x86_64|i686|aarch64|armv7l
+
+    if [ "${HOST_MACHINE}" == "x86_64" ]
+    then
+      HOST_BITS="64"
+      HOST_NODE_ARCH="x64"
+    elif [ "${HOST_MACHINE}" == "i386" -o "${HOST_MACHINE}" == "i686" ]
+    then
+      HOST_BITS="32"
+      HOST_NODE_ARCH="x32"
+    elif [ "${HOST_MACHINE}" == "aarch64" ]
+    then
+      HOST_BITS="64"
+      HOST_NODE_ARCH="arm64"
+    elif [ "${HOST_MACHINE}" == "armv7l" -o "${HOST_MACHINE}" == "armv8l" ]
+    then
+      HOST_BITS="32"
+      HOST_NODE_ARCH="arm"
+    else
+      echo "Unknown uname -m ${HOST_MACHINE}"
+      exit 1
+    fi
+
+    HOST_NODE_PLATFORM="linux"
+
+    local lsb_path=$(which lsb_release)
+    if [ -z "${lsb_path}" ]
+    then
+      echo "Please install the lsb core package and rerun."
+      exit 1
+    fi
+
+    HOST_DISTRO_NAME=$(lsb_release -si)
+    HOST_DISTRO_LC_NAME=$(echo ${HOST_DISTRO_NAME} | tr "[:upper:]" "[:lower:]")
+
+  else
+    echo "Unsupported uname ${HOST_UNAME}"
+    exit 1
+  fi
+
+  echo
+  echo "Running on ${HOST_DISTRO_NAME} ${HOST_NODE_ARCH} (${HOST_BITS}-bit)."
+
+  USER_ID=$(id -u)
+  USER_NAME="$(id -u -n)"
+  GROUP_ID=$(id -g)
+  GROUP_NAME="$(id -g -n)"
+
+  TARGET_ARCH="${HOST_NODE_ARCH}"
+  TARGET_PLATFORM="${HOST_NODE_PLATFORM}"
+  TARGET_MACHINE="${HOST_MACHINE}"
+
+  IS_NATIVE=""
+  IS_DEVELOP=""
+  # Redefine it to "y" to run as root inside the container.
+  CONTAINER_RUN_AS_ROOT=${CONTAINER_RUN_AS_ROOT:-""}
+  HAS_WINPTHREAD=${HAS_WINPTHREAD:-""}
+}
+
+# -----------------------------------------------------------------------------
+
+function host_prepare_cache()
+{
+  # The folder that caches all downloads is in Work, for easy access.
+  HOST_CACHE_FOLDER_PATH=${HOST_CACHE_FOLDER_PATH:-"${HOME}/Work/cache"}
+  CONTAINER_CACHE_FOLDER_PATH="/Host${HOST_CACHE_FOLDER_PATH}"
+
+  mkdir -pv "${HOST_CACHE_FOLDER_PATH}"
+}
+
+function host_options()
+{
+  local help_message="$1"
+  shift
+
+  ACTION=""
+
+  DO_BUILD_SOURCES=""
+
+  DO_BUILD_WIN32=""
+  DO_BUILD_WIN64=""
+  DO_BUILD_LINUX32=""
+  DO_BUILD_LINUX64=""
+  DO_BUILD_LINUX_ARM32=""
+  DO_BUILD_LINUX_ARM64=""
+  DO_BUILD_OSX=""
+  ENV_FILE=""
+
+  argc=$#
+  declare -a argv
+  argv=( "$@" )
+  if [ ! -z "${DEBUG}" ]
+  then
+    echo ${argv[@]-}
+  fi
+  i=0
+
+  # Must be declared by the caller.
+  # declare -a rest
+
+
+  # Identify some of the options. The rest are collected and passed
+  # to the container script.
+  while [ $i -lt $argc ]
+  do
+
+    arg="${argv[$i]}"
+    case "${arg}" in
+
+      clean|cleanlibs|cleanall|preload-images)
+        ACTION="${arg}"
+        ;;
+
+      --win32|--windows32)
+        DO_BUILD_WIN32="y"
+        ;;
+
+      --win64|--windows64)
+        DO_BUILD_WIN64="y"
+        ;;
+
+      --linux32)
+        DO_BUILD_LINUX32="y"
+        ;;
+
+      --linux64)
+        DO_BUILD_LINUX64="y"
+        ;;
+
+      --arm32)
+        DO_BUILD_LINUX_ARM32="y"
+        ;;
+
+      --arm64)
+        DO_BUILD_LINUX_ARM64="y"
+        ;;
+
+      --osx)
+        DO_BUILD_OSX="y"
+        ;;
+
+      --sources)
+        DO_BUILD_SOURCES="y"
+        ;;
+
+      --all)
+        if [ "${HOST_NODE_ARCH}" == "arm64" ]
+        then
+          DO_BUILD_LINUX_ARM32="y"
+          DO_BUILD_LINUX_ARM64="y"
+        elif [ "${HOST_NODE_ARCH}" == "x64" ]
+        then
+          DO_BUILD_WIN32="y"
+          DO_BUILD_WIN64="y"
+          DO_BUILD_LINUX32="y"
+          DO_BUILD_LINUX64="y"
+          DO_BUILD_SOURCES="y"
+          if [ "$(uname)" == "Darwin" ] 
+          then
+            DO_BUILD_OSX="y"
+          fi
+        else
+          echo "--all supported only on 64-bit hosts"
+        fi
+        ;;
+
+      --env-file)
+        ((++i))
+        ENV_FILE="${argv[$i]}"
+        if [ ! -f "${ENV_FILE}" ];
+        then
+          echo "The specified environment file \"${ENV_FILE}\" does not exist, exiting..."
+          exit 1
+        fi
+        ;;
+
+      # Deprecated.
+      --date)
+        ((++i))
+        DISTRIBUTION_FILE_DATE="${argv[$i]}"
+        ;;
+
+      --help)
+        echo "Usage:"
+        # Some of the options are processed by the container script.
+        echo "${help_message}"
+        echo
+        exit 1
+        ;;
+
+      *)
+        # Collect all other in an array. Append to the end.
+        # Will be later processed by the container script.
+        set +u
+        rest[${#rest[*]}]="$arg"
+        set -u
+        ;;
+
+    esac
+    ((++i))
+
+  done
+
+  DO_BUILD_ANY="${DO_BUILD_OSX}${DO_BUILD_LINUX64}${DO_BUILD_LINUX_ARM64}${DO_BUILD_WIN64}${DO_BUILD_LINUX32}${DO_BUILD_LINUX_ARM32}${DO_BUILD_WIN32}${DO_BUILD_SOURCES}"
+
+  # The ${rest[@]} options will be passed to the inner script.
+  if [ ! -z "${DEBUG}" ]
+  then
+    echo ${rest[@]-}
+  fi
+}
+
+function host_options_windows()
+{
+  local help_message="$1"
+  shift
+
+  ACTION=""
+
+  DO_BUILD_WIN32=""
+  DO_BUILD_WIN64=""
+
+  # Kept, since they are used in various common functions.
+  DO_BUILD_LINUX32=""
+  DO_BUILD_LINUX64=""
+  DO_BUILD_LINUX_ARM32=""
+  DO_BUILD_LINUX_ARM64=""
+  DO_BUILD_OSX=""
+
+  ENV_FILE=""
+
+  argc=$#
+  declare -a argv
+  argv=( "$@" )
+  if [ ! -z "${DEBUG}" ]
+  then
+    echo ${argv[@]-}
+  fi
+  i=0
+
+  # Must be declared by the caller.
+  # declare -a rest
+
+
+  # Identify some of the options. The rest are collected and passed
+  # to the container script.
+  while [ $i -lt $argc ]
+  do
+
+    arg="${argv[$i]}"
+    case "${arg}" in
+
+      clean|cleanlibs|cleanall|preload-images)
+        ACTION="${arg}"
+        ;;
+
+      --win32|--windows32)
+        DO_BUILD_WIN32="y"
+        ;;
+
+      --win64|--windows64)
+        DO_BUILD_WIN64="y"
+        ;;
+
+      --all)
+        DO_BUILD_WIN32="y"
+        DO_BUILD_WIN64="y"
+        ;;
+
+      --env-file)
+        ((++i))
+        ENV_FILE="${argv[$i]}"
+        if [ ! -f "${ENV_FILE}" ];
+        then
+          echo "The specified environment file \"${ENV_FILE}\" does not exist, exiting..."
+          exit 1
+        fi
+        ;;
+
+      # Deprecated.
+      --date)
+        ((++i))
+        DISTRIBUTION_FILE_DATE="${argv[$i]}"
+        ;;
+
+      --help)
+        echo "Usage:"
+        # Some of the options are processed by the container script.
+        echo "${help_message}"
+        echo
+        exit 1
+        ;;
+
+      *)
+        # Collect all other in an array. Append to the end.
+        # Will be later processed by the container script.
+        set +u
+        rest[${#rest[*]}]="$arg"
+        set -u
+        ;;
+
+    esac
+    ((++i))
+
+  done
+
+  DO_BUILD_ANY="${DO_BUILD_WIN64}${DO_BUILD_WIN32}"
+
+  # The ${rest[@]} options will be passed to the inner script.
+  if [ ! -z "${DEBUG}" ]
+  then
+    echo ${rest[@]-}
+  fi
+}
+
+function host_native_options()
+{
+  local help_message="$1"
+  shift
+
+  ACTION=""
+
+  DO_BUILD_WIN=""
+  IS_DEBUG=""
+  IS_DEVELOP=""
+  WITH_STRIP="y"
+  IS_NATIVE="y"
+
+  if [ "$(uname)" == "Linux" ]
+  then
+    JOBS="$(nproc)"
+  elif [ "$(uname)" == "Darwin" ]
+  then
+    JOBS="$(sysctl hw.ncpu | sed 's/hw.ncpu: //')"
+  else
+    JOBS="1"
+  fi
+
+  while [ $# -gt 0 ]
+  do
+    case "$1" in
+
+      clean|cleanlibs|cleanall)
+        ACTION="$1"
+        ;;
+
+      --win|--windows)
+        DO_BUILD_WIN="y"
+        ;;
+
+      --debug)
+        IS_DEBUG="y"
+        ;;
+
+      --develop)
+        IS_DEVELOP="y"
+        ;;
+
+      --jobs)
+        shift
+        JOBS=$1
+        ;;
+
+      --disable-strip)
+        WITH_STRIP="n"
+        shift
+        ;;
+
+      --help)
+        echo "Build a local/native ${DISTRO_UC_NAME} ${APP_NAME}."
+        echo "Usage:"
+        # Some of the options are processed by the container script.
+        echo "${help_message}"
+        echo
+        exit 0
+        ;;
+
+      *)
+        echo "Unknown action/option $1"
+        exit 1
+        ;;
+
+    esac
+    shift
+
+  done
+
+  if [ "${DO_BUILD_WIN}" == "y" ]
+  then
+    if [ "${HOST_NODE_PLATFORM}" == "linux" ]
+    then
+      TARGET_PLATFORM="win32"
+    else
+      echo "Windows cross builds are available only on GNU/Linux."
+      exit 1
+    fi
+  fi
+}
+
+function host_common()
+{
+  if [ -f "${script_folder_path}/VERSION" ]
+  then
+    # When running from the distribution folder.
+    RELEASE_VERSION=${RELEASE_VERSION:-"$(cat "${script_folder_path}"/VERSION)"}
+  fi
+
+  echo
+  echo "Preparing release ${RELEASE_VERSION}..."
+
+  # -----------------------------------------------------------------------------
+
+  common_helper_functions_script_path="${script_folder_path}/helper/common-functions-source.sh"
+  echo "Common helper functions source script: \"${common_helper_functions_script_path}\"."
+  source "${common_helper_functions_script_path}"
+
+  # May override some of the helper/common definitions.
+  common_functions_script_path="${script_folder_path}/common-functions-source.sh"
+  if [ -f "${common_functions_script_path}" ]
+  then
+    echo "Common functions source script: \"${common_functions_script_path}\"."
+    source "${common_functions_script_path}"
+  fi
+
+  # ---------------------------------------------------------------------------
+
+  # The Work folder is in HOME.
+  HOST_WORK_FOLDER_PATH=${WORK_FOLDER_PATH:-"${HOME}/Work"}
+  if [ "${IS_NATIVE}" == "y" -a "${IS_DEVELOP}" == "y" ]
+  then
+    HOST_WORK_FOLDER_PATH+="/${APP_LC_NAME}-dev"
+  else
+    HOST_WORK_FOLDER_PATH+="/${APP_LC_NAME}-${RELEASE_VERSION}"
+  fi
+  CONTAINER_WORK_FOLDER_PATH="/Host${HOST_WORK_FOLDER_PATH}"
+
+  SOURCES_FOLDER_PATH="${SOURCES_FOLDER_PATH:-"${HOST_WORK_FOLDER_PATH}/sources"}"
+
+  do_actions
+
+  host_prepare_cache
+
+  CONTAINER_BUILD_SCRIPT_REL_PATH="build.git/scripts/${CONTAINER_SCRIPT_NAME}"
+  echo "Container build script: \"${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}\"."
+
+  # ---------------------------------------------------------------------------
+
+  mkdir -pv "${HOST_WORK_FOLDER_PATH}"
+  mkdir -pv "${SOURCES_FOLDER_PATH}"
+
+  # ---------------------------------------------------------------------------
+
+  # Set the DISTRIBUTION_FILE_DATE.
+  host_get_current_date
+
+  # ---------------------------------------------------------------------------
+
+  host_start_timer
+
+  host_prepare_prerequisites
+
+  # ---------------------------------------------------------------------------
+
+  copy_build_git
+}
+
+function host_prepare_prerequisites() 
+{
+  if [ "${HOST_UNAME}" == "Darwin" ]
+  then
+    local xbb_folder_path
+
+    
+    local must_install=""
+
+    if [ -d "${HOME}/opt/xbb" ]
+    then
+      xbb_folder_path="${HOME}/opt/xbb"
+    elif [ -d "${HOME}/opt/homebrew/xbb" ]
+    then
+      xbb_folder_path="${HOME}/opt/homebrew/xbb"
+    else
+      must_install="y"
+    fi
+
+
+    if [ ! -z "${xbb_folder_path}" ]
+    then
+
+      echo
+      echo "Checking XBB in '${xbb_folder_path}'..."
+      if [ ! -f "${xbb_folder_path}/xbb-source.sh" ]
+      then
+        must_install="y"
+      fi
+      
+    fi
+
+    if [ -n "${must_install}" ]
+    then
+
+      echo
+      echo "Please install the macOS XBB and rerun."
+      echo "https://github.com/xpack/xpack-build-box/tree/master/macos"
+      
+      exit 1
+
+    fi
+
+    if true
+    then
+
+      local tl_folder="$HOME/opt/texlive"
+
+      must_install=""
+      # Check local TeX Live.
+      if [ ! -d "${tl_folder}" ]
+      then
+        must_install="y"
+      else
+
+        PATH="${tl_folder}/bin/x86_64-darwin:${PATH}"
+        export PATH
+
+        echo
+        echo "Checking TeX Live in '${tl_folder}'..."
+        set +e
+        tex --version | grep 'TeX 3'
+        if [ $? != 0 ]
+        then
+          must_install="y"
+        fi
+        set -e
+
+      fi
+
+      if [ -n "${must_install}" ]
+      then
+
+        echo
+        echo "Please install TeX Live and rerun."
+        echo "Alternatively restart the build script using '--without-pdf'."
+        echo "https://github.com/xpack/xpack-build-box/blob/master/macos/README.md#install-tex"
+
+        exit 1
+
+      fi
+
+    fi # -z "${no_pdf}"
+  fi # "${HOST_UNAME}" == "Darwin"
+
+  host_prepare_cache
+
+  # The host script will pass to the container script
+  # various environment variables.
+  HOST_DEFINES_SCRIPT_PATH="${HOST_WORK_FOLDER_PATH}/build.git/scripts/host-defs-source.sh"
+
+  DEPLOY_FOLDER_NAME=${DEPLOY_FOLDER_NAME:-"deploy"}
+}
+
+# -----------------------------------------------------------------------------
+
+function host_prepare_docker() 
+{
+  echo
+  echo "Checking Docker..."
+
+  set +e
+  docker --version
+  if [ $? != 0 ]
+  then
+    echo "Please start docker daemon and rerun."
+    echo "If not installed, see https://docs.docker.com/installation/."
+    exit 1
+  fi
+
+  echo
+  echo "Pruning Docker..."
+  
+  docker system prune -f
+  set -e
+}
+
+# -----------------------------------------------------------------------------
+
+function host_build_target() 
+{
+  message="$1"
+  shift
+
+  echo
+  echo "================================================================================"
+  echo "=== ${message}"
+
+  echo
+  echo $@
+
+  local container_script_path=""
+  local target_platform="${HOST_NODE_PLATFORM}"
+  local target_arch="${HOST_NODE_ARCH}"
+  local target_machine="${HOST_MACHINE}"
+  local target_bits="${HOST_BITS}"
+  # If the docker image is not set, it is a native build.
+  local docker_image=""
+  local build_binaries_path=""
+  local env_file=""
+
+  while [ $# -gt 0 ]
+  do
+
+    case "$1" in
+      --script)
+        container_script_path="$2"
+        shift 2
+        ;;
+
+      --target-platform)
+        target_platform="$2"
+        shift 2
+        ;;
+
+      --target-arch)
+        target_arch="$2"
+        shift 2
+        ;;
+
+      --target-machine)
+        target_machine="$2"
+        shift 2
+        ;;
+
+      --target-bits)
+        target_bits="$2"
+        shift 2
+        ;;
+
+      --docker-image)
+        docker_image="$2"
+        shift 2
+        ;;
+
+      --env-file)
+        env_file="$2"
+        shift 2
+        ;;
+
+      --)
+        shift
+        break
+        ;;
+
+      *)
+        echo "Unknown option $1, exit."
+        exit 1
+
+    esac
+
+  done
+
+  if [ "${target_platform}" == "sources" ]
+  then
+    target_arch="none"
+    target_bits=""
+  fi
+
+  # The remaining "$@" options will be passed to the inner script.
+  if [ -n "${DEBUG}" ]
+  then
+    echo "$@"
+  fi
+
+  # ---------------------------------------------------------------------------
+
+  mkdir -pv "$(dirname "${HOST_DEFINES_SCRIPT_PATH}")"
+  echo "${RELEASE_VERSION}" >"$(dirname "${HOST_DEFINES_SCRIPT_PATH}")"/VERSION
+
+  rm -rf "${HOST_DEFINES_SCRIPT_PATH}"
+  touch "${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "RELEASE_VERSION=\"${RELEASE_VERSION}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "DISTRIBUTION_FILE_DATE=\"${DISTRIBUTION_FILE_DATE}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "TARGET_PLATFORM=\"${target_platform}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "TARGET_ARCH=\"${target_arch}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "TARGET_MACHINE=\"${target_machine}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "TARGET_BITS=\"${target_bits}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "HOST_UNAME=\"${HOST_UNAME}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "USER_ID=\"${USER_ID}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "USER_NAME=\"${USER_NAME}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "GROUP_ID=\"${GROUP_ID}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "GROUP_NAME=\"${GROUP_NAME}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "CONTAINER_RUN_AS_ROOT=\"${CONTAINER_RUN_AS_ROOT}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "HOST_WORK_FOLDER_PATH=\"${HOST_WORK_FOLDER_PATH}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "CONTAINER_WORK_FOLDER_PATH=\"${CONTAINER_WORK_FOLDER_PATH}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "HOST_CACHE_FOLDER_PATH=\"${HOST_CACHE_FOLDER_PATH}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+  echo "CONTAINER_CACHE_FOLDER_PATH=\"${CONTAINER_CACHE_FOLDER_PATH}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  echo "DEPLOY_FOLDER_NAME=\"${DEPLOY_FOLDER_NAME}\"" >>"${HOST_DEFINES_SCRIPT_PATH}"
+
+  if [ -z "${docker_image}" ]
+  then
+
+    host_run_native_script \
+      --script "${container_script_path}" \
+      --env-file "${env_file}" \
+      -- \
+      "$@"
+
+  else
+
+    host_run_docker_script \
+      --script "${container_script_path}" \
+      --docker-image "${docker_image}" \
+      --docker-container-name "${APP_LC_NAME}-${target_platform}-${target_arch}-build" \
+      --env-file "${env_file}" \
+      --host-uname "${HOST_UNAME}" \
+      -- \
+      "$@"    
+
+  fi
+
+  if [ -n "${DEBUG}" ]
+  then
+    echo "host_build_target ${rest[@]-} completed."
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function host_run_native_script() 
+{
+  local local_script=""
+  local env_file=""
+
+  while [ $# -gt 0 ]
+  do
+
+    case "$1" in
+
+      --script)
+        local_script="$2"
+        shift 2
+        ;;
+
+      --env-file)
+        env_file="$2"
+        shift 2
+        ;;
+
+      --)
+        shift
+        break
+        ;;
+
+      *)
+        echo "Unknown option $1, exit."
+        exit 1
+
+    esac
+
+  done
+
+  # The remaining $@ options will be passed to the inner script.
+
+  echo
+  echo "Running script \"$(basename "${local_script}")\" natively..."
+
+  # Run the inner script in a local sub-shell, possibly with the 
+  # custom environment.
+  (
+    if [ -n "${env_file}" -a -f "${env_file}" ]
+    then
+      source "${env_file}"
+    fi
+    /bin/bash ${DEBUG} "${local_script}" "$@"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+function host_run_docker_script() 
+{
+  local docker_script=""
+  local docker_image=""
+  local docker_container_name=""
+  local host_uname=""
+  local env_file=""
+  local opt_env_file=
+
+  while [ $# -gt 0 ]
+  do
+
+    case "$1" in
+
+      --script)
+        docker_script="$2"
+        shift 2
+        ;;
+
+      --docker-image)
+        docker_image="$2"
+        shift 2
+        ;;
+
+      --docker-container-name)
+        docker_container_name="$2"
+        shift 2
+        ;;
+
+      --host-uname)
+        host_uname="$2"
+        shift 2
+        ;;
+
+      --env-file)
+        env_file="$2"
+        shift 2
+        ;;
+
+      --)
+        shift
+        break
+        ;;
+
+      *)
+        echo "Unknown option $1, exit."
+        exit 1
+
+    esac
+
+  done
+
+  set +e
+  # Remove a possible previously crashed container.
+  docker rm --force "${docker_container_name}" > /dev/null 2> /dev/null
+  set -e
+
+  echo
+  echo "Running script \"$(basename "${docker_script}")\" inside docker image \"${docker_image}\"..."
+
+
+  local env_file_option=""
+  # Run the inner script in a fresh Docker container.
+  if [ -n "${env_file}" -a -f "${env_file}" ]
+  then
+    env_file_option="--env-file=\"${env_file}\""
+  fi
+
+  if [ "${HOST_UNAME}" == "Darwin" -o "${CONTAINER_RUN_AS_ROOT}" == "y" ]
+  then
+
+    docker run \
+      --name="${docker_container_name}" \
+      --tty \
+      --hostname "docker" \
+      --workdir="/root" \
+      --volume="${HOST_WORK_FOLDER_PATH}/:${CONTAINER_WORK_FOLDER_PATH}" \
+      --volume="${HOST_CACHE_FOLDER_PATH}/:${CONTAINER_CACHE_FOLDER_PATH}" \
+      ${env_file_option} \
+      "${docker_image}" \
+      /bin/bash ${DEBUG} "${docker_script}" "$@"
+
+  else
+
+    # This is a bit tricky, since it needs to do multiple actions in
+    # one go: add a new user and run the script with that user credentials,
+    # including passing the extra args (in the middle of the string).
+    #
+    # From the [bash manual](https://www.gnu.org/software/bash/manual/bash.html):
+    # ($*) Expands to the positional parameters, starting from one. 
+    # When the expansion is not within double quotes, each positional 
+    # parameter expands to a separate word. In contexts where it is 
+    # performed, those words are subject to further word splitting and 
+    # pathname expansion. When the expansion occurs within double quotes, 
+    # it expands to a single word with the value of each parameter separated 
+    # by the first character of the IFS special variable. That is, "$*" 
+    # is equivalent to "$1c$2c…", where c is the first character of the 
+    # value of the IFS variable. If IFS is unset, the parameters are 
+    # separated by spaces. If IFS is null, the parameters are joined 
+    # without intervening separators.
+    local ifs="${IFS}"
+    IFS=" "
+    # Without -m, wine fails to create .wine.
+    local cmd_string="groupadd -g ${GROUP_ID} ${GROUP_NAME} && useradd -m -u ${USER_ID} -g ${GROUP_ID} ${USER_NAME} && su -c \"DEBUG=${DEBUG} bash ${docker_script} $*\" ${USER_NAME}"
+    IFS="${ifs}"
+ 
+    docker run \
+      --name="${docker_container_name}" \
+      --tty \
+      --hostname "docker" \
+      --workdir="/root" \
+      --volume="${HOST_WORK_FOLDER_PATH}/:${CONTAINER_WORK_FOLDER_PATH}" \
+      --volume="${HOST_CACHE_FOLDER_PATH}/:${CONTAINER_CACHE_FOLDER_PATH}" \
+      ${env_file_option} \
+      "${docker_image}" \
+      /bin/bash ${DEBUG} -c "${cmd_string}"
+
+  fi
+
+  # Remove the container.
+  echo "Docker container \"$(docker rm --force "${docker_container_name}")\" removed."
+}
+
+# -----------------------------------------------------------------------------
+
+function host_build_all() {
+
+  if [ ! -z "${DO_BUILD_LINUX64}${DO_BUILD_WIN64}${DO_BUILD_LINUX_ARM64}${DO_BUILD_LINUX32}${DO_BUILD_WIN32}${DO_BUILD_LINUX_ARM32}" ]
+  then
+    host_prepare_docker
+  fi
+
+  if [ -z "${DO_BUILD_ANY}" ]
+  then
+
+    # ----- Build the native distribution. --------------------------------------
+
+    host_build_target "Creating the native distribution..." \
+      --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+      --env-file "${ENV_FILE}" \
+      -- \
+      ${rest[@]-}
+
+  else
+
+    # ----- Build the OS X distribution. ----------------------------------------
+
+    if [ "${DO_BUILD_OSX}" == "y" ]
+    then
+      if [ "${HOST_UNAME}" == "Darwin" ]
+      then
+        host_build_target "Creating the OS X distribution..." \
+          --script "${HOST_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+          --env-file "${ENV_FILE}" \
+          --target-platform "darwin" \
+          -- \
+          ${rest[@]-}
+      else
+        echo "Building the macOS image is not possible on this platform."
+        exit 1
+      fi
+    fi
+
+    # ----- Build the GNU/Linux 64-bit distribution. ----------------------------
+    
+    if [ "${DO_BUILD_LINUX64}" == "y" ]
+    then
+      host_build_target "Creating the GNU/Linux 64-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "x64" \
+        --target-machine "x86_64" \
+        --target-bits 64 \
+        --docker-image "${docker_linux64_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    # ----- Build the Windows 64-bit distribution. ------------------------------
+
+    if [ "${DO_BUILD_WIN64}" == "y" ]
+    then
+      host_build_target "Creating the Windows 64-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "win32" \
+        --target-arch "x64" \
+        --target-machine "x86_64" \
+        --target-bits 64 \
+        --docker-image "${docker_linux64_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    # ----- Build the GNU/Linux 32-bit distribution. ----------------------------
+
+    if [ "${DO_BUILD_LINUX32}" == "y" ]
+    then
+      host_build_target "Creating the GNU/Linux 32-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "x32" \
+        --target-machine "i386" \
+        --target-bits 32 \
+        --docker-image "${docker_linux32_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    # ----- Build the Windows 32-bit distribution. ------------------------------
+
+    # Since the actual container is a 32-bit, use the debian32 binaries.
+    if [ "${DO_BUILD_WIN32}" == "y" ]
+    then
+      host_build_target "Creating the Windows 32-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "win32" \
+        --target-arch "x32" \
+        --target-machine "i386" \
+        --target-bits 32 \
+        --docker-image "${docker_linux32_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    # ----- Build the GNU/Linux Arm 64-bit distribution. ---------------------------
+
+    if [ "${DO_BUILD_LINUX_ARM64}" == "y" ]
+    then
+      host_build_target "Creating the GNU/Linux Arm 64-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "arm64" \
+        --target-machine "aarch64" \
+        --target-bits 64 \
+        --docker-image "${docker_linux_arm64_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+    # ----- Build the GNU/Linux Arm 32-bit distribution. ---------------------------
+
+    if [ "${DO_BUILD_LINUX_ARM32}" == "y" ]
+    then
+      host_build_target "Creating the GNU/Linux Arm 32-bit distribution..." \
+        --script "${CONTAINER_WORK_FOLDER_PATH}/${CONTAINER_BUILD_SCRIPT_REL_PATH}" \
+        --env-file "${ENV_FILE}" \
+        --target-platform "linux" \
+        --target-arch "arm" \
+        --target-machine "armhf" \
+        --target-bits 32 \
+        --docker-image "${docker_linux_arm32_image}" \
+        -- \
+        ${rest[@]-}
+    fi
+
+  fi
+}
+
+# -----------------------------------------------------------------------------
+
+function host_show_sha() {
+
+  if [ -d "${HOST_WORK_FOLDER_PATH}/${DEPLOY_FOLDER_NAME}" ]
+  then
+    echo
+    echo "${HOST_WORK_FOLDER_PATH}/${DEPLOY_FOLDER_NAME}"
+    ls -l "${HOST_WORK_FOLDER_PATH}/${DEPLOY_FOLDER_NAME}"
+    echo
+    echo "SHA signatures..."
+    set +e
+    cat "${HOST_WORK_FOLDER_PATH}/${DEPLOY_FOLDER_NAME}"/*.sha
+    set -e
+  fi
+}
+
+# -----------------------------------------------------------------------------

+ 77 - 0
distro-info/scripts/helper/templates.sh

@@ -0,0 +1,77 @@
+# Templates to be used with copy/paste in the bash source files.
+
+# Build xxx library.
+
+function do_xxx() 
+{
+  # XXX_VERSION="1.1"
+
+  XXX_SRC_FOLDER_NAME="xxx-${XXX_VERSION}"
+  XXX_FOLDER_NAME="${XXX_SRC_FOLDER_NAME}"
+  local xxx_archive="${XXX_SRC_FOLDER_NAME}.tar.gz"
+  local xxx_url="http://.../${xxx_archive}"
+
+  local xxx_stamp_file_path="${STAMPS_FOLDER_PATH}/stamp-xxx-installed"
+  if [ ! -f "${xxx_stamp_file_path}" ]
+  then
+
+    cd "${WORK_FOLDER_PATH}"
+
+    download_and_extract "${xxx_url}" "${xxx_archive}" \
+      "${XXX_SRC_FOLDER_NAME}"
+
+    (
+      mkdir -pv "${BUILD_FOLDER_PATH}/${XXX_FOLDER_NAME}"
+      cd "${BUILD_FOLDER_PATH}/${XXX_FOLDER_NAME}"
+
+      xbb_activate
+
+      export CFLAGS="${XBB_CFLAGS}"
+      export CPPFLAGS="${XBB_CPPFLAGS}"
+      export LDFLAGS="${XBB_LDFLAGS}"
+      
+      if [ ! -f "config.status" ]
+      then 
+
+        echo
+        echo "Running xxx configure..."
+
+        (
+          bash "${WORK_FOLDER_PATH}/${XXX_SRC_FOLDER_NAME}/configure" --help
+
+          bash "${WORK_FOLDER_PATH}/${XXX_SRC_FOLDER_NAME}/configure" \
+            --prefix="${INSTALL_FOLDER_PATH}" \
+            \
+            --build=${BUILD} \
+            --host=${HOST} \
+            --target=${TARGET} \
+            \
+            --disable-shared \
+            --enable-static
+
+        ) 2>&1 | tee "${INSTALL_FOLDER_PATH}/configure-xxx-output.txt"
+        cp "config.log" "${INSTALL_FOLDER_PATH}"/config-xxx-log.txt
+
+      fi
+
+      echo
+      echo "Running xxx make..."
+
+      (
+        # Build.
+        make -j ${JOBS}
+        if [ "${WITH_STRIP}" == "y" ]
+        then
+          make install-strip
+        else
+          make install
+        fi
+      ) 2>&1 | tee "${INSTALL_FOLDER_PATH}/make-xxx-output.txt"
+    )
+
+    touch "${xxx_stamp_file_path}"
+
+  else
+    echo "Library xxx already installed."
+  fi
+}

+ 1100 - 0
distro-info/scripts/helper/test-functions-source.sh

@@ -0,0 +1,1100 @@
+# -----------------------------------------------------------------------------
+# This file is part of the xPack distribution.
+#   (https://xpack.github.io)
+# Copyright (c) 2020 Liviu Ionescu.
+#
+# Permission to use, copy, modify, and/or distribute this software 
+# for any purpose is hereby granted, under the terms of the MIT license.
+# -----------------------------------------------------------------------------
+
+# Helper script used in the tests.
+
+# -----------------------------------------------------------------------------
+
+# https://github.com/docker-library/official-images#architectures-other-than-amd64
+# - https://hub.docker.com/_/ubuntu
+# - https://hub.docker.com/r/i386/ubuntu/
+# - https://hub.docker.com/r/arm32v7/ubuntu
+# - https://hub.docker.com/_/debian
+# - https://hub.docker.com/r/i386/debian
+# - https://hub.docker.com/r/arm32v7/debian
+# - https://hub.docker.com/_/centos
+# - https://hub.docker.com/r/i386/centos
+# - https://hub.docker.com/r/opensuse/tumbleweed
+# - https://hub.docker.com/_/fedora
+# - https://hub.docker.com/_/archlinux
+# - https://hub.docker.com/u/manjarolinux
+# - https://hub.docker.com/r/gentoo/portage
+
+# "i386/ubuntu:20.04" # Fails to install prerequisites
+# "i386/ubuntu:12.04" --skip-gdb-py # Not available
+# "i386/centos:8" # not available
+
+# arm32v7/fedora:29 - Error: Failed to synchronize cache for repo 'fedora-modular'
+# arm32v7/fedora:27 - Error: Failed to synchronize cache for repo 'fedora-modular'
+# arm32v7/fedora:25 - KeyError: 'armv8l'
+
+# Debian versions: 8 jessie, 9 stretch, 10 buster.
+
+function create_stable_data_file()
+{
+  local message="$1"
+  local branch="$2"
+  local base_url="$3"
+  local data_file_path="$4"
+
+# Note: __EOF__ is NOT quoted to allow substitutions.
+cat <<__EOF__ > "${data_file_path}"
+{
+  "request": {
+    "message": "${message}",
+    "branch": "${branch}",
+    "config": {
+      "merge_mode": "replace",
+      "jobs": [
+        {
+          "name": "Ubuntu 12, 14, 16, 18, 20 (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:20.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:18.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:16.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:14.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:12.04 ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu 14, 16, 18 (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:18.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:16.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:14.04 ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu 16, 18, 20 (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:20.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:18.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:16.04 ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu 16, 18 (Arm 32-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:18.04 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:16.04 ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian 8, 9, 10 (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:buster ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:stretch ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:jessie ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian 8, 9, 10 (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:buster ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:stretch ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:jessie ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian 9, 10 (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:buster ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:stretch ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian 9, 10 (Arm 32-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:buster ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:stretch ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS 7, 8 (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:8 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:7 ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS 7 (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/centos:7 ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS 7, 8 (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:8 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:7 ${base_url} "
+          ]
+        },
+        {
+          "name": "OpenSUSE 13, 15 (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/leap:15 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/amd64:13.2 ${base_url} "
+          ]
+        },
+        {
+          "name": "OpenSUSE 15 (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/leap:15 ${base_url} "
+          ]
+        },
+        {
+          "name": "Fedora 20, 25, 27, 29, 31 (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:31 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:29 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:27 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:25 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:20 ${base_url} "
+          ]
+        },
+        {
+          "name": "Fedora 27, 29, 31 (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:31 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:29 ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:27 ${base_url} "
+          ]
+        },
+        {
+          "name": "Raspbian 8, 9 (Arm 32-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 raspbian/stretch ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 raspbian/jessie ${base_url} "
+          ]
+        },
+        {
+          "name": "macOS 10.15 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode11.5",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.14 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode11.3",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.13 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode10.1",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.12 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode9.2",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.11 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode8",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.10 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode6.4",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "Windows 10 (Intel 64-bit)",
+          "os": "windows",
+          "arch": "amd64",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url} " 
+          ]
+        },
+        {
+          "name": "Windows 10 (Intel 32-bit)",
+          "os": "windows",
+          "arch": "amd64",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh --32 ${base_url} " 
+          ]
+        }
+      ],
+      "notifications": {
+        "email": {
+          "on_success": "always",
+          "on_failure": "always"
+        }
+      }
+    }
+  }
+}
+__EOF__
+
+}
+
+function create_latest_data_file()
+{
+  local message="$1"
+  local branch="$2"
+  local base_url="$3"
+  local data_file_path="$4"
+
+# Note: __EOF__ is NOT quoted to allow substitutions.
+cat <<__EOF__ > "${data_file_path}"
+{
+  "request": {
+    "message": "${message}",
+    "branch": "${branch}",
+    "config": {
+      "merge_mode": "replace",
+      "jobs": [
+        {
+          "name": "Ubuntu rolling, latest (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:latest ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:rolling ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu rolling, latest (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:latest ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/ubuntu:rolling ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu rolling, latest (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:latest ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh ubuntu:rolling ${base_url} "
+          ]
+        },
+        {
+          "name": "Ubuntu rolling, latest (Arm 32-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:latest ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/ubuntu:rolling ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian latet, testing (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:testing ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian testing (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/debian:testing ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian latest, testing (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:testing ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh debian:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "Debian testing (Arm 32-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 arm32v7/debian:testing ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS latest (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS latest (Intel 32-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh --32 i386/centos:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "CentOS latest (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh centos:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "OpenSUSE tumbleweed (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/tumbleweed ${base_url} "
+          ]
+        },
+        {
+          "name": "OpenSUSE tumbleweed (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh opensuse/tumbleweed ${base_url} "
+          ]
+        },
+        {
+          "name": "Fedora latest, rawhide (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:rawhide ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "Fedora latest, rawhide (Arm 64-bit)",
+          "os": "linux",
+          "arch": "arm64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:rawhide ${base_url} ",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh fedora:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "Arch latest (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh archlinux:latest ${base_url} "
+          ]
+        },
+        {
+          "name": "Manjaro base (Intel 64-bit)",
+          "os": "linux",
+          "arch": "amd64",
+          "dist": "bionic",
+          "services": [ "docker" ],
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/docker-test.sh manjarolinux/base ${base_url} "
+          ]
+        },
+        {}
+      ],
+      "notifications": {
+        "email": {
+          "on_success": "always",
+          "on_failure": "always"
+        }
+      }
+    }
+  }
+}
+__EOF__
+
+}
+
+function create_macos_data_file()
+{
+  local message="$1"
+  local branch="$2"
+  local base_url="$3"
+  local data_file_path="$4"
+
+# Note: __EOF__ is NOT quoted to allow substitutions.
+cat <<__EOF__ > "${data_file_path}"
+{
+  "request": {
+    "message": "${message}",
+    "branch": "${branch}",
+    "config": {
+      "merge_mode": "replace",
+      "jobs": [
+        {
+          "name": "macOS 10.15 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode11.5",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.14 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode11.3",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.13 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode10.1",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.12 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode9.2",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.11 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode8",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        },
+        {
+          "name": "macOS 10.10 Intel",
+          "os": "osx",
+          "arch": "amd64",
+          "osx_image": "xcode6.4",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url}" 
+          ]
+        }
+      ],
+      "notifications": {
+        "email": {
+          "on_success": "always",
+          "on_failure": "always"
+        }
+      }
+    }
+  }
+}
+__EOF__
+
+}
+
+function create_windows_data_file()
+{
+  local message="$1"
+  local branch="$2"
+  local base_url="$3"
+  local data_file_path="$4"
+
+# Note: __EOF__ is NOT quoted to allow substitutions.
+cat <<__EOF__ > "${data_file_path}"
+{
+  "request": {
+    "message": "${message}",
+    "branch": "${branch}",
+    "config": {
+      "merge_mode": "replace",
+      "jobs": [
+        {
+          "name": "Windows 10 (Intel 64-bit)",
+          "os": "windows",
+          "arch": "amd64",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh ${base_url} " 
+          ]
+        },
+        {
+          "name": "Windows 10 (Intel 32-bit)",
+          "os": "windows",
+          "arch": "amd64",
+          "language": "minimal",
+          "script": [
+            "env | sort",
+            "pwd",
+            "DEBUG=${DEBUG} bash tests/scripts/native-test.sh --32 ${base_url} " 
+          ]
+        }
+      ],
+      "notifications": {
+        "email": {
+          "on_success": "always",
+          "on_failure": "always"
+        }
+      }
+    }
+  }
+}
+__EOF__
+
+}
+
+# data_file_path
+# github_org
+# github_repo
+function trigger_travis()
+{
+  local github_org="$1"
+  local github_repo="$2"
+  local data_file_path="$3"
+
+  curl -v -X POST \
+   -H "Content-Type: application/json" \
+   -H "Accept: application/json" \
+   -H "Travis-API-Version: 3" \
+   -H "Authorization: token ${TRAVIS_ORG_TOKEN}" \
+   --data-binary @"${data_file_path}" \
+   https://api.travis-ci.org/repo/${github_org}%2F${github_repo}/requests
+}
+
+# -----------------------------------------------------------------------------
+
+# Runs inside a container.
+# Set the following variables:
+#
+# - node_platform={win32,linux,darwin}
+# - node_architecture={x64,x32,arm64,arm}
+# - bits={32,64}
+
+function detect_architecture()
+{
+  uname -a
+
+  uname_platform=$(uname -s | tr '[:upper:]' '[:lower:]')
+  uname_machine=$(uname -m | tr '[:upper:]' '[:lower:]')
+
+  node_platform="${uname_platform}"
+  # Travis uses Msys2; git for Windows uses mingw-w64.
+  if [[ "${uname_platform}" == msys_nt* ]] \
+  || [[ "${uname_platform}" == mingw64_nt* ]] \
+  || [[ "${uname_platform}" == mingw32_nt* ]]
+  then
+    node_platform="win32"
+  fi
+
+  node_architecture=""
+  bits=""
+  if [ "${uname_machine}" == "x86_64" ]
+  then
+    node_architecture="x64"
+    bits="64"
+  elif [ "${uname_machine}" == "i386" -o "${uname_machine}" == "i586" -o "${uname_machine}" == "i686" ]
+  then
+    node_architecture="x32"
+    bits="32"
+  elif [ "${uname_machine}" == "aarch64" ]
+  then
+    node_architecture="arm64"
+    bits="64"
+  elif [ "${uname_machine}" == "armv7l" -o "${uname_machine}" == "armv8l" ]
+  then
+    node_architecture="arm"
+    bits="32"
+  else
+    echo "${uname_machine} not supported"
+    exit 1
+  fi
+}
+
+function prepare_env() 
+{
+  container_work_folder_path="/Host/Work"
+  container_repo_folder_path="/Host/repo"
+
+  if [ -f "/.dockerenv" -a -d "${container_work_folder_path}" ]
+  then
+    work_folder_path="${container_work_folder_path}"
+    repo_folder_path="${container_repo_folder_path}"
+  else
+    work_folder_path="${HOME}/Work"
+    # On the host, it must be called using the script folder path.
+    repo_folder_path="$1"
+  fi
+
+  cache_folder_path="${work_folder_path}/cache"
+
+  # Extract only the first line
+  version="$(cat ${repo_folder_path}/scripts/VERSION | sed -e '2,$d')"
+  if [ -z "${version}" ]
+  then
+    echo "Check the version, it cannot be empty."
+    exit 1
+  fi
+
+  # Always in the user home, even when inside a container.
+  test_folder_path="${HOME}/tmp/test-${app_lc_name}"
+}
+
+# -----------------------------------------------------------------------------
+
+# Requires base_url and lots of other variables.
+function install_archive()
+{
+  local archive_extension
+  local archive_architecture="${node_architecture}"
+  if [ "${node_platform}" == "win32" ]
+  then
+    archive_extension="zip"
+    if [ "${force_32_bit}" == "y" ]
+    then
+      archive_architecture="x32"
+    fi
+  else
+    archive_extension="tar.gz"
+  fi
+  archive_name="xpack-${app_lc_name}-${version}-${node_platform}-${archive_architecture}.${archive_extension}"
+  archive_folder_name="xpack-${app_lc_name}-${version}"
+
+  mkdir -pv "${cache_folder_path}"
+
+  if [ ! -f "${cache_folder_path}/${archive_name}" ]
+  then
+    echo
+    echo "Downloading ${archive_name}..."
+    curl -L --fail -o "${cache_folder_path}/${archive_name}" \
+      "${base_url}/${archive_name}"
+    echo
+  fi
+
+  app_folder_path="${test_folder_path}/${archive_folder_name}"
+
+  rm -rf "${app_folder_path}"
+
+  mkdir -pv "${test_folder_path}"
+  cd "${test_folder_path}"
+
+  echo
+  echo "Extracting ${archive_name}..."
+  if [[ "${archive_name}" == *.zip ]]
+  then
+    unzip -q "${cache_folder_path}/${archive_name}"
+  else 
+    tar xf "${cache_folder_path}/${archive_name}"
+  fi
+
+  echo ls -lL "${app_folder_path}"
+  ls -lL "${app_folder_path}"
+}
+
+# -----------------------------------------------------------------------------
+
+# $1 = image name
+# $2 = base URL
+function docker_run_test() {
+  local image_name="$1"
+  shift
+
+  local base_url="$1"
+  shift
+
+  (
+    prefix32="${prefix32:-""}"
+
+    docker run \
+      --tty \
+      --hostname "docker" \
+      --workdir="/root" \
+      --env DEBUG=${DEBUG} \
+      --volume "${work_folder_path}:${container_work_folder_path}" \
+      --volume "${repo_folder_path}:${container_repo_folder_path}" \
+      "${image_name}" \
+      ${prefix32} /bin/bash "${container_repo_folder_path}/tests/scripts/container-test.sh" \
+        "${image_name}" \
+        "${base_url}" \
+        "$@"
+  )
+}
+
+function docker_run_test_32() {
+  (
+    prefix32="linux32"
+
+    docker_run_test "$@"
+  )
+}
+
+# -----------------------------------------------------------------------------
+
+function show_libs()
+{
+  # Does not include the .exe extension.
+  local app_path=$1
+  shift
+  if [ "${node_platform}" == "win32" ]
+  then
+    app_path+='.exe'
+  fi
+
+  if [ "${node_platform}" == "linux" ]
+  then
+    echo
+    echo "readelf -d ${app_path} | egrep -i ..."
+    readelf -d "${app_path}" | egrep -i '(SONAME)' || true
+    readelf -d "${app_path}" | egrep -i '(RUNPATH|RPATH)' || true
+    readelf -d "${app_path}" | egrep -i '(NEEDED)' || true
+    echo
+    echo "ldd -v ${app_path}"
+    ldd -v "${app_path}" 2>&1 || true
+  elif [ "${node_platform}" == "darwin" ]
+  then
+    echo
+    echo "otool -L ${app_path}"
+    otool -L "${app_path}"
+  fi
+}
+
+function run_verbose()
+{
+  echo
+  echo "$@"
+  "$@" 2>&1
+}
+
+function run_app()
+{
+  local app_path=$1
+  shift
+  if [ "${node_platform}" == "win32" ]
+  then
+    app_path+='.exe'
+  fi
+
+  echo
+  echo "${app_path} $@"
+  "${app_path}" "$@" 2>&1
+}
+
+function run_app_silent()
+{
+  local app_path=$1
+  shift
+  if [ "${node_platform}" == "win32" ]
+  then
+    app_path+='.exe'
+  fi
+
+  "${app_path}" "$@" 2>&1
+}
+
+function do_run()
+{
+  local app_path=$1
+  shift
+
+  echo
+  echo "${app_path} $@"
+  "${app_path}" "$@" 2>&1
+}
+
+function do_expect()
+{
+  local app_name="$1"
+  local expected="$2"
+
+  show_libs "${app_name}"
+
+  local output="$(run_app_silent "./${app_name}")"
+
+  if [ "x${output}x" == "x${expected}x" ]
+  then
+    echo "Test ${app_name} ok"
+  else
+    exit 1
+  fi
+}
+
+function good_bye()
+{
+  echo
+  echo "All tests completed successfully."
+
+  do_run uname -a
+  if [ "${node_platform}" == "linux" ]
+  then
+    do_run lsb_release -a
+    do_run ldd --version
+  elif [ "${node_platform}" == "darwin" ]
+  then
+    do_run sw_vers
+  fi
+}
+
+# -----------------------------------------------------------------------------

+ 17 - 0
distro-info/scripts/host-defs-source.sh

@@ -0,0 +1,17 @@
+RELEASE_VERSION="8.3.0-1.2"
+DISTRIBUTION_FILE_DATE="20200703-1336"
+TARGET_PLATFORM="linux"
+TARGET_ARCH="x64"
+TARGET_MACHINE="x86_64"
+TARGET_BITS="64"
+HOST_UNAME="Linux"
+USER_ID="1000"
+USER_NAME="ilg"
+GROUP_ID="1000"
+GROUP_NAME="ilg"
+CONTAINER_RUN_AS_ROOT=""
+HOST_WORK_FOLDER_PATH="/home/ilg/Work/riscv-none-embed-gcc-8.3.0-1.2"
+CONTAINER_WORK_FOLDER_PATH="/Host/home/ilg/Work/riscv-none-embed-gcc-8.3.0-1.2"
+HOST_CACHE_FOLDER_PATH="/home/ilg/Work/cache"
+CONTAINER_CACHE_FOLDER_PATH="/Host/home/ilg/Work/cache"
+DEPLOY_FOLDER_NAME="deploy"

+ 70 - 0
distro-info/scripts/python-win-config.sh

@@ -0,0 +1,70 @@
+#!/bin/sh
+# Copyright (c) 2017, ARM Limited
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#     * Redistributions of source code must retain the above copyright notice,
+#       this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in the
+#       documentation and/or other materials provided with the distribution.
+#     * Neither the name of Arm nor the names of its contributors may be used
+#       to endorse or promote products derived from this software without
+#       specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+# Windows Python configuration script
+#
+# As per comment regarding --with-python in gdb/configure.ac, this script
+# follows the interface of gdb/python/python-config.py but return path
+# related to Windows Python.
+
+if [ ! -d "${GNURM_PYTHON_WIN_DIR}" ]; then
+  exit 1
+fi
+
+GNURM_PYTHON_WIN_DIR="$(readlink -f ${GNURM_PYTHON_WIN_DIR})"
+
+while [ $# -ge 1 ]; do
+  opt="$1"
+  case ${opt} in
+    --prefix)
+      echo "${GNURM_PYTHON_WIN_DIR}";;
+    --exec-prefix)
+      echo "${GNURM_PYTHON_WIN_DIR}";;
+    --includes|--cflags)
+      cflags="-I${GNURM_PYTHON_WIN_DIR}"
+      if [ "${opt}" = "--cflags" ]; then
+        cflags="${cflags} ${CFLAGS}"
+      fi
+      echo ${cflags};;
+    --libs|--ldflags)
+      # Options to link to static libpython2.7 archive so as to avoid  an
+      # external dependency on python
+      echo "-L${GNURM_PYTHON_WIN_DIR} -lpython27";;
+    --*)
+      echo "Unknown option: ${opt}" >&2
+      exit 1;;
+    *)
+      # Ignore non options since we are called with gdb provided
+      # python-config.py as first parameter
+      ;;
+  esac
+  shift
+done
+
+exit 0

+ 346 - 0
include/gdb/jit-reader.h

@@ -0,0 +1,346 @@
+/* JIT declarations for GDB, the GNU Debugger.
+
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef GDB_JIT_READER_H
+#define GDB_JIT_READER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Versioning information.  See gdb_reader_funcs.  */
+
+#define GDB_READER_INTERFACE_VERSION 1
+
+/* Readers must be released under a GPL compatible license.  To
+   declare that the reader is indeed released under a GPL compatible
+   license, invoke the macro GDB_DECLARE_GPL_COMPATIBLE in a source
+   file.  */
+
+#ifdef __cplusplus
+#define GDB_DECLARE_GPL_COMPATIBLE_READER       \
+  extern "C" {                                  \
+  extern int plugin_is_GPL_compatible (void);   \
+  extern int plugin_is_GPL_compatible (void)    \
+  {                                             \
+    return 0;                                   \
+  }                                             \
+  }
+
+#else
+
+#define GDB_DECLARE_GPL_COMPATIBLE_READER       \
+  extern int plugin_is_GPL_compatible (void);   \
+  extern int plugin_is_GPL_compatible (void)    \
+  {                                             \
+    return 0;                                   \
+  }
+
+#endif
+
+/* Represents an address on the target system.  */
+
+typedef unsigned long GDB_CORE_ADDR;
+
+/* Return status codes.  */
+
+enum gdb_status {
+  GDB_FAIL = 0,
+  GDB_SUCCESS = 1
+};
+
+struct gdb_object;
+struct gdb_symtab;
+struct gdb_block;
+struct gdb_symbol_callbacks;
+
+/* An array of these are used to represent a map from code addresses to line
+   numbers in the source file.  */
+
+struct gdb_line_mapping
+{
+  int line;
+  GDB_CORE_ADDR pc;
+};
+
+/* Create a new GDB code object.  Each code object can have one or
+   more symbol tables, each representing a compiled source file.  */
+
+typedef struct gdb_object *(gdb_object_open) (struct gdb_symbol_callbacks *cb);
+
+/* The callback used to create new symbol table.  CB is the
+   gdb_symbol_callbacks which the structure is part of.  FILE_NAME is
+   an (optionally NULL) file name to associate with this new symbol
+   table.
+
+   Returns a new instance to gdb_symtab that can later be passed to
+   gdb_block_new, gdb_symtab_add_line_mapping and gdb_symtab_close.  */
+
+typedef struct gdb_symtab *(gdb_symtab_open) (struct gdb_symbol_callbacks *cb,
+                                              struct gdb_object *obj,
+                                              const char *file_name);
+
+/* Creates a new block in a given symbol table.  A symbol table is a
+   forest of blocks, each block representing an code address range and
+   a corresponding (optionally NULL) NAME.  In case the block
+   corresponds to a function, the NAME passed should be the name of
+   the function.
+
+   If the new block to be created is a child of (i.e. is nested in)
+   another block, the parent block can be passed in PARENT.  SYMTAB is
+   the symbol table the new block is to belong in.  BEGIN, END is the
+   code address range the block corresponds to.
+
+   Returns a new instance of gdb_block, which, as of now, has no use.
+   Note that the gdb_block returned must not be freed by the
+   caller.  */
+
+typedef struct gdb_block *(gdb_block_open) (struct gdb_symbol_callbacks *cb,
+                                            struct gdb_symtab *symtab,
+                                            struct gdb_block *parent,
+                                            GDB_CORE_ADDR begin,
+                                            GDB_CORE_ADDR end,
+                                            const char *name);
+
+/* Adds a PC to line number mapping for the symbol table SYMTAB.
+   NLINES is the number of elements in LINES, each element
+   corresponding to one (PC, line) pair.  */
+
+typedef void (gdb_symtab_add_line_mapping) (struct gdb_symbol_callbacks *cb,
+                                            struct gdb_symtab *symtab,
+                                            int nlines,
+                                            struct gdb_line_mapping *lines);
+
+/* Close the symtab SYMTAB.  This signals to GDB that no more blocks
+   will be opened on this symtab.  */
+
+typedef void (gdb_symtab_close) (struct gdb_symbol_callbacks *cb,
+                                 struct gdb_symtab *symtab);
+
+
+/* Closes the gdb_object OBJ and adds the emitted information into
+   GDB's internal structures.  Once this is done, the debug
+   information will be picked up and used; this will usually be the
+   last operation in gdb_read_debug_info.  */
+
+typedef void (gdb_object_close) (struct gdb_symbol_callbacks *cb,
+                                 struct gdb_object *obj);
+
+/* Reads LEN bytes from TARGET_MEM in the target's virtual address
+   space into GDB_BUF.
+
+   Returns GDB_FAIL on failure, and GDB_SUCCESS on success.  */
+
+typedef enum gdb_status (gdb_target_read) (GDB_CORE_ADDR target_mem,
+                                           void *gdb_buf, int len);
+
+/* The list of callbacks that are passed to read.  These callbacks are
+   to be used to construct the symbol table.  The functions have been
+   described above.  */
+
+struct gdb_symbol_callbacks
+{
+  gdb_object_open *object_open;
+  gdb_symtab_open *symtab_open;
+  gdb_block_open *block_open;
+  gdb_symtab_close *symtab_close;
+  gdb_object_close *object_close;
+
+  gdb_symtab_add_line_mapping *line_mapping_add;
+  gdb_target_read *target_read;
+
+  /* For internal use by GDB.  */
+  void *priv_data;
+};
+
+/* Forward declaration.  */
+
+struct gdb_reg_value;
+
+/* A function of this type is used to free a gdb_reg_value.  See the
+   comment on `free' in struct gdb_reg_value.  */
+
+typedef void (gdb_reg_value_free) (struct gdb_reg_value *);
+
+/* Denotes the value of a register.  */
+
+struct gdb_reg_value
+{
+  /* The size of the register in bytes.  The reader need not set this
+     field.  This will be set for (defined) register values being read
+     from GDB using reg_get.  */
+  int size;
+
+  /* Set to non-zero if the value for the register is known.  The
+     registers for which the reader does not call reg_set are also
+     assumed to be undefined */
+  int defined;
+
+  /* Since gdb_reg_value is a variable sized structure, it will
+     usually be allocated on the heap.  This function is expected to
+     contain the corresponding "free" function.
+
+     When a pointer to gdb_reg_value is being sent from GDB to the
+     reader (via gdb_unwind_reg_get), the reader is expected to call
+     this function (with the same gdb_reg_value as argument) once it
+     is done with the value.
+
+     When the function sends the a gdb_reg_value to GDB (via
+     gdb_unwind_reg_set), it is expected to set this field to point to
+     an appropriate cleanup routine (or to NULL if no cleanup is
+     required).  */
+  gdb_reg_value_free *free;
+
+  /* The value of the register.  */
+  unsigned char value[1];
+};
+
+/* get_frame_id in gdb_reader_funcs is to return a gdb_frame_id
+   corresponding to the current frame.  The registers corresponding to
+   the current frame can be read using reg_get.  Calling get_frame_id
+   on a particular frame should return the same gdb_frame_id
+   throughout its lifetime (i.e. till before it gets unwound).  One
+   way to do this is by having the CODE_ADDRESS point to the
+   function's first instruction and STACK_ADDRESS point to the value
+   of the stack pointer when entering the function.  */
+
+struct gdb_frame_id
+{
+  GDB_CORE_ADDR code_address;
+  GDB_CORE_ADDR stack_address;
+};
+
+/* Forward declaration.  */
+
+struct gdb_unwind_callbacks;
+
+/* Returns the value of a particular register in the current frame.
+   The current frame is the frame that needs to be unwound into the
+   outer (earlier) frame.
+
+   CB is the struct gdb_unwind_callbacks * the callback belongs to.
+   REGNUM is the DWARF register number of the register that needs to
+   be unwound.
+
+   Returns the gdb_reg_value corresponding to the register requested.
+   In case the value of the register has been optimized away or
+   otherwise unavailable, the defined flag in the returned
+   gdb_reg_value will be zero.  */
+
+typedef struct gdb_reg_value *(gdb_unwind_reg_get)
+                              (struct gdb_unwind_callbacks *cb, int regnum);
+
+/* Sets the previous value of a particular register.  REGNUM is the
+   (DWARF) register number whose value is to be set.  VAL is the value
+   the register is to be set to.
+
+   VAL is *not* copied, so the memory allocated to it cannot be
+   reused.  Once GDB no longer needs the value, it is deallocated
+   using the FREE function (see gdb_reg_value).
+
+   A register can also be "set" to an undefined value by setting the
+   defined in VAL to zero.  */
+
+typedef void (gdb_unwind_reg_set) (struct gdb_unwind_callbacks *cb, int regnum,
+                                   struct gdb_reg_value *val);
+
+/* This struct is passed to unwind in gdb_reader_funcs, and is to be
+   used to unwind the current frame (current being the frame whose
+   registers can be read using reg_get) into the earlier frame.  The
+   functions have been described above.  */
+
+struct gdb_unwind_callbacks
+{
+  gdb_unwind_reg_get *reg_get;
+  gdb_unwind_reg_set *reg_set;
+  gdb_target_read *target_read;
+
+  /* For internal use by GDB.  */
+  void *priv_data;
+};
+
+/* Forward declaration.  */
+
+struct gdb_reader_funcs;
+
+/* Parse the debug info off a block of memory, pointed to by MEMORY
+   (already copied to GDB's address space) and MEMORY_SZ bytes long.
+   The implementation has to use the functions in CB to actually emit
+   the parsed data into GDB.  SELF is the same structure returned by
+   gdb_init_reader.
+
+   Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
+
+typedef enum gdb_status (gdb_read_debug_info) (struct gdb_reader_funcs *self,
+                                               struct gdb_symbol_callbacks *cb,
+                                               void *memory, long memory_sz);
+
+/* Unwind the current frame, CB is the set of unwind callbacks that
+   are to be used to do this.
+
+   Return GDB_FAIL on failure and GDB_SUCCESS on success.  */
+
+typedef enum gdb_status (gdb_unwind_frame) (struct gdb_reader_funcs *self,
+                                            struct gdb_unwind_callbacks *cb);
+
+/* Return the frame ID corresponding to the current frame, using C to
+   read the current register values.  See the comment on struct
+   gdb_frame_id.  */
+
+typedef struct gdb_frame_id (gdb_get_frame_id) (struct gdb_reader_funcs *self,
+                                                struct gdb_unwind_callbacks *c);
+
+/* Called when a reader is being unloaded.  This function should also
+   free SELF, if required.  */
+
+typedef void (gdb_destroy_reader) (struct gdb_reader_funcs *self);
+
+/* Called when the reader is loaded.  Must either return a properly
+   populated gdb_reader_funcs or NULL.  The memory allocated for the
+   gdb_reader_funcs is to be managed by the reader itself (i.e. if it
+   is allocated from the heap, it must also be freed in
+   gdb_destroy_reader).  */
+
+extern struct gdb_reader_funcs *gdb_init_reader (void);
+
+/* Pointer to the functions which implement the reader's
+   functionality.  The individual functions have been documented
+   above.
+
+   None of the fields are optional.  */
+
+struct gdb_reader_funcs
+{
+  /* Must be set to GDB_READER_INTERFACE_VERSION.  */
+  int reader_version;
+
+  /* For use by the reader.  */
+  void *priv_data;
+
+  gdb_read_debug_info *read;
+  gdb_unwind_frame *unwind;
+  gdb_get_frame_id *get_frame_id;
+  gdb_destroy_reader *destroy;
+};
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif

+ 1 - 0
lib/bfd-plugins/liblto_plugin.so

@@ -0,0 +1 @@
+../../libexec/gcc/riscv-none-embed/8.3.0/liblto_plugin.so.0.0.0

BIN
lib/gcc/riscv-none-embed/8.3.0/crtbegin.o


BIN
lib/gcc/riscv-none-embed/8.3.0/crtend.o


BIN
lib/gcc/riscv-none-embed/8.3.0/crti.o


BIN
lib/gcc/riscv-none-embed/8.3.0/crtn.o


+ 14 - 0
lib/gcc/riscv-none-embed/8.3.0/include-fixed/README

@@ -0,0 +1,14 @@
+This README file is copied into the directory for GCC-only header files
+when fixincludes is run by the makefile for GCC.
+
+Many of the files in this directory were automatically edited from the
+standard system header files by the fixincludes process.  They are
+system-specific, and will not work on any other kind of system.  They
+are also not part of GCC.  The reason we have to do this is because
+GCC requires ANSI C headers and many vendors supply ANSI-incompatible
+headers.
+
+Because this is an automated process, sometimes headers get "fixed"
+that do not, strictly speaking, need a fix.  As long as nothing is broken
+by the process, it is just an unfortunate collateral inconvenience.
+We would like to rectify it, if it is not "too inconvenient".

+ 197 - 0
lib/gcc/riscv-none-embed/8.3.0/include-fixed/limits.h

@@ -0,0 +1,197 @@
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* This administrivia gets added to the beginning of limits.h
+   if the system has its own version of limits.h.  */
+
+/* We use _GCC_LIMITS_H_ because we want this not to match
+   any macros that the system's limits.h uses for its own purposes.  */
+#ifndef _GCC_LIMITS_H_  /* Terminated in limity.h.  */
+#define _GCC_LIMITS_H_
+
+#ifndef _LIBC_LIMITS_H_
+/* Use "..." so that we find syslimits.h only in this same directory.  */
+#include "syslimits.h"
+#endif
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef _LIMITS_H___
+#define _LIMITS_H___
+
+/* Number of bits in a `char'.  */
+#undef CHAR_BIT
+#define CHAR_BIT __CHAR_BIT__
+
+/* Maximum length of a multibyte character.  */
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 1
+#endif
+
+/* Minimum and maximum values a `signed char' can hold.  */
+#undef SCHAR_MIN
+#define SCHAR_MIN (-SCHAR_MAX - 1)
+#undef SCHAR_MAX
+#define SCHAR_MAX __SCHAR_MAX__
+
+/* Maximum value an `unsigned char' can hold.  (Minimum is 0).  */
+#undef UCHAR_MAX
+#if __SCHAR_MAX__ == __INT_MAX__
+# define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
+#else
+# define UCHAR_MAX (SCHAR_MAX * 2 + 1)
+#endif
+
+/* Minimum and maximum values a `char' can hold.  */
+#ifdef __CHAR_UNSIGNED__
+# undef CHAR_MIN
+# if __SCHAR_MAX__ == __INT_MAX__
+#  define CHAR_MIN 0U
+# else
+#  define CHAR_MIN 0
+# endif
+# undef CHAR_MAX
+# define CHAR_MAX UCHAR_MAX
+#else
+# undef CHAR_MIN
+# define CHAR_MIN SCHAR_MIN
+# undef CHAR_MAX
+# define CHAR_MAX SCHAR_MAX
+#endif
+
+/* Minimum and maximum values a `signed short int' can hold.  */
+#undef SHRT_MIN
+#define SHRT_MIN (-SHRT_MAX - 1)
+#undef SHRT_MAX
+#define SHRT_MAX __SHRT_MAX__
+
+/* Maximum value an `unsigned short int' can hold.  (Minimum is 0).  */
+#undef USHRT_MAX
+#if __SHRT_MAX__ == __INT_MAX__
+# define USHRT_MAX (SHRT_MAX * 2U + 1U)
+#else
+# define USHRT_MAX (SHRT_MAX * 2 + 1)
+#endif
+
+/* Minimum and maximum values a `signed int' can hold.  */
+#undef INT_MIN
+#define INT_MIN (-INT_MAX - 1)
+#undef INT_MAX
+#define INT_MAX __INT_MAX__
+
+/* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */
+#undef UINT_MAX
+#define UINT_MAX (INT_MAX * 2U + 1U)
+
+/* Minimum and maximum values a `signed long int' can hold.
+   (Same as `int').  */
+#undef LONG_MIN
+#define LONG_MIN (-LONG_MAX - 1L)
+#undef LONG_MAX
+#define LONG_MAX __LONG_MAX__
+
+/* Maximum value an `unsigned long int' can hold.  (Minimum is 0).  */
+#undef ULONG_MAX
+#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+/* Minimum and maximum values a `signed long long int' can hold.  */
+# undef LLONG_MIN
+# define LLONG_MIN (-LLONG_MAX - 1LL)
+# undef LLONG_MAX
+# define LLONG_MAX __LONG_LONG_MAX__
+
+/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */
+# undef ULLONG_MAX
+# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
+#endif
+
+#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
+/* Minimum and maximum values a `signed long long int' can hold.  */
+# undef LONG_LONG_MIN
+# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
+# undef LONG_LONG_MAX
+# define LONG_LONG_MAX __LONG_LONG_MAX__
+
+/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */
+# undef ULONG_LONG_MAX
+# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
+#endif
+
+#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
+/* TS 18661-1 widths of integer types.  */
+# undef CHAR_WIDTH
+# define CHAR_WIDTH __SCHAR_WIDTH__
+# undef SCHAR_WIDTH
+# define SCHAR_WIDTH __SCHAR_WIDTH__
+# undef UCHAR_WIDTH
+# define UCHAR_WIDTH __SCHAR_WIDTH__
+# undef SHRT_WIDTH
+# define SHRT_WIDTH __SHRT_WIDTH__
+# undef USHRT_WIDTH
+# define USHRT_WIDTH __SHRT_WIDTH__
+# undef INT_WIDTH
+# define INT_WIDTH __INT_WIDTH__
+# undef UINT_WIDTH
+# define UINT_WIDTH __INT_WIDTH__
+# undef LONG_WIDTH
+# define LONG_WIDTH __LONG_WIDTH__
+# undef ULONG_WIDTH
+# define ULONG_WIDTH __LONG_WIDTH__
+# undef LLONG_WIDTH
+# define LLONG_WIDTH __LONG_LONG_WIDTH__
+# undef ULLONG_WIDTH
+# define ULLONG_WIDTH __LONG_LONG_WIDTH__
+#endif
+
+#endif /* _LIMITS_H___ */
+/* This administrivia gets added to the end of limits.h
+   if the system has its own version of limits.h.  */
+
+#else /* not _GCC_LIMITS_H_ */
+
+#ifdef _GCC_NEXT_LIMITS_H
+#include_next <limits.h>		/* recurse down to the real one */
+#endif
+
+#endif /* not _GCC_LIMITS_H_ */

+ 8 - 0
lib/gcc/riscv-none-embed/8.3.0/include-fixed/syslimits.h

@@ -0,0 +1,8 @@
+/* syslimits.h stands for the system's own limits.h file.
+   If we can use it ok unmodified, then we install this text.
+   If fixincludes fixes it, then the fixed version is installed
+   instead of this text.  */
+
+#define _GCC_NEXT_LIMITS_H		/* tell gcc's limits.h to recurse */
+#include_next <limits.h>
+#undef _GCC_NEXT_LIMITS_H

+ 506 - 0
lib/gcc/riscv-none-embed/8.3.0/include/float.h

@@ -0,0 +1,506 @@
+/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/*
+ * ISO C Standard:  5.2.4.2.2  Characteristics of floating types <float.h>
+ */
+
+#ifndef _FLOAT_H___
+#define _FLOAT_H___
+
+/* Radix of exponent representation, b. */
+#undef FLT_RADIX
+#define FLT_RADIX	__FLT_RADIX__
+
+/* Number of base-FLT_RADIX digits in the significand, p.  */
+#undef FLT_MANT_DIG
+#undef DBL_MANT_DIG
+#undef LDBL_MANT_DIG
+#define FLT_MANT_DIG	__FLT_MANT_DIG__
+#define DBL_MANT_DIG	__DBL_MANT_DIG__
+#define LDBL_MANT_DIG	__LDBL_MANT_DIG__
+
+/* Number of decimal digits, q, such that any floating-point number with q
+   decimal digits can be rounded into a floating-point number with p radix b
+   digits and back again without change to the q decimal digits,
+
+	p * log10(b)			if b is a power of 10
+	floor((p - 1) * log10(b))	otherwise
+*/
+#undef FLT_DIG
+#undef DBL_DIG
+#undef LDBL_DIG
+#define FLT_DIG		__FLT_DIG__
+#define DBL_DIG		__DBL_DIG__
+#define LDBL_DIG	__LDBL_DIG__
+
+/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */
+#undef FLT_MIN_EXP
+#undef DBL_MIN_EXP
+#undef LDBL_MIN_EXP
+#define FLT_MIN_EXP	__FLT_MIN_EXP__
+#define DBL_MIN_EXP	__DBL_MIN_EXP__
+#define LDBL_MIN_EXP	__LDBL_MIN_EXP__
+
+/* Minimum negative integer such that 10 raised to that power is in the
+   range of normalized floating-point numbers,
+
+	ceil(log10(b) * (emin - 1))
+*/
+#undef FLT_MIN_10_EXP
+#undef DBL_MIN_10_EXP
+#undef LDBL_MIN_10_EXP
+#define FLT_MIN_10_EXP	__FLT_MIN_10_EXP__
+#define DBL_MIN_10_EXP	__DBL_MIN_10_EXP__
+#define LDBL_MIN_10_EXP	__LDBL_MIN_10_EXP__
+
+/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax.  */
+#undef FLT_MAX_EXP
+#undef DBL_MAX_EXP
+#undef LDBL_MAX_EXP
+#define FLT_MAX_EXP	__FLT_MAX_EXP__
+#define DBL_MAX_EXP	__DBL_MAX_EXP__
+#define LDBL_MAX_EXP	__LDBL_MAX_EXP__
+
+/* Maximum integer such that 10 raised to that power is in the range of
+   representable finite floating-point numbers,
+
+	floor(log10((1 - b**-p) * b**emax))
+*/
+#undef FLT_MAX_10_EXP
+#undef DBL_MAX_10_EXP
+#undef LDBL_MAX_10_EXP
+#define FLT_MAX_10_EXP	__FLT_MAX_10_EXP__
+#define DBL_MAX_10_EXP	__DBL_MAX_10_EXP__
+#define LDBL_MAX_10_EXP	__LDBL_MAX_10_EXP__
+
+/* Maximum representable finite floating-point number,
+
+	(1 - b**-p) * b**emax
+*/
+#undef FLT_MAX
+#undef DBL_MAX
+#undef LDBL_MAX
+#define FLT_MAX		__FLT_MAX__
+#define DBL_MAX		__DBL_MAX__
+#define LDBL_MAX	__LDBL_MAX__
+
+/* The difference between 1 and the least value greater than 1 that is
+   representable in the given floating point type, b**1-p.  */
+#undef FLT_EPSILON
+#undef DBL_EPSILON
+#undef LDBL_EPSILON
+#define FLT_EPSILON	__FLT_EPSILON__
+#define DBL_EPSILON	__DBL_EPSILON__
+#define LDBL_EPSILON	__LDBL_EPSILON__
+
+/* Minimum normalized positive floating-point number, b**(emin - 1).  */
+#undef FLT_MIN
+#undef DBL_MIN
+#undef LDBL_MIN
+#define FLT_MIN		__FLT_MIN__
+#define DBL_MIN		__DBL_MIN__
+#define LDBL_MIN	__LDBL_MIN__
+
+/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown.  */
+/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */
+#undef FLT_ROUNDS
+#define FLT_ROUNDS 1
+
+#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
+     || (defined (__cplusplus) && __cplusplus >= 201103L)
+/* The floating-point expression evaluation method.  The precise
+   definitions of these values are generalised to include support for
+   the interchange and extended types defined in ISO/IEC TS 18661-3.
+   Prior to this (for C99/C11) the definitions were:
+
+	-1  indeterminate
+	 0  evaluate all operations and constants just to the range and
+	    precision of the type
+	 1  evaluate operations and constants of type float and double
+	    to the range and precision of the double type, evaluate
+	    long double operations and constants to the range and
+	    precision of the long double type
+	 2  evaluate all operations and constants to the range and
+	    precision of the long double type
+
+   The TS 18661-3 definitions are:
+
+	-1  indeterminate
+	 0  evaluate all operations and constants, whose semantic type has
+	    at most the range and precision of float, to the range and
+	    precision of float; evaluate all other operations and constants
+	    to the range and precision of the semantic type.
+	 1  evaluate all operations and constants, whose semantic type has
+	    at most the range and precision of double, to the range and
+	    precision of double; evaluate all other operations and constants
+	    to the range and precision of the semantic type.
+	 2  evaluate all operations and constants, whose semantic type has
+	    at most the range and precision of long double, to the range and
+	    precision of long double; evaluate all other operations and
+	    constants to the range and precision of the semantic type.
+	 N  where _FloatN  is a supported interchange floating type
+	    evaluate all operations and constants, whose semantic type has
+	    at most the range and precision of the _FloatN type, to the
+	    range and precision of the _FloatN type; evaluate all other
+	    operations and constants to the range and precision of the
+	    semantic type.
+	 N + 1, where _FloatNx is a supported extended floating type
+	    evaluate operations and constants, whose semantic type has at
+	    most the range and precision of the _FloatNx type, to the range
+	    and precision of the _FloatNx type; evaluate all other
+	    operations and constants to the range and precision of the
+	    semantic type.
+
+   The compiler predefines two macros:
+
+      __FLT_EVAL_METHOD__
+      Which, depending on the value given for
+      -fpermitted-flt-eval-methods, may be limited to only those values
+      for FLT_EVAL_METHOD defined in C99/C11.
+
+     __FLT_EVAL_METHOD_TS_18661_3__
+      Which always permits the values for FLT_EVAL_METHOD defined in
+      ISO/IEC TS 18661-3.
+
+     Here we want to use __FLT_EVAL_METHOD__, unless
+     __STDC_WANT_IEC_60559_TYPES_EXT__ is defined, in which case the user
+     is specifically asking for the ISO/IEC TS 18661-3 types, so we use
+     __FLT_EVAL_METHOD_TS_18661_3__.
+
+   ??? This ought to change with the setting of the fp control word;
+   the value provided by the compiler assumes the widest setting.  */
+#undef FLT_EVAL_METHOD
+#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
+#define FLT_EVAL_METHOD __FLT_EVAL_METHOD_TS_18661_3__
+#else
+#define FLT_EVAL_METHOD	__FLT_EVAL_METHOD__
+#endif
+
+/* Number of decimal digits, n, such that any floating-point number in the
+   widest supported floating type with pmax radix b digits can be rounded
+   to a floating-point number with n decimal digits and back again without
+   change to the value,
+
+	pmax * log10(b)			if b is a power of 10
+	ceil(1 + pmax * log10(b))	otherwise
+*/
+#undef DECIMAL_DIG
+#define DECIMAL_DIG	__DECIMAL_DIG__
+
+#endif /* C99 */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+/* Versions of DECIMAL_DIG for each floating-point type.  */
+#undef FLT_DECIMAL_DIG
+#undef DBL_DECIMAL_DIG
+#undef LDBL_DECIMAL_DIG
+#define FLT_DECIMAL_DIG		__FLT_DECIMAL_DIG__
+#define DBL_DECIMAL_DIG		__DBL_DECIMAL_DIG__
+#define LDBL_DECIMAL_DIG	__LDBL_DECIMAL_DIG__
+
+/* Whether types support subnormal numbers.  */
+#undef FLT_HAS_SUBNORM
+#undef DBL_HAS_SUBNORM
+#undef LDBL_HAS_SUBNORM
+#define FLT_HAS_SUBNORM		__FLT_HAS_DENORM__
+#define DBL_HAS_SUBNORM		__DBL_HAS_DENORM__
+#define LDBL_HAS_SUBNORM	__LDBL_HAS_DENORM__
+
+/* Minimum positive values, including subnormals.  */
+#undef FLT_TRUE_MIN
+#undef DBL_TRUE_MIN
+#undef LDBL_TRUE_MIN
+#define FLT_TRUE_MIN	__FLT_DENORM_MIN__
+#define DBL_TRUE_MIN	__DBL_DENORM_MIN__
+#define LDBL_TRUE_MIN	__LDBL_DENORM_MIN__
+
+#endif /* C11 */
+
+#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
+/* Number of decimal digits for which conversions between decimal
+   character strings and binary formats, in both directions, are
+   correctly rounded.  */
+#define CR_DECIMAL_DIG	__UINTMAX_MAX__
+#endif
+
+#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
+/* Constants for _FloatN and _FloatNx types from TS 18661-3.  See
+   comments above for their semantics.  */
+
+#ifdef __FLT16_MANT_DIG__
+#undef FLT16_MANT_DIG
+#define FLT16_MANT_DIG		__FLT16_MANT_DIG__
+#undef FLT16_DIG
+#define FLT16_DIG		__FLT16_DIG__
+#undef FLT16_MIN_EXP
+#define FLT16_MIN_EXP		__FLT16_MIN_EXP__
+#undef FLT16_MIN_10_EXP
+#define FLT16_MIN_10_EXP	__FLT16_MIN_10_EXP__
+#undef FLT16_MAX_EXP
+#define FLT16_MAX_EXP		__FLT16_MAX_EXP__
+#undef FLT16_MAX_10_EXP
+#define FLT16_MAX_10_EXP	__FLT16_MAX_10_EXP__
+#undef FLT16_MAX
+#define FLT16_MAX		__FLT16_MAX__
+#undef FLT16_EPSILON
+#define FLT16_EPSILON		__FLT16_EPSILON__
+#undef FLT16_MIN
+#define FLT16_MIN		__FLT16_MIN__
+#undef FLT16_DECIMAL_DIG
+#define FLT16_DECIMAL_DIG	__FLT16_DECIMAL_DIG__
+#undef FLT16_TRUE_MIN
+#define FLT16_TRUE_MIN		__FLT16_DENORM_MIN__
+#endif /* __FLT16_MANT_DIG__.  */
+
+#ifdef __FLT32_MANT_DIG__
+#undef FLT32_MANT_DIG
+#define FLT32_MANT_DIG		__FLT32_MANT_DIG__
+#undef FLT32_DIG
+#define FLT32_DIG		__FLT32_DIG__
+#undef FLT32_MIN_EXP
+#define FLT32_MIN_EXP		__FLT32_MIN_EXP__
+#undef FLT32_MIN_10_EXP
+#define FLT32_MIN_10_EXP	__FLT32_MIN_10_EXP__
+#undef FLT32_MAX_EXP
+#define FLT32_MAX_EXP		__FLT32_MAX_EXP__
+#undef FLT32_MAX_10_EXP
+#define FLT32_MAX_10_EXP	__FLT32_MAX_10_EXP__
+#undef FLT32_MAX
+#define FLT32_MAX		__FLT32_MAX__
+#undef FLT32_EPSILON
+#define FLT32_EPSILON		__FLT32_EPSILON__
+#undef FLT32_MIN
+#define FLT32_MIN		__FLT32_MIN__
+#undef FLT32_DECIMAL_DIG
+#define FLT32_DECIMAL_DIG	__FLT32_DECIMAL_DIG__
+#undef FLT32_TRUE_MIN
+#define FLT32_TRUE_MIN		__FLT32_DENORM_MIN__
+#endif /* __FLT32_MANT_DIG__.  */
+
+#ifdef __FLT64_MANT_DIG__
+#undef FLT64_MANT_DIG
+#define FLT64_MANT_DIG		__FLT64_MANT_DIG__
+#undef FLT64_DIG
+#define FLT64_DIG		__FLT64_DIG__
+#undef FLT64_MIN_EXP
+#define FLT64_MIN_EXP		__FLT64_MIN_EXP__
+#undef FLT64_MIN_10_EXP
+#define FLT64_MIN_10_EXP	__FLT64_MIN_10_EXP__
+#undef FLT64_MAX_EXP
+#define FLT64_MAX_EXP		__FLT64_MAX_EXP__
+#undef FLT64_MAX_10_EXP
+#define FLT64_MAX_10_EXP	__FLT64_MAX_10_EXP__
+#undef FLT64_MAX
+#define FLT64_MAX		__FLT64_MAX__
+#undef FLT64_EPSILON
+#define FLT64_EPSILON		__FLT64_EPSILON__
+#undef FLT64_MIN
+#define FLT64_MIN		__FLT64_MIN__
+#undef FLT64_DECIMAL_DIG
+#define FLT64_DECIMAL_DIG	__FLT64_DECIMAL_DIG__
+#undef FLT64_TRUE_MIN
+#define FLT64_TRUE_MIN		__FLT64_DENORM_MIN__
+#endif /* __FLT64_MANT_DIG__.  */
+
+#ifdef __FLT128_MANT_DIG__
+#undef FLT128_MANT_DIG
+#define FLT128_MANT_DIG		__FLT128_MANT_DIG__
+#undef FLT128_DIG
+#define FLT128_DIG		__FLT128_DIG__
+#undef FLT128_MIN_EXP
+#define FLT128_MIN_EXP		__FLT128_MIN_EXP__
+#undef FLT128_MIN_10_EXP
+#define FLT128_MIN_10_EXP	__FLT128_MIN_10_EXP__
+#undef FLT128_MAX_EXP
+#define FLT128_MAX_EXP		__FLT128_MAX_EXP__
+#undef FLT128_MAX_10_EXP
+#define FLT128_MAX_10_EXP	__FLT128_MAX_10_EXP__
+#undef FLT128_MAX
+#define FLT128_MAX		__FLT128_MAX__
+#undef FLT128_EPSILON
+#define FLT128_EPSILON		__FLT128_EPSILON__
+#undef FLT128_MIN
+#define FLT128_MIN		__FLT128_MIN__
+#undef FLT128_DECIMAL_DIG
+#define FLT128_DECIMAL_DIG	__FLT128_DECIMAL_DIG__
+#undef FLT128_TRUE_MIN
+#define FLT128_TRUE_MIN		__FLT128_DENORM_MIN__
+#endif /* __FLT128_MANT_DIG__.  */
+
+#ifdef __FLT32X_MANT_DIG__
+#undef FLT32X_MANT_DIG
+#define FLT32X_MANT_DIG		__FLT32X_MANT_DIG__
+#undef FLT32X_DIG
+#define FLT32X_DIG		__FLT32X_DIG__
+#undef FLT32X_MIN_EXP
+#define FLT32X_MIN_EXP		__FLT32X_MIN_EXP__
+#undef FLT32X_MIN_10_EXP
+#define FLT32X_MIN_10_EXP	__FLT32X_MIN_10_EXP__
+#undef FLT32X_MAX_EXP
+#define FLT32X_MAX_EXP		__FLT32X_MAX_EXP__
+#undef FLT32X_MAX_10_EXP
+#define FLT32X_MAX_10_EXP	__FLT32X_MAX_10_EXP__
+#undef FLT32X_MAX
+#define FLT32X_MAX		__FLT32X_MAX__
+#undef FLT32X_EPSILON
+#define FLT32X_EPSILON		__FLT32X_EPSILON__
+#undef FLT32X_MIN
+#define FLT32X_MIN		__FLT32X_MIN__
+#undef FLT32X_DECIMAL_DIG
+#define FLT32X_DECIMAL_DIG	__FLT32X_DECIMAL_DIG__
+#undef FLT32X_TRUE_MIN
+#define FLT32X_TRUE_MIN		__FLT32X_DENORM_MIN__
+#endif /* __FLT32X_MANT_DIG__.  */
+
+#ifdef __FLT64X_MANT_DIG__
+#undef FLT64X_MANT_DIG
+#define FLT64X_MANT_DIG		__FLT64X_MANT_DIG__
+#undef FLT64X_DIG
+#define FLT64X_DIG		__FLT64X_DIG__
+#undef FLT64X_MIN_EXP
+#define FLT64X_MIN_EXP		__FLT64X_MIN_EXP__
+#undef FLT64X_MIN_10_EXP
+#define FLT64X_MIN_10_EXP	__FLT64X_MIN_10_EXP__
+#undef FLT64X_MAX_EXP
+#define FLT64X_MAX_EXP		__FLT64X_MAX_EXP__
+#undef FLT64X_MAX_10_EXP
+#define FLT64X_MAX_10_EXP	__FLT64X_MAX_10_EXP__
+#undef FLT64X_MAX
+#define FLT64X_MAX		__FLT64X_MAX__
+#undef FLT64X_EPSILON
+#define FLT64X_EPSILON		__FLT64X_EPSILON__
+#undef FLT64X_MIN
+#define FLT64X_MIN		__FLT64X_MIN__
+#undef FLT64X_DECIMAL_DIG
+#define FLT64X_DECIMAL_DIG	__FLT64X_DECIMAL_DIG__
+#undef FLT64X_TRUE_MIN
+#define FLT64X_TRUE_MIN		__FLT64X_DENORM_MIN__
+#endif /* __FLT64X_MANT_DIG__.  */
+
+#ifdef __FLT128X_MANT_DIG__
+#undef FLT128X_MANT_DIG
+#define FLT128X_MANT_DIG	__FLT128X_MANT_DIG__
+#undef FLT128X_DIG
+#define FLT128X_DIG		__FLT128X_DIG__
+#undef FLT128X_MIN_EXP
+#define FLT128X_MIN_EXP		__FLT128X_MIN_EXP__
+#undef FLT128X_MIN_10_EXP
+#define FLT128X_MIN_10_EXP	__FLT128X_MIN_10_EXP__
+#undef FLT128X_MAX_EXP
+#define FLT128X_MAX_EXP		__FLT128X_MAX_EXP__
+#undef FLT128X_MAX_10_EXP
+#define FLT128X_MAX_10_EXP	__FLT128X_MAX_10_EXP__
+#undef FLT128X_MAX
+#define FLT128X_MAX		__FLT128X_MAX__
+#undef FLT128X_EPSILON
+#define FLT128X_EPSILON		__FLT128X_EPSILON__
+#undef FLT128X_MIN
+#define FLT128X_MIN		__FLT128X_MIN__
+#undef FLT128X_DECIMAL_DIG
+#define FLT128X_DECIMAL_DIG	__FLT128X_DECIMAL_DIG__
+#undef FLT128X_TRUE_MIN
+#define FLT128X_TRUE_MIN	__FLT128X_DENORM_MIN__
+#endif /* __FLT128X_MANT_DIG__.  */
+
+#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__.  */
+
+#ifdef __STDC_WANT_DEC_FP__
+/* Draft Technical Report 24732, extension for decimal floating-point
+   arithmetic: Characteristic of decimal floating types <float.h>.  */
+
+/* Number of base-FLT_RADIX digits in the significand, p.  */
+#undef DEC32_MANT_DIG
+#undef DEC64_MANT_DIG
+#undef DEC128_MANT_DIG
+#define DEC32_MANT_DIG	__DEC32_MANT_DIG__
+#define DEC64_MANT_DIG	__DEC64_MANT_DIG__
+#define DEC128_MANT_DIG	__DEC128_MANT_DIG__
+
+/* Minimum exponent. */
+#undef DEC32_MIN_EXP
+#undef DEC64_MIN_EXP
+#undef DEC128_MIN_EXP
+#define DEC32_MIN_EXP	__DEC32_MIN_EXP__
+#define DEC64_MIN_EXP	__DEC64_MIN_EXP__
+#define DEC128_MIN_EXP	__DEC128_MIN_EXP__
+
+/* Maximum exponent. */
+#undef DEC32_MAX_EXP
+#undef DEC64_MAX_EXP
+#undef DEC128_MAX_EXP
+#define DEC32_MAX_EXP	__DEC32_MAX_EXP__
+#define DEC64_MAX_EXP	__DEC64_MAX_EXP__
+#define DEC128_MAX_EXP	__DEC128_MAX_EXP__
+
+/* Maximum representable finite decimal floating-point number
+   (there are 6, 15, and 33 9s after the decimal points respectively). */
+#undef DEC32_MAX
+#undef DEC64_MAX
+#undef DEC128_MAX
+#define DEC32_MAX   __DEC32_MAX__
+#define DEC64_MAX   __DEC64_MAX__
+#define DEC128_MAX  __DEC128_MAX__
+
+/* The difference between 1 and the least value greater than 1 that is
+   representable in the given floating point type. */
+#undef DEC32_EPSILON
+#undef DEC64_EPSILON
+#undef DEC128_EPSILON
+#define DEC32_EPSILON	__DEC32_EPSILON__
+#define DEC64_EPSILON	__DEC64_EPSILON__
+#define DEC128_EPSILON	__DEC128_EPSILON__
+
+/* Minimum normalized positive floating-point number. */
+#undef DEC32_MIN
+#undef DEC64_MIN
+#undef DEC128_MIN
+#define DEC32_MIN	__DEC32_MIN__
+#define DEC64_MIN	__DEC64_MIN__
+#define DEC128_MIN	__DEC128_MIN__
+
+/* Minimum subnormal positive floating-point number. */
+#undef DEC32_SUBNORMAL_MIN
+#undef DEC64_SUBNORMAL_MIN
+#undef DEC128_SUBNORMAL_MIN
+#define DEC32_SUBNORMAL_MIN       __DEC32_SUBNORMAL_MIN__
+#define DEC64_SUBNORMAL_MIN       __DEC64_SUBNORMAL_MIN__
+#define DEC128_SUBNORMAL_MIN      __DEC128_SUBNORMAL_MIN__
+
+/* The floating-point expression evaluation method.
+         -1  indeterminate
+         0  evaluate all operations and constants just to the range and
+            precision of the type
+         1  evaluate operations and constants of type _Decimal32 
+	    and _Decimal64 to the range and precision of the _Decimal64 
+            type, evaluate _Decimal128 operations and constants to the 
+	    range and precision of the _Decimal128 type;
+	 2  evaluate all operations and constants to the range and
+	    precision of the _Decimal128 type.  */
+
+#undef DEC_EVAL_METHOD
+#define DEC_EVAL_METHOD	__DEC_EVAL_METHOD__
+
+#endif /* __STDC_WANT_DEC_FP__ */
+
+#endif /* _FLOAT_H___ */

+ 41 - 0
lib/gcc/riscv-none-embed/8.3.0/include/gcov.h

@@ -0,0 +1,41 @@
+/* GCOV interface routines.
+   Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GCOV_H
+#define GCC_GCOV_H
+
+/* Set all counters to zero.  */
+
+extern void __gcov_reset (void);
+
+/* Write profile information to a file.  */
+
+extern void __gcov_dump (void);
+
+/* Write profile information to a file and reset counters to zero.
+   The function does operations under a mutex.  */
+
+extern void __gcov_flush (void);
+
+#endif /* GCC_GCOV_H */

Некоторые файлы не были показаны из-за большого количества измененных файлов