media-libs/avidemux-plugins: Remove py2
[gentoo.git] / media-libs / freetype / freetype-2.10.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic libtool multilib-build multilib-minimal toolchain-funcs
7
8 DESCRIPTION="A high-quality and portable font engine"
9 HOMEPAGE="https://www.freetype.org/"
10 IUSE="X +adobe-cff bindist bzip2 +cleartype_hinting debug fontforge harfbuzz infinality png static-libs utils"
11
12 if [[ "${PV}" != 9999 ]] ; then
13         SRC_URI="mirror://sourceforge/freetype/${P/_/}.tar.bz2
14                 mirror://nongnu/freetype/${P/_/}.tar.bz2
15                 utils?  ( mirror://sourceforge/freetype/ft2demos-${PV}.tar.bz2
16                         mirror://nongnu/freetype/ft2demos-${PV}.tar.bz2 )
17                 doc?    ( mirror://sourceforge/freetype/${PN}-doc-${PV}.tar.bz2
18                         mirror://nongnu/freetype/${PN}-doc-${PV}.tar.bz2 )"
19         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
20         IUSE+=" doc"
21 else
22         inherit autotools git-r3
23 fi
24
25 LICENSE="|| ( FTL GPL-2+ )"
26 SLOT="2"
27 RESTRICT="!bindist? ( bindist )" # bug 541408
28
29 RDEPEND="
30         >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
31         bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
32         harfbuzz? ( >=media-libs/harfbuzz-1.3.0[truetype,${MULTILIB_USEDEP}] )
33         png? ( >=media-libs/libpng-1.2.51:0=[${MULTILIB_USEDEP}] )
34         utils? (
35                 X? (
36                         >=x11-libs/libX11-1.6.2[${MULTILIB_USEDEP}]
37                         >=x11-libs/libXau-1.0.7-r1[${MULTILIB_USEDEP}]
38                         >=x11-libs/libXdmcp-1.1.1-r1[${MULTILIB_USEDEP}]
39                 )
40         )"
41 DEPEND="${RDEPEND}"
42 BDEPEND="
43         virtual/pkgconfig
44 "
45 PDEPEND="infinality? ( media-libs/fontconfig-infinality )"
46
47 PATCHES=(
48         "${FILESDIR}"/${PN}-2.4.11-sizeof-types.patch # 459966
49 )
50
51 _egit_repo_handler() {
52         if [[ "${PV}" == 9999 ]] ; then
53                 local phase="${1}"
54                 case ${phase} in
55                         fetch|unpack)
56                                 :;
57                         ;;
58                         *)
59                                 die "Please use this function with either \"fetch\" or \"unpack\""
60                         ;;
61                 esac
62
63                 local EGIT_REPO_URI
64                 EGIT_REPO_URI="https://git.sv.nongnu.org/r/freetype/freetype2.git"
65                 git-r3_src_${phase}
66                 if use utils ; then
67                         EGIT_REPO_URI="https://git.sv.nongnu.org/r/freetype/freetype2-demos.git"
68                         local EGIT_CHECKOUT_DIR="${WORKDIR}/ft2demos-${PV}"
69                         git-r3_src_${phase}
70                 fi
71         else
72                 default
73         fi
74 }
75
76 src_fetch() {
77         _egit_repo_handler ${EBUILD_PHASE}
78 }
79
80 src_unpack() {
81         _egit_repo_handler ${EBUILD_PHASE}
82 }
83
84 src_prepare() {
85         if [[ "${PV}" == 9999 ]] ; then
86                 # inspired by shipped autogen.sh script
87                 eval $(sed -nf version.sed include/freetype/freetype.h)
88                 pushd builds/unix &>/dev/null || die
89                 sed -e "s;@VERSION@;$freetype_major$freetype_minor$freetype_patch;" \
90                         < configure.raw > configure.ac || die
91                 # eautoheader produces broken ftconfig.in
92                 eautoheader() { return 0 ; }
93                 AT_M4DIR="." eautoreconf
94                 unset freetype_major freetype_minor freetype_patch
95                 popd &>/dev/null || die
96         fi
97
98         default
99
100         # This is the same as the 01 patch from infinality
101         sed '/AUX_MODULES += \(gx\|ot\)valid/s@^# @@' -i modules.cfg || die
102
103         enable_option() {
104                 sed -i -e "/#define $1/ { s:/\* ::; s: \*/:: }" \
105                         include/${PN}/config/ftoption.h \
106                         || die "unable to enable option $1"
107         }
108
109         disable_option() {
110                 sed -i -e "/#define $1/ { s:^:/* :; s:$: */: }" \
111                         include/${PN}/config/ftoption.h \
112                         || die "unable to disable option $1"
113         }
114
115         # Will be the new default for >=freetype-2.7.0
116         disable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  2"
117
118         if use infinality && use cleartype_hinting; then
119                 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  ( 1 | 2 )"
120         elif use infinality; then
121                 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  1"
122         elif use cleartype_hinting; then
123                 enable_option "TT_CONFIG_OPTION_SUBPIXEL_HINTING  2"
124         fi
125
126         # Can be disabled with FREETYPE_PROPERTIES="pcf:no-long-family-names=1"
127         # via environment (new since v2.8)
128         enable_option PCF_CONFIG_OPTION_LONG_FAMILY_NAMES
129
130         if ! use bindist; then
131                 # See http://freetype.org/patents.html
132                 # ClearType is covered by several Microsoft patents in the US
133                 enable_option FT_CONFIG_OPTION_SUBPIXEL_RENDERING
134         fi
135
136         if ! use adobe-cff; then
137                 enable_option CFF_CONFIG_OPTION_OLD_ENGINE
138         fi
139
140         if use debug; then
141                 enable_option FT_DEBUG_LEVEL_TRACE
142                 enable_option FT_DEBUG_MEMORY
143         fi
144
145         if use utils; then
146                 cd "${WORKDIR}/ft2demos-${PV}" || die
147                 # Disable tests needing X11 when USE="-X". (bug #177597)
148                 if ! use X; then
149                         sed -i -e "/EXES\ +=\ ftdiff/ s:^:#:" Makefile || die
150                 fi
151                 cd "${S}" || die
152         fi
153
154         # we need non-/bin/sh to run configure
155         if [[ -n ${CONFIG_SHELL} ]] ; then
156                 sed -i -e "1s:^#![[:space:]]*/bin/sh:#!${CONFIG_SHELL}:" \
157                         "${S}"/builds/unix/configure || die
158         fi
159
160         elibtoolize --patch-only
161 }
162
163 multilib_src_configure() {
164         append-flags -fno-strict-aliasing
165         type -P gmake &> /dev/null && export GNUMAKE=gmake
166
167         local myeconfargs=(
168                 --disable-freetype-config
169                 --enable-biarch-config
170                 --enable-shared
171                 $(use_with bzip2)
172                 $(use_with harfbuzz)
173                 $(use_with png)
174                 $(use_enable static-libs static)
175
176                 # avoid using libpng-config
177                 LIBPNG_CFLAGS="$($(tc-getPKG_CONFIG) --cflags libpng)"
178                 LIBPNG_LDFLAGS="$($(tc-getPKG_CONFIG) --libs libpng)"
179         )
180
181         case ${CHOST} in
182                 mingw*|*-mingw*) ;;
183                 # Workaround windows mis-detection: bug #654712
184                 # Have to do it for both ${CHOST}-windres and windres
185                 *) myeconfargs+=( ac_cv_prog_RC= ac_cv_prog_ac_ct_RC= ) ;;
186         esac
187
188         ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
189 }
190
191 multilib_src_compile() {
192         default
193
194         if multilib_is_native_abi && use utils; then
195                 einfo "Building utils"
196                 # fix for Prefix, bug #339334
197                 emake \
198                         X11_PATH="${EPREFIX}/usr/$(get_libdir)" \
199                         FT2DEMOS=1 TOP_DIR_2="${WORKDIR}/ft2demos-${PV}"
200         fi
201 }
202
203 multilib_src_install() {
204         default
205
206         if multilib_is_native_abi && use utils; then
207                 einfo "Installing utils"
208                 rm "${WORKDIR}"/ft2demos-${PV}/bin/README || die
209                 dodir /usr/bin #654780
210                 local ft2demo
211                 for ft2demo in ../ft2demos-${PV}/bin/*; do
212                         ./libtool --mode=install $(type -P install) -m 755 "${ft2demo}" \
213                                 "${ED}"/usr/bin || die
214                 done
215         fi
216 }
217
218 multilib_src_install_all() {
219         if use fontforge; then
220                 # Probably fontforge needs less but this way makes things simplier...
221                 einfo "Installing internal headers required for fontforge"
222                 local header
223                 find src/truetype include/freetype/internal -name '*.h' | \
224                 while read header; do
225                         mkdir -p "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
226                         cp ${header} "${ED}/usr/include/freetype2/internal4fontforge/$(dirname ${header})" || die
227                 done
228         fi
229
230         dodoc docs/{CHANGES,CUSTOMIZE,DEBUG,INSTALL.UNIX,*.txt,PROBLEMS,TODO}
231         if [[ "${PV}" != 9999 ]] && use doc ; then
232                 docinto html
233                 dodoc -r docs/*
234         fi
235
236         find "${ED}" -name '*.la' -delete || die
237         if ! use static-libs ; then
238                 find "${ED}" -name '*.a' -delete || die
239         fi
240 }