summaryrefslogtreecommitdiff
blob: c6f529263025a96154037595ee731dead85d5409 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit toolchain-funcs

MY_PV=${PV//./_}

DESCRIPTION="File System Library for the Lua Programming Language"
HOMEPAGE="https://keplerproject.github.io/luafilesystem/"
SRC_URI="https://github.com/keplerproject/luafilesystem/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~x86"
IUSE="luajit test"

RESTRICT="!test? ( test )"

RDEPEND="
	>=dev-lang/lua-5.1:*
	luajit? ( dev-lang/luajit:2 )"
BDEPEND="
	virtual/pkgconfig
	test? ( ${RDEPEND} )"
DEPEND="${RDEPEND}"

S="${WORKDIR}/${PN}-${MY_PV}"

src_configure() {
	cat > config <<-EOF
		# Installation directories

		# Default installation prefix
		PREFIX="${ED}/$($(tc-getPKG_CONFIG) --variable exec_prefix $(usex luajit 'luajit' 'lua'))"

		# System's libraries directory (where binary libraries are installed)
		LUA_LIBDIR="${ED}/$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD $(usex luajit 'luajit' 'lua'))"

		# Lua includes directory
		LUA_INC=-I$(pwd)/src
		LUA_INC+=-I$($(tc-getPKG_CONFIG) --variable includedir $(usex luajit 'luajit' 'lua'))

		# OS dependent
		LIB_OPTION=-shared #for Linux

		LIBNAME=$T.so.$V

		# Compilation directives
		WARN=-O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
		INCS=\$(LUA_INC)
		CFLAGS=\$(WARN) \$(INCS)
		CC=gcc
	EOF
}

src_test() {
	LUA_CPATH=./src/?.so $(usex luajit 'luajit' 'lua') tests/test.lua || die
}

src_install() {
	local -a HTML_DOCS=( doc/us )
	einstalldocs

	emake DESTDIR="${D}" install
}