From 6323a64c051817854a7c992e0259cc0e2bc5fb38 Mon Sep 17 00:00:00 2001 From: Benjamin Beasley Date: Tue, 20 Oct 2020 18:02:55 -0400 Subject: Add ZOPFLI_LIBS and ZOPFLI_CFLAGS variables to the Makefile to make it easy to build with an external Zopfli library. Set their default values such that the bundled Zopfli library is still used by default. Re-order the linker flags so that both cases work as expected. Fix linker flag order --- Makefile | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 173394b..c377015 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,35 @@ -FILES=zopfli/blocksplitter.c zopfli/cache.c zopfli/deflate.c zopfli/gzip_container.c zopfli/hash.c zopfli/katajainen.c zopfli/lz77.c zopfli/squeeze.c zopfli/tree.c zopfli/util.c zopfli/zlib_container.c zopfli/zopfli_lib.c woff.c +# When using the bundled Zopfli library, this is a list of sources to compile. +# To use an external Zopfli library, override it with the path to a static +# library, or with something like -lzopfli. +ZOPFLI_LIBS=zopfli/blocksplitter.c \ + zopfli/cache.c \ + zopfli/deflate.c \ + zopfli/gzip_container.c \ + zopfli/hash.c \ + zopfli/katajainen.c \ + zopfli/lz77.c \ + zopfli/squeeze.c \ + zopfli/tree.c \ + zopfli/util.c \ + zopfli/zlib_container.c \ + zopfli/zopfli_lib.c +# When not using the bundled Zopfli library, this should normally be overridden +# with the empty string to avoid finding bundled Zopfli headers. +ZOPFLI_CFLAGS=-Izopfli + +FILES=woff.c all: sfnt2woff-zopfli woff2sfnt-zopfli sfnt2woff-zopfli: sfnt2woff.c $(FILES) Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) -Izopfli $(LDFLAGS) $(FILES) $< -o $@ -lz -lm + $(CC) $(CPPFLAGS) $(CFLAGS) $(ZOPFLI_CFLAGS) \ + $(FILES) $< -o $@ \ + $(LDFLAGS) $(ZOPFLI_LIBS) -lz -lm woff2sfnt-zopfli: woff2sfnt.c $(FILES) Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) -Izopfli $(LDFLAGS) $(FILES) $< -o $@ -lz -lm + $(CC) $(CPPFLAGS) $(CFLAGS) $(ZOPFLI_CFLAGS) \ + $(FILES) $< -o $@ \ + $(LDFLAGS) $(ZOPFLI_LIBS) -lz -lm clean: $(RM) -r *.o *.dSYM sfnt2woff-zopfli woff2sfnt-zopfli *.gch *.out -- cgit v1.2.3