sys-libs/newlib: Migrate CROSSCOMPILE_OPTS=headers-only -> USE=headers-only
[gentoo.git] / sys-libs / newlib / newlib-2.4.0.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="4"
5
6 inherit flag-o-matic toolchain-funcs eutils
7
8 if [[ ${PV} == "9999" ]] ; then
9         EGIT_REPO_URI="git://sourceware.org/git/newlib-cygwin.git"
10         inherit git-r3
11 else
12         SRC_URI="ftp://sourceware.org/pub/newlib/${P}.tar.gz"
13 #       if [[ ${PV} != *.201[5-9]???? ]] ; then
14                 KEYWORDS="-* ~arm ~hppa ~m68k ~mips ~ppc ~ppc64 ~sh ~sparc ~x86"
15 #       fi
16 fi
17
18 export CBUILD=${CBUILD:-${CHOST}}
19 export CTARGET=${CTARGET:-${CHOST}}
20 if [[ ${CTARGET} == ${CHOST} ]] ; then
21         if [[ ${CATEGORY} == cross-* ]] ; then
22                 export CTARGET=${CATEGORY#cross-}
23         fi
24 fi
25
26 DESCRIPTION="Newlib is a C library intended for use on embedded systems"
27 HOMEPAGE="https://sourceware.org/newlib/"
28
29 LICENSE="NEWLIB LIBGLOSS GPL-2"
30 SLOT="0"
31 IUSE="nls threads unicode headers-only"
32 RESTRICT="strip"
33
34 NEWLIBBUILD="${WORKDIR}/build"
35
36 pkg_setup() {
37         # Reject newlib-on-glibc type installs
38         if [[ ${CTARGET} == ${CHOST} ]] ; then
39                 case ${CHOST} in
40                         *-newlib|*-elf) ;;
41                         *) die "Use sys-devel/crossdev to build a newlib toolchain" ;;
42                 esac
43         fi
44 }
45
46 src_prepare() {
47         epatch_user
48 }
49
50 src_configure() {
51         # we should fix this ...
52         unset LDFLAGS
53         CHOST=${CTARGET} strip-unsupported-flags
54
55         local myconf=(
56                 # Disable legacy syscall stub code in newlib.  These have been
57                 # moved to libgloss for a long time now, so the code in newlib
58                 # itself just gets in the way.
59                 --disable-newlib-supplied-syscalls
60         )
61         [[ ${CTARGET} == "spu" ]] \
62                 && myconf+=( --disable-newlib-multithread ) \
63                 || myconf+=( $(use_enable threads newlib-multithread) )
64
65         mkdir -p "${NEWLIBBUILD}"
66         cd "${NEWLIBBUILD}"
67
68         ECONF_SOURCE=${S} \
69         econf \
70                 $(use_enable unicode newlib-mb) \
71                 $(use_enable nls) \
72                 "${myconf[@]}"
73 }
74
75 src_compile() {
76         emake -C "${NEWLIBBUILD}"
77 }
78
79 src_install() {
80         cd "${NEWLIBBUILD}"
81         emake -j1 DESTDIR="${D}" install
82 #       env -uRESTRICT CHOST=${CTARGET} prepallstrip
83         # minor hack to keep things clean
84         rm -fR "${D}"/usr/share/info
85         rm -fR "${D}"/usr/info
86 }