dev-embedded/sdcc: x86 stable (bug #679816)
[gentoo.git] / dev-embedded / sdcc / sdcc-3.8.0-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 inherit autotools toolchain-funcs
6
7 if [[ ${PV} == "9999" ]] ; then
8         ESVN_REPO_URI="https://svn.code.sf.net/p/sdcc/code/trunk/sdcc"
9         inherit subversion
10 else
11         SRC_URI="
12                 mirror://sourceforge/sdcc/${PN}-src-${PV}.tar.bz2
13                 doc? ( mirror://sourceforge/sdcc/${PN}-doc-${PV}.tar.bz2 )
14         "
15         KEYWORDS="~amd64 x86"
16 fi
17
18 DESCRIPTION="Small device C compiler (for various microprocessors)"
19 HOMEPAGE="http://sdcc.sourceforge.net/"
20
21 LICENSE="
22         GPL-2 ZLIB
23         non-free? ( MicroChip-SDCC )
24         packihx? ( public-domain )
25 "
26 SLOT="0"
27 SDCC_PORTS="
28         avr ds390 ds400 gbz80 hc08 mcs51 pic14 pic16 r2k r3ka s08 stm8 tlcs90 z180
29         z80
30 "
31 IUSE="
32         ${SDCC_PORTS}
33         +boehm-gc device-lib doc non-free packihx +sdbinutils sdcdb +sdcpp ucsim
34 "
35
36 for port in ${SDCC_PORTS}; do
37 REQUIRED_USE="${REQUIRED_USE}
38         ${port}? ( sdbinutils )
39 "
40 done
41 REQUIRED_USE="${REQUIRED_USE}
42         || ( ${SDCC_PORTS} )
43 "
44
45 RESTRICT="strip"
46
47 RDEPEND="
48         dev-libs/boost:=
49         sys-libs/ncurses:=
50         sys-libs/readline:0=
51         >=dev-embedded/gputils-0.13.7
52         boehm-gc? ( dev-libs/boehm-gc:= )
53         !dev-embedded/sdcc-svn
54 "
55 DEPEND="
56         ${RDEPEND}
57         dev-util/gperf
58 "
59 PATCHES=(
60         "${FILESDIR}"/${PN}-3.8.0-override-override.patch
61 )
62
63 src_prepare() {
64         # Fix conflicting variable names between Gentoo and sdcc
65         find \
66                 '(' -name 'Makefile*.in' -o -name 'configure' ')' \
67                 -exec sed -r -i \
68                         -e 's:\<(PORTDIR|ARCH)\>:SDCC\1:g' \
69                         {} + || die
70
71         # https://sourceforge.net/p/sdcc/bugs/2398/
72         sed -i -e '1iAR = @AR@' Makefile.common.in || die
73         sed -i \
74                 -e "/^AR =/s:=.*:=$(tc-getAR):" \
75                 support/cpp/Makefile.in || die
76
77         # Make sure timestamps don't get messed up.
78         [[ ${PV} == "9999" ]] && find "${S}" -type f -exec touch -r . {} +
79
80         default
81         eautoreconf
82 }
83
84 src_configure() {
85         # sdbinutils subdir doesn't pass down --docdir properly, so need to
86         # expand $(datarootdir) ourselves.
87         econf \
88                 ac_cv_prog_AR="$(tc-getAR)" \
89                 ac_cv_prog_AS="$(tc-getAS)" \
90                 ac_cv_prog_STRIP=true \
91                 $(use_enable avr avr-port) \
92                 $(use_enable boehm-gc libgc) \
93                 $(use_enable device-lib) \
94                 $(use_enable ds390 ds390-port) \
95                 $(use_enable ds400 ds400-port) \
96                 $(use_enable gbz80 gbz80-port) \
97                 $(use_enable hc08 hc08-port) \
98                 $(use_enable mcs51 mcs51-port) \
99                 $(use_enable non-free) \
100                 $(use_enable packihx) \
101                 $(use_enable pic14 pic14-port) \
102                 $(use_enable pic16 pic16-port) \
103                 $(use_enable r2k r2k-port) \
104                 $(use_enable r3ka r3ka-port) \
105                 $(use_enable s08 s08-port) \
106                 $(use_enable sdbinutils) \
107                 $(use_enable sdcdb) \
108                 $(use_enable sdcpp) \
109                 $(use_enable stm8 stm8-port) \
110                 $(use_enable tlcs90 tlcs90-port) \
111                 $(use_enable ucsim) \
112                 $(use_enable z180 z180-port) \
113                 $(use_enable z80 z80-port) \
114                 --disable-doc \
115                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
116                 --without-ccache
117 }
118
119 src_install() {
120         default
121         dodoc doc/*.txt
122         find "${D}" -name .deps -exec rm -rf {} + || die
123
124         if use doc && [[ ${PV} != "9999" ]]; then
125                 cd "${WORKDIR}"/doc
126                 dodoc -r *
127         fi
128
129         # a bunch of archives (*.a) are built & installed by gputils
130         # for PIC processors, but they do not work with standard `ar`
131         # & `scanelf` utils and they're not for the host.
132         dostrip "${D%/}"/usr/bin
133 }