dev-libs/darts: ppc stable wrt bug #704258
[gentoo.git] / dev-lang / fpc / fpc-2.6.4.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit toolchain-funcs
7
8 HOMEPAGE="https://www.freepascal.org/"
9 DESCRIPTION="Free Pascal Compiler"
10 SRC_URI="mirror://sourceforge/freepascal/fpcbuild-${PV}.tar.gz
11         mirror://sourceforge/freepascal/fpc-${PV}.source.tar.gz
12         amd64? ( mirror://sourceforge/freepascal/${P}.x86_64-linux.tar )
13         arm? ( mirror://sourceforge/freepascal/${P}.arm-linux.tar )
14         ppc? ( mirror://sourceforge/freepascal/${P}.powerpc-linux.tar )
15         ppc64? ( mirror://sourceforge/freepascal/${P}.powerpc64-linux.tar )
16         sparc? ( mirror://sourceforge/freepascal/${PN}-2.6.2.sparc-linux.tar )
17         x86? ( mirror://sourceforge/freepascal/${P}.i386-linux.tar )
18         doc? ( mirror://sourceforge/freepascal/Documentation/${PV}/doc-html.tar.gz -> ${P}-doc-html.tar.gz
19                 https://dev.gentoo.org/~radhermit/distfiles/${P}-fpctoc.htx.bz2 )"
20
21 SLOT="0"
22 LICENSE="GPL-2 LGPL-2.1-with-linking-exception"
23 KEYWORDS="amd64 ~arm x86"
24 IUSE="doc ide source"
25
26 RDEPEND="ide? ( !dev-lang/fpc-ide )"
27
28 RESTRICT="strip" #269221
29
30 S=${WORKDIR}/fpcbuild-${PV}/fpcsrc
31
32 pkg_pretend() {
33         if [[ ${MERGE_TYPE} != binary ]]; then
34                 # Bug 475210
35                 if $(tc-getLD) --version | grep -q "GNU gold"; then
36                         eerror "fpc does not function correctly when built with the gold linker."
37                         eerror "Please select the bfd linker with binutils-config."
38                         die "GNU gold detected"
39                 fi
40         fi
41 }
42
43 src_unpack() {
44         case ${ARCH} in
45                 amd64)  FPC_ARCH="x86_64"    PV_BIN=${PV} ;;
46                 arm)    FPC_ARCH="arm"       PV_BIN=${PV} ;;
47                 ppc)    FPC_ARCH="powerpc"   PV_BIN=${PV} ;;
48                 ppc64)  FPC_ARCH="powerpc64" PV_BIN=${PV} ;;
49                 sparc)  FPC_ARCH="sparc"     PV_BIN=2.6.2 ;;
50                 x86)    FPC_ARCH="i386"      PV_BIN=${PV} ;;
51                 *)      die "This ebuild doesn't support ${ARCH}." ;;
52         esac
53
54         unpack ${A}
55
56         tar -xf ${PN}-${PV_BIN}.${FPC_ARCH}-linux/binary.${FPC_ARCH}-linux.tar || die "Unpacking binary.${FPC_ARCH}-linux.tar failed!"
57         tar -xzf base.${FPC_ARCH}-linux.tar.gz || die "Unpacking base.${FPC_ARCH}-linux.tar.gz failed!"
58 }
59
60 src_prepare() {
61         find "${WORKDIR}" -name Makefile -exec sed -i -e 's/ -Xs / /g' {} + || die
62
63         # let the pkg manager compress man files
64         sed -i '/find man.* gzip /d' "${WORKDIR}"/fpcbuild-${PV}/install/man/Makefile || die
65 }
66
67 set_pp() {
68         case ${ARCH} in
69                 amd64)  FPC_ARCH="x64" ;;
70                 arm)    FPC_ARCH="arm" ;;
71                 ppc)    FPC_ARCH="ppc" ;;
72                 ppc64)  FPC_ARCH="ppc64" ;;
73                 sparc)  FPC_ARCH="sparc" ;;
74                 x86)    FPC_ARCH="386" ;;
75                 *)      die "This ebuild doesn't support ${ARCH}." ;;
76         esac
77
78         case ${1} in
79                 bootstrap)      pp="${WORKDIR}"/lib/fpc/${PV_BIN}/ppc${FPC_ARCH} ;;
80                 new)    pp="${S}"/compiler/ppc${FPC_ARCH} ;;
81                 *)      die "set_pp: unknown argument: ${1}" ;;
82         esac
83 }
84
85 src_compile() {
86         local pp
87
88         # Using the bootstrap compiler.
89         set_pp bootstrap
90
91         emake -j1 PP="${pp}" compiler_cycle AS="$(tc-getAS)"
92
93         # Save new compiler from cleaning...
94         cp "${S}"/compiler/ppc${FPC_ARCH} "${S}"/ppc${FPC_ARCH}.new || die
95
96         # ...rebuild with current version...
97         emake -j1 PP="${S}"/ppc${FPC_ARCH}.new AS="$(tc-getAS)" compiler_cycle
98
99         # ..and clean up afterwards
100         rm "${S}"/ppc${FPC_ARCH}.new || die
101
102         # Using the new compiler.
103         set_pp new
104
105         emake -j1 PP="${pp}" AS="$(tc-getAS)" rtl_clean
106
107         emake -j1 PP="${pp}" AS="$(tc-getAS)" rtl packages_all utils
108
109         if use ide ; then
110                 cd "${S}"/ide || die
111                 emake -j1 PP="${pp}" AS="$(tc-getAS)"
112         fi
113 }
114
115 src_install() {
116         local pp
117         set_pp new
118
119         set -- PP="${pp}" FPCMAKE="${S}/utils/fpcm/fpcmake" \
120                 INSTALL_PREFIX="${D}"/usr \
121                 INSTALL_DOCDIR="${D}"/usr/share/doc/${PF} \
122                 INSTALL_MANDIR="${D}"/usr/share/man \
123                 INSTALL_SOURCEDIR="${D}"/usr/lib/fpc/${PV}/source
124
125         emake -j1 "$@" compiler_install rtl_install packages_install utils_install
126
127         dosym ../lib/fpc/${PV}/ppc${FPC_ARCH} /usr/bin/ppc${FPC_ARCH}
128
129         cd "${S}"/../install/doc || die
130         emake -j1 "$@" installdoc
131
132         cd "${S}"/../install/man || die
133         emake -j1 "$@" installman
134
135         if use doc ; then
136                 cd "${S}"/../../doc || die
137                 dodoc -r *
138                 newdoc "${WORKDIR}"/${P}-fpctoc.htx fpctoc.htx
139                 docompress -x /usr/share/doc/${PF}/fpctoc.htx
140         fi
141
142         if use ide ; then
143                 cd "${S}"/ide
144                 emake -j1 "$@" install
145         fi
146
147         if use source ; then
148                 cd "${S}" || die
149                 shift
150                 emake -j1 PP="${D}"/usr/bin/ppc${FPC_ARCH} "$@" sourceinstall
151                 find "${D}"/usr/lib/fpc/${PV}/source -name '*.o' -exec rm {} \;
152         fi
153
154         "${D}"/usr/lib/fpc/${PV}/samplecfg "${D}"/usr/lib/fpc/${PV} "${D}"/etc || die
155
156         sed -i "s:${D}::g" "${D}"/etc/fpc.cfg || die
157
158         if use ide ; then
159                 sed -e "s:${D}::g" \
160                         -i "${D}"/etc/fppkg.cfg \
161                         -i "${D}"/etc/fppkg/* \
162                         -i "${D}"/usr/lib/fpc/${PV}/ide/text/fp*.cfg \
163                         || die
164         fi
165
166         rm -r "${D}"/usr/lib/fpc/lexyacc || die
167 }
168
169 pkg_postinst() {
170         if [[ -z ${REPLACING_VERSIONS} ]] && use ide; then
171                 einfo "To read the documentation in the fpc IDE, enable the doc USE flag"
172                 einfo "and add /usr/share/doc/${PF}/fpctoc.htx to the Help Files list."
173         fi
174 }