File freerdp.spec of Package freerdp

%define realname FreeRDP
%define realver  3.18.0
%define srcext   tar.gz

%bcond_without krb5
%bcond_without icu
%bcond_with    sdl2
%bcond_without sdl3

%define gen          3
%define rdp_so_ver   3
%define winpr_so_ver 3
%define uwac_so_ver  0
%define rdtk_so_ver  0
%define pkg_lib_ver  3-3

# Common info
Name:          freerdp
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         Productivity/Networking/Other
URL:           http://www.freerdp.com/
Summary:       A free implementation of the Remote Desktop Protocol (RDP)

# Install-time parameters
Provides:      xfreerdp = %{version}-%{release}
Obsoletes:     xfreerdp < %{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.13 ninja
BuildRequires: pkg-config
BuildRequires: gcc-c++
BuildRequires: systemd-devel
BuildRequires: libX11-devel
# Wayland dependecies
BuildRequires: pkgconfig(alsa)
BuildRequires: zlib-devel
BuildRequires: pkgconfig(wayland-client) pkgconfig(wayland-scanner) pkgconfig(wayland-cursor) pkgconfig(xkbcommon)
BuildRequires: pkgconfig(xkbcommon)
#
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libpkcs11-helper-1)
BuildRequires: pkgconfig(libpulse)
BuildRequires: cups-devel
BuildRequires: pkgconfig(libpcsclite)
%if 0%{?suse_version}
BuildRequires: pkgconfig(opensc-pkcs11)
%endif
BuildRequires: pkgconfig(jansson) >= 2.13
BuildRequires: pkgconfig(libcjson)
BuildRequires: pkgconfig(json-c)
BuildRequires: uriparser-devel
BuildRequires: libavcodec-devel libavdevice-devel libavfilter-devel libavformat-devel
BuildRequires: libavutil-devel libswresample-devel libswscale-devel
BuildRequires: pkgconfig(libva)
BuildRequires: libjpeg-devel
BuildRequires: pkgconfig(OpenCL)
# winpr utils image support
BuildRequires: libpng-devel
BuildRequires: pkgconfig(libwebp)
BuildRequires: pkgconfig(libjpeg)
#
%if %{with krb5}
BuildRequires: krb5-devel
%endif
%if %{with icu}
BuildRequires: pkgconfig(icu-i18n) pkgconfig(icu-uc) pkgconfig(icu-io)
%endif
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(libusb-1.0)
BuildRequires: pkgconfig(fuse3)
%if %{with sdl2}
BuildRequires: pkgconfig(sdl2) pkgconfig(SDL2_ttf)
BuildRequires: pkgconfig(webkit2gtk-4.0)
%endif
%if %{with sdl3}
BuildRequires: pkgconfig(sdl3) pkgconfig(sdl3-ttf)
%endif
BuildRequires: pkgconfig(xkbfile)
BuildRequires: pkgconfig(xext)    pkgconfig(xinerama) pkgconfig(xcursor)
BuildRequires: pkgconfig(xv)      pkgconfig(xi)       pkgconfig(xrender)
BuildRequires: pkgconfig(xrandr)  pkgconfig(xfixes)
# Server reqs
BuildRequires: pkgconfig(xtst) pkgconfig(xdamage)
#
BuildRequires: pam-devel
%if 0%{?suse_version}
BuildRequires: libxslt-tools
BuildRequires: docbook-xsl-stylesheets docbook_4
BuildRequires: fdupes
%else
BuildRequires: libxslt
BuildRequires: docbook-style-xsl
BuildRequires: avahi-libs
%endif
Source0:       https://codeload.github.com/FreeRDP/FreeRDP/%{srcext}/refs/tags/%{realver}#/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

This package contains command-line client for X11.

%package wayland
Group:         Productivity/Networking/Other
Summary:       A Remote Desktop Protocol Implementation for Wayland

Provides:      wlfreerdp = %{version}-%{release}
Obsoletes:     wlfreerdp < %{version}-%{release}

%description wayland
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

This package contains command-line client for Wayland.

%package sdl
Group:         Productivity/Networking/Other
Summary:       A Remote Desktop Protocol SDL-based client

Provides:      sdl-freerdp = %{version}-%{release}
Obsoletes:     sdl-freerdp < %{version}-%{release}

%description sdl
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

This package contains SDL-based command-line client.

%package server
Group:         Productivity/Networking/Other
Summary:       Tools providing access to display via Remote Desktop Protocol

%description server
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

This package contains utility for sharing a X display via RDP.

%package proxy
Group:         Productivity/Networking/Other
Summary:       Tools providing access to display via Remote Desktop Protocol

Provides:      freerdp-proxy-plugins = %{version}-%{release}
Obsoletes:     freerdp-proxy-plugins < %{version}-%{release}

%description proxy
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

This package contains RDP proxy.

%package -n libfreerdp%{?pkg_lib_ver}
Group:         System/Libraries
Summary:       A library providing Remote Desktop Protocol Implementation
Provides:      libfreerdp%{gen} = %{version}-%{release}
Provides:      libfreerdp%{?pkg_lib_ver}-plugins = %{version}-%{release}
Provides:      libwinpr%{gen} = %{version}-%{release}
Provides:      libwinpr%{?pkg_lib_ver} = %{version}-%{release}
Provides:      libuwac0-0 = %{version}-%{release}
Provides:      librdtk0-0 = %{version}-%{release}
Obsoletes:     libfreerdp%{gen} < %{version}-%{release}
Obsoletes:     libfreerdp%{?pkg_lib_ver}-plugins < %{version}-%{release}
Obsoletes:     libwinpr%{gen} < %{version}-%{release}
Obsoletes:     libwinpr%{?pkg_lib_ver} < %{version}-%{release}
Obsoletes:     libuwac0-0 < %{version}-%{release}
Obsoletes:     librdtk0-0 < %{version}-%{release}

