public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] download_prerequisites: New script port from GCC
@ 2023-08-29  5:42 Jerry Zhang Jian
  2023-08-29  5:52 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry Zhang Jian @ 2023-08-29  5:42 UTC (permalink / raw)
  To: binutils; +Cc: Jerry Zhang Jian

download_prerequisites: add this script from GCC contrib/ folder to help
setting up the build dependencies for binutils

Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
---
 contrib/download_prerequisites | 279 +++++++++++++++++++++++++++++++++
 contrib/prerequisites.md5      |   4 +
 contrib/prerequisites.sha512   |   4 +
 3 files changed, 287 insertions(+)
 create mode 100755 contrib/download_prerequisites
 create mode 100644 contrib/prerequisites.md5
 create mode 100644 contrib/prerequisites.sha512

diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
new file mode 100755
index 00000000000..ed6c647fcfe
--- /dev/null
+++ b/contrib/download_prerequisites
@@ -0,0 +1,279 @@
+#! /bin/sh
+#! -*- coding:utf-8; mode:shell-script; -*-
+
+# Download some prerequisites needed by GCC.
+# Run this from the top level of the GCC source tree and the GCC build will do
+# the right thing.  Run it with the `--help` option for more information.
+#
+# (C) 2010-2021 Free Software Foundation
+#
+# 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/.
+
+program='download_prerequisites'
+version='(unversioned)'
+
+# MAINTAINERS: If you update the package versions below, please
+# remember to also update the files `contrib/prerequisites.sha512` and
+# `contrib/prerequisites.md5` with the new checksums.
+
+gmp='gmp-6.2.1.tar.bz2'
+mpfr='mpfr-4.1.0.tar.bz2'
+mpc='mpc-1.2.1.tar.gz'
+isl='isl-0.24.tar.bz2'
+
+base_url='http://gcc.gnu.org/pub/gcc/infrastructure/'
+
+echo_archives() {
+    echo "${gmp}"
+    echo "${mpfr}"
+    echo "${mpc}"
+    if [ ${graphite} -gt 0 ]; then echo "${isl}"; fi
+}
+
+graphite=1
+verify=1
+force=0
+OS=$(uname)
+
+if type wget > /dev/null ; then
+  fetch='wget'
+else
+  fetch='curl -LO'
+fi
+chksum_extension='sha512'
+directory='.'
+
+helptext="usage: ${program} [OPTION...]
+
+Downloads some prerequisites needed by GCC.  Run this from the top level of the
+GCC source tree and the GCC build will do the right thing.
+
+The following options are available:
+
+ --directory=DIR  download and unpack packages into DIR instead of '.'
+ --force          download again overwriting existing packages
+ --no-force       do not download existing packages again (default)
+ --isl            download ISL, needed for Graphite loop optimizations (default)
+ --graphite       same as --isl
+ --no-isl         don't download ISL
+ --no-graphite    same as --no-isl
+ --verify         verify package integrity after download (default)
+ --no-verify      don't verify package integrity
+ --sha512         use SHA512 checksum to verify package integrity (default)
+ --md5            use MD5 checksum to verify package integrity
+ --help           show this text and exit
+ --version        show version information and exit
+"
+
+versiontext="${program} ${version}
+Copyright (C) 2016-2023 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+die() {
+    echo "error: $@" >&2
+    exit 1
+}
+
+for arg in "$@"
+do
+    case "${arg}" in
+        --help)
+            echo "${helptext}"
+            exit
+            ;;
+        --version)
+            echo "${versiontext}"
+            exit
+            ;;
+    esac
+done
+unset arg
+
+# Emulate Linux's 'md5sum --check' on macOS
+md5_check() {
+  # Store the standard input: a line from contrib/prerequisites.md5:
+  md5_checksum_line=$(cat -)
+  # Grab the text before the first space
+  md5_checksum_expected="${md5_checksum_line%% *}"
+  # Grab the text after the first space
+  file_to_check="${md5_checksum_line##* }"
+  # Calculate the md5 checksum for the downloaded file
+  md5_checksum_output=$(md5 -r "${file_to_check}")
+  # Grab the text before the first space
+  md5_checksum_detected="${md5_checksum_output%% *}"
+  [ "${md5_checksum_expected}" = "${md5_checksum_detected}" ] \
+    || die "Cannot verify integrity of possibly corrupted file ${file_to_check}"
+  echo "${file_to_check}: OK"
+}
+
+
+argnext=
+for arg in "$@"
+do
+    if [ "x${argnext}" = x ]
+    then
+        case "${arg}" in
+            --directory)
+                argnext='directory'
+                ;;
+            --directory=*)
+                directory="${arg#--directory=}"
+                ;;
+            --force)
+                force=1
+                ;;
+            --no-force)
+                force=0
+                ;;
+            --isl|--graphite)
+                graphite=1
+                ;;
+            --no-isl|--no-graphite)
+                graphite=0
+                ;;
+            --verify)
+                verify=1
+                ;;
+            --no-verify)
+                verify=0
+                ;;
+            --sha512)
+                chksum_extension='sha512'
+                verify=1
+                ;;
+            --md5)
+                chksum_extension='md5'
+                verify=1
+                ;;
+            -*)
+                die "unknown option: ${arg}"
+                ;;
+            *)
+                die "too many arguments"
+                ;;
+        esac
+    else
+        case "${arg}" in
+            -*)
+                die "Missing argument for option --${argnext}"
+                ;;
+        esac
+        case "${argnext}" in
+            directory)
+                directory="${arg}"
+                ;;
+            *)
+                die "The impossible has happened"
+                ;;
+        esac
+        argnext=
+    fi
+done
+[ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
+unset arg argnext
+
+case $chksum_extension in
+  sha512)
+    case $OS in
+      "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
+        chksum='shasum -a 512 --check'
+      ;;
+      "OpenBSD")
+        chksum='sha512 -c'
+      ;;
+      *)
+        chksum='sha512sum -c'
+      ;;
+    esac
+  ;;
+  md5)
+    case $OS in
+      "Darwin")
+        chksum='md5_check'
+      ;;
+      *)
+        chksum='md5sum -c'
+      ;;
+    esac
+    ;;
+  *)
+    die "Unkown checksum $chksum_extension"
+  ;;
+esac
+
+[ -e ./binutils ]                                                         \
+    || die "You must run this script in the top-level Binutils source directory"
+
+[ -d "${directory}" ]                                                         \
+    || die "No such directory: ${directory}"
+
+for ar in $(echo_archives)
+do
+    if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
+    [ -e "${directory}/${ar}" ]                                               \
+        || ( cd "${directory}" && ${fetch} --no-verbose "${base_url}${ar}" )  \
+        || die "Cannot download ${ar} from ${base_url}"
+done
+unset ar
+
+if [ ${verify} -gt 0 ]
+then
+    chksumfile="contrib/prerequisites.${chksum_extension}"
+    [ -r "${chksumfile}" ] || die "No checksums available"
+    for ar in $(echo_archives)
+    do
+        grep "${ar}" "${chksumfile}"                                          \
+            | ( cd "${directory}" && ${chksum} )                              \
+            || die "Cannot verify integrity of possibly corrupted file ${ar}"
+    done
+    unset chksumfile
+fi
+unset ar
+
+for ar in $(echo_archives)
+do
+    package="${ar%.tar*}"
+    if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
+    case $ar in
+    *.gz)
+	uncompress='gzip -d'
+	;;
+    *.bz2)
+	uncompress='bzip2 -d'
+	;;
+    *)
+	uncompress='cat'
+	;;
+    esac
+    [ -e "${directory}/${package}" ]                                          \
+        || ( cd "${directory}" && $uncompress <"${ar}" | tar -xf - )          \
+        || die "Cannot extract package from ${ar}"
+    unset package
+done
+unset ar
+
+for ar in $(echo_archives)
+do
+    target="${directory}/${ar%.tar*}/"
+    linkname="${ar%-*}"
+    if [ ${force} -gt 0 ]; then rm -f "${linkname}"; fi
+    [ -e "${linkname}" ]                                                      \
+        || ln -s "${target}" "${linkname}"                                    \
+        || die "Cannot create symbolic link ${linkname} --> ${target}"
+    unset target linkname
+done
+unset ar
+
+echo "All prerequisites downloaded successfully."
diff --git a/contrib/prerequisites.md5 b/contrib/prerequisites.md5
new file mode 100644
index 00000000000..a20f986c2e0
--- /dev/null
+++ b/contrib/prerequisites.md5
@@ -0,0 +1,4 @@
+28971fc21cf028042d4897f02fd355ea  gmp-6.2.1.tar.bz2
+44b892bc5a45bafb4294d134e13aad1d  mpfr-4.1.0.tar.bz2
+9f16c976c25bb0f76b50be749cd7a3a8  mpc-1.2.1.tar.gz
+dd2f7b78e118c25bd96134a52aae7f4d  isl-0.24.tar.bz2
diff --git a/contrib/prerequisites.sha512 b/contrib/prerequisites.sha512
new file mode 100644
index 00000000000..89541b9ad4d
--- /dev/null
+++ b/contrib/prerequisites.sha512
@@ -0,0 +1,4 @@
+8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9  gmp-6.2.1.tar.bz2
+410208ee0d48474c1c10d3d4a59decd2dfa187064183b09358ec4c4666e34d74383128436b404123b831e585d81a9176b24c7ced9d913967c5fce35d4040a0b4  mpfr-4.1.0.tar.bz2
+3279f813ab37f47fdcc800e4ac5f306417d07f539593ca715876e43e04896e1d5bceccfb288ef2908a3f24b760747d0dbd0392a24b9b341bc3e12082e5c836ee  mpc-1.2.1.tar.gz
+aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95  isl-0.24.tar.bz2
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] download_prerequisites: New script port from GCC
  2023-08-29  5:42 [PATCH] download_prerequisites: New script port from GCC Jerry Zhang Jian
