# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=freerdp
_pkgname=FreeRDP
pkgver=2.11.7
pkgrel=0
pkgdesc="FreeRDP client"
url="https://www.freerdp.com/"
arch="all"
license="Apache-2.0"
options="!check" # As of 2.0.0_rc4 no test suite is available
makedepends="
	alsa-lib-dev
	bsd-compat-headers
	cmake
	cups-dev
	gsm-dev
	gst-plugins-base-dev
	libjpeg-turbo-dev
	libusb-dev
	libxcursor-dev
	libxdamage-dev
	libxi-dev
	libxinerama-dev
	libxkbcommon-dev
	libxkbfile-dev
	libxv-dev
	linux-headers
	openssl-dev>3
	samurai
	wayland-dev
	"
subpackages="$pkgname-doc $pkgname-dev $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/FreeRDP/FreeRDP/archive/$pkgver.tar.gz
	0002-info-Fix-incompatible-pointer-type.patch
	0003-redirection-Fix-incompatible-pointer-type.patch
	0004-redirection-Fix-incompatible-pointer-type.patch
	0005-X11-fix-pointer-integer-type-mismatch.patch
	0006-client-wayland-fix-const-correctness.patch
	0007-warnings-fix-Wincompatible-pointer-types.patch
	0008-server-proxy-deactivate-capture-module.patch
	"
builddir="$srcdir"/$_pkgname-$pkgver

# backwards compat since now merged into main package
provides="freerdp-plugins=$pkgver-r$pkgrel"

# secfixes:
#   2.11.5-r0:
#     - CVE-2024-22211
#   2.9.0-r0:
#     - CVE-2022-39316
#     - CVE-2022-39317
#     - CVE-2022-39318
#     - CVE-2022-39319
#     - CVE-2022-39320
#     - CVE-2022-39347
#     - CVE-2022-41877
#   2.4.1-r0:
#     - CVE-2021-41159
#     - CVE-2021-41160
#   2.2.0-r0:
#     - CVE-2020-15103
#   2.1.2-r0:
#     - CVE-2020-4033
#     - CVE-2020-4031
#     - CVE-2020-4032
#     - CVE-2020-4030
#     - CVE-2020-11099
#     - CVE-2020-11098
#     - CVE-2020-11097
#     - CVE-2020-11095
#     - CVE-2020-11096
#   2.0.0-r1:
#     - CVE-2020-13398
#     - CVE-2020-13397
#     - CVE-2020-13396
#   2.0.0-r0:
#     - CVE-2020-11521
#     - CVE-2020-11522
#     - CVE-2020-11523
#     - CVE-2020-11524
#     - CVE-2020-11525
#     - CVE-2020-11526
#   2.0.0_rc4-r0:
#     - CVE-2018-8786
#     - CVE-2018-8787
#     - CVE-2018-8788
#     - CVE-2018-8789

build() {
	export CFLAGS="$CFLAGS -D_BSD_SOURCE -flto=auto"
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DWITH_ALSA=ON \
		-DWITH_CUPS=ON \
		-DWITH_CHANNELS=ON \
		-DBUILTIN_CHANNELS=OFF \
		-DWITH_DIRECTFB=OFF \
		-DWITH_FFMPEG=OFF \
		-DWITH_GSM=ON \
		-DWITH_GSTREAMER_1_0=ON \
		-DWITH_IPP=OFF \
		-DWITH_JPEG=ON \
		-DWITH_OPENSSL=ON \
		-DWITH_PCSC=OFF \
		-DWITH_PULSE=OFF \
		-DWITH_WAYLAND=ON \
		-DWITH_SERVER=ON \
		-DWITH_X11=ON \
		-DWITH_XCURSOR=ON \
		-DWITH_XEXT=ON \
		-DWITH_XKBFILE=ON \
		-DWITH_XI=ON \
		-DWITH_XINERAMA=ON \
		-DWITH_XRENDER=ON \
		-DWITH_XV=ON \
		-DWITH_ZLIB=ON \
		-DWITH_NEON=OFF
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

libs() {
	default_libs
	amove usr/lib/freerdp2
}

sha512sums="
3a308346b2825a06f60e4c3eaf335c151351ecc6e4b990d63d3ef4da1bc6e6de3fb77aefd041bad4bcb40b9269d9ea8d627ac24786c927e4eaaaac2d4ae4b4b9  freerdp-2.11.7.tar.gz
dadede89434f26df987ad435b9cea9530bdc20f7042c25587c4a51dbcbbb57ad88669dc142a84a0beb5c71864aa6e486a8896908b7072e2960fcbab21ffca05a  0002-info-Fix-incompatible-pointer-type.patch
a9f6f00b990ced8e26ea15fcfa7f1bef311fa9b16e80ab709ffe6e5edac1f07b6713fa7f3ceb5e81bfe5c0dd74e3994472e9b6543e9173c0b3204e22d0f1aec9  0003-redirection-Fix-incompatible-pointer-type.patch
662c2d868c41c77d0f3f2020d65119a1f8ad0bbac2127aa4dcb1cfdd6294357f481c253c06e71273d08a9ccf8c378af89ae4ee2f25259190768b248b07633248  0004-redirection-Fix-incompatible-pointer-type.patch
7cf1d67d72acbfce69bfdfd3ff64d78959f222a25640bc70b4fb9ed66f35fa91e46a171f3b1668e6d91876d7881387973df984ee2a322eef93192c29ce5fe91b  0005-X11-fix-pointer-integer-type-mismatch.patch
0846449e113f942e55dd3aa4a74e935e4ec8d70284b6311f094140e275e526034dfb3c1dec3bc3da15037034dad60ba77a9198e3dd2e1800fc9be107046da04d  0006-client-wayland-fix-const-correctness.patch
474316fe10abc51babf12ce993ff2331145bca1e339c68cfb002cfdce2565deadff5aeed5d4098f5378f8042bd918e8f875d76b13ac8e5b30ab03db0c34832cd  0007-warnings-fix-Wincompatible-pointer-types.patch
e3ee2d7c98fe78b51d0a9e174a56439d5035bfad437246415777c2047c6fd9f6a2acee386fef311ea57a1f0e99aab009660cf6c6c7943f90ff20bf7633e812a3  0008-server-proxy-deactivate-capture-module.patch
"
