sys-apps/file: Add missing gl_VISIBILITY macro in configure script
[gentoo.git] / sys-apps / file / file-5.33-r3.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{4,5,6,7} pypy )
7 DISTUTILS_OPTIONAL=1
8
9 inherit distutils-r1 libtool ltprune toolchain-funcs multilib-minimal
10
11 if [[ ${PV} == "9999" ]] ; then
12         EGIT_REPO_URI="https://github.com/glensc/file.git"
13         inherit autotools git-r3
14 else
15         SRC_URI="ftp://ftp.astron.com/pub/file/${P}.tar.gz"
16         KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
17 fi
18
19 DESCRIPTION="identify a file's format by scanning binary data for patterns"
20 HOMEPAGE="https://www.darwinsys.com/file/"
21
22 LICENSE="BSD-2"
23 SLOT="0"
24 IUSE="python static-libs zlib"
25 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
26
27 DEPEND="
28         python? (
29                 ${PYTHON_DEPS}
30                 dev-python/setuptools[${PYTHON_USEDEP}]
31         )
32         zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
33 RDEPEND="${DEPEND}
34         python? ( !dev-python/python-magic )"
35
36 PATCHES=(
37         "${FILESDIR}"/${P}-CVE-2018-10360.patch
38         "${FILESDIR}"/${P}-gl_VISIBILITY-macro.patch
39 )
40
41 src_prepare() {
42         default
43
44         # We are patching configure script so fix timestamp to avoid autoreconf
45         touch -r compile configure
46
47         [[ ${PV} == "9999" ]] && eautoreconf
48         elibtoolize
49
50         # don't let python README kill main README #60043
51         mv python/README{,.python} || die
52 }
53
54 multilib_src_configure() {
55         local myeconfargs=(
56                 --disable-libseccomp
57                 --enable-fsect-man5
58                 $(use_enable static-libs static)
59                 $(use_enable zlib)
60         )
61         ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
62 }
63
64 src_configure() {
65         # when cross-compiling, we need to build up our own file
66         # because people often don't keep matching host/target
67         # file versions #362941
68         if tc-is-cross-compiler && ! ROOT=/ has_version ~${CATEGORY}/${P} ; then
69                 mkdir -p "${WORKDIR}"/build || die
70                 cd "${WORKDIR}"/build || die
71                 tc-export_build_env BUILD_C{C,XX}
72                 ECONF_SOURCE=${S} \
73                 ac_cv_header_zlib_h=no \
74                 ac_cv_lib_z_gzopen=no \
75                 CHOST=${CBUILD} \
76                 CFLAGS=${BUILD_CFLAGS} \
77                 CXXFLAGS=${BUILD_CXXFLAGS} \
78                 CPPFLAGS=${BUILD_CPPFLAGS} \
79                 LDFLAGS="${BUILD_LDFLAGS} -static" \
80                 CC=${BUILD_CC} \
81                 CXX=${BUILD_CXX} \
82                 econf --disable-shared --disable-libseccomp
83         fi
84
85         multilib-minimal_src_configure
86 }
87
88 multilib_src_compile() {
89         if multilib_is_native_abi ; then
90                 emake
91         else
92                 cd src || die
93                 emake magic.h #586444
94                 emake libmagic.la
95         fi
96 }
97
98 src_compile() {
99         if tc-is-cross-compiler && ! ROOT=/ has_version "~${CATEGORY}/${P}" ; then
100                 emake -C "${WORKDIR}"/build/src magic.h #586444
101                 emake -C "${WORKDIR}"/build/src file
102                 PATH="${WORKDIR}/build/src:${PATH}"
103         fi
104         multilib-minimal_src_compile
105
106         if use python ; then
107                 cd python || die
108                 distutils-r1_src_compile
109         fi
110 }
111
112 multilib_src_install() {
113         if multilib_is_native_abi ; then
114                 default
115         else
116                 emake -C src install-{nodist_includeHEADERS,libLTLIBRARIES} DESTDIR="${D}"
117         fi
118 }
119
120 multilib_src_install_all() {
121         dodoc ChangeLog MAINT README
122
123         # Required for `file -C`
124         dodir /usr/share/misc/magic
125         insinto /usr/share/misc/magic
126         doins -r magic/Magdir/*
127
128         if use python ; then
129                 cd python || die
130                 distutils-r1_src_install
131         fi
132         prune_libtool_files
133 }