File DirectFB.spec of Package DirectFB

#
# spec file for package DirectFB
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_with    FusionSound
%if 0%{?suse_version} >= 1550 || ( 0%{?sle_version} >= 150600 && 0%{?is_opensuse} )
%bcond_with    drmkms
%else
%bcond_without drmkms
%endif

%define s_version 1_7_7
%global directfbdir %{_libdir}/directfb-1.7-7
%global libdirectfb	libdirectfb-1_7-7
%global libdfb          lib++dfb-1_7-7
Name:           DirectFB
Version:        1.7.7
Release:        0
Summary:        Graphics Library for Framebuffer Devices
License:        LGPL-2.1-or-later
Group:          System/Libraries
URL:            https://github.com/deniskropp/DirectFB
Source:         https://github.com/deniskropp/DirectFB/archive/refs/tags/DIRECTFB_%{s_version}.tar.gz#/%{name}-DIRECTFB_%{s_version}.tar.gz
Source2:        baselibs.conf
# PATCH-FIX-UPSTREAM
Patch0:         DirectFB-0.9.24-matroxi2c.diff
# PATCH-FIX-UPSTREAM
Patch1:         DirectFB-1.2.9-headers.patch
# PATCH-FIX-UPSTREAM
Patch2:         DirectFB-cc-cflags.patch
# PATCH-FIX-UPSTREAM
Patch3:         DirectFB-1.7.0-int.patch
# PATCH-FIX-UPSTREAM
Patch4:         DirectFB-0.9.24-warning.patch
# PATCH-FIX-UPSTREAM
Patch5:         DirectFB-1.2.9-ignore-fbmodes.patch
# PATCH-FIX-UPSTREAM pngtoico-libpng15.patch -- pgajdos@suse.com; build with libpng15; sent today to andi@directfb.org
# build against libpng14 should not be affected, otherwise please let me know
Patch6:         DirectFB-1.5.3-fix_v4l1.patch
# PATCH-FIX-UPSTREAM
Patch7:         DirectFB-1.6.1-lm.patch
# PATCH-FIX-UPSTREAM
Patch8:         DirectFB-1.6.1-gcc-atomics-on-arm.patch
# PATCH-FIX-UPSTREAM
Patch10:        DirectFB-1.5.3-vdpau.patch
# PATCH-FIX-UPSTREAM
Patch11:        DirectFB-1.6.1-FusionID-fix-git21c3684.patch
# PATCH-FIX-OPENSUSE DirectFB-setregion.patch -- dvaleev@suse.com; fixes cyber5k and readeon drivers build on powerpc
Patch12:        DirectFB-setregion.patch
# PATCH-FIX_OPENSUSE drop test_foo as it does not build in 1.7, mvyskocil@suse.com
Patch13:        DirectFB-1.7.1-drop-test_foo.patch
Patch14:        DirectFB-CVE-2014-2977.patch
Patch15:        DirectFB-CVE-2014-2978.patch
# PATCH-FIX-OPENSUSE DirectFB-i2c-tools.patch -- dvaleev@suse.com; fix build against new i2c-tools
Patch16:        DirectFB-i2c-tools.patch
# PATCH-FIX-UPSTREAM -- Find newer vncserver
Patch17:        find-vncserver.patch
# PATCH-FIX-UPSTREAM -- Fix tslib version check
Patch18:        https://github.com/deniskropp/DirectFB/commit/5c7c4b197b9d04587b05624db4cfca6503adb3ff.patch#/fix_tslib_check.patch
# PATCH-FIX-UPSTREAM -- Update tslib version check
Patch19:        https://patch-diff.githubusercontent.com/raw/deniskropp/DirectFB/pull/16.patch#/update_tslib_check.patch
BuildRequires:  LibVNCServer-devel
BuildRequires:  Mesa-libEGL-devel
BuildRequires:  Mesa-libGL-devel
BuildRequires:  Mesa-libGLESv2-devel
BuildRequires:  SDL-devel
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  fluxcomp
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++
BuildRequires:  imlib2-devel
BuildRequires:  libdrm-devel
BuildRequires:  libgbm-devel
BuildRequires:  libjasper-devel
BuildRequires:  libjpeg-devel
%if %{with drmkms}
BuildRequires:  libkms-devel
%endif
BuildRequires:  libpng-devel
BuildRequires:  libstdc++-devel
BuildRequires:  libtiff-devel
BuildRequires:  libtool
BuildRequires:  libv4l-devel
BuildRequires:  libvdpau-devel
BuildRequires:  libwebp-devel
BuildRequires:  sysfsutils-devel
BuildRequires:  tslib-devel
BuildRequires:  xorg-x11-libX11-devel
BuildRequires:  xorg-x11-libXext-devel
%ifnarch s390 s390x
BuildRequires:  i2c-tools
BuildRequires:  libi2c0-devel
%endif
%if %{with FusionSound}
BuildRequires:  libcddb-devel
BuildRequires:  libtimidity-devel
BuildRequires:  libvorbis-devel
%endif

