Skip to content

Commit

Permalink
zmat now supports gnu octave on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed May 1, 2019
1 parent d6a48c6 commit 396cb6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ else
endif
endif

oct: OUTPUT_DIR=..
oct: AR= CXXFLAGS='-O3' LFLAGS='$(-lz)' LDFLAGS='$(LFLAGS)' mkoctfile
oct: BINARY=zmat.mex
oct: LINKOPT+=--mex $(INCLUDEDIRS)
oct: CXX=mkoctfile

mex: CXX=$(MEX)
mex: AR=$(MEX)
mex: LINKOPT+= -cxx CLIBS='$$CLIBS -lz' CXXLIBS='$$CXXLIBS -lz' -outdir $(ZMATDIR)
Expand All @@ -88,7 +94,7 @@ OBJS := $(addsuffix $(OBJSUFFIX), $(FILES))

TARGETSUFFIX:=$(suffix $(BINARY))

all mex: $(OUTPUT_DIR)/$(BINARY)
all mex oct: $(OUTPUT_DIR)/$(BINARY)

makedirs:
@if test ! -d $(OUTPUT_DIR); then $(MKDIR) $(OUTPUT_DIR); fi
Expand Down
6 changes: 5 additions & 1 deletion src/compilezmat.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
mex zmat.cpp -outdir ../ CXXLIBS='$CXXLIBS -lz'
if(~exist('OCTAVE_VERSION','builtin'))
mex zmat.cpp -outdir ../ CXXLIBS='$CXXLIBS -lz'
else
mex zmat.cpp -o ../zmat
end

4 changes: 2 additions & 2 deletions src/zmat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
}

try{
if(mxIsChar(prhs[0]) || mxIsUint8(prhs[0])){
if(mxIsChar(prhs[0]) || mxIsUint8(prhs[0]) || mxIsInt8(prhs[0])){
z_stream zs;
int ret;
dimtype inputsize=mxGetNumberOfElements(prhs[0]);
dimtype buflen[2]={0};
unsigned char *temp=NULL;
char * inputstr=(mxIsChar(prhs[0])? mxArrayToString(prhs[0]) : (char *)mxGetChars(prhs[0]));
char * inputstr=(mxIsChar(prhs[0])? mxArrayToString(prhs[0]) : (char *)mxGetData(prhs[0]));

zs.zalloc = Z_NULL;
zs.zfree = Z_NULL;
Expand Down

0 comments on commit 396cb6f

Please sign in to comment.