1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit toolchain-funcs
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 )"
22 LICENSE="GPL-2 LGPL-2.1-with-linking-exception"
23 KEYWORDS="amd64 ~arm x86"
26 RDEPEND="ide? ( !dev-lang/fpc-ide )"
28 RESTRICT="strip" #269221
30 S=${WORKDIR}/fpcbuild-${PV}/fpcsrc
33 if [[ ${MERGE_TYPE} != binary ]]; then
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"
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}." ;;
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!"
61 find "${WORKDIR}" -name Makefile -exec sed -i -e 's/ -Xs / /g' {} + || die
63 # let the pkg manager compress man files
64 sed -i '/find man.* gzip /d' "${WORKDIR}"/fpcbuild-${PV}/install/man/Makefile || die
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}." ;;
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}" ;;
88 # Using the bootstrap compiler.
91 emake -j1 PP="${pp}" compiler_cycle AS="$(tc-getAS)"
93 # Save new compiler from cleaning...
94 cp "${S}"/compiler/ppc${FPC_ARCH} "${S}"/ppc${FPC_ARCH}.new || die
96 # ...rebuild with current version...
97 emake -j1 PP="${S}"/ppc${FPC_ARCH}.new AS="$(tc-getAS)" compiler_cycle
99 # ..and clean up afterwards
100 rm "${S}"/ppc${FPC_ARCH}.new || die
102 # Using the new compiler.
105 emake -j1 PP="${pp}" AS="$(tc-getAS)" rtl_clean
107 emake -j1 PP="${pp}" AS="$(tc-getAS)" rtl packages_all utils
111 emake -j1 PP="${pp}" AS="$(tc-getAS)"
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
125 emake -j1 "$@" compiler_install rtl_install packages_install utils_install
127 dosym ../lib/fpc/${PV}/ppc${FPC_ARCH} /usr/bin/ppc${FPC_ARCH}
129 cd "${S}"/../install/doc || die
130 emake -j1 "$@" installdoc
132 cd "${S}"/../install/man || die
133 emake -j1 "$@" installman
136 cd "${S}"/../../doc || die
138 newdoc "${WORKDIR}"/${P}-fpctoc.htx fpctoc.htx
139 docompress -x /usr/share/doc/${PF}/fpctoc.htx
144 emake -j1 "$@" install
150 emake -j1 PP="${D}"/usr/bin/ppc${FPC_ARCH} "$@" sourceinstall
151 find "${D}"/usr/lib/fpc/${PV}/source -name '*.o' -exec rm {} \;
154 "${D}"/usr/lib/fpc/${PV}/samplecfg "${D}"/usr/lib/fpc/${PV} "${D}"/etc || die
156 sed -i "s:${D}::g" "${D}"/etc/fpc.cfg || die
160 -i "${D}"/etc/fppkg.cfg \
161 -i "${D}"/etc/fppkg/* \
162 -i "${D}"/usr/lib/fpc/${PV}/ide/text/fp*.cfg \
166 rm -r "${D}"/usr/lib/fpc/lexyacc || die
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."