%{!?_with_subpixel_rendering: %{!?_without_subpixel_rendering: %define _without_subpixel_rendering --without-subpixel_rendering}}

%{!?with_xfree86:%define with_xfree86 1}

Name:           freetype
Version:        2.10.1
Release:        1
Summary:        FreeType is a freely available software library to render fonts
License:        (FTL or GPLv2+) and BSD and MIT and Public Domain and zlib with acknowledgement
URL:            http://www.freetype.org
Source0:        http://download.savannah.gnu.org/releases/freetype/freetype-%{version}.tar.gz
Source1:        http://download.savannah.gnu.org/releases/freetype/freetype-doc-%{version}.tar.gz
Source2:        http://download.savannah.gnu.org/releases/freetype/ft2demos-%{version}.tar.gz
Source3:        ftconfig.h

Patch6000:  	freetype-2.3.0-enable-spr.patch
Patch6001:  	freetype-2.2.1-enable-valid.patch
Patch6002:      freetype-2.5.2-more-demos.patch
Patch6003:  	freetype-2.6.5-libtool.patch 
Patch6004:  	freetype-2.8-multilib.patch
Patch6005:  	freetype-2.10.0-internal-outline.patch
Patch6006:  	freetype-2.10.1-debughook.patch

BuildRequires:  gcc libX11-devel libpng-devel zlib-devel bzip2-devel

Provides:       %{name}-bytecode %{name}-demos = %{version}-%{release}
Provides:       %{name}-subpixel 
Obsoletes:      %{name}-demos < %{version}-%{release} freetype-freeworld < 2.9.1-2

%description
FreeType is written in C, designed to be small,efficient, highly customizable, and portable while capable of producing high-quality
output (glyph images) of most vector and bitmap font formats

%package        devel
Summary:        FreeType development libraries and header files
Requires:       %{name} = %{version}-%{release} pkgconf

%description    devel
The freetype-devel package includes the static libraries and header files
for the FreeType font rendering engine.Install freetype-devel if you want to develop programs which will use
FreeType.

%package        help
Summary:        Documents for freetype
Buildarch:      noarch

%description    help
Man pages and other related for freetype documents.

%prep
%setup   -q  -b 1 -a 2
%patch6000 -p1
%patch6001 -p1

pushd ft2demos-%{version}
%patch6002  -p1 -b .more-demos
popd

%patch6003 -p1
%patch6004 -p1
%patch6005 -p1
%patch6006 -p1

%build
%configure --disable-static --with-zlib=yes --with-bzip2=yes --with-png=yes --enable-freetype-config --with-harfbuzz=no
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' builds/unix/libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' builds/unix/libtool
%make_build

cd ft2demos-%{version}
make TOP_DIR=".."

%install
%make_install gnulocaledir=$RPM_BUILD_ROOT%{_datadir}/locale
{
  for ftdemo in ftbench ftchkwd ftmemchk ftpatchk fttimer ftdump ftlint ftmemchk ftvalid ; do
      builds/unix/libtool --mode=install install -m 755 ft2demos-%{version}/bin/$ftdemo $RPM_BUILD_ROOT/%{_bindir}
  done
}
for ftdemo in ftdiff ftgamma ftgrid ftmulti ftstring fttimer ftview ; do
     builds/unix/libtool --mode=install install -m 755 ft2demos-%{version}/bin/$ftdemo $RPM_BUILD_ROOT/%{_bindir}
done

%define wordsize %{__isa_bits}

mv $RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig.h \
   $RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig-%{wordsize}.h
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig.h

%delete_la_and_a

%triggerpostun -- freetype < 2.0.5-3
{
  # ttmkfdir updated - as of 2.0.5-3, on upgrades we need xfs to regenerate
  # things to get the iso10646-1 encoding listed.
  for I in %{_datadir}/fonts/*/TrueType /usr/share/X11/fonts/TTF; do
      [ -d $I ] && [ -f $I/fonts.scale ] && [ -f $I/fonts.dir ] && touch $I/fonts.scale
  done
  exit 0
}

%ldconfig_scriptlets

%files
%defattr(-,root,root)
%license docs/LICENSE.TXT docs/FTL.TXT docs/GPLv2.TXT
%{_libdir}/libfreetype.so.*
%{_bindir}/ft*

%files devel
%defattr(-,root,root)
%{_datadir}/aclocal/freetype2.m4
%{_includedir}/freetype2/*
%{_libdir}/libfreetype.so
%{_libdir}/pkgconfig/freetype2.pc
%{_bindir}/freetype-config

%files help
%defattr(-,root,root)
%doc docs/design
%doc docs/glyphs
%doc docs/reference
%doc docs/tutorial
%doc docs/CHANGES docs/formats.txt docs/ft2faq.html
%doc ChangeLog README
%{_mandir}/man1/*

%changelog
* Mon Jun 15 2020 fuyangqing <fuyangqing@huawei.com> - 2.10.1-1
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:update to 2.10.1

* Tue Jan 14 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.9.1-5
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:optimization the spec

* Sat Jan 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.9.1-4
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:optimization the spec

* Wed Sep 11 2019 openEuler jimmy<dukaitian@huawei.com> - 2.9.1-3
- Package init jimmy
