summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c7240db327811dba752911b1b030a89ea08ead93 (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
94
95
96
97
# Maintainer: Gonzalo Exequiel Pedone <hipersayan DOT x AT gmail DOT com>
# Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Eric BĂ©langer <eric@archlinux.org>

_android_arch=armv7a-eabi

pkgname=android-${_android_arch}-flac
pkgver=1.4.3
pkgrel=2
arch=('any')
pkgdesc="Free Lossless Audio Codec (Android ${_android_arch})"
url='https://xiph.org/flac/'
license=('BSD'
         'GPL')
depends=("android-${_android_arch}-libogg")
makedepends=('android-cmake'
             'nasm')
options=(!strip !buildflags staticlibs !emptydirs)
source=("https://github.com/xiph/flac/releases/download/${pkgver}/flac-${pkgver}.tar.xz")
sha256sums=('6c58e69cd22348f441b861092b825e591d0b822e106de6eb0ee4d05d27205b70')

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

    # Shorten tests
    sed -i 's/FLAC__TEST_LEVEL=1/FLAC__TEST_LEVEL=0/' test/CMakeLists.txt

    if [ "${ANDROID_MINIMUM_PLATFORM}" -lt 24 ]; then
        files=(include/FLAC/callback.h
               include/FLAC/stream_decoder.h
               include/FLAC/stream_encoder.h
               include/share/compat.h
               src/flac/decode.c
               src/flac/encode.c
               src/flac/foreign_metadata.c
               src/flac/iffscan.c
               src/libFLAC/metadata_iterators.c
               src/libFLAC/stream_decoder.c
               src/libFLAC/stream_encoder.c
               src/test_libFLAC++/decoders.cpp
               src/test_libFLAC++/encoders.cpp
               src/test_libFLAC++/metadata_manip.cpp
               src/test_libFLAC/decoders.c
               src/test_libFLAC/encoders.c
               src/test_libFLAC/metadata_manip.c
               src/utils/flacdiff/main.cpp)

        for f in "${files[@]}"; do
            sed -i 's|fseeko|fseek|g' $f
            sed -i 's|ftello|ftell|g' $f
        done
    fi
}

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

    android-${_android_arch}-cmake \
        -S . \
        -B build-shared \
        -DBUILD_SHARED_LIBS=ON \
        -DBUILD_DOCS=OFF \
        -DBUILD_EXAMPLES=OFF \
        -DBUILD_PROGRAMS=OFF \
        -DINSTALL_MANPAGES=OFF \
        -DBUILD_TESTING=OFF \
        -DWITH_STACK_PROTECTOR=OFF \
        -DOGG_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DOGG_LIBRARY="${ANDROID_PREFIX_LIB}/libogg.so"
    make -C build-shared $MAKEFLAGS

    android-${_android_arch}-cmake \
        -S . \
        -B build-static \
        -DBUILD_SHARED_LIBS=OFF \
        -DBUILD_DOCS=OFF \
        -DBUILD_EXAMPLES=OFF \
        -DBUILD_PROGRAMS=OFF \
        -DINSTALL_MANPAGES=OFF \
        -DBUILD_TESTING=OFF \
        -DWITH_STACK_PROTECTOR=OFF \
        -DOGG_INCLUDE_DIR="${ANDROID_PREFIX_INCLUDE}" \
        -DOGG_LIBRARY="${ANDROID_PREFIX_LIB}/libogg.a"
    make -C build-static $MAKEFLAGS
}

package() {
    cd "${srcdir}/flac-${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
}