summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3c4f5b0e17f22c828a236a7708d8d370aaaaa1bc (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Maintainer: Gonzalo Exequiel Pedone <hipersayan DOT x AT gmail DOT com>
# Contributor: Karl-Felix Glatzer <karl.glatzer@gmx.de>
# Contributor: Antonio Rojas <arojas@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: ice-man <icemanf@gmail.com>
# Contributor: sergeantspoon <sergeantspoon@archlinux.us>
# Contributor: Alexey Pavlov <alexpux@gmail.com>

_android_arch=x86

pkgname=android-${_android_arch}-libssh
pkgver=0.11.1
pkgrel=1
arch=('any')
pkgdesc="Library for accessing ssh client services through C libraries (Android ${_android_arch})"
license=('LGPL')
url="https://www.libssh.org/"
groups=('android-libssh')
depends=("android-${_android_arch}-zlib"
         "android-${_android_arch}-openssl")
makedepends=('android-cmake'
             'doxygen'
             'python')
options=(!strip !buildflags staticlibs !emptydirs)
source=("https://www.libssh.org/files/${pkgver%.*}/libssh-${pkgver}.tar.xz"
        '0001-Fix-static-lib.patch'
        '0002-Disable-getifaddrs.patch')
md5sums=('93e6fe0c9effb216a48b8b6bc1e4a576'
         '66588a420aac9c580c31018a5b1c78cf'
         '063230102f24f4bcb8aea86575e00def')

prepare() {
    cd "${srcdir}/libssh-${pkgver}"
    source android-env ${_android_arch}

    # Disable automatic detection of openssl since it picks up openssl-1.0
    sed 's/find_package(OpenSSL)/#find_package(OpenSSL)/' -i CMakeLists.txt

    patch -Np1 -i ../0001-Fix-static-lib.patch

    if [ "${ANDROID_MINIMUM_PLATFORM}" -lt 24 ]; then
        patch -Np1 -i ../0002-Disable-getifaddrs.patch
    fi
}

build() {
    cd "${srcdir}/libssh-${pkgver}"
    source android-env ${_android_arch}

    export CFLAGS="${CFLAGS} -D__USE_BSD"
    export CXXFLAGS="${CXXFLAGS} -D__USE_BSD"

    version=$(cat "${ANDROID_PREFIX_INCLUDE}/openssl/opensslv.h" | grep "OPENSSL_VERSION_TEXT" | sed 's/^[^\"]*"OpenSSL //' | sed 's/ .*$//')

    android-${_android_arch}-cmake \
        -S . \
        -B build-shared \
        -DWITH_GSSAPI=OFF \
        -DBUILD_SHARED_LIBS=ON \
        -DOPENSSL_FOUND=ON \
        -DOPENSSL_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DOPENSSL_SSL_LIBRARY="${ANDROID_PREFIX_LIB}/libssl.so" \
        -DOPENSSL_CRYPTO_LIBRARY="${ANDROID_PREFIX_LIB}/libcrypto.so" \
        -DOPENSSL_VERSION="${version}" \
        -DUNIT_TESTING=OFF \
        -DWITH_EXAMPLES=OFF
    make -C build-shared $MAKEFLAGS

    android-${_android_arch}-cmake \
        -S . \
        -B build-static \
        -DWITH_GSSAPI=OFF \
        -DBUILD_SHARED_LIBS=OFF \
        -DOPENSSL_FOUND=ON \
        -DOPENSSL_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DOPENSSL_SSL_LIBRARY="${ANDROID_PREFIX_LIB}/libssl.a" \
        -DOPENSSL_CRYPTO_LIBRARY="${ANDROID_PREFIX_LIB}/libcrypto.a" \
        -DOPENSSL_VERSION="${version}" \
        -DUNIT_TESTING=OFF \
        -DWITH_EXAMPLES=OFF
    make -C build-static $MAKEFLAGS
}

package(){
    cd "${srcdir}/libssh-${pkgver}"
    source android-env ${_android_arch}

    make -C build-shared DESTDIR="${pkgdir}" install
    make -C build-static DESTDIR="${pkgdir}" install
    ${ANDROID_STRIP} -g --strip-unneeded "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.so
    ${ANDROID_STRIP} -g "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.a
}