Add option to link zlib statically
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 14 Sep 2015 14:59:13 +0000 (16:59 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 14 Sep 2015 14:59:23 +0000 (16:59 +0200)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Makefile

index 17b5d88b06008985ec2d72e0a36ed18eb87e3f5f..908e44a43646fe1ba9318c320ccb8a2244e3c59e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,12 @@
 CC ?= gcc
 CFLAGS += -Iinclude -Ilibsparse/include
 
+ifeq ($(STATIC),1)
+  ZLIB := -Wl,-Bstatic -lz -Wl,-Bdynamic
+else
+  ZLIB := -lz
+endif
+
 OBJ := \
     allocate.o \
        canned_fs_config.o \
@@ -21,7 +27,7 @@ OBJ := \
        $(CC) $(CFLAGS) -c -o $@ $^
 
 make_ext4fs: $(OBJ) libsparse/libsparse.a
-       $(CC) -o $@ $^ -lz
+       $(CC) -o $@ $^ $(ZLIB)
 
 libsparse/libsparse.a:
        $(MAKE) -C libsparse/ libsparse.a