From a7cc0b590a634e3c2612976c1dc83e74f8448d43 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Fri, 4 May 2018 13:35:10 -0700 Subject: Fix make install * Uninstall didn't remove the pkg-config correctly. * Fix `mandir` * Allow overriding either upper- or lower-case location variables, but always use the lower case variables. * Add test case that ensures overriding both upper- and lower-case variables is the same, and that the directory is empty after uninstall. --- lib/Makefile | 70 ++++++++++++++++++++++++++------------------------- programs/Makefile | 62 ++++++++++++++++++++++----------------------- tests/Makefile | 5 +++- tests/test_install.sh | 21 ++++++++++++++++ 4 files changed, 91 insertions(+), 67 deletions(-) create mode 100755 tests/test_install.sh diff --git a/lib/Makefile b/lib/Makefile index d63de18..abb6c07 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -62,7 +62,7 @@ ifeq ($(shell uname), Darwin) SHARED_EXT = dylib SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) - SONAME_FLAGS = -install_name $(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) + SONAME_FLAGS = -install_name $(libdir)/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) else SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR) SHARED_EXT = so @@ -132,20 +132,22 @@ listL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (n DESTDIR ?= # directory variables : GNU conventions prefer lowercase # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html -# support both lower and uppercase (BSD), use uppercase in script -prefix ?= /usr/local -PREFIX ?= $(prefix) -exec_prefix ?= $(PREFIX) -libdir ?= $(exec_prefix)/lib -LIBDIR ?= $(libdir) -includedir ?= $(PREFIX)/include -INCLUDEDIR ?= $(includedir) +# support both lower and uppercase (BSD), use lower in script +PREFIX ?= /usr/local +prefix ?= $(PREFIX) +EXEC_PREFIX ?= $(prefix) +exec_prefix ?= $(EXEC_PREFIX) +LIBDIR ?= $(exec_prefix)/lib +libdir ?= $(LIBDIR) +INCLUDEDIR ?= $(prefix)/include +includedir ?= $(INCLUDEDIR) ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly)) -PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig +PKGCONFIGDIR ?= $(prefix)/libdata/pkgconfig else -PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig +PKGCONFIGDIR ?= $(libdir)/pkgconfig endif +pkgconfigdir ?= $(PKGCONFIGDIR) ifneq (,$(filter $(shell uname),SunOS)) INSTALL ?= ginstall @@ -158,41 +160,41 @@ INSTALL_DATA ?= $(INSTALL) -m 644 liblz4.pc: liblz4.pc.in Makefile @echo creating pkgconfig - $(Q)sed -e 's|@PREFIX@|$(PREFIX)|' \ - -e 's|@LIBDIR@|$(LIBDIR)|' \ - -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ + $(Q)sed -e 's|@PREFIX@|$(prefix)|' \ + -e 's|@LIBDIR@|$(libdir)|' \ + -e 's|@INCLUDEDIR@|$(includedir)|' \ -e 's|@VERSION@|$(LIBVER)|' \ $< >$@ install: lib liblz4.pc - $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ $(DESTDIR)$(INCLUDEDIR)/ $(DESTDIR)$(LIBDIR)/ - $(Q)$(INSTALL_DATA) liblz4.pc $(DESTDIR)$(PKGCONFIGDIR)/ + $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ + $(Q)$(INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/ @echo Installing libraries ifeq ($(BUILD_STATIC),yes) - $(Q)$(INSTALL_DATA) liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a - $(Q)$(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(INCLUDEDIR)/lz4frame_static.h + $(Q)$(INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a + $(Q)$(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h endif ifeq ($(BUILD_SHARED),yes) - $(Q)$(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR) - $(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) - $(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) + $(Q)$(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir) + $(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) + $(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) endif - @echo Installing headers in $(INCLUDEDIR) - $(Q)$(INSTALL_DATA) lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h - $(Q)$(INSTALL_DATA) lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h - $(Q)$(INSTALL_DATA) lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h + @echo Installing headers in $(includedir) + $(Q)$(INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h + $(Q)$(INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h + $(Q)$(INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h @echo lz4 libraries installed uninstall: - $(Q)$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc - $(Q)$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) - $(Q)$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) - $(Q)$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) - $(Q)$(RM) $(DESTDIR)$(LIBDIR)/liblz4.a - $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4.h - $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4hc.h - $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4frame.h - $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4frame_static.h + $(Q)$(RM) $(DESTDIR)$(pkgconfigdir)/liblz4.pc + $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) + $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) + $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_VER) + $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.a + $(Q)$(RM) $(DESTDIR)$(includedir)/lz4.h + $(Q)$(RM) $(DESTDIR)$(includedir)/lz4hc.h + $(Q)$(RM) $(DESTDIR)$(includedir)/lz4frame.h + $(Q)$(RM) $(DESTDIR)$(includedir)/lz4frame_static.h @echo lz4 libraries successfully uninstalled endif diff --git a/programs/Makefile b/programs/Makefile index a51bd4b..72bdcaa 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -120,21 +120,19 @@ lz4cat: lz4 DESTDIR ?= # directory variables : GNU conventions prefer lowercase # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html -# support both lower and uppercase (BSD), use uppercase in script -prefix ?= /usr/local -PREFIX ?= $(prefix) -exec_prefix ?= $(PREFIX) -bindir ?= $(exec_prefix)/bin -BINDIR ?= $(bindir) -datarootdir ?= $(PREFIX)/share -mandir ?= $(datarootdir)/man -man1dir ?= $(mandir)/man1 - -ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS)) -MANDIR ?= $(PREFIX)/man/man1 -else -MANDIR ?= $(man1dir) -endif +# support both lower and uppercase (BSD), use lowercase in script +PREFIX ?= /usr/local +prefix ?= $(PREFIX) +EXEC_PREFIX ?= $(prefix) +exec_prefix ?= $(EXEC_PREFIX) +BINDIR ?= $(exec_prefix)/bin +bindir ?= $(BINDIR) +DATAROOTDIR ?= $(prefix)/share +datarootdir ?= $(DATAROOTDIR) +MANDIR ?= $(datarootdir)/man +mandir ?= $(MANDIR) +MAN1DIR ?= $(mandir)/man1 +man1dir ?= $(MAN1DIR) ifneq (,$(filter $(shell uname),SunOS)) INSTALL ?= ginstall @@ -148,27 +146,27 @@ INSTALL_DATA ?= $(INSTALL) -m 644 install: lz4 @echo Installing binaries - @$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ - @$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(BINDIR)/lz4 - @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4c - @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat - @ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4 + @$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/ + @$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(bindir)/lz4 + @ln -sf lz4 $(DESTDIR)$(bindir)/lz4c + @ln -sf lz4 $(DESTDIR)$(bindir)/lz4cat + @ln -sf lz4 $(DESTDIR)$(bindir)/unlz4 @echo Installing man pages - @$(INSTALL_DATA) lz4.1 $(DESTDIR)$(MANDIR)/lz4.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4c.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4cat.1 - @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/unlz4.1 + @$(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1 + @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4c.1 + @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1 + @ln -sf lz4.1 $(DESTDIR)$(man1dir)/unlz4.1 @echo lz4 installation completed uninstall: - @$(RM) $(DESTDIR)$(BINDIR)/lz4cat - @$(RM) $(DESTDIR)$(BINDIR)/unlz4 - @$(RM) $(DESTDIR)$(BINDIR)/lz4 - @$(RM) $(DESTDIR)$(BINDIR)/lz4c - @$(RM) $(DESTDIR)$(MANDIR)/lz4.1 - @$(RM) $(DESTDIR)$(MANDIR)/lz4c.1 - @$(RM) $(DESTDIR)$(MANDIR)/lz4cat.1 - @$(RM) $(DESTDIR)$(MANDIR)/unlz4.1 + @$(RM) $(DESTDIR)$(bindir)/lz4cat + @$(RM) $(DESTDIR)$(bindir)/unlz4 + @$(RM) $(DESTDIR)$(bindir)/lz4 + @$(RM) $(DESTDIR)$(bindir)/lz4c + @$(RM) $(DESTDIR)$(man1dir)/lz4.1 + @$(RM) $(DESTDIR)$(man1dir)/lz4c.1 + @$(RM) $(DESTDIR)$(man1dir)/lz4cat.1 + @$(RM) $(DESTDIR)$(man1dir)/unlz4.1 @echo lz4 programs successfully uninstalled endif diff --git a/tests/Makefile b/tests/Makefile index d4847b1..196426e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -141,11 +141,14 @@ endif DD:=dd -test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer +test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-install test32: CFLAGS+=-m32 test32: test +test-install: + lz4_root=.. ./test_install.sh + test-lz4-sparse: lz4 datagen @echo "\n ---- test sparse file support ----" ./datagen -g5M -P100 > tmplsdg5M diff --git a/tests/test_install.sh b/tests/test_install.sh new file mode 100755 index 0000000..2e1a5a5 --- /dev/null +++ b/tests/test_install.sh @@ -0,0 +1,21 @@ +#/usr/bin/env sh +set -e + +make="make -C $lz4_root" +$make CFLAGS=-O0 > /dev/null +for cmd in install uninstall; do + for upper in DUMMY PREFIX EXEC_PREFIX LIBDIR INCLUDEDIR PKGCONFIGDIR BINDIR MANDIR MAN1DIR ; do + lower=$(echo $upper | tr '[:upper:]' '[:lower:]') + tmp_lower="$(pwd)/tmp-lower-$lower/" + tmp_upper="$(pwd)/tmp-upper-$lower/" + echo $make $cmd DESTDIR="$tmp_upper" $upper="test" + $make $cmd DESTDIR="$tmp_upper" $upper="test" >/dev/null + echo $make $cmd DESTDIR="$tmp_lower" $lower="test" + $make $cmd DESTDIR="$tmp_lower" $lower="test" >/dev/null + command diff -r "$tmp_lower" "$tmp_upper" && echo "SAME!" || false + if [ "x$cmd" = "xuninstall" ]; then + test -z "$(find "$tmp_lower" -type f)" && echo "EMPTY!" || false + rm -rf "$tmp_upper" "$tmp_lower" + fi + done +done -- cgit v0.12