fpc-3.0.2.ebuild 4.1 KB

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