Merge remote-tracking branch 'github/pr/484'.
[gentoo.git] / dev-embedded / sdcc / sdcc-2.6.0.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 DESCRIPTION="Small device C compiler (for various microprocessors)"
6 HOMEPAGE="http://sdcc.sourceforge.net/"
7 SRC_URI="mirror://sourceforge/sdcc/${PN}-src-${PV}.tar.gz
8         doc? ( mirror://sourceforge/sdcc/${PN}-doc-${PV}.tar.gz )"
9
10 LICENSE="GPL-2"
11 SLOT="0"
12 KEYWORDS="~amd64 ~ppc ~x86"
13 IUSE="doc"
14
15 DEPEND=">=dev-embedded/gputils-0.13.2
16         dev-libs/boehm-gc"
17 RDEPEND="!dev-embedded/sdcc-svn"
18
19 S=${WORKDIR}/${PN}
20
21 src_unpack() {
22         unpack ${A}
23         cd "${S}"
24
25         # Fix conflicting variable names between Gentoo and sdcc
26         find ./ -type f -exec sed -i s:PORTDIR:PORTINGDIR:g  {} \; || die "sed failed"
27         find device/lib/pic*/ -type f -exec sed -i s:ARCH:SDCCARCH:g  {} \; || die "sed failed"
28         find device/lib/pic/libdev/ -type f -exec sed -i s:CFLAGS:SDCCFLAGS:g  {} \; || die "sed failed"
29
30         # --as-needed fix :
31         sed -i -e "s/= @CURSES_LIBS@ @LIBS@/= @CURSES_LIBS@ @LIBS@ -lcurses/" sim/ucsim/gui.src/serio.src/Makefile.in || die "sed failed"
32 }
33
34 src_compile() {
35         econf --enable-libgc docdir=/usr/share/doc/${PF} || die "configure failed"
36         emake || die "emake failed"
37 }
38
39 src_install() {
40         make DESTDIR="${D}" install || die "Install failed"
41         dodoc ChangeLog
42         if use doc ; then
43                 cp -pPR "${WORKDIR}"/doc/* "${D}"/usr/share/doc/${PF}/
44         fi
45         find "${D}"/usr/share/doc/${PF}/ -name *.txt -exec gzip -f -9 {} \;
46         find "${D}"/usr/share/doc/${PF}/ -name */*.txt -exec gzip -f -9 {} \;
47 }