1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{4,5,6,7} pypy )
9 inherit distutils-r1 libtool ltprune toolchain-funcs multilib-minimal
11 if [[ ${PV} == "9999" ]] ; then
12 EGIT_REPO_URI="https://github.com/glensc/file.git"
13 inherit autotools git-r3
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"
19 DESCRIPTION="identify a file's format by scanning binary data for patterns"
20 HOMEPAGE="https://www.darwinsys.com/file/"
24 IUSE="python static-libs zlib"
25 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
30 dev-python/setuptools[${PYTHON_USEDEP}]
32 zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
34 python? ( !dev-python/python-magic )"
37 "${FILESDIR}"/${P}-CVE-2018-10360.patch
38 "${FILESDIR}"/${P}-gl_VISIBILITY-macro.patch
44 # We are patching configure script so fix timestamp to avoid autoreconf
45 touch -r compile configure
47 [[ ${PV} == "9999" ]] && eautoreconf
50 # don't let python README kill main README #60043
51 mv python/README{,.python} || die
54 multilib_src_configure() {
58 $(use_enable static-libs static)
61 ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
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}
73 ac_cv_header_zlib_h=no \
74 ac_cv_lib_z_gzopen=no \
76 CFLAGS=${BUILD_CFLAGS} \
77 CXXFLAGS=${BUILD_CXXFLAGS} \
78 CPPFLAGS=${BUILD_CPPFLAGS} \
79 LDFLAGS="${BUILD_LDFLAGS} -static" \
82 econf --disable-shared --disable-libseccomp
85 multilib-minimal_src_configure
88 multilib_src_compile() {
89 if multilib_is_native_abi ; then
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}"
104 multilib-minimal_src_compile
108 distutils-r1_src_compile
112 multilib_src_install() {
113 if multilib_is_native_abi ; then
116 emake -C src install-{nodist_includeHEADERS,libLTLIBRARIES} DESTDIR="${D}"
120 multilib_src_install_all() {
121 dodoc ChangeLog MAINT README
123 # Required for `file -C`
124 dodir /usr/share/misc/magic
125 insinto /usr/share/misc/magic
126 doins -r magic/Magdir/*
130 distutils-r1_src_install