summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d1845f8ddda3999aa6c6fec6e84ffb1a5670d39c (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
# Maintainer: Patrick Northon <northon_patrick3@yahoo.ca>
# Contributor: Andrew Sun <adsun701@gmail.com>

_pkgname=kvazaar
pkgname=mingw-w64-${_pkgname}
pkgver=2.3.1
pkgrel=1
pkgdesc="An open-source HEVC encoder (mingw-w64)"
arch=('any')
url='http://ultravideo.cs.tut.fi/#encoder'
license=('LGPL')
depends=('mingw-w64-crt')
makedepends=('mingw-w64-cmake' 'mingw-w64-crypto++' 'ninja')
options=('!strip' '!buildflags' 'staticlibs')
source=("${_pkgname}-${pkgver}.tar.gz"::"https://github.com/ultravideo/kvazaar/archive/v${pkgver}.tar.gz")
sha256sums=('c5a1699d0bd50bc6bdba485b3438a5681a43d7b2c4fd6311a144740bfa59c9cc')

_srcdir="${_pkgname}-${pkgver}"
_architectures="i686-w64-mingw32 x86_64-w64-mingw32"
_flags=(
	-Wno-dev
	-DCMAKE_BUILD_TYPE=Release
	-DCMAKE_CXX_FLAGS_RELEASE='-DNDEBUG'
	-DUSE_CRYPTO=ON
)

prepare() {
	cd "${_srcdir}"

	sed -i \
		-e 's|include(FetchContent)|find_package(cryptopp REQUIRED)|' 'CMakeLists.txt' \
		-e 's|if (NOT CRYPTOPP_FOUND)|if (0)|' \
		-e 's|set(BUILD_SHARED_LIBS OFF)||' \
		-e 's|set(EXTRA_LIBS ${EXTRA_LIBS} ${CMAKE_BINARY_DIR}/lib/libcryptopp.a)|target_link_libraries(kvazaar PRIVATE cryptopp::cryptopp)|' \
		'CMakeLists.txt'
}

build() {
	for _arch in ${_architectures}; do
		${_arch}-cmake -G Ninja -S "${_srcdir}" -B "build-${_arch}-static" "${_flags[@]}" \
			-DBUILD_SHARED_LIBS=OFF \
			-DBUILD_TESTS=OFF \
			-DCMAKE_INSTALL_PREFIX="/usr/${_arch}/static"
		cmake --build "build-${_arch}-static"

		${_arch}-cmake -G Ninja -S "${_srcdir}" -B "build-${_arch}" "${_flags[@]}" \
			-DBUILD_TESTS=OFF
		cmake --build "build-${_arch}"
	done
}

package() {
	for _arch in ${_architectures}; do
		DESTDIR="${pkgdir}" cmake --install "build-${_arch}-static"
		${_arch}-strip -g "$pkgdir"/usr/${_arch}/static/lib/*.a
		rm -rf "$pkgdir/usr/${_arch}/static/bin"
		rm -rf "$pkgdir/usr/${_arch}/static/share"

		DESTDIR="${pkgdir}" cmake --install "build-${_arch}"
		${_arch}-strip --strip-unneeded "$pkgdir"/usr/${_arch}/bin/*.dll
		${_arch}-strip -g "$pkgdir"/usr/${_arch}/lib/*.a
		rm -rf "$pkgdir/usr/${_arch}/share"
	done
}