Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1commit abcb3cca9452779e91380b7636f32745166af3de 2Author: John Ericson <John.Ericson@Obsidian.Systems> 3Date: Wed Nov 29 23:55:38 2023 -0500 4 5 Make build system: enable/disable shared/static support 6 7 This allows building this package in static-lib-only distros. 8 9diff --git a/Makefile b/Makefile 10index 5d21221..cbc7914 100644 11--- a/Makefile 12+++ b/Makefile 13@@ -18,6 +18,9 @@ 14 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 15 # IN THE SOFTWARE. 16 17+ENABLE_SHARED ?= 1 18+ENABLE_STATIC ?= 19+ 20 PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') 21 HELPER ?= 22 BINEXT ?= 23@@ -25,6 +28,8 @@ SOLIBNAME = libhttp_parser 24 SOMAJOR = 2 25 SOMINOR = 9 26 SOREV = 4 27+AEXT = a 28+STATICLIBNAME = $(SOLIBNAME).$(AEXT) 29 ifeq (darwin,$(PLATFORM)) 30 SOEXT ?= dylib 31 SONAME ?= $(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT) 32@@ -109,11 +114,17 @@ test-valgrind: test_g 33 libhttp_parser.o: http_parser.c http_parser.h Makefile 34 $(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o 35 36-library: libhttp_parser.o 37- $(CC) $(LDFLAGS_LIB) -o $(LIBNAME) $< 38+.PHONY: library 39+library: $(LIBNAME) 40+ 41+$(LIBNAME): libhttp_parser.o 42+ $(CC) $(LDFLAGS_LIB) -o $@ $< 43 44-package: http_parser.o 45- $(AR) rcs libhttp_parser.a http_parser.o 46+.PHONY: package 47+package: $(STATICLIBNAME) 48+ 49+$(STATICLIBNAME): http_parser.o 50+ $(AR) rcs $@ $< 51 52 url_parser: http_parser.o contrib/url_parser.c 53 $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@ 54@@ -130,12 +141,30 @@ parsertrace_g: http_parser_g.o contrib/parsertrace.c 55 tags: http_parser.c http_parser.h test.c 56 ctags $^ 57 58-install: library 59+.PHONY: install-headers 60+install-headers: 61 $(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h 62+ 63+.PHONY: install-library 64+install-library: library 65 $(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME) 66 ln -sf $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME) 67 ln -sf $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT) 68 69+.PHONY: install-package 70+install-package: package 71+ $(INSTALL) -D $(STATICLIBNAME) $(DESTDIR)$(LIBDIR)/$(STATICLIBNAME) 72+ 73+.PHONY: install 74+install: install-headers 75+ifeq ($(ENABLE_SHARED),1) 76+install: install-library 77+endif 78+ifeq ($(ENABLE_STATIC),1) 79+install: install-package 80+endif 81+ 82+.PHONY: install-strip 83 install-strip: library 84 $(INSTALL) -D http_parser.h $(DESTDIR)$(INCLUDEDIR)/http_parser.h 85 $(INSTALL) -D -s $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME) 86@@ -147,6 +176,7 @@ uninstall: 87 rm $(DESTDIR)$(LIBDIR)/$(SOLIBNAME).$(SOEXT) 88 rm $(DESTDIR)$(LIBDIR)/$(SONAME) 89 rm $(DESTDIR)$(LIBDIR)/$(LIBNAME) 90+ rm $(DESTDIR)$(LIBDIR)/$(STATICLIBNAME) 91 92 clean: 93 rm -f *.o *.a tags test test_fast test_g \