Skip to content

Commit

Permalink
app-arch/lz4: add support for USE=static-libs
Browse files Browse the repository at this point in the history
  • Loading branch information
vapier committed Nov 10, 2016
1 parent 373863e commit 22099ce
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 18 deletions.
49 changes: 49 additions & 0 deletions app-arch/lz4/files/lz4-0_p131-static-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
fix from upstream

From 43b631223b2d0425a0970876974074934f89c450 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <[email protected]>
Date: Thu, 22 Sep 2016 23:59:02 -0400
Subject: [PATCH] add a flag to disable static libs

---
lib/Makefile | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/lib/Makefile b/lib/Makefile
index b5352a0cb372..27b35c41b693 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -40,6 +40,8 @@
LIBVER_PATCH=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)

+BUILD_STATIC:= yes
+
DESTDIR?=
PREFIX ?= /usr/local
CFLAGS ?= -O3
@@ -71,9 +72,11 @@
all: liblz4

liblz4: lz4.c lz4hc.c lz4frame.c xxhash.c
+ifeq ($(BUILD_STATIC),yes)
@echo compiling static library
@$(CC) $(CPPFLAGS) $(CFLAGS) -c $^
@$(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o
+endif
@echo compiling dynamic library $(LIBVER)
@$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER)
@echo creating versioned links
@@ -104,7 +107,9 @@
@cp -a liblz4.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR)
@cp -a liblz4.$(SHARED_EXT) $(DESTDIR)$(LIBDIR)
@cp -a liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
+ifeq ($(BUILD_STATIC),yes)
@install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a
+endif
@install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
@install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
@install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h
--
2.9.0

23 changes: 14 additions & 9 deletions app-arch/lz4/lz4-0_p131-r1.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,40 @@ LICENSE="BSD-2 GPL-2"
# with abi-compliance-checker and update the subslot every time ABI
# changes. This is the least we can do to keep things sane.
SLOT="0/r131"
IUSE="test valgrind"
IUSE="static-libs test valgrind"

DEPEND="test? ( valgrind? ( dev-util/valgrind ) )"

src_prepare() {
if ! use valgrind; then
sed -i -e '/^test:/s|test-mem||g' programs/Makefile || die
fi
epatch "${FILESDIR}"/${PN}-0_p131-static-libs.patch
multilib_copy_sources
}

lmake() {
emake \
BUILD_STATIC=$(usex static-libs) \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir) \
"$@"
}

multilib_src_compile() {
tc-export CC AR
# we must not use the 'all' target since it builds test programs
# & extra -m32 executables
emake -C lib liblz4 liblz4.pc \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir)
emake -C programs lz4 lz4c
lmake -C lib liblz4 liblz4.pc
lmake -C programs lz4 lz4c
# work around lack of proper target dependencies
touch lib/liblz4
}

multilib_src_test() {
emake -j1 test
lmake -j1 test
}

multilib_src_install() {
emake install DESTDIR="${D}" \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir)
lmake install DESTDIR="${D}"
}
23 changes: 14 additions & 9 deletions app-arch/lz4/lz4-9999.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,40 @@ LICENSE="BSD-2 GPL-2"
# with abi-compliance-checker and update the subslot every time ABI
# changes. This is the least we can do to keep things sane.
SLOT="0/r131"
IUSE="test valgrind"
IUSE="static-libs test valgrind"

DEPEND="test? ( valgrind? ( dev-util/valgrind ) )"

src_prepare() {
if ! use valgrind; then
sed -i -e '/^test:/s|test-mem||g' programs/Makefile || die
fi
epatch "${FILESDIR}"/${PN}-0_p131-static-libs.patch
multilib_copy_sources
}

lmake() {
emake \
BUILD_STATIC=$(usex static-libs) \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir) \
"$@"
}

multilib_src_compile() {
tc-export CC AR
# we must not use the 'all' target since it builds test programs
# & extra -m32 executables
emake -C lib liblz4 liblz4.pc \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir)
emake -C programs lz4 lz4c
lmake -C lib liblz4 liblz4.pc
lmake -C programs lz4 lz4c
# work around lack of proper target dependencies
touch lib/liblz4
}

multilib_src_test() {
emake -j1 test
lmake -j1 test
}

multilib_src_install() {
emake install DESTDIR="${D}" \
PREFIX="${EPREFIX}/usr" \
LIBDIR="${EPREFIX}"/usr/$(get_libdir)
lmake install DESTDIR="${D}"
}

0 comments on commit 22099ce

Please sign in to comment.