media-libs/freetype: Stable for HPPA PPC64 (bug #583980).
[gentoo.git] / media-libs / freetype / freetype-2.5.5.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 inherit autotools-multilib flag-o-matic multilib toolchain-funcs
7
8 DESCRIPTION="A high-quality and portable font engine"
9 HOMEPAGE="http://www.freetype.org/"
10 SRC_URI="mirror://sourceforge/freetype/${P/_/}.tar.bz2
11         mirror://nongnu/freetype/${P/_/}.tar.bz2
12         utils?  ( mirror://sourceforge/freetype/ft2demos-${PV}.tar.bz2
13                 mirror://nongnu/freetype/ft2demos-${PV}.tar.bz2 )
14         doc?    ( mirror://sourceforge/freetype/${PN}-doc-${PV}.tar.bz2
15                 mirror://nongnu/freetype/${PN}-doc-${PV}.tar.bz2 )
16         infinality? ( https://dev.gentoo.org/~polynomial-c/${P}-infinality-patches.tar.xz )"
17
18 LICENSE="|| ( FTL GPL-2+ )"
19 SLOT="2"
20 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~m68k ~mips ppc ppc64 ~s390 ~sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~x86-interix ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
21 IUSE="X +adobe-cff auto-hinter bindist bzip2 debug doc fontforge harfbuzz
22         infinality png static-libs utils"
23 REQUIRED_USE="harfbuzz? ( auto-hinter )"
24 RESTRICT="!bindist? ( bindist )" # bug 541408
25
26 CDEPEND=">=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
27         bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
28         harfbuzz? ( >=media-libs/harfbuzz-0.9.19[truetype,${MULTILIB_USEDEP}] )
29         png? ( >=media-libs/libpng-1.2.51:=[${MULTILIB_USEDEP}] )
30         utils? (
31                 X? (
32                         >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
33                         >=x11-libs/libXau-1.0.7-r1[${MULTILIB_USEDEP}]
34                         >=x11-libs/libXdmcp-1.1.1-r1[${MULTILIB_USEDEP}]
35                 )
36         )"
37 DEPEND="${CDEPEND}
38         virtual/pkgconfig"
39 RDEPEND="${CDEPEND}
40         abi_x86_32? ( utils? ( !app-emulation/emul-linux-x86-xlibs[-abi_x86_32(-)] ) )"
41 PDEPEND="infinality? ( media-libs/fontconfig-infinality )"
42
43 src_prepare() {
44         enable_option() {
45                 sed -i -e "/#define $1/a #define $1" \
46                         include/config/ftoption.h \
47                         || die "unable to enable option $1"
48         }
49
50         disable_option() {
51                 sed -i -e "/#define $1/ { s:^:/*:; s:$:*/: }" \
52                         include/config/ftoption.h \
53                         || die "unable to disable option $1"
54         }
55
56         # This is the same as the 01 patch from infinality
57         epatch "${FILESDIR}"/${PN}-2.3.2-enable-valid.patch
58
59         if use infinality; then
60                 EPATCH_SOURCE="${WORKDIR}/${P}-infinality-patches" EPATCH_SUFFIX="patch" \
61                         EPATCH_FORCE="yes" epatch
62
63                 # FT_CONFIG_OPTION_SUBPIXEL_RENDERING is already enabled in freetype-2.4.11
64                 enable_option TT_CONFIG_OPTION_SUBPIXEL_HINTING
65         fi
66
67         if ! use bindist; then
68                 # See http://freetype.org/patents.html
69                 # ClearType is covered by several Microsoft patents in the US
70                 enable_option FT_CONFIG_OPTION_SUBPIXEL_RENDERING
71         fi
72
73         if use auto-hinter; then
74                 disable_option TT_CONFIG_OPTION_BYTECODE_INTERPRETER
75                 enable_option TT_CONFIG_OPTION_UNPATENTED_HINTING
76         fi
77
78         if ! use adobe-cff; then
79                 enable_option CFF_CONFIG_OPTION_OLD_ENGINE
80         fi
81
82         if use debug; then
83                 enable_option FT_DEBUG_LEVEL_TRACE
84                 enable_option FT_DEBUG_MEMORY
85         fi
86
87         epatch "${FILESDIR}"/${PN}-2.4.11-sizeof-types.patch # 459966
88
89         if use utils; then
90                 cd "${WORKDIR}/ft2demos-${PV}" || die
91                 # Disable tests needing X11 when USE="-X". (bug #177597)
92                 if ! use X; then
93                         sed -i -e "/EXES\ +=\ ftdiff/ s:^:#:" Makefile || die
94                 fi
95                 cd "${S}" || die
96         fi
97
98         # we need non-/bin/sh to run configure
99         if [[ -n ${CONFIG_SHELL} ]] ; then
100                 sed -i -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
101                         "${S}"/builds/unix/configure || die
102         fi
103
104         autotools-utils_src_prepare
105 }
106
107 multilib_src_configure() {
108         append-flags -fno-strict-aliasing
109         type -P gmake &> /dev/null && export GNUMAKE=gmake
110
111         local myeconfargs=(
112                 --enable-biarch-config
113                 $(use_with bzip2)
114                 $(use_with harfbuzz)
115                 $(use_with png)
116
117                 # avoid using libpng-config
118                 LIBPNG_CFLAGS="$($(tc-getPKG_CONFIG) --cflags libpng)"
119                 LIBPNG_LDFLAGS="$($(tc-getPKG_CONFIG) --libs libpng)"
120         )
121
122         autotools-utils_src_configure
123 }
124
125 multilib_src_compile() {
126         default
127
128         if multilib_is_native_abi && use utils; then
129                 einfo "Building utils"
130                 # fix for Prefix, bug #339334
131                 emake \
132                         X11_PATH="${EPREFIX}/usr/$(get_libdir)" \
133                         FT2DEMOS=1 TOP_DIR_2="${WORKDIR}/ft2demos-${PV}"
134         fi
135 }
136
137 multilib_src_install() {
138         default
139
140         if multilib_is_native_abi && use utils; then
141                 einfo "Installing utils"
142                 rm "${WORKDIR}"/ft2demos-${PV}/bin/README || die
143                 local ft2demo
144                 for ft2demo in ../ft2demos-${PV}/bin/*; do
145                         ./libtool --mode=install $(type -P install) -m 755 "$ft2demo" \
146                                 "${ED}"/usr/bin || die
147                 done
148         fi
149 }
150
151 multilib_src_install_all() {
152         if use fontforge; then
153                 # Probably fontforge needs less but this way makes things simplier...
154                 einfo "Installing internal headers required for fontforge"
155                 local header
156                 find src/truetype include/internal -name '*.h' | \
157                 while read header; do
158                         mkdir -p "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
159                         cp ${header} "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
160                 done
161         fi
162
163         dodoc docs/{CHANGES,CUSTOMIZE,DEBUG,INSTALL.UNIX,*.txt,PROBLEMS,TODO}
164         use doc && dohtml -r docs/*
165
166         prune_libtool_files --all
167 }
168
169 pkg_postinst() {
170         if use auto-hinter && ! use harfbuzz; then
171                 elog "To improve OpenType font hinting with the auto-hinter, the harfbuzz"
172                 elog "useflag needs to be enabled for ${CATEGORY}/${PN}."
173                 elog "See the INSTALL.UNIX file in the doc directory of this package for"
174                 elog "more information. But it is recommended not to use the auto-hinter."
175         fi
176 }