File freerdp.spec of Package freerdp

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

%bcond_without krb5
%bcond_without icu
%bcond_with    sdl2

%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_0

# Common info
Name:          xfreerdp
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:      freerdp = %{version}-%{release}
Obsoletes:     freerdp < %{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.13 ninja
BuildRequires: pkgconfig
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)
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(libcjson)
BuildRequires: pkgconfig(json-c)
BuildRequires: uriparser-devel
BuildRequires: libavcodec-devel 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
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
BuildRoot:     %{_tmppath}/%{name}-root
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 -n wlfreerdp
Group:         Productivity/Networking/Other
Summary:       A Remote Desktop Protocol Implementation for Wayland

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

%description -n wlfreerdp
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 -n sfreerdp
Group:         Productivity/Networking/Other
Summary:       A Remote Desktop Protocol sample client Implementation

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

This package contains sample command-line client.

%package -n sfreerdp-server
Group:         Productivity/Networking/Other
Summary:       A Remote Desktop Protocol sample server Implementation

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

This package contains sample server implementation.

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

%description -n freerdp-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 -n freerdp-proxy
Group:         Productivity/Networking/Other
Summary:       Tools providing access to display via Remote Desktop Protocol

%description -n freerdp-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}'
_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 \
 \
 -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 krb5}
 -DWITH_KRB5=ON \
%else
 -DWITH_KRB5=OFF \
%endif
%if %{with icu}
 -DWITH_ICU=ON \
%else
 -DWITH_ICU=OFF \
%endif
 -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

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

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

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

%files -n sfreerdp
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/sfreerdp

%files -n sfreerdp-server
%defattr(-,root,root)
%doc LICENSE README.md
%defattr(-,root,root)
%{_bindir}/sfreerdp-server

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

# Proxy
%files -n freerdp-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)
%{_bindir}/winpr-*
%{_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}*
%{_datadir}/FreeRDP/
%doc %{_mandir}/man1/winpr-hash.1*
%doc %{_mandir}/man1/winpr-makecert.1*
%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