fpc-2.6.4.ebuild 4.7 KB

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