Skip to content

Commit

Permalink
app-arch/zopfli: respect CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Aug 20, 2016
1 parent 05436c8 commit 96a2115
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
44 changes: 44 additions & 0 deletions app-arch/zopfli/files/zopfli-1.0.1-makefile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--- zopfli-zopfli-1.0.1/Makefile
+++ zopfli-zopfli-1.0.1/Makefile
@@ -1,8 +1,10 @@
-CC = gcc
-CXX = g++
+CC ?= gcc
+CXX ?= g++

-CFLAGS = -W -Wall -Wextra -ansi -pedantic -lm -O2
-CXXFLAGS = -W -Wall -Wextra -ansi -pedantic -O2
+CFLAGS += -W -Wall -Wextra -ansi -pedantic
+CXXFLAGS += -W -Wall -Wextra -ansi -pedantic
+LIBS = -lm
+LDFLAGS += $(LIBS)

ZOPFLILIB_SRC = src/zopfli/blocksplitter.c src/zopfli/cache.c\
src/zopfli/deflate.c src/zopfli/gzip_container.c\
@@ -20,22 +22,22 @@

# Zopfli binary
zopfli:
- $(CC) $(ZOPFLILIB_SRC) $(ZOPFLIBIN_SRC) $(CFLAGS) -o zopfli
+ $(CC) $(ZOPFLILIB_SRC) $(ZOPFLIBIN_SRC) $(CFLAGS) $(LDFLAGS) -o zopfli

# Zopfli shared library
libzopfli:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -fPIC -c
- $(CC) $(ZOPFLILIB_OBJ) $(CFLAGS) -shared -Wl,-soname,libzopfli.so.1 -o libzopfli.so.1.0.1
+ $(CC) $(ZOPFLILIB_OBJ) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname,libzopfli.so.1 -o libzopfli.so.1.0.1

# ZopfliPNG binary
zopflipng:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -c
- $(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(ZOPFLIPNGBIN_SRC) $(CFLAGS) -o zopflipng
+ $(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(ZOPFLIPNGBIN_SRC) $(CFLAGS) $(LDFLAGS) -o zopflipng

# ZopfliPNG shared library
libzopflipng:
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -fPIC -c
- $(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(CFLAGS) -fPIC --shared -Wl,-soname,libzopflipng.so.1 -o libzopflipng.so.1.0.0
+ $(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(CFLAGS) $(LDFLAGS) -fPIC --shared -Wl,-soname,libzopflipng.so.1 -o libzopflipng.so.1.0.0

# Remove all libraries and binaries
clean:
51 changes: 51 additions & 0 deletions app-arch/zopfli/zopfli-1.0.1-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

inherit toolchain-funcs

DESCRIPTION="Very good, but slow, deflate or zlib compression"
HOMEPAGE="https://github.com/google/zopfli/"
SRC_URI="https://github.com/google/zopfli/archive/${P}.tar.gz"

S="${WORKDIR}/${PN}-${P}"

LICENSE="Apache-2.0"
SLOT="0/1"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"

DOCS=( CONTRIBUTORS README README.zopflipng )

PATCHES=( "${FILESDIR}"/${P}-makefile.patch )

# zopfli statically links libzopfli
# zopflipng statically links libzopflipng
# zopflipng also statically links an exact version of LodePNG (https://github.com/lvandeve/lodepng)
# As of version 1.0.1 neither of the binaries
# use the libraries we install. The libraries
# exist solely for use by external programs.

src_compile() {
tc-export CC CXX
emake libzopfli
emake zopfli

emake libzopflipng
emake zopflipng
}

# The Makefile has no install phase
src_install() {
dolib.so libzopfli.so.${PV}
dosym libzopfli.so.${PV} /usr/$(get_libdir)/libzopfli.so.1

dobin ${PN}

# This version was erroneously not bumped to match ${PV}
dolib.so libzopflipng.so.1.0.0
dosym libzopflipng.so.1.0.0 /usr/$(get_libdir)/libzopflipng.so.1

dobin zopflipng
}

0 comments on commit 96a2115

Please sign in to comment.