File fontconfig.spec of Package fontconfig-iu

#
# specfile for package fontconfig
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#

%global freetype_version 2.6.3

Name:           fontconfig
BuildRequires:  automake >= 1.11
BuildRequires:  freetype2-iu-devel >= %{freetype_version}
BuildRequires:  libexpat-devel
BuildRequires:  libtool
BuildRequires:  gperf
BuildRequires:  pkgconfig
BuildRequires:	python-lxml
Provides:       XFree86:%{_sysconfdir}/fonts/fonts.dtd
Url:            http://fontconfig.org/
# bug437293
%ifarch ppc64
Obsoletes:      fontconfig-64bit
%endif
Requires:       bash
Version:        2.11.95
Release:        1
Summary:        Library for Font Configuration
License:        MIT
Group:          System/Libraries
Source0:        http://fontconfig.org/release/fontconfig-%version.tar.bz2
Source4:        baselibs.conf
Source5:        local.conf
# Patches available at https://github.com/bohoomil/fontconfig-ultimate/archive/master.zip
Source6:	fontconfig-ultimate-master.tar.bz2
# suse specific because freetype2-bitmap-foundry.patch 
# https://www.libreoffice.org/bugzilla/show_bug.cgi?id=47704
Patch0:         make-check.patch
Patch1:		fc-presets.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=140335
Patch2:		fontconfig-sleep-less.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:	fontconfig = %{version},fontconfig-iu = %{version}
Obsoletes:	fontconfig < %{version},fontconfig-iu < %{version}
Provides:       ipa-fonts-config = 003.02
Obsoletes:      ipa-fonts-config <= 003.02
Provides:       IPA-fonts-config = 003.02
Obsoletes:      IPA-fonts-config <= 003.02

%description
Fontconfig is a library for configuring and customizing font access. It
contains two essential modules: the configuration module, which builds
an internal configuration from XML files, and the matching module,
which accepts font patterns and returns the nearest matching font.
bohoomil.com infinality-ultimate patches applied.

%package devel
Requires:       %{name} = %version
Requires:       freetype2-iu-devel >= %{freetype_version}
Requires:       glibc-devel
Provides:       XFree86-devel:%_libdir/pkgconfig/fontconfig.pc,fontconfig-devel = %{version},fontconfig-iu-devel = %{version}
Summary:        Include Files and Libraries mandatory for Development
Group:          Development/Libraries/C and C++
# bug437293
%ifarch ppc64
Obsoletes:      fontconfig-devel-64bit
%endif

%description devel
This package countains all include files, libraries, configuration
files needed for compiling applications which use the fontconfig
library.

In addition, it contains extensive documentation and manual pages for
developers using the library.

Fontconfig is a library for configuring and customizing font access. It
contains two essential modules, the configuration module which builds
an internal configuration from XML files and the matching module which
accepts font patterns and returns the nearest matching font.
bohoomil.com infinality-ultimate patches applied.

