File harfbuzz.spec of Package harfbuzz

%define realname harfbuzz
%define realver  11.2.1
%define srcext   tar.gz

%define so_ver   0

%bcond_without freetype

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       MIT
Group:         System/Libraries
URL:           http://harfbuzz.github.io/
Summary:       OpenType text shaping engine

# Build-time parameters
BuildRequires: pkg-config
BuildRequires: gcc-c++
BuildRequires: meson >= 0.55.0 ninja
# Note! Dependency loop!
# Freetype requires header hb-ft.h which is shipped only if
# harfbuzz is built with freetype support
# So it's need to build freetype without harfbuzz
# then build harfbuzz using freetype
# and then freetype using harfbuzz
%if %{with freetype}
BuildRequires: pkgconfig(freetype2) >= 12.0.6
BuildRequires: pkgconfig(harfbuzz)
%endif
BuildRequires: pkgconfig(glib-2.0)    >= 2.30.0
BuildRequires: pkgconfig(gobject-2.0) >= 2.30.0
# CLI deps
BuildRequires: pkgconfig(cairo)    >= 1.10.0
BuildRequires: pkgconfig(cairo-ft) >= 1.10.0
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(icu-uc) >= 49.0
BuildRequires: pkgconfig(graphite2) >= 1.2.0
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       https://codeload.github.com/harfbuzz/harfbuzz/%{srcext}/refs/tags/%{realver}#/%{realname}-%{version}%{?extraver}.%{srcext}

%description
HarfBuzz is an OpenType text shaping engine.

# Library
%package -n lib%{name}%{?so_ver}
Group:         System/Libraries
Summary:       OpenType text shaping engine
Provides:      %{realname}(%{__isa_name}-%{__isa_bits}) = %{version}-%{release}
Provides:      lib%{name}  = %{version}-%{release}
Provides:      %{realname} = %{version}-%{release}
Obsoletes:     lib%{name}  < %{version}-%{release}
Obsoletes:     %{realname} < %{version}-%{release}

%description -n lib%{name}%{?so_ver}
HarfBuzz is an OpenType text shaping engine.

# Library
%package -n lib%{name}-subset%{?so_ver}
Group:         System/Libraries
Summary:       HarfBuzz font subsetter
Provides:      lib%{name}-subset = %{version}-%{release}
Obsoletes:     lib%{name}-subset < %{version}-%{release}

%description -n lib%{name}-subset%{?so_ver}
HarfBuzz is an OpenType text shaping engine.

This package contains HarfBuzz font subsetter.

# Library
%package -n lib%{name}-icu%{?so_ver}
Group:         System/Libraries
Summary:       HarfBuzz text shaping library ICU integration
Provides:      lib%{name}-icu = %{version}-%{release}
Obsoletes:     lib%{name}-icu < %{version}-%{release}

%description -n lib%{name}-icu%{?so_ver}
HarfBuzz is an OpenType text shaping engine.

This package contains HarfBuzz text shaping library ICU integration.

# Library
%package -n lib%{name}-gobject%{?so_ver}
Group:         System/Libraries
Summary:       HarfBuzz GObject integration support
Provides:      lib%{name}-gobject = %{version}-%{release}
Obsoletes:     lib%{name}-gobject < %{version}-%{release}

%description -n lib%{name}-gobject%{?so_ver}
HarfBuzz is an OpenType text shaping engine.

This package contains HarfBuzz GObject integration support.

# Library
%package -n lib%{name}-cairo%{?so_ver}
Group:         System/Libraries
Summary:       HarfBuzz cairo rendering
Provides:      lib%{name}-cairo = %{version}-%{release}
Obsoletes:     lib%{name}-cairo < %{version}-%{release}

%description -n lib%{name}-cairo%{?so_ver}
HarfBuzz is an OpenType text shaping engine.

This package contains HarfBuzz support for cairo rendering.

# Devel
%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      lib%{name}%{?so_ver} = %{version}-%{release}
Provides:      lib%{name}%{?so_ver}-devel = %{version}-%{release}
Provides:      lib%{name}-devel = %{version}-%{release}
%if 0%{?suse_version} || 0%{?rhel} >= 7
Requires:      lib%{name}-icu%{?so_ver} = %{version}-%{release}
%endif

%description devel
Development files for %{name}

# Tools
%package tools
Group:         Development/Tools/Other
Summary:       Tools for OpenType text shaping engine

%description tools
HarfBuzz is an OpenType text shaping engine.

This package contains some tools for HarfBuzz.

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

%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
meson setup build \
 --buildtype=release \
 --strip \
 \
 --prefix=%{_prefix} \
 --default-library=shared \
 \
 -Db_lto=true \
 -Db_ndebug=true \
 \
 -Dgraphite2=enabled \
 -Dtests=disabled \
 -Dbenchmark=disabled \
 \
 -Dc_args="$_CFLAGS" \
 -Dcpp_args="$_CFLAGS %{?cxx11abi}" \
 -Dc_link_args="$_LDFLAGS" \
 -Dcpp_link_args="$_LDFLAGS"
ninja -v -C build %{?_smp_mflags}

%install
DESTDIR=%{buildroot} ninja -v -C build install

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

# Library
%files -n lib%{name}%{?so_ver}
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_libdir}/lib%{name}.so.%{?so_ver}*


%files -n lib%{name}-gobject%{?so_ver}
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_libdir}/lib%{name}-gobject.so.%{?so_ver}*

%files -n lib%{name}-subset%{?so_ver}
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_libdir}/lib%{name}-subset.so.%{?so_ver}*

%files -n lib%{name}-cairo%{?so_ver}
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_libdir}/lib%{name}-cairo.so.%{?so_ver}*

# Development stuff
%files devel
%defattr(-,root,root)
%docdir %{_datadir}/gtk-doc/html/harfbuzz
%dir %{_libdir}/cmake/harfbuzz
%dir %{_libdir}/cmake
%{_libdir}/cmake/harfbuzz/harfbuzz-config.cmake
%{_libdir}/pkgconfig/*.pc
%dir %{_includedir}/%{name}/
%{_includedir}/%{name}/*.h
%{_includedir}/%{name}/*.hh
%{_libdir}/*.so

# Tools are built only with glib2
%files tools
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_bindir}/hb-*

%post   -n lib%{name}%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}%{?so_ver} -p /sbin/ldconfig

%post   -n lib%{name}-gobject%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}-gobject%{?so_ver} -p /sbin/ldconfig

%post   -n lib%{name}-subset%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}-subset%{?so_ver} -p /sbin/ldconfig

%post   -n lib%{name}-cairo%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}-cairo%{?so_ver} -p /sbin/ldconfig

%if 0%{?suse_version} || 0%{?rhel} >= 7
%files -n lib%{name}-icu%{?so_ver}
%defattr(-,root,root)
%license COPYING
%doc AUTHORS NEWS README.md THANKS
%{_libdir}/lib%{name}-icu.so.%{?so_ver}*

%post   -n lib%{name}-icu%{?so_ver} -p /sbin/ldconfig
%postun -n lib%{name}-icu%{?so_ver} -p /sbin/ldconfig
%endif

%changelog
openSUSE Build Service is sponsored by