Skip to content

Commit

Permalink
include easylzma source tree directly for easy deployment and building
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed May 11, 2020
1 parent 79e214b commit 1ac6464
Show file tree
Hide file tree
Showing 43 changed files with 8,345 additions and 24 deletions.
37 changes: 21 additions & 16 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DOXY := doxygen
DOCDIR := $(ZMATDIR)/doc
DOXYCFG=zmat.cfg

INCLUDEDIRS=-Ieasylzma/easylzma-0.0.8/include
INCLUDEDIRS=-Ieasylzma -Ieasylzma/pavlov -Ilz4

CUOMPLINK=

Expand All @@ -33,17 +33,20 @@ PLATFORM = $(shell uname -s)
DLLFLAG=-fPIC
OMP=-fopenmp

CPPOPT=-g -Wall -O3 #-g -Wall -std=c99 # -DUSE_OS_TIMER
CPPOPT=-g -Wall -O3 -fPIC #-g -Wall -std=c99 # -DUSE_OS_TIMER

OUTPUTFLAG:=-o
OBJSUFFIX=.o
EXESUFFIX=.mex*

FILES=zmatlib lz4/lz4 lz4/lz4hc
FILES=zmatlib lz4/lz4 lz4/lz4hc easylzma/compress easylzma/decompress \
easylzma/lzma_header easylzma/lzip_header easylzma/common_internal \
easylzma/pavlov/LzmaEnc easylzma/pavlov/LzmaDec easylzma/pavlov/LzmaLib \
easylzma/pavlov/LzFind easylzma/pavlov/Bra easylzma/pavlov/BraIA64 \
easylzma/pavlov/Alloc easylzma/pavlov/7zCrc

ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN)
CC=nvcc
CUOMPLINK=-Xcompiler
ifeq ($(findstring x86_64,$(ARCH)), x86_64)
LINKOPT=-L"$(CUDA_PATH)/lib/x64" $(CUDART)
else
Expand All @@ -52,11 +55,10 @@ ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN)
INCLUDEDIRS +=-I"$(CUDA_PATH)/lib/include"
CPPOPT =-c -D_CRT_SECURE_NO_DEPRECATE -DWIN32
OBJSUFFIX=.obj
EXESUFFIX=.exe
EXESUFFIX=
DLLFLAG=
OMP=/openmp
OMP=-fopenmp
MEX=cmd /c mex
CPPOPT+=-Xcompiler $(OMP)
else ifeq ($(findstring Darwin,$(PLATFORM)), Darwin)
CPPOPT+=
else
Expand All @@ -75,28 +77,31 @@ else
endif
endif

