Merge pull request #293 from inikep/dev

improved *BSD and Solaris compatibility
This commit is contained in:
Yann Collet 2016-12-28 14:43:17 +01:00 committed by GitHub
commit 581da2bf80
3 changed files with 87 additions and 46 deletions

View File

@ -42,11 +42,6 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
BUILD_STATIC:= yes
DESTDIR ?=
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR=$(PREFIX)/include
CPPFLAGS+= -DXXH_NAMESPACE=LZ4_
CFLAGS ?= -O3
DEBUGFLAGS:=-g -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
@ -112,10 +107,30 @@ clean:
@echo Cleaning library completed
#------------------------------------------------------------------------
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and
#FreeBSD targets
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD))
#-----------------------------------------------------------------------------
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
#-----------------------------------------------------------------------------
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
ifneq (,$(filter $(shell uname),SunOS))
INSTALL ?= ginstall
else
INSTALL ?= install
endif
PREFIX ?= /usr/local
DESTDIR ?=
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly))
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
else
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
endif
INSTALL_LIB ?= $(INSTALL) -m 755
INSTALL_DATA ?= $(INSTALL) -m 644
liblz4.pc: liblz4.pc.in Makefile
@echo creating pkgconfig
@ -126,17 +141,19 @@ liblz4.pc: liblz4.pc.in Makefile
$< >$@
install: lib liblz4.pc
@install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/
@install -m 755 liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
@install -m 755 liblz4.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR)
@install -m 755 liblz4.$(SHARED_EXT) $(DESTDIR)$(LIBDIR)
@install -m 644 liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
@$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ $(DESTDIR)$(INCLUDEDIR)/
@$(INSTALL_DATA) liblz4.pc $(DESTDIR)$(PKGCONFIGDIR)/
@echo Installing libraries
ifeq ($(BUILD_STATIC),yes)
@install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)
@$(INSTALL_LIB) liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a
endif
@install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)
@install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)
@install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)
@$(INSTALL_LIB) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
@ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR)
@ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT)
@echo Installing includes
@$(INSTALL_DATA) lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
@$(INSTALL_DATA) lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
@$(INSTALL_DATA) lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h
@echo lz4 static and shared libraries installed
uninstall:

View File

