Skip to content

Commit

Permalink
Added libzip support on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Kamenev committed Feb 25, 2016
1 parent 467520a commit bbf67cf
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
# If not specified, Kaldi plugins will not be built
# OPENCV_PATH= path to OpenCV 3.0.0 installation, so $(OPENCV_PATH) exists
# defaults to /usr/local/opencv-3.0.0
# LIBZIP_PATH= path to libzip installation, so $(LIBZIP_PATH) exists
# defaults to /usr/local/

ifndef BUILD_TOP
BUILD_TOP=.
Expand Down Expand Up @@ -445,6 +447,15 @@ endif
########################################
ifdef OPENCV_PATH
LIBS += -lopencv_core -lopencv_imgproc -lopencv_imgcodecs
ifdef LIBZIP_PATH
CPPFLAGS += -DUSE_ZIP
INCLUDEPATH += $(LIBZIP_PATH)/lib/libzip/include
LIBS += -lzip
endif
IMAGEREADER_SRC =\
$(SOURCEDIR)/Readers/ImageReader/Exports.cpp \
$(SOURCEDIR)/Readers/ImageReader/ImageConfigHelper.cpp \
Expand All @@ -463,7 +474,7 @@ LIBPATH += $(OPENCV_PATH)/lib $(OPENCV_PATH)/release/lib
$(IMAGEREADER): $(IMAGEREADER_OBJ) | $(CNTKMATH_LIB)
@echo $(SEPARATOR)
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ -l$(CNTKMATH) -lopencv_core -lopencv_imgproc -lopencv_imgcodecs
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ -l$(CNTKMATH)
endif
########################################
Expand Down
49 changes: 49 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ cudnn_check=cuda/include/cudnn.h
have_opencv=no
opencv_path=
opencv_check=include/opencv2/opencv.hpp

have_libzip=no
libzip_path=
libzip_check=include/zip.h

mathlib=

default_use_1bitsgd=no
Expand All @@ -64,6 +69,7 @@ default_gdks=". gdk/usr"
default_cubs="cub-1.4.1"
default_cudnns="cudnn-4.0"
default_opencvs="opencv-3.0.0"
default_libzips="libzip-1.1.2"

function default_paths ()
{
Expand Down Expand Up @@ -145,6 +151,12 @@ function find_opencv ()
{
find_dir "$default_opencvs" "$opencv_check"
}

function find_libzip ()
{
find_dir "$default_libzips" "$libzip_check"
}

function is_hardlinked ()
{
r=no
Expand Down Expand Up @@ -196,6 +208,7 @@ function show_help ()
echo " --with-buildtype=(debug|release) $(show_default $default_buildtype)"
echo " --with-kaldi[=directory] $(show_default $(find_kaldi))"
echo " --with-opencv[=directory] $(show_default $(find_opencv))"
echo " --with-libzip[=directory] $(show_default $(find_libzip))"
echo "Libraries search path:"
for head in $(default_paths)
do
Expand Down Expand Up @@ -460,6 +473,28 @@ do
fi
fi
;;
--with-libzip*)
have_libzip=yes
if test x$optarg = x
then
libzip_path=$(find_libzip)
if test x$libzip_path = x
then
echo "Cannot find libzip directory."
echo "Please specify a value for --with-libzip"
echo "libzip can be downloaded from http://www.nih.at/libzip/"
exit 1
fi
else
if test $(check_dir $optarg $$libzip_check) = yes
then
libzip_path=$optarg
else
echo "Invalid libzip directory $optarg"
exit 1
fi
fi
;;
*)
echo Invalid option $key
show_help
Expand Down Expand Up @@ -554,6 +589,17 @@ then
fi
fi

if test x$libzip_path = x
then
libzip_path=$(find_libzip)
if test x$libzip_path = x ; then
echo Cannot locate libzip files
echo ImageReader will be built without zip container support.
else
echo Found libzip at $libzip_path
fi
fi

config=$build_top/Config.make
echo Generating $config
echo "#Configuration file for cntk" > $config
Expand Down Expand Up @@ -582,6 +628,9 @@ fi
if test x$opencv_path != x ; then
echo OPENCV_PATH=$opencv_path >> $config
fi
if test x$libzip_path != x ; then
echo LIBZIP_PATH=$libzip_path >> $config
fi
if test $enable_1bitsgd = yes ; then
echo CNTK_ENABLE_1BitSGD=true >> $config
fi
Expand Down

0 comments on commit bbf67cf

Please sign in to comment.