%prep
%setup -q -n fontconfig-%{version}
tar -xf %{SOURCE6} --strip-components=1
cp -r fontconfig_patches/*.patch .

%patch0 -p1
%patch1 -p1
%patch2 -p1

# bohoomil.com infinality-ultimate patches
patches=(
         01-configure.patch
         02-configure.ac.patch
         03-Makefile.in.patch
         04-Makefile.conf.d.patch
         05-Makefile.am.in.patch)

# infinality & post release fixes
for patch in "${patches[@]}"; do
    patch -Np1 -i ${patch}
done

# use suse-specific doc path:
find -name \*.1 -o -name \*.sgml | xargs sed -i -e 's/usr\/share\/doc\/fontconfig/usr\/share\/doc\/packages\/fontconfig/g'

%build
# ----- build with automake 1.13
# work around from https://bugs.archlinux.org/task/33406
find . -name Makefile.am -exec sed -i "s/\(TESTS_ENVIRONMENT=.*\) sh/\1/" {} \;
chmod u+x test/run-test.sh
chmod u+x doc/check-missing-doc
# -----
autoreconf -fiv

%configure --with-pic --with-arch=%_host_cpu \
        --disable-static \
	--with-freetype-lib=%_libdir \
  	--with-x \
  	--enable-libxml2=no \
  	--with-confdir=%{_sysconfdir}/fonts \
  	--with-templateinfdir=%{_datadir}/fontconfig/conf.avail.infinality \
  	--with-templatedir=%{_datadir}/fontconfig/conf.avail \
  	--with-docdir=%{_defaultdocdir}/fontconfig \
  	--with-add-fonts=/usr/X11R6/lib/X11/fonts,/opt/kde3/share/fonts,/usr/local/share/fonts \
  	--disable-docs

make %{?_smp_mflags} V=1

%check
export MALLOC_CHECK_=2
make %{?_smp_mflags} check
unset MALLOC_CHECK_

%install
make DESTDIR=%{buildroot} pkgconfigdir=%{_libdir}/pkgconfig install
rm -f %{buildroot}%{_libdir}/*.la

# package /etc/fonts/conf.avail for compatibility reasons
mkdir %{buildroot}%{_sysconfdir}/fonts/conf.avail
 
# copy presets
cp -r fontconfig_patches/{combi,free,ms} %{buildroot}%{_datadir}/fontconfig/conf.avail.infinality

# install fc-presets
install -m755 fontconfig_patches/"fc-presets" %{buildroot}/usr/bin/"fc-presets"

# copy font settings
install -m755 -d %{buildroot}/usr/share/doc/packages/fontconfig/fonts-settings
cp fontconfig_patches/fonts-settings/*.conf %{buildroot}/usr/share/doc/packages/fontconfig/fonts-settings

# documentation
mkdir -p %{buildroot}/%{_defaultdocdir}/fontconfig
mkdir -p %{buildroot}/%{_defaultdocdir}/fontconfig-devel
install -m 644 AUTHORS COPYING ChangeLog README \
        %{buildroot}/%{_defaultdocdir}/fontconfig
install -m 644 doc/*.html %{buildroot}/%{_defaultdocdir}/fontconfig
install -m 644 doc/fontconfig-user.txt %{buildroot}/%{_defaultdocdir}/fontconfig
install -m 644 doc/fontconfig-devel/*  %{buildroot}/%{_defaultdocdir}/fontconfig-devel
install -m 644 doc/fontconfig-devel.txt  %{buildroot}/%{_defaultdocdir}/fontconfig-devel
for i in 1 3 5
do
    mkdir -p %{buildroot}/%{_mandir}/man${i}/
    for j in fc-*/*.${i} doc/*.${i} doc/*/*.${i}
    do
        test -f ${j} && install -m 644 ${j} %{buildroot}/%{_mandir}/man${i}/
    done
    gzip --best %{buildroot}/%{_mandir}/man${i}/*.${i}
done
install -m 644 conf.d/README %{buildroot}%{_sysconfdir}/fonts/conf.d
install -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/fonts


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%{_libdir}/libfontconfig.so.*
%{_bindir}/*
%dir %{_sysconfdir}/fonts
%dir %{_sysconfdir}/fonts/conf.d

# packaging /etc/fonts/conf.avail for compatibility reasons
%dir %{_sysconfdir}/fonts/conf.avail

%config %{_sysconfdir}/fonts/fonts.conf
%config %{_sysconfdir}/fonts/conf.d/*.conf
%config(noreplace) %{_sysconfdir}/fonts/local.conf
%{_sysconfdir}/fonts/conf.d/README

%dir %{_datadir}/fontconfig
%dir %{_datadir}/fontconfig/conf.avail
%dir %{_datadir}/fontconfig/conf.avail.infinality
%dir %{_datadir}/fontconfig/conf.avail.infinality/ms
%dir %{_datadir}/fontconfig/conf.avail.infinality/combi
%dir %{_datadir}/fontconfig/conf.avail.infinality/free
%{_datadir}/fontconfig/conf.avail/*.conf
%{_datadir}/fontconfig/conf.avail.infinality/*.conf
%{_datadir}/fontconfig/conf.avail.infinality/ms/*.conf
%{_datadir}/fontconfig/conf.avail.infinality/combi/*.conf
%{_datadir}/fontconfig/conf.avail.infinality/free/*.conf

%dir %{_datadir}/xml/fontconfig
%{_datadir}/xml/fontconfig/fonts.dtd
%dir /var/cache/fontconfig/
%doc %{_docdir}/fontconfig
%{_mandir}/man5/fonts-conf.5.gz
%{_mandir}/man1/*

%files devel
%defattr(-,root,root)
%doc %{_defaultdocdir}/fontconfig-devel
%{_libdir}/pkgconfig/fontconfig.pc
%{_libdir}/libfontconfig.so
%{_mandir}/man3/Fc*
%{_includedir}/fontconfig/

%changelog