1 # Makefile to build all the available variants
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 = bag ball1 car1
5 TESTFLAGS = default fit128
7 all: $(foreach build,$(BUILDS),build-$(build)/kcf_vot)
10 #CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
12 CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
13 CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
14 CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
15 CMAKE_OTPS_fftw = -DFFT=fftw
16 CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
17 CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
18 CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
19 CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
20 CMAKE_OTPS_cufftw = -DFFT=cuFFTW
21 CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW -DBIG_BATCH=ON
22 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW -DBIG_BATCH=ON -DOPENMP=ON
23 CMAKE_OTPS_cufft = -DFFT=cuFFT
24 CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT -DOPENMP=ON
25 CMAKE_OTPS_cufft-big = -DFFT=cuFFT -DBIG_BATCH=ON
26 CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT -DBIG_BATCH=ON -DOPENMP=ON
28 .SECONDARY: $(BUILDS:%=build-%/build.ninja)
31 @echo '############################################################'
33 cd $(@D) && cmake $(CMAKE_OPTS) $(CMAKE_OTPS_$*) ..
36 build-%/kcf_vot: build-%/build.ninja $(shell git ls-files)
37 @echo '############################################################'
40 $(BUILDS): %: build-%/kcf_vot
43 rm -rf $(BUILDS:%=build-%)
45 ##########################
47 ##########################
49 print-test-results = grep ^Average $(1)|sed -E -e 's|build-(.*)/kcf_vot-(.*).log:|\2;\1;|'|sort|column -t -s';'
51 test: $(BUILDS:%=test-%)
52 @echo; echo "Summary test results:"
53 @$(call print-test-results,$(foreach build,$(BUILDS),\
54 $(foreach seq,$(TESTSEQ),\
55 $(foreach f,$(TESTFLAGS),build-$(build)/kcf_vot-$(seq)-$(f).log))))
57 $(BUILDS:%=test-%): test-%:
58 @$(call print-test-results,$(foreach seq,$(TESTSEQ),\
59 $(foreach f,$(TESTFLAGS),build-$*/kcf_vot-$(seq)-$(f).log)))
61 # Usage: testcase <build> <seq>
63 test-$(1): test-$(1)-$(2)
64 test-$(1)-$(2): $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log)
65 $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log): build-$(1)/kcf_vot $$(filter-out %/output.txt,$$(wildcard vot2016/$(2)/*)) | vot2016/$(2)
66 $$< $$(if $$(@:%fit128.log=),,--fit=128) vot2016/$(2) > $$@
70 $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(eval $(call testcase,$(build),$(seq)))))
72 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
73 unzip -d vot2016 -q $^
74 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
76 .INTERMEDIATE: vot2016.zip
77 .SECONDARY: vot2016.zip
79 wget http://data.votchallenge.net/vot2016/vot2016.zip
85 # Building all $(BUILDS) with make is slow, even when run with in
86 # parallel (make -j). The target below generates build.ninja file that
87 # compiles all variants in the same ways as this makefile, but faster.
88 # The down side is that the build needs about 10 GB of memory.
93 # Ninja generator - to have faster parallel builds
96 $(file >$@,$(ninja-rule))
97 $(foreach build,$(BUILDS),$(file >>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
101 command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts ..
102 description = CMake $$out
104 # Absolute path in -C allows Emacs to properly jump to error message locations
105 command = ninja -C `realpath $$$$(dirname $$out)`
106 description = Ninja $$out
110 build build-$(1)/build.ninja: cmake
112 build build-$(1)/kcf_vot: ninja build-$(1)/build.ninja build.ninja