1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6,7,8} )
9 inherit distutils-r1 libtool 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 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~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="bzip2 lzma python seccomp static-libs zlib"
25 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
28 bzip2? ( app-arch/bzip2[${MULTILIB_USEDEP}] )
29 lzma? ( app-arch/xz-utils[${MULTILIB_USEDEP}] )
32 dev-python/setuptools[${PYTHON_USEDEP}]
34 zlib? ( >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] )"
36 python? ( !dev-python/python-magic )
37 seccomp? ( sys-libs/libseccomp[${MULTILIB_USEDEP}] )"
42 [[ ${PV} == "9999" ]] && eautoreconf
45 # don't let python README kill main README #60043
46 mv python/README.md python/README.python.md || die
47 sed 's@README.md@README.python.md@' -i python/setup.py || die #662090
50 multilib_src_configure() {
53 $(use_enable bzip2 bzlib)
54 $(use_enable lzma xzlib)
55 $(use_enable seccomp libseccomp)
56 $(use_enable static-libs static)
59 econf "${myeconfargs[@]}"
62 build_src_configure() {
70 tc-env_build econf "${myeconfargs[@]}"
74 # when cross-compiling, we need to build up our own file
75 # because people often don't keep matching host/target
76 # file versions #362941
77 tc-is-cross-compiler && ! has_version -b "~${CATEGORY}/${P}"
81 local ECONF_SOURCE=${S}
83 if need_build_file; then
84 mkdir -p "${WORKDIR}"/build || die
85 cd "${WORKDIR}"/build || die
89 multilib-minimal_src_configure
92 multilib_src_compile() {
93 if multilib_is_native_abi ; then
103 if need_build_file; then
104 emake -C "${WORKDIR}"/build/src magic.h #586444
105 emake -C "${WORKDIR}"/build/src file
106 local -x PATH="${WORKDIR}/build/src:${PATH}"
108 multilib-minimal_src_compile
112 distutils-r1_src_compile
116 multilib_src_install() {
117 if multilib_is_native_abi ; then
120 emake -C src install-{nodist_includeHEADERS,libLTLIBRARIES} DESTDIR="${D}"
124 multilib_src_install_all() {
125 dodoc ChangeLog MAINT README
127 # Required for `file -C`
128 dodir /usr/share/misc/magic
129 insinto /usr/share/misc/magic
130 doins -r magic/Magdir/*
134 distutils-r1_src_install
136 find "${ED}" -type f -name "*.la" -delete || die