# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com>
pkgname=lua-socket
_name=luasocket
pkgver=3.0_rc1_git20160306
pkgrel=0
_ver=${pkgver%_git*}
_ver=$(printf '%s' "$_ver" | sed 's/_rc/-rc/')
pkgdesc="Networking library for Lua"
url="http://luaforge.net/projects/luasocket/"
arch="all"
license="MIT"
depends="lua5.3"
makedepends="lua5.3-dev"
source="luasocket-$_ver.tar.gz::https://github.com/diegonehab/luasocket/archive/v$_ver.tar.gz
	git.patch
	lua-cflags.patch
	0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch"
builddir="$srcdir/$_name-$_ver"

build() {
	cd "$builddir"
	make LUAV=""
}

check() {
	cd "$builddir"
	mkdir -p src/socket && cp src/socket-$_ver.so src/socket/core.so
	mkdir -p src/mime   && cp src/mime-1.0.3.so src/mime/core.so
	LUA_CPATH=./src/?.so LUA_PATH="./src/?.lua;;" lua test/hello.lua
}

package() {
	cd "$builddir"
	make prefix=/usr DESTDIR="$pkgdir" LUAV="5.3" install-unix
}

sha512sums="f6efce259aaacaa11472911471f8a13b118fe009b8953a82c6aa18b9ec829cd1293180904e56935cb130d36d267e3f27c91db2d78e03f7488f3e100571ed0540  luasocket-3.0-rc1.tar.gz
45c80e488fedc879f0217bc8a654d80da003039f5d1ff21b0dea0eb769151787dbe793e44a3dfd72cb07ff2697eceaf4fc7b55b4634cd170fa71281f19f025a5  git.patch
61c15238a2f116b7239fdbdb8f617c82dbbecd0117c6e8389b12015bf07f3978299a8e8995e93a45a23530c747662b08d161073cdb6a8e07c4f449e45856e8cb  lua-cflags.patch
c45a12e17771a1b3b71154b5415421f524cd10b7969b4649a5f37b652cdc826721e117edb8fe64758d3520e59946e2f755b814f72cbb39ff42bf59bbcf9a64e9  0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch"