commit:     6bef8677037bd45ca3be141120335a526dd5f181
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 14:26:20 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 14:26:20 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6bef8677

sys-libs/newlib: add 4.5.0.20241231

Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/newlib/Manifest                     |   1 +
 sys-libs/newlib/newlib-4.5.0.20241231.ebuild | 178 +++++++++++++++++++++++++++
 2 files changed, 179 insertions(+)

diff --git a/sys-libs/newlib/Manifest b/sys-libs/newlib/Manifest
index 9dd6901fa600..f0710f0cffe2 100644
--- a/sys-libs/newlib/Manifest
+++ b/sys-libs/newlib/Manifest
@@ -1,2 +1,3 @@
 DIST newlib-4.3.0.20230120.tar.gz 8832922 BLAKE2B 
b5493f25e44049f4e1222698894e7e67756928062e05f5d16bcd52b2221e5c04a80a9e0cbc3fc6e92d67fe6b3813e06b6d3a6d39e8742e02b8f13ff84d809de1
 SHA512 
4a06309d36c2255fef8fc8f2d133cafa850f1ed2eddfb27b5d45f5d16af69e0fca829a0b4c9b34af4ed3a28c6fcc929761e0ee823a4229f35c2853d432b5e7ef
 DIST newlib-4.4.0.20231231.tar.gz 9022406 BLAKE2B 
1df810c7776aa1fe2806682509ab45df642f5e80d6069b7c6ca513b3d820440fc73abdf7505d1f3149d0a07f0c5558a48620d2824f1698c2f1df5f6473105eb4
 SHA512 
ea3baa0b7c9175aae024f0b7d272be092ef2c07483239a99329203e18a44bc23093d29e0ffcbe14bc591f610f0829eacd646cabb06d1c34aa23239cb1b814b46
+DIST newlib-4.5.0.20241231.tar.gz 9081514 BLAKE2B 
8b019d50ef30e736eaf5de8a6ad2f9aee25757162cfc38fca4ad33496b98394292c013d1e3de3309cd81514b3738472405a0841b965b92ec092d2e7f618021fe
 SHA512 
d391ea3ac68ddb722909ef790f81ba4d6c35d9b2e0fcdb029f91a6c47db9ee94a686a2bdff211fb84025e1a317e257acfa59abda3fd2bc6609966798e1c604dc

