lpeg-1.0.2-r101.ebuild 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. LUA_COMPAT=( lua5-{1..4} luajit )
  5. inherit lua flag-o-matic toolchain-funcs
  6. DESCRIPTION="Parsing Expression Grammars for Lua"
  7. HOMEPAGE="http://www.inf.puc-rio.br/~roberto/lpeg/"
  8. SRC_URI="http://www.inf.puc-rio.br/~roberto/${PN}/${P}.tar.gz"
  9. LICENSE="MIT"
  10. SLOT="0"
  11. KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv sparc x86 ~x64-macos"
  12. IUSE="test debug doc"
  13. REQUIRED_USE="${LUA_REQUIRED_USE}"
  14. RESTRICT="!test? ( test )"
  15. RDEPEND="${LUA_DEPS}"
  16. DEPEND="${RDEPEND}"
  17. BDEPEND="
  18. virtual/pkgconfig
  19. test? ( ${RDEPEND} )
  20. "
  21. DOCS=( HISTORY )
  22. HTML_DOCS=( lpeg.html re.html )
  23. PATCHES=( "${FILESDIR}"/${PN}-1.0.2-makefile.patch )
  24. lua_src_prepare() {
  25. if ! test -d "${S}.${ELUA}/" ; then
  26. cp -ral "${S}/" "${S}.${ELUA}/" || die
  27. fi
  28. }
  29. src_prepare() {
  30. default
  31. use debug && append-cflags -DLPEG_DEBUG
  32. if [[ ${CHOST} == *-darwin* ]] ; then
  33. append-ldflags "-undefined dynamic_lookup"
  34. fi
  35. lua_foreach_impl lua_src_prepare
  36. }
  37. lua_src_compile() {
  38. cd "${S}.${ELUA}/" || die
  39. emake CC="$(tc-getCC)" LUADIR="$(lua_get_include_dir)"
  40. }
  41. src_compile() {
  42. lua_foreach_impl lua_src_compile
  43. }
  44. lua_src_test() {
  45. cd "${S}.${ELUA}/" || die
  46. ${ELUA} test.lua || die
  47. }
  48. src_test() {
  49. lua_foreach_impl lua_src_test
  50. }
  51. lua_src_install() {
  52. cd "${S}.${ELUA}/" || die
  53. local instdir
  54. instdir="$(lua_get_cmod_dir)"
  55. exeinto "${instdir#${ESYSROOT#${EPREFIX}}}"
  56. doexe lpeg.so
  57. instdir="$(lua_get_lmod_dir)"
  58. insinto "${instdir#${ESYSROOT#${EPREFIX}}}"
  59. doins re.lua
  60. if [[ ${CHOST} == *-darwin* ]] ; then
  61. local luav=$(lua_get_version)
  62. # we only want the major version (e.g. 5.1)
  63. local luamv=${luav:0:3}
  64. local file="lua/${luamv}/lpeg.so"
  65. install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${file}" "${ED}/usr/$(get_libdir)/${file}" || die "Failed to adjust install_name"
  66. fi
  67. }
  68. src_install() {
  69. lua_foreach_impl lua_src_install
  70. cd "${S}" || die
  71. use doc && einstalldocs
  72. }