Skip to content

Commit

Permalink
dev-lua/lua-openssl: new package
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Oct 6, 2015
1 parent 8e8cc07 commit 6dc1794
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-lua/lua-openssl/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST lua-openssl-0.4.1.tar.gz 363525 SHA256 cce51e33b07b6450854d2e57e129b5f369b749a780d58c44719c834f198ee340 SHA512 c6deda86f77f9d6de1863611db9eb82506ea9789ec0425cb40cdb7d142d53aa633d53e1446b7eeb464636261385822d9cedc841bd35163931cc3758e7c3a308d WHIRLPOOL cbb5367bc7b716bcde731340339e7dafc3b4c5a542e1cf30e4fcf1d6c720e4f49676afe33f77860ab1da0a55b6dde434d0c312ae42c96765512494c6e8bbeb49
86 changes: 86 additions & 0 deletions dev-lua/lua-openssl/files/lua-openssl-0.4.1-Makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
From: Jakub Jirutka <[email protected]>

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 \
45 changes: 45 additions & 0 deletions dev-lua/lua-openssl/lua-openssl-0.4.1.ebuild
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 16 additions & 0 deletions dev-lua/lua-openssl/metadata.xml
Original file line number Diff line number Diff line change
@@ -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>[email protected]</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>

0 comments on commit 6dc1794

Please sign in to comment.