%description -n libfreerdp%{?pkg_lib_ver}
FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released
under the Apache license.

Enjoy the freedom of using your software wherever you want, the way you want it,
in a world where interoperability can finally liberate your computing experience.

This package contains shared library.

%package -n freerdp-devel
Group:         Development/Languages/C and C++
Summary:       Development files for freerdp
Requires:      libfreerdp%{?pkg_lib_ver} = %{version}-%{release}
Provides:      freerdp-devel = %{version}-%{release}
Provides:      libfreerdp-devel = %{version}-%{release}

%description -n freerdp-devel
Development files for freerdp

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}

%build
_CFLAGS='%{optflags} %{?gcc_lto} -D_FORTIFY_SOURCE=0'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
cmake -S . -B build \
 -G Ninja \
 -Wno-dev \
 \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS" \
 -DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_VERBOSE_MAKEFILE=YES \
 -DCMAKE_SKIP_RPATH=YES \
 \
 -DWITH_NO_UNDEFINED=ON \
 \
 -DFREERDP_UNIFIED_BUILD=ON \
 -DWITH_WAYLAND=ON \
 -DWITH_SERVER=ON \
 -DWITH_MANPAGES=ON \
 -DWITH_CAIRO=ON \
 -DWITH_SWSCALE=ON \
 -DWITH_ALSA=ON \
 -DWITH_PULSE=ON \
 -DWITH_CUPS=ON \
 -DWITH_PCSC=ON \
 -DWITH_DSP_FFMPEG=ON \
 -DWITH_FFMPEG=ON \
 -DWITH_JPEG=ON \
 -DWITH_OPENCL=ON \
%if 0%{?suse_version}
 -DWITH_OPENSC_PKCS11_LINKED=ON \
%endif
%if %{with sdl3}
 -DWITH_CLIENT_SDL3=ON \
%endif
%if %{with krb5}
 -DWITH_KRB5=ON \
%else
 -DWITH_KRB5=OFF \
%endif
%if %{with icu}
 -DWITH_ICU=ON \
%else
 -DWITH_ICU=OFF \
%endif
 -DWITH_SAMPLE=OFF \
 -DWITH_VAAPI=ON \
 -DWITH_VERBOSE_WINPR_ASSERT=OFF \
 -DWITH_WINPR_TOOLS_CLI=OFF \
 -DCHANNEL_SSHAGENT=ON \
 -DWINPR_UTILS_IMAGE_PNG=ON \
 -DWINPR_UTILS_IMAGE_WEBP=ON \
 -DWINPR_UTILS_IMAGE_JPEG=ON
ninja -v -C build %{?_smp_mflags}

%install
DESTDIR=%{buildroot} ninja -v -C build install
%{__ln_s} xfreerdp %{buildroot}%{_bindir}/mstsc
%if 0%{?suse_version}
%fdupes %{buildroot}%{_libdir}
%endif

%files
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/mstsc
%{_bindir}/xfreerdp
%doc %{_mandir}/man1/xfreerdp.1*

%files wayland
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/wlfreerdp
%doc %{_mandir}/man1/wlfreerdp.1*

%files sdl
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/sdl-freerdp
%doc %{_mandir}/man1/sdl-freerdp.1*

# Server
%files server
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/freerdp-shadow-cli
%doc %{_mandir}/man1/freerdp-shadow-cli.1*

# Proxy
%files proxy
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/freerdp-proxy
%dir %{_libdir}/freerdp%{gen}/proxy
%dir %{_libdir}/freerdp%{gen}
%{_libdir}/freerdp%{gen}/proxy/*.so
%doc %{_mandir}/man1/freerdp-proxy.1*

# Library
%files -n libfreerdp%{?pkg_lib_ver}
%defattr(-,root,root)
%{_libdir}/libfreerdp*.so.%{?rdp_so_ver}*
%{_libdir}/libwinpr*.so.%{?winpr_so_ver}*
# Wayland client
%{_libdir}/libuwac0.so.%{?uwac_so_ver}*
# Remote Desktop Toolkit
%{_libdir}/librdtk*.so.%{?rdtk_so_ver}*
%doc %{_mandir}/man7/wlog.7*

# Development stuff
%files -n freerdp-devel
%defattr(-,root,root)
%dir %{_libdir}/cmake
%{_libdir}/cmake/*
%{_libdir}/pkgconfig/*.pc
%dir %{_includedir}/freerdp%{gen}/
%dir %{_includedir}/winpr%{gen}/
%{_includedir}/freerdp%{gen}/*
%{_includedir}/winpr%{gen}/*
%{_libdir}/libfreerdp*.so
%{_libdir}/libwinpr*.so
# Wayland client
%dir %{_includedir}/uwac0/uwac
%dir %{_includedir}/uwac0
%{_includedir}/uwac0/uwac/*
%{_libdir}/libuwac0.so
# Remote Desktop Toolkit
%dir %{_includedir}/rdtk0/rdtk
%dir %{_includedir}/rdtk0
%{_includedir}/rdtk0/rdtk/*.h
%{_libdir}/librdtk0.so

%post   -n libfreerdp%{?pkg_lib_ver} -p /sbin/ldconfig
%postun -n libfreerdp%{?pkg_lib_ver} -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by