diff --git a/sys-libs/newlib/newlib-4.5.0.20241231.ebuild 
b/sys-libs/newlib/newlib-4.5.0.20241231.ebuild
new file mode 100644
index 000000000000..3a1f6a3d13af
--- /dev/null
+++ b/sys-libs/newlib/newlib-4.5.0.20241231.ebuild
@@ -0,0 +1,178 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+inherit flag-o-matic toolchain-funcs
+
+if [[ ${PV} == "9999" ]] ; then
+       EGIT_REPO_URI="https://sourceware.org/git/newlib-cygwin.git";
+       inherit git-r3
+else
+       SRC_URI="https://sourceware.org/pub/newlib/${P}.tar.gz";
+       KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv 
~sparc ~x86"
+fi
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+       if [[ ${CATEGORY} == cross-* ]] ; then
+               export CTARGET=${CATEGORY#cross-}
+       fi
+fi
+
+DESCRIPTION="Newlib is a C library intended for use on embedded systems"
+HOMEPAGE="https://sourceware.org/newlib/";
+
+LICENSE="NEWLIB LIBGLOSS GPL-2"
+SLOT="0"
+IUSE="nls threads unicode headers-only nano"
+RESTRICT="strip"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.3.0-no-nano-cxx.patch
+)
+
+NEWLIBBUILD="${WORKDIR}/build"
+NEWLIBNANOBUILD="${WORKDIR}/build.nano"
+NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install"
+
+CFLAGS_FULL="-ffunction-sections -fdata-sections"
+CFLAGS_NANO="-Os -ffunction-sections -fdata-sections"
+
+pkg_setup() {
+       # Reject newlib-on-glibc type installs
+       if [[ ${CTARGET} == ${CHOST} ]] ; then
+               case ${CHOST} in
+                       *-newlib|*-elf) ;;
+                       *) die "Use sys-devel/crossdev to build a newlib 
toolchain" ;;
+               esac
+       fi
+
+       case ${CTARGET} in
+               msp430*)
+                       if ver_test $(gcc-version ${CTARGET}) -lt 10.1; then
+                               # bug #717610
+                               die "gcc for ${CTARGET} has to be 10.1 or above"
+                       fi
+                       ;;
+       esac
+}
+
+src_configure() {
+       # TODO: we should fix this
+       unset LDFLAGS
+       CHOST=${CTARGET} strip-unsupported-flags
+       CCASFLAGS_ORIG="${CCASFLAGS}"
+       CFLAGS_ORIG="${CFLAGS}"
+
+       local myconf=(
+               # The top-level configure doesn't utilize this flag, but 
subdirs do,
+               # so autodetection for econf doesn't work.  Add ourselves.
+               --disable-dependency-tracking
+               --disable-silent-rules
+               # Disable legacy syscall stub code in newlib.  These have been
+               # moved to libgloss for a long time now, so the code in newlib
+               # itself just gets in the way.
+               --disable-newlib-supplied-syscalls
+       )
+       [[ ${CTARGET} == "spu" ]] \
+               && myconf+=( --disable-newlib-multithread ) \
+               || myconf+=( $(use_enable threads newlib-multithread) )
+
+       mkdir -p "${NEWLIBBUILD}"
+       cd "${NEWLIBBUILD}"
+
+       export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+       export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+
+       [[ ${CTARGET} == nvptx* ]] && {
+               CFLAGS_FOR_TARGET+=" -Wa,--no-verify"
+               CCASFLAGS+=" -Wa,--no-verify"
+       }
+
+       ECONF_SOURCE=${S} \
+       econf \
+               $(use_enable unicode newlib-mb) \
+               $(use_enable nls) \
+               "${myconf[@]}"
+
+       # Build newlib-nano beside newlib (original)
+       # Based on 
https://tracker.debian.org/media/packages/n/newlib/rules-2.1.0%2Bgit20140818.1a8323b-2
+       if use nano ; then
+               mkdir -p "${NEWLIBNANOBUILD}" || die
+               cd "${NEWLIBNANOBUILD}" || die
+               export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+               export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+
+               [[ ${CTARGET} == nvptx* ]] && {
+                       CFLAGS_FOR_TARGET+=" -Wa,--no-verify"
+                       CCASFLAGS+=" -Wa,--no-verify"
+               }
+
+               ECONF_SOURCE=${S} \
+               econf \
+                       $(use_enable unicode newlib-mb) \
+                       $(use_enable nls) \
+                       --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 \
+                       "${myconf[@]}"
+       fi
+}
+
+src_compile() {
+       export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_FULL}"
+       export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_FULL}"
+
+       [[ ${CTARGET} == nvptx* ]] && {
+               CFLAGS_FOR_TARGET+=" -Wa,--no-verify"
+               CCASFLAGS+=" -Wa,--no-verify"
+       }
+
+       emake -C "${NEWLIBBUILD}"
+
+       if use nano ; then
+               export "CFLAGS_FOR_TARGET=${CFLAGS_ORIG} ${CFLAGS_NANO}"
+               export "CCASFLAGS=${CCASFLAGS_ORIG} ${CFLAGS_NANO}"
+
+               [[ ${CTARGET} == nvptx* ]] && {
+                       CFLAGS_FOR_TARGET+=" -Wa,--no-verify"
+                       CCASFLAGS+=" -Wa,--no-verify"
+               }
+
+               emake -C "${NEWLIBNANOBUILD}"
+       fi
+}
+
+src_install() {
+       cd "${NEWLIBBUILD}" || die
+       emake DESTDIR="${D}" install
+
+       if use nano ; then
+               cd "${NEWLIBNANOBUILD}" || die
+               emake DESTDIR="${NEWLIBNANOTMPINSTALL}" install
+               # Rename nano lib* files to lib*_nano and move to the real ${D}
+               local nanolibfiles=""
+               nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex 
".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -print)
+               for f in ${nanolibfiles}; do
+                       local l="${f##${NEWLIBNANOTMPINSTALL}}"
+                       mv -v "${f}" "${D}/${l%%\.a}_nano.a" || die
+               done
+
+               # Move newlib-nano's version of newlib.h to newlib-nano/newlib.h
+               mkdir -p "${ED}/usr/${CTARGET}/include/newlib-nano" || die
+               mv 
"${NEWLIBNANOTMPINSTALL}/${EPREFIX}/usr/${CTARGET}/include/newlib.h" \
+                       "${ED}/usr/${CTARGET}/include/newlib-nano/newlib.h" || 
die
+       fi
+
+       # minor hack to keep things clean
+       rm -rf "${D}"/usr/share/info || die
+       rm -rf "${D}"/usr/info || die
+}

Reply via email to