From ee4d18872bfe09a32cfd031c716b9069a04a50a0 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Wed, 3 Nov 2021 17:57:36 -0400 Subject: [PATCH] Add environment variable to disable building shared library Environment variable DISABLE_SHARED (following convention of --disable-shared of ./configure script) disables building of shared library and shared lib symlink. It makes life of downstream maintainer easier when maintaining package for environment that supports only static libraries. See https://github.com/NixOS/nixpkgs/pull/144438 --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 276d75d..0541de9 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ # Define USE_SHARED_LIB to link the binaries to the shared library version of # libdeflate rather than to the static library version. # +# Define DISABLE_SHARED to disable building and installing of shared library. +# Defining this variable undefines USE_SHARED_LIB. +# # Define DECOMPRESSION_ONLY to omit all compression code, building a # decompression-only library. If doing this, you must also build a specific # library target such as 'libdeflate.a', as the programs will no longer compile. @@ -142,6 +145,7 @@ endif .build-config: FORCE @flags=$$( \ echo 'USE_SHARED_LIB=$(USE_SHARED_LIB)'; \ + echo 'DISABLE_SHARED=$(DISABLE_SHARED)'; \ echo 'DECOMPRESSION_ONLY=$(DECOMPRESSION_ONLY)'; \ echo 'DISABLE_GZIP=$(DISABLE_GZIP)'; \ echo 'DISABLE_ZLIB=$(DISABLE_ZLIB)'; \ @@ -216,7 +220,11 @@ $(SHARED_LIB):$(SHARED_LIB_OBJ) $(QUIET_CCLD) $(CC) -o $@ $(LDFLAGS) $(LIB_CFLAGS) \ $(SHARED_LIB_LDFLAGS) -shared $+ +ifdef DISABLE_SHARED +undefine SHARED_LIB_SYMLINK +else DEFAULT_TARGETS += $(SHARED_LIB) +endif ifdef SHARED_LIB_SYMLINK # Create the symlink libdeflate.so => libdeflate.so.$SOVERSION @@ -305,7 +313,9 @@ all:$(DEFAULT_TARGETS) install:all install -d $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR) $(DESTDIR)$(BINDIR) install -m644 $(STATIC_LIB) $(DESTDIR)$(LIBDIR) - install -m755 $(SHARED_LIB) $(DESTDIR)$(LIBDIR) + if [ -z "$(DISABLE_SHARED)" ]; then \ + install -m755 $(SHARED_LIB) $(DESTDIR)$(LIBDIR); \ + fi install -m644 libdeflate.h $(DESTDIR)$(INCDIR) install -m755 gzip$(PROG_SUFFIX) \ $(DESTDIR)$(BINDIR)/libdeflate-gzip$(PROG_SUFFIX)