summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ee7d5b6fe60c27b0a22da4ccd019f58b99bd6cf3 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Maintainer: Daniel Bermond < yahoo-com: danielbermond >

pkgname=intel-media-sdk-git
pkgver=1.2a.r16.gc3ba904
pkgrel=1
pkgdesc='API to access hardware-accelerated video decode, encode and filtering on Intel platforms with integrated graphics (git version)'
arch=('x86_64')
url='https://github.com/Intel-Media-SDK/MediaSDK/'
license=('MIT')
depends=(
    # AUR:
        'libva-git' 'intel-media-driver-git'
)
makedepends=(
    # official repositories:
        'git' 'perl' 'cmake'
    # AUR:
        'git-lfs' 'gcc49'
)
provides=('intel-media-sdk' 'libmfx')
conflicts=('intel-media-sdk' 'libmfx')
source=('intel-media-sdk-change-gcc-version.patch'
        'intel-media-sdk-detect-intel-opencl.patch'
        'intel-media-sdk-add-runtime-libraries.patch')
sha256sums=('d9fc114d06624504891b545df2913b01d4b07edfb99512388490eae40f9b9ab7'
            '689ebc270532c0e1e5132d39898ff2a93fe3483a5a2673aea396a24fc07ad24c'
            '8bbbbe1729c54980103c7ab76815a565df7427ce44bd2789c891a1d521e1f737')

prepare() {
    # makepkg does not support cloning git-lfs repositories
    if [ -d "$pkgname" ] 
    then
        msg2 "Updating '${pkgname}' git repo..."
        cd "$pkgname"
        git pull origin
    else
        msg2 "Cloning '${pkgname}' git repo..."
        git lfs install
        git clone https://github.com/Intel-Media-SDK/MediaSDK.git "$pkgname"
        cd "$pkgname"
    fi
    
    for _patch in intel-media-sdk-change-gcc-version.patch \
                  intel-media-sdk-detect-intel-opencl.patch \
                  intel-media-sdk-add-runtime-libraries.patch
    do
        printf '%s\n' "Checking patch '${_patch}'"
        if patch -Np1 --dry-run -i "${srcdir}/${_patch}" >/dev/null
        then
            patch -Np1 -i "${srcdir}/${_patch}"
        fi
    done
}

pkgver() {
    cd "$pkgname"
    
    # git, tags available
    git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//;s/,//'
}

build() {
    cd "$pkgname"
    
    export MFX_HOME="$(pwd)"
    
    export CFLAGS="$(  printf '%s' "$CFLAGS"   | sed 's/-fno-plt//')"
    export CXXFLAGS="$(printf '%s' "$CXXFLAGS" | sed 's/-fno-plt//')"
    
    perl tools/builder/build_mfx.pl \
                            --no-warn-as-error \
                            --cmake='intel64.make.release' \
                            --prefix='/usr' \
    
    make -C __cmake/intel64.make.release
}

package() {
    cd "$pkgname"
    
    make \
        -C __cmake/intel64.make.release \
        DESTDIR="$pkgdir" \
        install
    
    mv -f  "${pkgdir}/usr/lib64" "${pkgdir}/usr/lib"
    
    mkdir -p "${pkgdir}/usr/"{include/mfx,lib/"$pkgname"}
    
    # move samples to a better place
    mv -f "${pkgdir}/usr/samples" "${pkgdir}/usr/lib/${pkgname}"
    
    # license
    cd "${srcdir}/${pkgname}"
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    
    # bellow are fixes for ffmpeg (some paths are hardcoded, use symlinks)
    
    # includes
    cd "${pkgdir}/usr/include"
    for _header in *.h
    do
        cd mfx
        ln -sf ../"$_header" "$_header"
        cd ..
    done
    
    # plugins
    cd "${pkgdir}/usr/plugins"
    for _plugin in *
    do
        ln -sf ../plugins/"$_plugin" ../lib/"$_plugin"
    done
    
    # pkgconfig file
    cd "${pkgdir}/usr/lib/pkgconfig"
    ln -sf mfx.pc libmfx.pc
}