lib: AR :=ar
lib: ARFLAGS :=cr
lib: AROUTPUT :=
lib: LINKOPT :=easylzma/src/CMakeFiles/easylzma_s.dir/*.o easylzma/src/CMakeFiles/easylzma_s.dir/pavlov/*.o
ifeq ($(MAKECMDGOALS),lib)
AR :=ar
ARFLAGS :=cr
BINARY :=libzmat.a
AROUTPUT :=
LINKOPT :=
endif

dll: CPPOPT +=$(DLLFLAG)
dll: AR :=gcc
dll: ARFLAGS :=-shared -Wl,-soname,$(BINARY).1
dll: LINKOPT :=easylzma/src/CMakeFiles/easylzma.dir/*.o easylzma/src/CMakeFiles/easylzma.dir/pavlov/*.o
dll: LINKOPT :=
dll: AROUTPUT :=-o

oct mex: CPPOPT+= $(DLLFLAG)
oct: OUTPUT_DIR=..
oct: AR= CXXFLAGS='-O3' LFLAGS='$(-lz)' LDFLAGS='$(LFLAGS)' mkoctfile zmat.cpp easylzma/easylzma-0.0.8/lib/libeasylzma_s.a
oct: AR= CXXFLAGS='-O3' LFLAGS='$(-lz)' LDFLAGS='$(LFLAGS)' mkoctfile zmat.cpp
oct: BINARY=zmat.mex
oct: ARFLAGS :=
oct: LINKOPT+=--mex $(INCLUDEDIRS)
oct: CXX=mkoctfile

mex: CXX=$(MEX)
mex: OUTPUTFLAG:=-output
mex: AR=$(MEX) zmat.cpp easylzma/easylzma-0.0.8/lib/libeasylzma_s.a $(INCLUDEDIRS)
mex: AR=$(MEX) zmat.cpp $(INCLUDEDIRS)
mex: LINKOPT+= -cxx CXXLIBS='$$CXXLIBS -lz' -outdir $(ZMATDIR)
mex: ARFLAGS :=
mex: OUTPUT_DIR=..
Expand Down Expand Up @@ -140,9 +145,9 @@ $(OUTPUT_DIR)/$(BINARY): $(OBJS)
$(CUDACC) -c $(CUCCOPT) -o $@ $<

clean:
-rm -f $(OBJS) $(OUTPUT_DIR)/$(BINARY)$(EXESUFFIX)
-rm -f $(OBJS) $(OUTPUT_DIR)/$(BINARY)$(EXESUFFIX) zmat$(OBJSUFFIX)

.PHONY: all mex oct lib
.PHONY: all mex oct lib dll

.DEFAULT_GOAL := all

35 changes: 27 additions & 8 deletions src/compilezmat.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
filelist={'lz4/lz4.c','lz4/lz4hc.c','easylzma/compress.c','easylzma/decompress.c', ...
'easylzma/lzma_header.c', 'easylzma/lzip_header.c', 'easylzma/common_internal.c', ...
'easylzma/pavlov/LzmaEnc.c', 'easylzma/pavlov/LzmaDec.c', 'easylzma/pavlov/LzmaLib.c' ...
'easylzma/pavlov/LzFind.c', 'easylzma/pavlov/Bra.c', 'easylzma/pavlov/BraIA64.c' ...
'easylzma/pavlov/Alloc.c', 'easylzma/pavlov/7zCrc.c','zmatlib.c'};

mexfile='zmat.cpp';

if(~exist('OCTAVE_VERSION','builtin'))
mex CFLAGS='$CFLAGS -O3 -g' -c lz4/lz4.c
mex CFLAGS='$CFLAGS -O3 -g' -c lz4/lz4hc.c
mex CFLAGS='$CFLAGS -O3 -g' -Ieasylzma/easylzma-0.0.8/include -c zmatlib.c
mex zmat.cpp zmatlib.o lz4.o lz4hc.o easylzma/easylzma-0.0.8/lib/libeasylzma_s.a -Ieasylzma/easylzma-0.0.8/include -output ../zipmat -outdir ../ CXXLIBS='$CXXLIBS -lz'
CCFLAG='CFLAGS=''\$CFLAGS -O3 -g -Ieasylzma -Ieasylzma/pavlov -Ilz4'' -c';
LINKFLAG='CXXLIBS=''\$CXXLIBS -lz'' -output ../zipmat -outdir ../';
for i=1:length(filelist)
fprintf(1,'mex %s %s\n', CCFLAG, filelist{i});
eval(sprintf('mex %s %s', CCFLAG, filelist{i}));
end
cmd=sprintf('mex %s -Ieasylzma %s %s',mexfile, LINKFLAG, regexprep(strjoin(filelist),'\.c[p]*','\.o'));
fprintf(1,'%s\n',cmd);
eval(cmd)
else
mex -O3 -g -c lz4/lz4.c
mex -O3 -g -c lz4/lz4hc.c
mex -Ieasylzma/easylzma-0.0.8/include -c zmatlib.c
mex zmat.cpp zmatlib.o lz4.o lz4hc.o easylzma/easylzma-0.0.8/lib/libeasylzma_s.a -Ieasylzma/easylzma-0.0.8/include -o ../zipmat -lz
CCFLAG='-O3 -g -c -Ieasylzma -Ieasylzma/pavlov -Ilz4';
LINKFLAG='-o ../zipmat -lz';
for i=1:length(filelist)
fprintf(stdout,'mex %s %s\n', CCFLAG, filelist{i});
fflush(stdout);
eval(sprintf('mex %s %s', CCFLAG, filelist{i}));
end
cmd=sprintf('mex %s -Ieasylzma %s %s',mexfile, LINKFLAG, regexprep(strjoin(filelist),'\.c[p]*','\.o'));
fprintf(stdout,'%s\n',cmd);fflush(stdout);
eval(cmd)
end

Loading

0 comments on commit 1ac6464

Please sign in to comment.