diff --git a/packages/security/openssl/build b/packages/security/openssl/build
deleted file mode 100755
index c8a81c38ac..0000000000
--- a/packages/security/openssl/build
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
-#
-# OpenELEC is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# OpenELEC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with OpenELEC. If not, see .
-################################################################################
-
-. config/options $1
-
-export MAKEFLAGS=-j1
-
-case $TARGET_ARCH in
- i386)
- TARGET=linux-elf
- ;;
- x86_64)
- TARGET=linux-x86_64
- ;;
- arm)
- TARGET=linux-armv4
- ;;
- powerpc)
- TARGET=linux-ppc
- ;;
- powerpc64)
- TARGET=linux-ppc64
- ;;
-esac
-
-cd $PKG_BUILD
-./Configure --prefix=/usr \
- --libdir=lib \
- --openssldir="$SSL_CERTIFICATES" \
- --install_prefix="$SYSROOT_PREFIX" \
- shared \
- threads \
- zlib \
- enable-camellia \
- enable-seed \
- enable-tlsext \
- enable-rfc3779 \
- enable-cms \
- enable-md2 \
- no-krb5 \
- no-mdc2 \
- no-rc5 \
- no-ec \
- no-ec2m \
- no-ecdh \
- no-ecdsa \
- no-srp \
- $TARGET
-
-make CC="$CC" \
- AR="$AR r" \
- RANLIB="$RANLIB" \
- MAKEDEPPROG="$CC" \
- depend all build-shared install
-
-$STRIP apps/openssl
diff --git a/packages/security/openssl/install b/packages/security/openssl/install
deleted file mode 100755
index df154636bc..0000000000
--- a/packages/security/openssl/install
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
-#
-# OpenELEC is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# OpenELEC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with OpenELEC. If not, see .
-################################################################################
-
-. config/options $1
-
-mkdir -p $INSTALL/$SSL_CERTIFICATES
- cp -P $PKG_BUILD/apps/openssl.cnf $INSTALL/$SSL_CERTIFICATES
-
-mkdir -p $INSTALL/usr/bin
- cp -P $PKG_BUILD/apps/openssl $INSTALL/usr/bin
-
-mkdir -p $INSTALL/usr/lib
- cp -P $PKG_BUILD/libcrypto.so* $INSTALL/usr/lib
- cp -P $PKG_BUILD/libssl.so* $INSTALL/usr/lib
-
-mkdir -p $INSTALL/usr/lib/engines
- cp -P $PKG_BUILD/engines/*.so $INSTALL/usr/lib/engines
diff --git a/packages/security/openssl/meta b/packages/security/openssl/package.mk
similarity index 55%
rename from packages/security/openssl/meta
rename to packages/security/openssl/package.mk
index 0991d25260..f923a769a4 100644
--- a/packages/security/openssl/meta
+++ b/packages/security/openssl/package.mk
@@ -24,11 +24,79 @@ PKG_LICENSE="OSS"
PKG_SITE="http://www.openssl.org/"
PKG_URL="http://www.openssl.org/source/$PKG_NAME-$PKG_VERSION.tar.gz"
PKG_DEPENDS="zlib ca-certification"
-PKG_BUILD_DEPENDS="toolchain zlib"
+PKG_BUILD_DEPENDS_TARGET="toolchain zlib"
PKG_PRIORITY="optional"
PKG_SECTION="security"
PKG_SHORTDESC="openssl: Open Source toolkit for Secure Sockets Layer and Transport Layer Security"
PKG_LONGDESC="The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, fully featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library. The project is managed by a worldwide community of volunteers that use the Internet to communicate, plan, and develop the OpenSSL toolkit and its related documentation."
-PKG_IS_ADDON="no"
+PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
+
+pre_configure_target() {
+ export MAKEFLAGS=-j1
+
+ case $TARGET_ARCH in
+ i386)
+ OPENSSL_TARGET=linux-elf
+ ;;
+ x86_64)
+ OPENSSL_TARGET=linux-x86_64
+ ;;
+ arm)
+ OPENSSL_TARGET=linux-armv4
+ ;;
+ powerpc)
+ OPENSSL_TARGET=linux-ppc
+ ;;
+ powerpc64)
+ OPENSSL_TARGET=linux-ppc64
+ ;;
+ esac
+}
+
+configure_target() {
+ ./Configure --prefix=/usr \
+ --libdir=lib \
+ --openssldir="$SSL_CERTIFICATES" \
+ shared \
+ threads \
+ zlib \
+ enable-camellia \
+ enable-seed \
+ enable-tlsext \
+ enable-rfc3779 \
+ enable-cms \
+ enable-md2 \
+ no-krb5 \
+ no-mdc2 \
+ no-rc5 \
+ no-ec \
+ no-ec2m \
+ no-ecdh \
+ no-ecdsa \
+ no-srp \
+ $OPENSSL_TARGET
+}
+
+make_target() {
+ make CC="$CC" \
+ AR="$AR r" \
+ RANLIB="$RANLIB" \
+ MAKEDEPPROG="$CC" \
+ depend all build-shared
+
+}
+
+makeinstall_target() {
+ make INSTALL_PREFIX=$SYSROOT_PREFIX install
+ make INSTALL_PREFIX=$INSTALL install
+ chmod 755 $INSTALL/usr/lib/*.so*
+ chmod 755 $INSTALL/usr/lib/engines/*.so
+}
+
+post_makeinstall_target() {
+ rm -rf $INSTALL/etc/pki/tls/misc
+ rm -rf $INSTALL/usr/bin/c_rehash
+ $STRIP $INSTALL/usr/bin/openssl
+}