From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 3 Oct 2015 14:36:35 +0000 (+0200)
Subject: dev-lua/lua-openssl: new package
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=refs%2Fremotes%2Fgithub%2Fpr%2F149;p=gentoo.git

dev-lua/lua-openssl: new package
---

diff --git a/dev-lua/lua-openssl/Manifest b/dev-lua/lua-openssl/Manifest
new file mode 100644
index 000000000000..1b7e99dfdf8b
--- /dev/null
+++ b/dev-lua/lua-openssl/Manifest
@@ -0,0 +1 @@
+DIST lua-openssl-0.4.1.tar.gz 363525 SHA256 cce51e33b07b6450854d2e57e129b5f369b749a780d58c44719c834f198ee340 SHA512 c6deda86f77f9d6de1863611db9eb82506ea9789ec0425cb40cdb7d142d53aa633d53e1446b7eeb464636261385822d9cedc841bd35163931cc3758e7c3a308d WHIRLPOOL cbb5367bc7b716bcde731340339e7dafc3b4c5a542e1cf30e4fcf1d6c720e4f49676afe33f77860ab1da0a55b6dde434d0c312ae42c96765512494c6e8bbeb49
diff --git a/dev-lua/lua-openssl/files/lua-openssl-0.4.1-Makefile.patch b/dev-lua/lua-openssl/files/lua-openssl-0.4.1-Makefile.patch
new file mode 100644
index 000000000000..bf5374ee90cd
--- /dev/null
+++ b/dev-lua/lua-openssl/files/lua-openssl-0.4.1-Makefile.patch
@@ -0,0 +1,86 @@
+From: Jakub Jirutka <jakub@jirutka.cz>
+
+Fix Makefile to respect system CFLAGS, LDFLAGS, and CC provided by environment.
+Allow to specify pkg-config command using variable, to be friendly with
+cross-compiling etc.
+
+diff --git a/Makefile b/Makefile
+index 195ef6b..375fb65 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2,9 +2,10 @@ T=openssl
+ 
+ PREFIX		?=/usr/local
+ LIB_OPTION	?= -shared 
++PKG_CONFIG	?= pkg-config
+ 
+ #Lua auto detect
+-LUA_VERSION ?= $(shell pkg-config luajit --print-provides)
++LUA_VERSION ?= $(shell $(PKG_CONFIG) luajit --print-provides)
+ ifeq ($(LUA_VERSION),)                         ############ Not use luajit
+ LUAV		?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
+ LUA_CFLAGS	?= -I$(PREFIX)/include/lua$(LUAV)
+@@ -12,8 +13,8 @@ LUA_LIBS	?= -L$(PREFIX)/lib
+ LUA_LIBDIR	?= $(PREFIX)/lib/lua/$(LUAV)
+ else
+ LUAV		?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
+-LUA_CFLAGS	?= $(shell pkg-config luajit --cflags)
+-LUA_LIBS	?= $(shell pkg-config luajit --libs)
++LUA_CFLAGS	?= $(shell $(PKG_CONFIG) luajit --cflags)
++LUA_LIBS	?= $(shell $(PKG_CONFIG) luajit --libs)
+ LUA_LIBDIR	?= $(PREFIX)/lib/lua/$(LUAV)
+ endif
+ 
+@@ -22,30 +23,30 @@ SYS := $(shell gcc -dumpmachine)
+ 
+ ifneq (, $(findstring linux, $(SYS)))
+ # Do linux things
+-LDFLAGS		    = -fPIC -lrt -ldl
+-OPENSSL_LIBS	?= $(shell pkg-config openssl --libs) 
+-OPENSSL_CFLAGS	?= $(shell pkg-config openssl --cflags)
+-CFLAGS		    = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
++LDFLAGS		    += -fPIC -lrt -ldl
++OPENSSL_LIBS	?= $(shell $(PKG_CONFIG) openssl --libs) 
++OPENSSL_CFLAGS	?= $(shell $(PKG_CONFIG) openssl --cflags)
++CFLAGS		    += -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
+ endif
+ ifneq (, $(findstring apple, $(SYS)))
+ # Do darwin things
+-LDFLAGS		    = -fPIC -lrt -ldl
+-OPENSSL_LIBS	?= $(shell pkg-config openssl --libs) 
+-OPENSSL_CFLAGS	?= $(shell pkg-config openssl --cflags)
+-CFLAGS		    = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
++LDFLAGS		    += -fPIC -lrt -ldl
++OPENSSL_LIBS	?= $(shell $(PKG_CONFIG) openssl --libs) 
++OPENSSL_CFLAGS	?= $(shell $(PKG_CONFIG) openssl --cflags)
++CFLAGS		    += -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
+ endif
+ ifneq (, $(findstring mingw, $(SYS)))
+ # Do mingw things
+ V			= $(shell lua -e "v=string.gsub('$(LUAV)','%.','');print(v)")
+-LDFLAGS		= -mwindows -lcrypt32 -lssl -lcrypto -lws2_32 $(PREFIX)/bin/lua$(V).dll 
++LDFLAGS		+= -mwindows -lcrypt32 -lssl -lcrypto -lws2_32 $(PREFIX)/bin/lua$(V).dll
+ LUA_CFLAGS	= -DLUA_LIB -DLUA_BUILD_AS_DLL -I$(PREFIX)/include/
+-CFLAGS		= $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
++CFLAGS		+= $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
+ endif
+ ifneq (, $(findstring cygwin, $(SYS)))
+ # Do cygwin things
+-OPENSSL_LIBS	?= $(shell pkg-config openssl --libs) 
+-OPENSSL_CFLAGS  ?= $(shell pkg-config openssl --cflags)
+-CFLAGS		= -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
++OPENSSL_LIBS	?= $(shell $(PKG_CONFIG) openssl --libs) 
++OPENSSL_CFLAGS  ?= $(shell $(PKG_CONFIG) openssl --cflags)
++CFLAGS		+= -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
+ endif
+ #custome config
+ ifeq (.config, $(wildcard .config))
+@@ -61,7 +62,7 @@ WARN_MOST	= -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnest
+ WARN		= -Wall -Wno-unused-value
+ WARN_MIN	= 
+ CFLAGS		+= $(WARN_MIN) -DPTHREADS 
+-CC= gcc -g $(CFLAGS) -Ideps
++CC			?= gcc -g $(CFLAGS) -Ideps
+ 
+ 
+ OBJS=src/asn1.o src/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o \
diff --git a/dev-lua/lua-openssl/lua-openssl-0.4.1.ebuild b/dev-lua/lua-openssl/lua-openssl-0.4.1.ebuild
new file mode 100644
index 000000000000..94b2ce6f3183
--- /dev/null
+++ b/dev-lua/lua-openssl/lua-openssl-0.4.1.ebuild
@@ -0,0 +1,45 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit eutils toolchain-funcs
+
+DESCRIPTION="OpenSSL binding for Lua"
+HOMEPAGE="https://github.com/zhaozg/lua-openssl"
+SRC_URI="https://github.com/zhaozg/lua-openssl/archive/${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="MIT openssl PHP-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="luajit"
+
+RDEPEND="
+	luajit? ( dev-lang/luajit:2 )
+	!luajit? ( >=dev-lang/lua-5.1:0 )
+	dev-libs/openssl:0"
+DEPEND="${RDEPEND}
+	virtual/pkgconfig"
+
+src_prepare() {
+	epatch "${FILESDIR}/${P}-Makefile.patch"
+	use luajit && LUAV=luajit || LUAV=lua
+}
+
+src_compile() {
+	local pkgconfig=$(tc-getPKG_CONFIG)
+	emake \
+		CC="$(tc-getCC) \$(CFLAGS) -Ideps" \
+		PKG_CONFIG="$pkgconfig" \
+		LUA_CFLAGS="$($pkgconfig --cflags $LUAV)" \
+		LUA_LIBS="$($pkgconfig --libs $LUAV)" \
+		LUA_LIBDIR="$($pkgconfig --variable INSTALL_CMOD $LUAV)"
+}
+
+src_install() {
+	emake \
+		LUA_LIBDIR="${D}$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD $LUAV)" \
+		install
+	einstalldocs
+}
diff --git a/dev-lua/lua-openssl/metadata.xml b/dev-lua/lua-openssl/metadata.xml
new file mode 100644
index 000000000000..ea456936e173
--- /dev/null
+++ b/dev-lua/lua-openssl/metadata.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<herd>proxy-maintainers</herd>
+	<maintainer>
+		<email>jakub@jirutka.cz</email>
+		<name>Jakub Jirutka</name>
+	</maintainer>
+	<use>
+		<flag name="luajit">Use <pkg>dev-lang/luajit</pkg> instead of
+			<pkg>dev-lang/lua</pkg></flag>
+	</use>
+	<upstream>
+		<remote-id type="github">zhaozg/lua-openssl</remote-id>
+	</upstream>
+</pkgmetadata>