@ 2023-08-29  5:52 ` Andrew Pinski
  2023-08-30  1:09   ` Jerry ZJ
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2023-08-29  5:52 UTC (permalink / raw)
  To: Jerry Zhang Jian; +Cc: binutils, GDB Patches

On Mon, Aug 28, 2023 at 10:48 PM Jerry Zhang Jian via Binutils
<binutils@sourceware.org> wrote:
>
> download_prerequisites: add this script from GCC contrib/ folder to help
> setting up the build dependencies for binutils

GMP/MFPR is not needed for building binutils but rather gdb. So I
added gdb-patches@ .
Releases of binutils will not include the gdb directory either.
I think this is a good idea though it would be good to have a script
which checks to make sure the 2 versions (in gcc git and gdb-binutils
git) are kept the same.

Thanks,
Andrew Pinski

>
> Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
> ---
>  contrib/download_prerequisites | 279 +++++++++++++++++++++++++++++++++
>  contrib/prerequisites.md5      |   4 +
>  contrib/prerequisites.sha512   |   4 +
>  3 files changed, 287 insertions(+)
>  create mode 100755 contrib/download_prerequisites
>  create mode 100644 contrib/prerequisites.md5
>  create mode 100644 contrib/prerequisites.sha512
>
> diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
> new file mode 100755
> index 00000000000..ed6c647fcfe
> --- /dev/null
> +++ b/contrib/download_prerequisites
> @@ -0,0 +1,279 @@
> +#! /bin/sh
> +#! -*- coding:utf-8; mode:shell-script; -*-
> +
> +# Download some prerequisites needed by GCC.
> +# Run this from the top level of the GCC source tree and the GCC build will do
> +# the right thing.  Run it with the `--help` option for more information.
> +#
> +# (C) 2010-2021 Free Software Foundation
> +#
> +# 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/.
> +
> +program='download_prerequisites'
> +version='(unversioned)'
> +
> +# MAINTAINERS: If you update the package versions below, please
> +# remember to also update the files `contrib/prerequisites.sha512` and
> +# `contrib/prerequisites.md5` with the new checksums.
> +
> +gmp='gmp-6.2.1.tar.bz2'
> +mpfr='mpfr-4.1.0.tar.bz2'
> +mpc='mpc-1.2.1.tar.gz'
> +isl='isl-0.24.tar.bz2'
> +
> +base_url='http://gcc.gnu.org/pub/gcc/infrastructure/'
> +
> +echo_archives() {
> +    echo "${gmp}"
> +    echo "${mpfr}"
> +    echo "${mpc}"
> +    if [ ${graphite} -gt 0 ]; then echo "${isl}"; fi
> +}
> +
> +graphite=1
> +verify=1
> +force=0
> +OS=$(uname)
> +
> +if type wget > /dev/null ; then
> +  fetch='wget'
> +else
> +  fetch='curl -LO'
> +fi
> +chksum_extension='sha512'
> +directory='.'
> +
> +helptext="usage: ${program} [OPTION...]
> +
> +Downloads some prerequisites needed by GCC.  Run this from the top level of the
> +GCC source tree and the GCC build will do the right thing.
> +
> +The following options are available:
> +
> + --directory=DIR  download and unpack packages into DIR instead of '.'
> + --force          download again overwriting existing packages
> + --no-force       do not download existing packages again (default)
> + --isl            download ISL, needed for Graphite loop optimizations (default)
> + --graphite       same as --isl
> + --no-isl         don't download ISL
> + --no-graphite    same as --no-isl
> + --verify         verify package integrity after download (default)
> + --no-verify      don't verify package integrity
> + --sha512         use SHA512 checksum to verify package integrity (default)
> + --md5            use MD5 checksum to verify package integrity
> + --help           show this text and exit
> + --version        show version information and exit
> +"
> +
> +versiontext="${program} ${version}
> +Copyright (C) 2016-2023 Free Software Foundation, Inc.
> +This is free software; see the source for copying conditions.  There is NO
> +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
> +
> +die() {
> +    echo "error: $@" >&2
> +    exit 1
> +}
> +
> +for arg in "$@"
> +do
> +    case "${arg}" in
> +        --help)
> +            echo "${helptext}"
> +            exit
> +            ;;
> +        --version)
> +            echo "${versiontext}"
> +            exit
> +            ;;
> +    esac
> +done
> +unset arg
> +
> +# Emulate Linux's 'md5sum --check' on macOS
> +md5_check() {
> +  # Store the standard input: a line from contrib/prerequisites.md5:
> +  md5_checksum_line=$(cat -)
> +  # Grab the text before the first space
> +  md5_checksum_expected="${md5_checksum_line%% *}"
> +  # Grab the text after the first space
> +  file_to_check="${md5_checksum_line##* }"
> +  # Calculate the md5 checksum for the downloaded file
> +  md5_checksum_output=$(md5 -r "${file_to_check}")
> +  # Grab the text before the first space
> +  md5_checksum_detected="${md5_checksum_output%% *}"
> +  [ "${md5_checksum_expected}" = "${md5_checksum_detected}" ] \
> +    || die "Cannot verify integrity of possibly corrupted file ${file_to_check}"
> +  echo "${file_to_check}: OK"
> +}
> +
> +
> +argnext=
> +for arg in "$@"
> +do
> +    if [ "x${argnext}" = x ]
> +    then
> +        case "${arg}" in
> +            --directory)
> +                argnext='directory'
> +                ;;
> +            --directory=*)
> +                directory="${arg#--directory=}"
> +                ;;
> +            --force)
> +                force=1
> +                ;;
> +            --no-force)
> +                force=0
> +                ;;
> +            --isl|--graphite)
> +                graphite=1
> +                ;;
> +            --no-isl|--no-graphite)
> +                graphite=0
> +                ;;
> +            --verify)
> +                verify=1
> +                ;;
> +            --no-verify)
> +                verify=0
> +                ;;
> +            --sha512)
> +                chksum_extension='sha512'
> +                verify=1
> +                ;;
> +            --md5)
> +                chksum_extension='md5'
> +                verify=1
> +                ;;
> +            -*)
> +                die "unknown option: ${arg}"
> +                ;;
> +            *)
> +                die "too many arguments"
> +                ;;
> +        esac
> +    else
> +        case "${arg}" in
> +            -*)
> +                die "Missing argument for option --${argnext}"
> +                ;;
> +        esac
> +        case "${argnext}" in
> +            directory)
> +                directory="${arg}"
> +                ;;
> +            *)
> +                die "The impossible has happened"
> +                ;;
> +        esac
> +        argnext=
> +    fi
> +done
> +[ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
> +unset arg argnext
> +
> +case $chksum_extension in
> +  sha512)
> +    case $OS in
> +      "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
> +        chksum='shasum -a 512 --check'
> +      ;;
> +      "OpenBSD")
> +        chksum='sha512 -c'
> +      ;;
> +      *)
> +        chksum='sha512sum -c'
> +      ;;
> +    esac
> +  ;;
> +  md5)
> +    case $OS in
> +      "Darwin")
> +        chksum='md5_check'
> +      ;;
> +      *)
> +        chksum='md5sum -c'
> +      ;;
> +    esac
> +    ;;
> +  *)
> +    die "Unkown checksum $chksum_extension"
> +  ;;
> +esac
> +
> +[ -e ./binutils ]                                                         \
> +    || die "You must run this script in the top-level Binutils source directory"
> +
> +[ -d "${directory}" ]                                                         \
> +    || die "No such directory: ${directory}"
> +
> +for ar in $(echo_archives)
> +do
> +    if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
> +    [ -e "${directory}/${ar}" ]                                               \
> +        || ( cd "${directory}" && ${fetch} --no-verbose "${base_url}${ar}" )  \
> +        || die "Cannot download ${ar} from ${base_url}"
> +done
> +unset ar
> +
> +if [ ${verify} -gt 0 ]
> +then
> +    chksumfile="contrib/prerequisites.${chksum_extension}"
> +    [ -r "${chksumfile}" ] || die "No checksums available"
> +    for ar in $(echo_archives)
> +    do
> +        grep "${ar}" "${chksumfile}"                                          \
> +            | ( cd "${directory}" && ${chksum} )                              \
> +            || die "Cannot verify integrity of possibly corrupted file ${ar}"
> +    done
> +    unset chksumfile
> +fi
> +unset ar
> +
> +for ar in $(echo_archives)
> +do
> +    package="${ar%.tar*}"
> +    if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
> +    case $ar in
> +    *.gz)
> +       uncompress='gzip -d'
> +       ;;
> +    *.bz2)
> +       uncompress='bzip2 -d'
> +       ;;
> +    *)
> +       uncompress='cat'
> +       ;;
> +    esac
> +    [ -e "${directory}/${package}" ]                                          \
> +        || ( cd "${directory}" && $uncompress <"${ar}" | tar -xf - )          \
> +        || die "Cannot extract package from ${ar}"
> +    unset package
> +done
> +unset ar
> +
> +for ar in $(echo_archives)
> +do
> +    target="${directory}/${ar%.tar*}/"
> +    linkname="${ar%-*}"
> +    if [ ${force} -gt 0 ]; then rm -f "${linkname}"; fi
> +    [ -e "${linkname}" ]                                                      \
> +        || ln -s "${target}" "${linkname}"                                    \
> +        || die "Cannot create symbolic link ${linkname} --> ${target}"
> +    unset target linkname
> +done
> +unset ar
> +
> +echo "All prerequisites downloaded successfully."
> diff --git a/contrib/prerequisites.md5 b/contrib/prerequisites.md5
> new file mode 100644
> index 00000000000..a20f986c2e0
> --- /dev/null
> +++ b/contrib/prerequisites.md5
> @@ -0,0 +1,4 @@
> +28971fc21cf028042d4897f02fd355ea  gmp-6.2.1.tar.bz2
> +44b892bc5a45bafb4294d134e13aad1d  mpfr-4.1.0.tar.bz2
> +9f16c976c25bb0f76b50be749cd7a3a8  mpc-1.2.1.tar.gz
> +dd2f7b78e118c25bd96134a52aae7f4d  isl-0.24.tar.bz2
> diff --git a/contrib/prerequisites.sha512 b/contrib/prerequisites.sha512
> new file mode 100644
> index 00000000000..89541b9ad4d
> --- /dev/null
> +++ b/contrib/prerequisites.sha512
> @@ -0,0 +1,4 @@
> +8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9  gmp-6.2.1.tar.bz2
> +410208ee0d48474c1c10d3d4a59decd2dfa187064183b09358ec4c4666e34d74383128436b404123b831e585d81a9176b24c7ced9d913967c5fce35d4040a0b4  mpfr-4.1.0.tar.bz2
> +3279f813ab37f47fdcc800e4ac5f306417d07f539593ca715876e43e04896e1d5bceccfb288ef2908a3f24b760747d0dbd0392a24b9b341bc3e12082e5c836ee  mpc-1.2.1.tar.gz
> +aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95  isl-0.24.tar.bz2
> --
> 2.41.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] download_prerequisites: New script port from GCC
  2023-08-29  5:52 ` Andrew Pinski
@ 2023-08-30  1:09   ` Jerry ZJ
  0 siblings, 0 replies; 3+ messages in thread
From: Jerry ZJ @ 2023-08-30  1:09 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: binutils, GDB Patches

[-- Attachment #1: Type: text/plain, Size: 10802 bytes --]

Hi, Andrew

Thanks for the feedback. To my knowledge, gcc and binutils share the same configure.ac and configure script. Is it possible for us to adopt the same approach?

Thanks,
Jerry

On Aug 29, 2023 at 13:52 +0800, Andrew Pinski <pinskia@gmail.com>, wrote:
> On Mon, Aug 28, 2023 at 10:48 PM Jerry Zhang Jian via Binutils
> <binutils@sourceware.org> wrote:
> >
> > download_prerequisites: add this script from GCC contrib/ folder to help
> > setting up the build dependencies for binutils
>
> GMP/MFPR is not needed for building binutils but rather gdb. So I
> added gdb-patches@ .
> Releases of binutils will not include the gdb directory either.
> I think this is a good idea though it would be good to have a script
> which checks to make sure the 2 versions (in gcc git and gdb-binutils
> git) are kept the same.
>
> Thanks,
> Andrew Pinski
>
> >
> > Signed-off-by: Jerry Zhang Jian <jerry.zhangjian@sifive.com>
> > ---
> > contrib/download_prerequisites | 279 +++++++++++++++++++++++++++++++++
> > contrib/prerequisites.md5 | 4 +
> > contrib/prerequisites.sha512 | 4 +
> > 3 files changed, 287 insertions(+)
> > create mode 100755 contrib/download_prerequisites
> > create mode 100644 contrib/prerequisites.md5
> > create mode 100644 contrib/prerequisites.sha512
> >
> > diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
> > new file mode 100755
> > index 00000000000..ed6c647fcfe
> > --- /dev/null
> > +++ b/contrib/download_prerequisites
> > @@ -0,0 +1,279 @@
> > +#! /bin/sh
> > +#! -*- coding:utf-8; mode:shell-script; -*-
> > +
> > +# Download some prerequisites needed by GCC.
> > +# Run this from the top level of the GCC source tree and the GCC build will do
> > +# the right thing. Run it with the `--help` option for more information.
> > +#
> > +# (C) 2010-2021 Free Software Foundation
> > +#
> > +# 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/.
> > +
> > +program='download_prerequisites'
> > +version='(unversioned)'
> > +
> > +# MAINTAINERS: If you update the package versions below, please
> > +# remember to also update the files `contrib/prerequisites.sha512` and
> > +# `contrib/prerequisites.md5` with the new checksums.
> > +
> > +gmp='gmp-6.2.1.tar.bz2'
> > +mpfr='mpfr-4.1.0.tar.bz2'
> > +mpc='mpc-1.2.1.tar.gz'
> > +isl='isl-0.24.tar.bz2'
> > +
> > +base_url='http://gcc.gnu.org/pub/gcc/infrastructure/'
> > +
> > +echo_archives() {
> > + echo "${gmp}"
> > + echo "${mpfr}"
> > + echo "${mpc}"
> > + if [ ${graphite} -gt 0 ]; then echo "${isl}"; fi
> > +}
> > +
> > +graphite=1
> > +verify=1
> > +force=0
> > +OS=$(uname)
> > +
> > +if type wget > /dev/null ; then
> > + fetch='wget'
> > +else
> > + fetch='curl -LO'
> > +fi
> > +chksum_extension='sha512'
> > +directory='.'
> > +
> > +helptext="usage: ${program} [OPTION...]
> > +
> > +Downloads some prerequisites needed by GCC. Run this from the top level of the
> > +GCC source tree and the GCC build will do the right thing.
> > +
> > +The following options are available:
> > +
> > + --directory=DIR download and unpack packages into DIR instead of '.'
> > + --force download again overwriting existing packages
> > + --no-force do not download existing packages again (default)
> > + --isl download ISL, needed for Graphite loop optimizations (default)
> > + --graphite same as --isl
> > + --no-isl don't download ISL
> > + --no-graphite same as --no-isl
> > + --verify verify package integrity after download (default)
> > + --no-verify don't verify package integrity
> > + --sha512 use SHA512 checksum to verify package integrity (default)
> > + --md5 use MD5 checksum to verify package integrity
> > + --help show this text and exit
> > + --version show version information and exit
> > +"
> > +
> > +versiontext="${program} ${version}
> > +Copyright (C) 2016-2023 Free Software Foundation, Inc.
> > +This is free software; see the source for copying conditions. There is NO
> > +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
> > +
> > +die() {
> > + echo "error: $@" >&2
> > + exit 1
> > +}
> > +
> > +for arg in "$@"
> > +do
> > + case "${arg}" in
> > + --help)
> > + echo "${helptext}"
> > + exit
> > + ;;
> > + --version)
> > + echo "${versiontext}"
> > + exit
> > + ;;
> > + esac
> > +done
> > +unset arg
> > +
> > +# Emulate Linux's 'md5sum --check' on macOS
> > +md5_check() {
> > + # Store the standard input: a line from contrib/prerequisites.md5:
> > + md5_checksum_line=$(cat -)
> > + # Grab the text before the first space
> > + md5_checksum_expected="${md5_checksum_line%% *}"
> > + # Grab the text after the first space
> > + file_to_check="${md5_checksum_line##* }"
> > + # Calculate the md5 checksum for the downloaded file
> > + md5_checksum_output=$(md5 -r "${file_to_check}")
> > + # Grab the text before the first space
> > + md5_checksum_detected="${md5_checksum_output%% *}"
> > + [ "${md5_checksum_expected}" = "${md5_checksum_detected}" ] \
> > + || die "Cannot verify integrity of possibly corrupted file ${file_to_check}"
> > + echo "${file_to_check}: OK"
> > +}
> > +
> > +
> > +argnext=
> > +for arg in "$@"
> > +do
> > + if [ "x${argnext}" = x ]
> > + then
> > + case "${arg}" in
> > + --directory)
> > + argnext='directory'
> > + ;;
> > + --directory=*)
> > + directory="${arg#--directory=}"
> > + ;;
> > + --force)
> > + force=1
> > + ;;
> > + --no-force)
> > + force=0
> > + ;;
> > + --isl|--graphite)
> > + graphite=1
> > + ;;
> > + --no-isl|--no-graphite)
> > + graphite=0
> > + ;;
> > + --verify)
> > + verify=1
> > + ;;
> > + --no-verify)
> > + verify=0
> > + ;;
> > + --sha512)
> > + chksum_extension='sha512'
> > + verify=1
> > + ;;
> > + --md5)
> > + chksum_extension='md5'
> > + verify=1
> > + ;;
> > + -*)
> > + die "unknown option: ${arg}"
> > + ;;
> > + *)
> > + die "too many arguments"
> > + ;;
> > + esac
> > + else
> > + case "${arg}" in
> > + -*)
> > + die "Missing argument for option --${argnext}"
> > + ;;
> > + esac
> > + case "${argnext}" in
> > + directory)
> > + directory="${arg}"
> > + ;;
> > + *)
> > + die "The impossible has happened"
> > + ;;
> > + esac
> > + argnext=
> > + fi
> > +done
> > +[ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
> > +unset arg argnext
> > +
> > +case $chksum_extension in
> > + sha512)
> > + case $OS in
> > + "Darwin"|"FreeBSD"|"DragonFly"|"AIX")
> > + chksum='shasum -a 512 --check'
> > + ;;
> > + "OpenBSD")
> > + chksum='sha512 -c'
> > + ;;
> > + *)
> > + chksum='sha512sum -c'
> > + ;;
> > + esac
> > + ;;
> > + md5)
> > + case $OS in
> > + "Darwin")
> > + chksum='md5_check'
> > + ;;
> > + *)
> > + chksum='md5sum -c'
> > + ;;
> > + esac
> > + ;;
> > + *)
> > + die "Unkown checksum $chksum_extension"
> > + ;;
> > +esac
> > +
> > +[ -e ./binutils ] \
> > + || die "You must run this script in the top-level Binutils source directory"
> > +
> > +[ -d "${directory}" ] \
> > + || die "No such directory: ${directory}"
> > +
> > +for ar in $(echo_archives)
> > +do
> > + if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
> > + [ -e "${directory}/${ar}" ] \
> > + || ( cd "${directory}" && ${fetch} --no-verbose "${base_url}${ar}" ) \
> > + || die "Cannot download ${ar} from ${base_url}"
> > +done
> > +unset ar
> > +
> > +if [ ${verify} -gt 0 ]
> > +then
> > + chksumfile="contrib/prerequisites.${chksum_extension}"
> > + [ -r "${chksumfile}" ] || die "No checksums available"
> > + for ar in $(echo_archives)
> > + do
> > + grep "${ar}" "${chksumfile}" \
> > + | ( cd "${directory}" && ${chksum} ) \
> > + || die "Cannot verify integrity of possibly corrupted file ${ar}"
> > + done
> > + unset chksumfile
> > +fi
> > +unset ar
> > +
> > +for ar in $(echo_archives)
> > +do
> > + package="${ar%.tar*}"
> > + if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
> > + case $ar in
> > + *.gz)
> > + uncompress='gzip -d'
> > + ;;
> > + *.bz2)
> > + uncompress='bzip2 -d'
> > + ;;
> > + *)
> > + uncompress='cat'
> > + ;;
> > + esac
> > + [ -e "${directory}/${package}" ] \
> > + || ( cd "${directory}" && $uncompress <"${ar}" | tar -xf - ) \
> > + || die "Cannot extract package from ${ar}"
> > + unset package
> > +done
> > +unset ar
> > +
> > +for ar in $(echo_archives)
> > +do
> > + target="${directory}/${ar%.tar*}/"
> > + linkname="${ar%-*}"
> > + if [ ${force} -gt 0 ]; then rm -f "${linkname}"; fi
> > + [ -e "${linkname}" ] \
> > + || ln -s "${target}" "${linkname}" \
> > + || die "Cannot create symbolic link ${linkname} --> ${target}"
> > + unset target linkname
> > +done
> > +unset ar
> > +
> > +echo "All prerequisites downloaded successfully."
> > diff --git a/contrib/prerequisites.md5 b/contrib/prerequisites.md5
> > new file mode 100644
> > index 00000000000..a20f986c2e0
> > --- /dev/null
> > +++ b/contrib/prerequisites.md5
> > @@ -0,0 +1,4 @@
> > +28971fc21cf028042d4897f02fd355ea gmp-6.2.1.tar.bz2
> > +44b892bc5a45bafb4294d134e13aad1d mpfr-4.1.0.tar.bz2
> > +9f16c976c25bb0f76b50be749cd7a3a8 mpc-1.2.1.tar.gz
> > +dd2f7b78e118c25bd96134a52aae7f4d isl-0.24.tar.bz2
> > diff --git a/contrib/prerequisites.sha512 b/contrib/prerequisites.sha512
> > new file mode 100644
> > index 00000000000..89541b9ad4d
> > --- /dev/null
> > +++ b/contrib/prerequisites.sha512
> > @@ -0,0 +1,4 @@
> > +8904334a3bcc5c896ececabc75cda9dec642e401fb5397c4992c4fabea5e962c9ce8bd44e8e4233c34e55c8010cc28db0545f5f750cbdbb5f00af538dc763be9 gmp-6.2.1.tar.bz2
> > +410208ee0d48474c1c10d3d4a59decd2dfa187064183b09358ec4c4666e34d74383128436b404123b831e585d81a9176b24c7ced9d913967c5fce35d4040a0b4 mpfr-4.1.0.tar.bz2
> > +3279f813ab37f47fdcc800e4ac5f306417d07f539593ca715876e43e04896e1d5bceccfb288ef2908a3f24b760747d0dbd0392a24b9b341bc3e12082e5c836ee mpc-1.2.1.tar.gz
> > +aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95 isl-0.24.tar.bz2
> > --
> > 2.41.0
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-30  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29  5:42 [PATCH] download_prerequisites: New script port from GCC Jerry Zhang Jian
2023-08-29  5:52 ` Andrew Pinski
2023-08-30  1:09   ` Jerry ZJ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).