commit 58663bc33f553f6f0af8df277dbae5d691eea88d Author: Joakim NohlgÄrd Date: Mon Jan 18 11:10:00 2016 +0100 newlib: add newlib-nano support diff --git a/sys-libs/newlib/newlib-9999.ebuild b/sys-libs/newlib/newlib-9999.ebuild index 44815ad..4cb5b56 100644 --- a/sys-libs/newlib/newlib-9999.ebuild +++ b/sys-libs/newlib/newlib-9999.ebuild @@ -29,10 +29,12 @@ HOMEPAGE="http://sourceware.org/newlib/" LICENSE="NEWLIB LIBGLOSS GPL-2" SLOT="0" -IUSE="nls threads unicode crosscompile_opts_headers-only" +IUSE="nls threads unicode crosscompile_opts_headers-only newlib-nano" RESTRICT="strip" NEWLIBBUILD="${WORKDIR}/build" +NEWLIBNANOBUILD="${WORKDIR}/build.nano" +NEWLIBNANOTMPINSTALL="${WORKDIR}/nano_tmp_install" pkg_setup() { # Reject newlib-on-glibc type installs @@ -65,17 +67,62 @@ src_configure() { econf \ $(use_enable unicode newlib-mb) \ $(use_enable nls) \ + --enable-newlib-io-long-long \ + --enable-newlib-register-fini \ ${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 newlib-nano ; then + mkdir -p "${NEWLIBNANOBUILD}" + cd "${NEWLIBNANOBUILD}" + + 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() { emake -C "${NEWLIBBUILD}" + use newlib-nano && emake -C "${NEWLIBNANOBUILD}" } src_install() { cd "${NEWLIBBUILD}" emake -j1 DESTDIR="${D}" install # env -uRESTRICT CHOST=${CTARGET} prepallstrip + + if use newlib-nano ; then + cd "${NEWLIBNANOBUILD}" + emake -j1 DESTDIR="${NEWLIBNANOTMPINSTALL}" install + # Rename nano lib* files to lib*_nano and move to the real ${D} + # Avoid dependency on perl-rename by using a for loop instead. + local nanolibfiles="" + nanolibfiles=$(find "${NEWLIBNANOTMPINSTALL}" -regex ".*/lib\(c\|g\|rdimon\)\.a" -print) + for f in ${nanolibfiles}; do + local l="${f##${NEWLIBNANOTMPINSTALL}}" + echo mv "${f}" "${D}/${l%%\.a}_nano.a" + mv "${f}" "${D}/${l%%\.a}_nano.a" + done + # Move nano's version of newlib.h to nano/newlib.h + mkdir -p ${D}/usr/${CTARGET}/include/nano + mv ${NEWLIBNANOTMPINSTALL}/usr/${CTARGET}/include/newlib.h \ + ${D}/usr/${CTARGET}/include/nano/newlib.h + + fi + # minor hack to keep things clean rm -fR "${D}"/usr/share/info rm -fR "${D}"/usr/info