#!/usr/bin/make -f #export DH_VERBOSE = 1 # Hardening Caffe according to https://wiki.debian.org/Hardening export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CFLAGS_MAINT_APPEND = -Wall #-pedantic export DEB_CXXFLAGS_MAINT_APPEND = -Wall #-pedantic export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) RULES := debian/rules CAFFE_SOVER := 1.0.0 BUILDDIR := "caffe_cpu_build" TEMPLATES := $(wildcard debian/*.in) AUTOGEN := $(patsubst %.in,%,$(TEMPLATES)) # arch-dependent cmake flags ARCHS_NO_OPENCV := m68k sparc64 sh4 x32 powerpc ifneq (,$(findstring $(DEB_HOST_ARCH),$(ARCHS_NO_OPENCV))) ADCF = -DUSE_OPENCV=OFF endif ## CMake Configuration Template. ## * PLEASE sync this common template with caffe-contrib source. CMAKE_CONFIGURE_TEMPLATE = \ -DALLOW_LMDB_NOLOCK=OFF \ -DBLAS="Generic" \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_docs=OFF \ -DBUILD_matlab=OFF \ -DBUILD_python=ON \ -DBUILD_python_layer=ON \ -Dpython_version="3" \ -DCMAKE_BUILD_TYPE="Release" \ -DCMAKE_C_FLAGS="$(CFLAGS) $(CPPFLAGS)" \ -DCMAKE_CXX_FLAGS="$(CXXFLAGS) $(CPPFLAGS)" \ -DCMAKE_SKIP_RPATH=TRUE \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DUSE_CUDNN=OFF \ -DUSE_LEVELDB=ON \ -DUSE_LMDB=ON \ -DUSE_OPENCV=ON \ -DCPU_ONLY=$(FILL_THIS_BLANK) \ -DCMAKE_INSTALL_PREFIX="/usr" # These flags are for the cuda version but please keep them # -DCUDA_ARCH_NAME="All" # -DCMAKE_CXX_COMPILER=g++-5 # -DCMAKE_C_COMPILER=gcc-5 CONFFLAG_CPU = \ $(CMAKE_CONFIGURE_TEMPLATE) \ -DCPU_ONLY=ON $(ADCF) %:: %.in perl -p \ -e 's{#CAFFE_CONFIGURE#}{caffe_cpu}g;' \ -e 's{#CAFFE_SOVER#}{$(CAFFE_SOVER)}g;' \ -e 's{#DEB_HOST_MULTIARCH#}{$(DEB_HOST_MULTIARCH)}g;' \ < $< > $@ %: dh $@ -Scmake --with python3,bash-completion override_dh_auto_configure: $(AUTOGEN) dh_auto_configure --builddirectory=$(BUILDDIR) \ -- $(CONFFLAG_CPU) override_dh_auto_clean: dh_auto_clean --builddirectory=$(BUILDDIR) -$(RM) -rf python/caffe/proto/ doxygen -$(RM) python/caffe/_caffe.so -find . -type d -name '__pycache__' -exec rm -rf '{}' + override_dh_auto_build-indep: doxygen .Doxyfile # we don't use BUILD_DOC provided by upstream cmake $(MAKE) -C doxygen/latex/ find docs -name '.gitignore' -delete # lintian vcs-control-file find docs -name '*.html' -exec sed -i -e "s@http://cdn.mathjax.org/mathjax/latest/MathJax.js@file:///usr/share/javascript/mathjax/MathJax.js@g" '{}' \; # lintian privacy-breach-uses-embedded-file find examples -name '*.html' -exec sed -i -e "s@//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js@file:///usr/share/javascript/bootstrap/js/bootstrap.min.js@g" '{}' \; # lintian privacy-breach-uses-embedded-file find examples -name '*.html' -exec sed -i -e "s@//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css@file:///usr/share/javascript/bootstrap/css/bootstrap.min.css@g" '{}' \; # lintian privacy-breach-uses-embedded-file find examples -name '*.html' -exec sed -i -e "s@//code.jquery.com/jquery-2.1.1.js@file:///usr/share/javascript/jquery/jquery.js@g" '{}' \; # lintian privacy-breach-uses-embedded-file override_dh_auto_build-arch: dh_auto_build --builddirectory=$(BUILDDIR) \ -- caffe pycaffe test.testbin all # In the test phase, we need to set LD_LIBRARY_PATH properly # for those test ELFs linked with libcaffe.so.X override_dh_auto_test-arch: ifeq (,$(filter mips, $(DEB_HOST_ARCH))) dh_auto_test --builddirectory=$(BUILDDIR) \ -- runtest pytest LD_LIBRARY_PATH=$(shell pwd)/$(BUILDDIR)/lib/ else # Ignore precision problems in mips* -dh_auto_test --builddirectory=$(BUILDDIR) \ -- runtest pytest LD_LIBRARY_PATH=$(shell pwd)/$(BUILDDIR)/lib/ endif override_dh_auto_test-indep: override_dh_python3: dh_python3 --requires=python/requirements.txt dh_numpy3 override_dh_install: dh_install # The upstream unittest can be used to verify the BLAS correctness. # the two lines start with dash in order to avoid FTBFS on Arch=all. -mv caffe_cpu_build/test/test.testbin caffe-gtest -install -m0755 caffe-gtest debian/caffe/usr/bin/ dh_missing --list-missing override_dh_auto_install-arch: dh_auto_install --builddirectory=$(BUILDDIR) -- install override_dh_auto_install-indep: override_dh_makeshlibs: dh_makeshlibs --package=python3-caffe -X/usr/lib/python dh_makeshlibs --remaining-packages override_dh_fixperms-arch: dh_fixperms chmod -x debian/tmp/usr/lib/python3/dist-packages/caffe/proto/caffe_pb2.py chmod -x debian/tmp/usr/lib/python3/dist-packages/caffe/proto/__init__.py