%description
DirectFB is a thin library that provides hardware graphics
acceleration, input device handling and abstraction, an integrated
windowing system with support for translucent windows, and multiple
display layers on top of the Linux framebuffer device. It is a complete
hardware abstraction layer with software fallbacks for every graphics
operation that is not supported by the underlying hardware. DirectFB
adds graphical power to embedded systems and sets a new standard for
graphics under Linux.

%package -n %{libdirectfb}
Summary:        Graphics Library for Framebuffer Devices
Group:          System/Libraries

%description -n %{libdirectfb}
DirectFB is a thin library that provides hardware graphics
acceleration, input device handling and abstraction, an integrated
windowing system with support for translucent windows, and multiple
display layers on top of the Linux framebuffer device. It is a
complete hardware abstraction layer with software fallbacks for every
graphics operation that is not supported by the underlying hardware.
DirectFB adds graphical power to embedded systems and sets a new
standard for graphics under Linux.

%package -n %{libdfb}
Summary:        Graphics Library for Framebuffer Devices
Group:          System/Libraries

%description -n %{libdfb}
DirectFB is a thin library that provides hardware graphics
acceleration, input device handling and abstraction, an integrated
windowing system with support for translucent windows, and multiple
display layers on top of the Linux framebuffer device. It is a
complete hardware abstraction layer with software fallbacks for every
graphics operation that is not supported by the underlying hardware.
DirectFB adds graphical power to embedded systems and sets a new
standard for graphics under Linux.

%package devel
Summary:        Graphics Library for Framebuffer Devices
Group:          Development/Libraries/C and C++
Requires:       %{libdirectfb} = %{version}
Requires:       /bin/sh
Requires:       glibc-devel
Requires:       zlib-devel

%description devel
Development files (headers, so files, pkg-config, documentation) for %{name}.

%package -n lib++dfb-devel
Summary:        C++ Bindings for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{libdfb} = %{version}
Requires:       %{name}-devel = %{version}
Requires:       /bin/sh
Requires:       glibc-devel
Requires:       zlib-devel

%description -n lib++dfb-devel
Development files (headers, so files, pkg-config, documentation) for C++
bindings for %{name}.

%package doc
Summary:        Graphics Library for Framebuffer Devices Documentation
Group:          System/Libraries

%description doc
Graphics Library for Framebuffer Devices Documentation in html form.

%package libSDL
Summary:        SDL backend of Graphics Library for Framebuffer Devices
Group:          System/Libraries
Supplements:    (%{name} and libSDL)

%description libSDL
SDL backend of Graphics Library for Framebuffer Devices:
 * gfxdrivers/libdirectfb_sdlgraphics.so
 * inputdrivers/libdirectfb_sdlinput.so
 * systems/libdirectfb_sdl.so

%package Mesa
Summary:        Mesa backend of Graphics Library for Framebuffer Devices
Group:          System/Libraries
Supplements:    (%{name} and Mesa)

%description Mesa
Mesa backend of Graphics Library for Framebuffer Devices:
 * gfxdrivers/libdirectfb_gl.so
 * systems/libdirectfb_x11.so

%package libvncclient
Summary:        VNC backend for DirectFB
Group:          System/Libraries
Supplements:    (%{name} and libvncclient)

%description libvncclient
VNC backend of Graphics Library for Framebuffer Devices:
 * systems/libdirectfb_vnc.so

%prep
%setup -q -n %{name}-DIRECTFB_%{s_version}
%patch0 -p1
%patch1
%patch2 -p1
%patch3 -p1
%patch4
%patch5 -p1
%patch6 -p1 -b .fix_v4l1
%patch7 -p1 -b .lm
%patch8 -p1 -b .arm-atomics
%patch10 -p1 -b .vdpau
%patch11 -p1 -b .fusionID
%patch12 -p1
%patch13 -p1
%patch14
%patch15
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1

#Disable ppc asm since compilation fails (and it seems better to use glibc)
sed -i.noppcasm -e 's/want_ppcasm=yes/want_ppcasm=no/'g configure.in
# Fix file-not-utf8
for i in ChangeLog README NEWS AUTHORS ; do
cp -pr $i $i.not-utf8
iconv -f ISO_8859-1 -t UTF8 $i.not-utf8 > $i
touch -r $i.not-utf8 $i
rm $i.not-utf8
done
#Remove old headers
rm interfaces/IDirectFBVideoProvider/{videodev.h,videodev2.h}

#FIXME: mvyskocil - can't compile test_foo.c due missing region->context
rm wm/unique/test_foo.c

%build
autoreconf -fi
%ifarch s390 s390x
  sed 's/-O3/-Os/' configure >c;chmod +x c;mv c configure;
%endif
%configure --enable-sdl --with-pic --enable-video4linux2 \
  %{?with_drmkms:--enable-drmkms} \
  %{?with_FusionSound:--enable-fusionsound} \
  --enable-zlib \
