luadbi-0.5-r5.ebuild 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 flag-o-matic eutils
  5. DESCRIPTION="DBI module for Lua"
  6. HOMEPAGE="https://code.google.com/p/luadbi/"
  7. SRC_URI="https://luadbi.googlecode.com/files/${PN}.${PV}.tar.gz"
  8. LICENSE="MIT"
  9. SLOT="0"
  10. KEYWORDS="amd64 ~arm x86"
  11. IUSE="mysql postgres +sqlite"
  12. REQUIRED_USE="|| ( mysql postgres sqlite )"
  13. RDEPEND=">=dev-lang/lua-5.1
  14. mysql? ( virtual/mysql )
  15. postgres? ( dev-db/postgresql )
  16. sqlite? ( >=dev-db/sqlite-3 )"
  17. DEPEND="${RDEPEND}
  18. virtual/pkgconfig"
  19. S="${WORKDIR}"
  20. src_prepare() {
  21. epatch "${FILESDIR}"/${PV}-r2-Makefile.patch
  22. sed -i -e "s#^INSTALL_DIR_LUA=.*#INSTALL_DIR_LUA=$(pkg-config --variable INSTALL_LMOD lua)#" \
  23. -e "s#^INSTALL_DIR_BIN=.*#INSTALL_DIR_BIN=$(pkg-config --variable INSTALL_CMOD lua)#" \
  24. -e "s#^LUA_INC_DIR=.*#LUA_INC_DIR=$(pkg-config --variable INSTALL_INC lua)#" \
  25. -e "s#^LUA_LIB_DIR=.*#LUA_LIB_DIR=$(pkg-config --variable INSTALL_LIB lua)#" \
  26. -e "s#^LUA_LIB =.*#LUA_LIB=lua#" Makefile || die
  27. drivers=""
  28. if use mysql; then
  29. drivers+="mysql "
  30. sed -i -e "s#^\(INCLUDES.*\)#\1 $(mysql_config --include)#" \
  31. -e "s#^\(MYSQL_LDFLAGS=\$(COMMON_LDFLAGS)\).*#\1 $(mysql_config --libs)#" Makefile || die
  32. fi
  33. if use postgres; then
  34. drivers+="psql "
  35. sed -i -e "s#^\(INCLUDES.*\)#\1 -I$(pg_config --includedir) -I$(pg_config --includedir-server)#" \
  36. -e "s#^\(PSQL_LDFLAGS=\$(COMMON_LDFLAGS)\).*#\1 -L$(pg_config --libdir) -lpq#" Makefile || die
  37. fi
  38. use sqlite && drivers+="sqlite3"
  39. }
  40. src_compile() {
  41. append-flags -fPIC
  42. for driver in ${drivers}; do
  43. emake CC="$(tc-getCC)" COMMON_LDFLAGS="${LDFLAGS}" ${driver}
  44. done
  45. }
  46. src_install() {
  47. for driver in ${drivers}; do
  48. emake DESTDIR="${D}" "install_${driver// /}"
  49. done
  50. }