@ -38,10 +38,6 @@ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
LIBVER := $(shell echo $(LIBVER_SCRIPT))
DESTDIR ?=
PREFIX ?= /usr/local
BINDIR := $(PREFIX)/bin
MANDIR := $(PREFIX)/share/man/man1
LZ4DIR := ../lib
SRCFILES := $(wildcard $(LZ4DIR)/*.c) $(wildcard *.c)
@ -112,10 +108,10 @@ preview-man: clean-man man
man ./lz4.1
#------------------------------------------------------------------------
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and
#FreeBSD targets
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD))
#-----------------------------------------------------------------------------
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
#-----------------------------------------------------------------------------
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
unlz4: lz4
ln -s lz4 unlz4
@ -123,15 +119,37 @@ unlz4: lz4
lz4cat: lz4
ln -s lz4 lz4cat
ifneq (,$(filter $(shell uname),SunOS))
INSTALL ?= ginstall
else
INSTALL ?= install
endif
PREFIX ?= /usr/local
DESTDIR ?=
BINDIR ?= $(PREFIX)/bin
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
MANDIR ?= $(PREFIX)/man/man1
else
MANDIR ?= $(PREFIX)/share/man/man1
endif
INSTALL_PROGRAM ?= $(INSTALL) -m 755
INSTALL_SCRIPT ?= $(INSTALL) -m 755
INSTALL_MAN ?= $(INSTALL) -m 644
install: lz4$(EXT) lz4c$(EXT)
@echo Installing binaries
@install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
@install -m 755 lz4 $(DESTDIR)$(BINDIR)/lz4
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
@$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(BINDIR)/lz4
@ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat
@ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4
@install -m 755 lz4c$(EXT) $(DESTDIR)$(BINDIR)/lz4c
@$(INSTALL_PROGRAM) lz4c$(EXT) $(DESTDIR)$(BINDIR)/lz4c
@echo Installing man pages
@install -m 644 lz4.1 $(DESTDIR)$(MANDIR)/lz4.1
@$(INSTALL_MAN) -m 644 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

View File

@ -120,15 +120,21 @@ versionsTest:
#------------------------------------------------------------------------
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and
#FreeBSD targets
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD))
#make test is validated only for Linux, OSX, kFreeBSD, FreeBSD, Hurd and
#Solaris targets
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
MD5:=md5sum
ifneq (,$(filter $(shell uname), Darwin ))
MD5:=md5 -r
endif
DIFF:=diff
ifneq (,$(filter $(shell uname),SunOS))
DIFF:=gdiff
endif
test: test-lz4 test-lz4c test-fasttest test-frametest test-fullbench test-fuzzer
test32: CFLAGS+=-m32
@ -138,18 +144,18 @@ test-lz4-sparse: lz4 datagen
@echo "\n ---- test sparse file support ----"
./datagen -g5M -P100 > tmpSrc
$(LZ4) -B4D tmpSrc | $(LZ4) -dv --sparse > tmpB4
diff -s tmpSrc tmpB4
$(DIFF) -s tmpSrc tmpB4
$(LZ4) -B5D tmpSrc | $(LZ4) -dv --sparse > tmpB5
diff -s tmpSrc tmpB5
$(DIFF) -s tmpSrc tmpB5
$(LZ4) -B6D tmpSrc | $(LZ4) -dv --sparse > tmpB6
diff -s tmpSrc tmpB6
$(DIFF) -s tmpSrc tmpB6
$(LZ4) -B7D tmpSrc | $(LZ4) -dv --sparse > tmpB7
diff -s tmpSrc tmpB7
$(DIFF) -s tmpSrc tmpB7
$(LZ4) tmpSrc | $(LZ4) -dv --no-sparse > tmpNoSparse
diff -s tmpSrc tmpNoSparse
$(DIFF) -s tmpSrc tmpNoSparse
ls -ls tmp*
./datagen -s1 -g1200007 -P100 | $(LZ4) | $(LZ4) -dv --sparse > tmpOdd # Odd size file (to generate non-full last block)
./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd
./datagen -s1 -g1200007 -P100 | $(DIFF) -s - tmpOdd
ls -ls tmpOdd
@$(RM) tmp*
@echo "\n Compatibility with Console :"
@ -163,7 +169,7 @@ test-lz4-sparse: lz4 datagen
$(LZ4) -d -v tmpC tmpR
$(LZ4) -d -v tmpC >> tmpR
ls -ls tmp*
diff tmp2M tmpR
$(DIFF) tmp2M tmpR
@$(RM) tmp*
test-lz4-contentSize: lz4 datagen
@ -171,13 +177,13 @@ test-lz4-contentSize: lz4 datagen
./datagen -g15M > tmp
$(LZ4) -v tmp | $(LZ4) -t
$(LZ4) -v --content-size tmp | $(LZ4) -d > tmp2
diff -s tmp tmp2
$(DIFF) -s tmp tmp2
# test large size [2-4] GB
@./datagen -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmp
@ls -ls tmp
@./datagen -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmp2
@ls -ls tmp2
diff -s tmp tmp2
$(DIFF) -s tmp tmp2
@$(RM) tmp*
test-lz4-frame-concatenation: lz4 datagen
@ -218,9 +224,9 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat
./datagen -g16KB | $(LZ4) -9 | $(LZ4) -t
./datagen -g20KB > tmpSrc
$(LZ4) < tmpSrc | $(LZ4) -d > tmpRes
diff -q tmpSrc tmpRes
$(DIFF) -q tmpSrc tmpRes
$(LZ4) --no-frame-crc < tmpSrc | $(LZ4) -d > tmpRes
diff -q tmpSrc tmpRes
$(DIFF) -q tmpSrc tmpRes
./datagen | $(LZ4) | $(LZ4) -t
./datagen -g6M -P99 | $(LZ4) -9BD | $(LZ4) -t
./datagen -g17M | $(LZ4) -9v | $(LZ4) -qt
@ -241,9 +247,9 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat
ls -ls tmp.lz4 && false || true # must fail (lz4cat)
$(LZ4) tmp # creates tmp.lz4
$(PRGDIR)/lz4cat < tmp.lz4 > tmp3 # checks lz4cat works with stdin (#285)
diff -q tmp tmp3
$(DIFF) -q tmp tmp3
$(PRGDIR)/lz4cat < tmp > tmp2 # checks lz4cat works with stdin (#285)
diff -q tmp tmp2
$(DIFF) -q tmp tmp2
@$(RM) tmp*
test-lz4-hugefile: lz4 datagen