]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - Makefile
Remove debug printf
[hercules2020/kcf.git] / Makefile
1 # Makefile to build all the available variants
2
3 BUILDS = opencvfft-st opencvfft-async opencvfft-openmp fftw fftw-async fftw-openmp fftw-big fftw-big-openmp cufftw cufftw-big cufftw-big-openmp cufft cufft-openmp cufft-big cufft-big-openmp
4 TESTSEQ = bmx ball1 crossing racing book
5 TESTFLAGS = default fit
6
7 all: $(BUILDS)
8
9 print_%:
10         @$(foreach v,$($*),echo $(v);)
11
12 ninja: build.ninja
13         ninja
14
15 $(BUILDS): build.ninja
16         ninja build-$@/build.ninja
17         ninja -C $(CURDIR)/build-$@
18
19 clean: build.ninja
20         ninja $@
21
22 ## Useful setting - uncomment and modify as needed
23 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
24 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
25 # export CC=gcc-5
26 # export CXX=g++-5
27 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
28 # export CUDA_ARCH_LIST=6.2
29
30 CMAKE_OTPS_opencvfft-st      = -DFFT=OpenCV
31 CMAKE_OTPS_opencvfft-async   = -DFFT=OpenCV -DASYNC=ON
32 CMAKE_OTPS_opencvfft-openmp  = -DFFT=OpenCV -DOPENMP=ON
33 CMAKE_OTPS_fftw              = -DFFT=fftw
34 CMAKE_OTPS_fftw-openmp       = -DFFT=fftw -DOPENMP=ON
35 CMAKE_OTPS_fftw-async        = -DFFT=fftw -DASYNC=ON
36 CMAKE_OTPS_fftw-big          = -DFFT=fftw -DBIG_BATCH=ON
37 CMAKE_OTPS_fftw-big-openmp   = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
38 CMAKE_OTPS_cufftw            = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
39 CMAKE_OTPS_cufftw-big        = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
40 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
41 CMAKE_OTPS_cufft             = -DFFT=cuFFT  $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
42 CMAKE_OTPS_cufft-openmp      = -DFFT=cuFFT  $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DOPENMP=ON
43 CMAKE_OTPS_cufft-big         = -DFFT=cuFFT  $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
44 CMAKE_OTPS_cufft-big-openmp  = -DFFT=cuFFT  $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
45
46 ##########################
47 ### Tests
48 ##########################
49
50 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
51         ninja $@
52
53 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
54         unzip -d vot2016 -q $^
55         for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
56
57 .INTERMEDIATE: vot2016.zip
58 .SECONDARY:    vot2016.zip
59 vot2016.zip:
60         wget --progress=dot:giga -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
61
62 ###################
63 # Ninja generator #
64 ###################
65
66 # Building all $(BUILDS) with make is slow, even when run with in
67 # parallel (make -j). The target below generates build.ninja file that
68 # compiles all variants in the same ways as this makefile, but faster.
69 # The down side is that the build needs about 10 GB of memory.
70
71
72 # Define echo depending on whether make supports the $(file) function.
73 $(file >.test.file)
74 ifneq ($(wildcard .test.file),)
75   echo = $(file $(1),$(2))
76 else
77   define nl
78
79
80   endef
81   echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
82 endif
83
84 # Ninja generator - to have faster parallel builds and tests
85 .PHONY: build.ninja
86
87 build.ninja:: $(MAKEFILE_LIST)
88         @echo "Generating $@"
89         @$(call echo,>$@,$(ninja-rule))
90         @$(foreach build,$(BUILDS),\
91                 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
92         @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
93                 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
94         @$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | print-test-results)
95         @$(foreach build,$(BUILDS),$(call echo,>>$@,build test-$(build): PRINT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | print-test-results))
96         @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build test-$(seq): PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | print-test-results))
97         @$(call echo,>>$@,build plot: PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | graphGen.sh)
98         @$(foreach build,$(BUILDS),$(call echo,>>$@,build plot-$(build): PLOT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
99         @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build plot-$(seq): PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
100         @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
101
102 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
103
104 define ninja-rule
105 rule REGENERATE
106   command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
107   description = Regenerating $$out
108   generator = 1
109 rule CMAKE
110   command = cd $$subdir && cmake -G Ninja $(CMAKE_OPTS) $$opts ..
111 rule NINJA
112   # Absolute path in -C allows Emacs to properly jump to error message locations
113   command = ninja -C $(CURDIR)/$$subdir
114   restat = 1
115 rule TEST_SEQ
116   # Errors are ignored - they will be reported by PRINT_RESULTS
117   command = build-$$build/kcf_vot $$flags $$seq $(if $(TRAVIS),2>&1) >$$out $(if $(TRAVIS),| grep -v libdc1394); true
118 rule PRINT_RESULTS
119   description = Print results
120   command = ./wvtool -w120 -v run ./print-test-results $$in
121 rule PLOT_RESULTS
122   description = Plot results
123   command = ./graphGen.sh -f -s $$in
124 rule MAKE
125   command = make $$out
126   pool = make
127 pool make
128   depth = 1
129 rule CLEAN
130 #  command = /usr/bin/ninja -t clean -r NINJA
131   description = Cleaning all built files...
132   command = rm -rf $(BUILDS:%=build-%)
133 build clean: CLEAN
134 build build.ninja: REGENERATE $(MAKEFILE_LIST)
135 endef
136
137 GIT_LS_FILES := $(shell git ls-files)
138
139 define ninja-build
140 build build-$(1)/build.ninja: CMAKE
141   opts = $(2)
142   subdir = build-$(1)
143 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
144   subdir = build-$(1)
145 default build-$(1)/kcf_vot
146 endef
147
148 # Usage: ninja-testcase <build> <seq> <flags>
149 define ninja-testcase
150 build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) vot2016/$(2)
151   build = $(1)
152   seq = vot2016/$(2)
153   flags = $(if $(3:fit128=),,--fit=128)$(if $(3:fit=),,--fit)
154 endef