%ifarch x86_64
  --enable-mmx \
  --enable-sse \
%endif
%ifarch ppc64 ppc
  --with-gfxdrivers="ati128 cle266 cyber5k gl i810 mach64 matrox neomagic nvidia pxa3xx radeon sis315 tdfx unichrome" \
%endif
%ifarch s390 s390x
  --with-gfxdrivers=none --with-inputdrivers=none --disable-video4linux --disable-fbdev \
%endif
%ifarch %{arm}
  --with-gfxdrivers="gl gles2 nvidia" \
%endif
%ifarch %{ix86} x86_64
  --with-gfxdrivers="ati128 ep9x gles2 i810 i830 mach64 matrox neomagic nvidia pxa3xx sis315 tdfx vdpau gl" \
%endif
  --enable-x11 \
  --enable-unique \
  --with-smooth-scaling \
  --disable-gettid
# Remove rpath for 64bit
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%make_build

%install
%make_install
find %{buildroot} -type f -name "*.la" -delete -print

%check
%make_build check

%post -n %{libdirectfb} -p /sbin/ldconfig
%postun -n %{libdirectfb} -p /sbin/ldconfig
%post -n %{libdfb} -p /sbin/ldconfig
%postun -n %{libdfb} -p /sbin/ldconfig

%files
%license COPYING
%doc AUTHORS ChangeLog NEWS README TODO
%{_datadir}/directfb-%{version}
%{_bindir}/dfbg
%{_bindir}/dfbdump
%{_bindir}/dfbdumpinput
%{_bindir}/dfbinfo
%{_bindir}/dfblayer
%{_bindir}/dfbplay
%{_bindir}/dfbshow
%{_bindir}/dfbswitch
%{_bindir}/directfb-csource
%{_bindir}/dfbscreen
%{_bindir}/dfbinspector
%{_bindir}/dfbmaster
%{_bindir}/dfbfx
%{_bindir}/uwmdump
%{_bindir}/dfbinput
%{_bindir}/dfbpenmount
%{_bindir}/directfb-config
%{_bindir}/mkdgifft
%ifnarch %{arm} s390 s390x
%{_bindir}/pxa3xx_dump
%endif
%{_bindir}/mkd*iff
%{_mandir}/man1/dfbg.1%{?ext_man}
%{_mandir}/man1/directfb-csource.1%{?ext_man}
%{_mandir}/man5/directfbrc.5%{?ext_man}

%files -n %{libdirectfb}
%license COPYING
%{_libdir}/libdirect*.so.*
%{_libdir}/libfusion*.so.*
%{_libdir}/libuniquewm*.so.*
%{directfbdir}
%exclude %{directfbdir}/gfxdrivers/libdirectfb_sdlgraphics.so
%exclude %{directfbdir}/inputdrivers/libdirectfb_sdlinput.so
%exclude %{directfbdir}/systems/libdirectfb_sdl.so
%exclude %{directfbdir}/gfxdrivers/libdirectfb_gl.so
%exclude %{directfbdir}/gfxdrivers/libdirectfb_gles2.so
%exclude %{directfbdir}/gfxdrivers/libdirectfb_vdpau.so
%exclude %{directfbdir}/systems/libdirectfb_x11*.so
%exclude %{directfbdir}/systems/libdirectfb_mesa_system.so
%exclude %{directfbdir}/systems/libdirectfb_vnc.so

%files devel
%{_libdir}/libdirect*.so
%{_libdir}/libfusion*.so
%{_libdir}/libuniquewm*.so
%{_includedir}/directfb-internal
%{_includedir}/directfb
%{_libdir}/pkgconfig/directfb-internal.pc
%{_libdir}/pkgconfig/directfb.pc
%{_libdir}/pkgconfig/direct.pc
%{_libdir}/pkgconfig/fusion.pc

%files -n %{libdfb}
%license COPYING
%{_libdir}/lib++dfb-1.7.so.*

%files -n lib++dfb-devel
%{_libdir}/lib++dfb.so
%{_includedir}/++dfb
%{_libdir}/pkgconfig/++dfb.pc

%files doc
%doc docs/html/*.html
%doc docs/html/*.png

%files libSDL
%{directfbdir}/gfxdrivers/libdirectfb_sdlgraphics.so
%{directfbdir}/inputdrivers/libdirectfb_sdlinput.so
%{directfbdir}/systems/libdirectfb_sdl.so

%files Mesa
%ifnarch s390 s390x
%{directfbdir}/gfxdrivers/libdirectfb_gl.so
%{directfbdir}/gfxdrivers/libdirectfb_gles2.so
%{directfbdir}/systems/libdirectfb_mesa_system.so
%endif
%ifnarch ppc ppc64 %{arm}
%{directfbdir}/gfxdrivers/libdirectfb_vdpau.so
%endif
%{directfbdir}/systems/libdirectfb_x11*.so

%files libvncclient
%{directfbdir}/systems/libdirectfb_vnc.so

%changelog
openSUSE Build Service is sponsored by