File: rules

package info (click to toggle)
caffe 1.0.0%2Bgit20180821.99bd997-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,228 kB
  • sloc: cpp: 61,577; python: 5,783; makefile: 600; sh: 562
file content (125 lines) | stat: -rwxr-xr-x 4,596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/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
ORIG_SOURCE   := "https://github.com/BVLC/caffe/archive/1.0.tar.gz"
CAFFE_SOVER   := 1.0.0
BUILDDIR      := "caffe_cpu_build"

TEMPLATES     := $(wildcard debian/*.in)
AUTOGEN       := $(patsubst %.in,%,$(TEMPLATES))

## 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 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

%:: %.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 $@ \
		--buildsystem=cmake \
		--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-tools-cpu/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-cpu -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

get-orig-source:
	wget -c $(ORIG_SOURCE) -O caffe_1.0.0.orig.tar.gz