From 0acc9e35031111b80f283f628ead0c17cfe09bb9 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Sat, 3 Jun 2023 23:10:47 -0400 Subject: [PATCH] allow using HAVE_ZLIB/HAVE_LZ4/HAVE_ZSTD=yes/no with make --- src/Makefile | 21 ++++++++++++++++----- src/blosc2/Makefile | 1 + src/blosc2/blosc/Makefile | 14 +++++++++++++- src/miniz/zlib.h | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) create mode 120000 src/miniz/zlib.h diff --git a/src/Makefile b/src/Makefile index 88c0ddd..7386549 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,10 +11,14 @@ ZMATDIR ?=$(ROOTDIR) LIBDIR ?=$(ROOTDIR)/lib MKDIR :=mkdir +HAVE_ZLIB ?=yes HAVE_LZMA ?=yes HAVE_LZ4 ?=yes HAVE_ZSTD ?=yes HAVE_BLOSC2?=yes +LIBZLIB =-lz + +export HAVE_ZLIB HAVE_LZ4 HAVE_ZSTD MEX?=mex AR=$(CC) @@ -61,6 +65,13 @@ else endif endif +ifeq ($(HAVE_ZLIB),no) + CFLAGS+=-DNO_ZLIB + INCLUDEDIRS+=-Iminiz + FILES+=miniz/miniz + LIBZLIB= +endif + ifeq ($(HAVE_LZMA),no) CFLAGS+=-DNO_LZMA else @@ -83,7 +94,7 @@ else INCLUDEDIRS+=-Iblosc2/internal-complibs/zstd-1.5.2 LINKOPT+=-Lblosc2/internal-complibs/zstd-1.5.2 -lzstd endif - LINKOPT+=-Lblosc2/lib -lblosc2 -Lblosc2/internal-complibs/zstd-1.5.2 -lzstd -lz + LINKOPT+=-Lblosc2/lib -lblosc2 -Lblosc2/internal-complibs/zstd-1.5.2 -lzstd $(LIBZLIB) INCLUDEDIRS+=-Iblosc2/include endif @@ -119,12 +130,12 @@ ifeq ($(MAKECMDGOALS),dll) OUTPUTFLAG :=-o BINARY :=libzmat.so.1 OUTPUT_DIR :=$(LIBDIR) - LINKOPT +=-lz + LINKOPT +=$(LIBZLIB) ifeq ($(findstring Darwin,$(PLATFORM)), Darwin) - ARFLAGS :=-shared -Wl,-install_name,$(BINARY) -lz + ARFLAGS :=-shared -Wl,-install_name,$(BINARY) $(LIBZLIB) else - ARFLAGS :=-shared -Wl,-soname,$(BINARY) -lz + ARFLAGS :=-shared -Wl,-soname,$(BINARY) $(LIBZLIB) endif endif @@ -143,7 +154,7 @@ oct: LINKOPT+=--mex $(INCLUDEDIRS) mex: CXX=$(MEX) mex: OUTPUTFLAG:=-output mex: AR=$(MEX) zmat.cpp $(INCLUDEDIRS) -mex: LINKOPT+= -cxx CXXLIBS='$$CXXLIBS -lz -static-libgcc -static-libstdc++' -outdir $(ZMATDIR) +mex: LINKOPT+= -cxx CXXLIBS='$$CXXLIBS $(LIBZLIB) -static-libgcc -static-libstdc++' -outdir $(ZMATDIR) mex: ARFLAGS := mex: OUTPUT_DIR=.. diff --git a/src/blosc2/Makefile b/src/blosc2/Makefile index d8531db..f3d4f0a 100644 --- a/src/blosc2/Makefile +++ b/src/blosc2/Makefile @@ -6,6 +6,7 @@ BLOSC_SRC=blosc ZSTD_SRC=internal-complibs/zstd-1.5.2 LIBBLOSC2=$(BLOSC_SRC)/lib/libblosc2.a +export all: lib zstd diff --git a/src/blosc2/blosc/Makefile b/src/blosc2/blosc/Makefile index 2a36fb3..1106d53 100644 --- a/src/blosc2/blosc/Makefile +++ b/src/blosc2/blosc/Makefile @@ -32,7 +32,19 @@ PLATFORM = $(shell uname -s) DLLFLAG=-fPIC -CPPOPT=-g -Wall -Wextra -O3 -msse2 -DHAVE_ZSTD -DHAVE_ZLIB -DHAVE_LZ4 -DNDEBUG $(DLLFLAG) -std=gnu99 #-g -Wall -std=c99 # -DUSE_OS_TIMER +CPPOPT=-g -Wall -Wextra -O3 -msse2 -DNDEBUG $(DLLFLAG) -std=gnu99 #-g -Wall -std=c99 # -DUSE_OS_TIMER + +ifeq ($(HAVE_ZLIB),yes) + CPPOPT+=-DHAVE_ZLIB +endif + +ifeq ($(HAVE_ZSTD),yes) + CPPOPT+=-DHAVE_ZSTD +endif + +ifeq ($(HAVE_LZ4),yes) + CPPOPT+=-DHAVE_LZ4 +endif OUTPUTFLAG:=-o OBJSUFFIX=.o diff --git a/src/miniz/zlib.h b/src/miniz/zlib.h new file mode 120000 index 0000000..f58ce50 --- /dev/null +++ b/src/miniz/zlib.h @@ -0,0 +1 @@ +miniz.h \ No newline at end of file