forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (76 loc) · 2.73 KB
/
Makefile
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
.ONESHELL:
.PHONY: test deps download build clean astyle cmds
# OpenCV version to use.
OPENCV_VERSION?=3.4.1
# Temporary directory to put files into.
TMP_DIR?=/tmp/
# Package list for each well-known Linux distribution
RPMS=cmake git gtk2-devel pkg-config libpng-devel libjpeg-devel libtiff-devel tbb tbb-devel libdc1394-devel
DEBS=unzip build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
# Detect Linux distribution
distro_deps=
ifneq ($(shell which dnf 2>/dev/null),)
distro_deps=deps_fedora
else
ifneq ($(shell which apt-get 2>/dev/null),)
distro_deps=deps_debian
else
ifneq ($(shell which yum 2>/dev/null),)
distro_deps=deps_rh_centos
endif
endif
endif
# Install all necessary dependencies.
deps: $(distro_deps)
deps_rh_centos:
sudo yum install $(RPMS)
deps_fedora:
sudo dnf install $(RPMS)
deps_debian:
sudo apt-get update
sudo apt-get install -y $(DEBS)
# Download OpenCV source tarballs.
download:
mkdir $(TMP_DIR)opencv
cd $(TMP_DIR)opencv
wget --show-progress --quiet -O opencv.zip https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).zip
unzip -q opencv.zip
wget --show-progress --quiet -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/$(OPENCV_VERSION).zip
unzip -q opencv_contrib.zip
rm opencv.zip opencv_contrib.zip
cd -
# Build OpenCV.
build:
cd $(TMP_DIR)opencv/opencv-$(OPENCV_VERSION)
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=$(TMP_DIR)opencv/opencv_contrib-$(OPENCV_VERSION)/modules -D BUILD_DOCS=OFF BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_java=OFF -D BUILD_opencv_python=OFF -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=OFF WITH_JASPER=OFF ..
$(MAKE) -j
$(MAKE) preinstall
cd -
# Cleanup temporary build files.
clean:
rm -rf $(TMP_DIR)opencv
# Do everything.
install: deps download build sudo_install clean verify
# Install system wide.
sudo_install:
cd $(TMP_DIR)opencv/opencv-$(OPENCV_VERSION)/build
sudo $(MAKE) install
sudo ldconfig
cd -
# Build a minimal Go app to confirm gocv works.
verify:
go run ./cmd/version/main.go
# Runs tests.
# This assumes env.sh was already sourced.
# pvt is not tested here since it requires additional depenedences.
test:
go test . ./contrib
astyle:
astyle --project=.astylerc --recursive *.cpp,*.h
CMDS=basic-drawing caffe-classifier captest capwindow counter faceblur facedetect find-circles hand-gestures img-similarity mjpeg-streamer motion-detect pose saveimage savevideo showimage ssd-facedetect tf-classifier tracking version
cmds:
for cmd in $(CMDS) ; do \
go build -o build/$$cmd cmd/$$cmd/main.go ;
done ; \