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