Skip to content

Commit

Permalink
allow using HAVE_ZLIB/HAVE_LZ4/HAVE_ZSTD=yes/no with make
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jun 4, 2023
1 parent 3276f50 commit 0acc9e3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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=..

Expand Down
1 change: 1 addition & 0 deletions src/blosc2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion src/blosc2/blosc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/miniz/zlib.h

0 comments on commit 0acc9e3

Please sign in to comment.