59957af5e23c052b42cba0accd7ad9c076ad4fc5
[gentoo.git] / sys-fs / dd-rescue / dd-rescue-1.99.8.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit toolchain-funcs flag-o-matic multilib autotools
7
8 MY_PN="${PN/-/_}"
9 MY_P="${MY_PN}-${PV}"
10
11 DESCRIPTION="Similar to dd but can copy from source with errors"
12 HOMEPAGE="http://www.garloff.de/kurt/linux/ddrescue/"
13 SRC_URI="http://www.garloff.de/kurt/linux/ddrescue/${MY_P}.tar.bz2"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS="amd64 ~arm ~mips ppc ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos"
18 IUSE="cpu_flags_x86_avx2 lzo cpu_flags_x86_sse4_2 static xattr"
19
20 RDEPEND="lzo? ( dev-libs/lzo )
21         xattr? ( sys-apps/attr )"
22 DEPEND="${RDEPEND}"
23
24 S="${WORKDIR}/${MY_P}"
25
26 PATCHES=(
27         "${FILESDIR}"/${MY_PN}-1.99-musl-r2.patch
28         "${FILESDIR}"/${PN}-1.99.8-xattr.patch
29 )
30
31 src_prepare() {
32         default
33
34         sed -i \
35                 -e 's:-ldl:$(LDFLAGS) -ldl:' \
36                 -e 's:-shared:$(CFLAGS) $(LDFLAGS) -shared:' \
37                 Makefile || die
38
39         if ! use cpu_flags_x86_sse4_2; then
40                 sed -i \
41                         -e 's:^CC_FLAGS_CHECK(-msse4.2,SSE42):#&:' \
42                         configure.in || die
43         fi
44
45         if ! use cpu_flags_x86_avx2; then
46                 sed -i \
47                         -e 's:^CC_FLAGS_CHECK(-mavx2,AVX2):#&:' \
48                         configure.in || die
49         fi
50
51         eautoreconf
52 }
53
54 src_configure() {
55         use static && append-ldflags -static
56         # OpenSSL is only used by a random helper tool we don't install.
57         ac_cv_header_attr_xattr_h=$(usex xattr) \
58         ac_cv_header_openssl_evp_h=no \
59         ac_cv_lib_crypto_EVP_aes_192_ctr=no \
60         ac_cv_lib_lzo2_lzo1x_1_compress=$(usex lzo) \
61         ac_cv_header_lzo_lzo1x_h=$(usex lzo) \
62         econf
63 }
64
65 _emake() {
66         local arch
67         case ${ARCH} in
68         x86)   arch=i386;;
69         amd64) arch=x86_64;;
70         arm)   arch=arm;;
71         arm64) arch=aarch64;;
72         esac
73
74         local os=$(usex kernel_linux Linux IDK)
75
76         # The Makefile is a mess.  Override a few vars rather than patch it.
77         emake \
78                 MACH="${arch}" \
79                 OS="${os}" \
80                 HAVE_SSE42=$(usex cpu_flags_x86_sse4_2 1 0) \
81                 HAVE_AVX2=$(usex cpu_flags_x86_avx2 1 0) \
82                 RPM_OPT_FLAGS="${CFLAGS} ${CPPFLAGS}" \
83                 CFLAGS_OPT='$(CFLAGS)' \
84                 LDFLAGS="${LDFLAGS} -Wl,-rpath,${EPREFIX}/usr/$(get_libdir)/${PN}" \
85                 CC="$(tc-getCC)" \
86                 "$@"
87 }
88
89 src_compile() {
90         _emake
91 }
92
93 src_test() {
94         _emake check
95 }
96
97 src_install() {
98         # easier to install by hand than trying to make sense of the Makefile.
99         dobin dd_rescue
100         dodir /usr/$(get_libdir)/${PN}
101         cp -pPR libddr_*.so "${ED%/}"/usr/$(get_libdir)/${PN}/ || die
102         dodoc README.dd_rescue
103         doman dd_rescue.1
104         use lzo && doman ddr_lzo.1
105 }