eclass/lua.eclass
author Rafael G. Martins <rafael@rafaelmartins.eng.br>
Sun, 19 Jun 2011 02:00:09 -0300
changeset 59 0bb6a8f19c70
permissions -rw-r--r--
Fixed python dep.

(Portage version: 2.2.0_alpha41/hg/Linux x86_64, signed Manifest commit with key 0293536F)
     1 # Copyright 1999-2009 Gentoo Foundation
     2 # Distributed under the terms of the GNU General Public License v2
     3 # $Header: $
     4 
     5 # @ECLASS: lua.eclass
     6 # @MAINTAINER: rafael@rafaelmartins.com
     7 # @BLURB: A utility eclass that should be inherited by anything that deals with
     8 # Lua modules.
     9 # @DESCRIPTION: Some useful functions for dealing with Lua. Based on Python eclass
    10 
    11 inherit multilib
    12 
    13 if [[ -n "${NEED_LUA}" ]]; then
    14 	LUA_ATOM=">=dev-lang/lua-${NEED_LUA}"
    15 else
    16 	LUA_ATOM="dev-lang/lua"
    17 fi
    18 
    19 DEPEND="${LUA_ATOM}"
    20 RDEPEND="${DEPEND}"
    21 
    22 __lua_version_extract() {
    23 	local verstr=$1
    24 	export LUAVER_MAJOR=${verstr:0:1}
    25 	export LUAVER_MINOR=${verstr:2:1}
    26 	if [[ ${verstr:3:1} == . ]]; then
    27 		export LUAVER_MICRO=${verstr:4}
    28 	fi
    29 	export LUAVER="${LUAVER_MAJOR}.${LUAVER_MINOR}"
    30 }
    31 
    32 __lua_version() {
    33 	[[ -n "${LUAVER}" ]] && return 0
    34 	local tmparr
    35 	lua=${lua:-/usr/bin/lua}
    36 	tmparr=( $(${lua} -v 2>&1 ) )
    37 	export LUAVER_ALL="${tmparr[1]}"
    38 	__lua_version_extract $LUAVER_ALL
    39 }
    40 
    41 __lua_install_paths() {
    42 	export LUA_LMOD="/usr/share/lua/${LUAVER}"
    43 	export LUA_CMOD="/usr/$(get_libdir)/lua/${LUAVER}"
    44 }
    45 
    46 
    47 lua_cmodules_install() {
    48 	local module=$(basename ${1})
    49 	einfo "Installing shared object module: ${2}/${module}"
    50 	install -Dm0755 "${1}" "${D}/${LUA_CMOD}/${2:-.}/${module}"
    51 }
    52 
    53 lua_lmodules_install() {
    54 	local module=$(basename ${1})
    55 	einfo "Installing Lua Module: ${2}/${module}"
    56 	install -Dm0644 "${1}" "${D}/${LUA_LMOD}/${2:-.}/${module}"
    57 }
    58 
    59 __lua_version
    60 __lua_install_paths