source: Makefile @ 63bc67b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 63bc67b was 9617edd, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[make] add branch coverage, improve html report

  • Property mode set to 100644
File size: 7.8 KB
Line 
1#!/usr/bin/make -f
2# -*- makefile -*-
3#
4# This makefile contains simple rules to prepare, compile, test, and install
5# aubio. Try one of the following rules:
6#
7# $ make configure
8# $ make build
9# $ make install
10# $ make test_python
11
12WAFCMD=python waf
13
14#WAFOPTS:=
15# turn on verbose mode
16WAFOPTS += --verbose
17# build wafopts
18WAFOPTS += --destdir $(DESTDIR)
19# multiple jobs
20WAFOPTS += --jobs 4
21# if HAVE_AUBIO_DOUBLE is defined, pass --enable-double to waf
22# python/lib/moresetuptools.py also checks for HAVE_AUBIO_DOUBLE
23WAFOPTS += $(shell [ -z $(HAVE_AUBIO_DOUBLE) ] || echo --enable-double )
24
25PIPOPTS += --verbose
26
27DESTDIR:=$(PWD)/build/dist
28PYDESTDIR:=$(PWD)/build/pydist
29
30# default install locations
31PREFIX?=/usr/local
32EXEC_PREFIX?=$(PREFIX)
33LIBDIR?=$(PREFIX)/lib
34INCLUDEDIR?=$(PREFIX)/include
35DATAROOTDIR?=$(PREFIX)/share
36MANDIR?=$(DATAROOTDIR)/man
37
38# default nose2 command
39NOSE2?=nose2 -N 4 --verbose
40
41SOX=sox
42
43TESTSOUNDS := python/tests/sounds
44
45LCOVOPTS += --rc lcov_branch_coverage=1
46
47all: build
48
49checkwaf:
50        @[ -f waf ] || make getwaf
51
52getwaf:
53        ./scripts/get_waf.sh
54
55expandwaf: getwaf
56        [ -d wafilb ] || rm -fr waflib
57        $(WAFCMD) --help > /dev/null
58        mv .waf*/waflib . && rm -fr .waf*
59        sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
60        chmod +x waf && chmod -R go-w waflib
61
62cleanwaf:
63        rm -rf waf waflib .waf*
64
65configure: checkwaf
66        $(WAFCMD) configure $(WAFOPTS)
67
68build: configure
69        $(WAFCMD) build $(WAFOPTS)
70
71install:
72        # install
73        $(WAFCMD) install $(WAFOPTS)
74
75list_installed:
76        find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
77
78list_installed_python:
79        pip show -f aubio
80
81list_all_installed: list_installed list_installed_python
82
83uninstall:
84        # uninstall
85        $(WAFCMD) uninstall $(WAFOPTS)
86
87delete_install:
88        rm -rf $(PWD)/dist/test
89
90build_python:
91        # build python-aubio, using locally built libaubio if found
92        python ./setup.py build
93
94build_python_extlib:
95        # build python-aubio using (locally) installed libaubio
96        [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ]
97        [ -d $(DESTDIR)/$(LIBDIR) ]
98        [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ]
99        PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \
100        CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \
101        LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \
102                make build_python
103
104deps_python:
105        # install or upgrade python requirements
106        pip install $(PIPOPTS) --requirement requirements.txt
107
108# use pip or distutils?
109install_python: install_python_with_pip
110uninstall_python: uninstall_python_with_pip
111#install_python: install_python_with_distutils
112#uninstall_python: uninstall_python_with_distutils
113
114install_python_with_pip:
115        # install package
116        pip install $(PIPOPTS) .
117
118uninstall_python_with_pip:
119        # uninstall package
120        ( pip show aubio | grep -l aubio > /dev/null ) && \
121        pip uninstall -y -v aubio || echo "info: aubio package is not installed"
122
123install_python_with_distutils:
124        ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
125
126uninstall_python_with_distutils:
127        #./setup.py uninstall
128        [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
129
130force_uninstall_python:
131        # ignore failure if not installed
132        -make uninstall_python
133
134local_dylib:
135        # DYLD_LIBRARY_PATH is no more on mac os
136        # create links from ~/lib/lib* to build/src/lib*
137        [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
138
139test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
140test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
141test_python: local_dylib
142        # run test with installed package
143        # ./python/tests/run_all_tests --verbose
144        # run with nose2, multiple processes
145        $(NOSE2)
146
147clean_python:
148        ./setup.py clean
149
150check_clean_python:
151        # check cleaning a second time works
152        make clean_python
153        make clean_python
154
155clean: checkwaf
156        # optionnaly clean before build
157        -$(WAFCMD) clean
158        # remove possible left overs
159        -rm -rf doc/_build
160
161check_clean:
162        # check cleaning after build works
163        $(WAFCMD) clean
164        # check cleaning a second time works
165        $(WAFCMD) clean
166
167distclean:
168        $(WAFCMD) distclean
169        -rm -rf doc/_build/
170        -rm -rf doc/web/
171
172check_distclean:
173        make distclean
174
175distcheck: checkwaf
176        $(WAFCMD) distcheck $(WAFOPTS)
177
178help:
179        $(WAFCMD) --help
180
181create_test_sounds:
182        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
183        -mkdir -p $(TESTSOUNDS)
184        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      trim 0 1s
185        -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav"   synth 5    brownnoise      vol 0.9
186        -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav"    synth 127s sine 440        vol 0.9
187        -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      trim 0 30
188        -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav"       synth 60   sine 100-20000  vol 0.9
189        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav"  synth 44100s   sine 441   vol 0.9
190        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav"    synth 100s sine 441       vol 0.9
191
192# build only libaubio, no python-aubio
193test_lib_only: clean distclean configure build install list_installed
194# additionally, clean after a fresh build
195test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
196
197# build libaubio, build and test python-aubio against it
198test_lib_python: force_uninstall_python deps_python \
199        clean_python clean distclean \
200        configure build build_python \
201        install install_python \
202        test_python \
203        list_all_installed
204
205test_lib_python_clean: test_lib_python \
206        uninstall_python uninstall \
207        check_clean_python \
208        check_clean \
209        check_distclean
210
211# build libaubio, install it, build python-aubio against it
212test_lib_install_python: force_uninstall_python deps_python \
213        clean_python distclean \
214        configure build \
215        install \
216        build_python_extlib \
217        install_python \
218        test_python \
219        list_all_installed
220
221test_lib_install_python_clean: test_lib_install_python \
222        uninstall_python \
223        delete_install \
224        check_clean_python \
225        check_distclean
226
227# build a python-aubio that includes libaubio
228test_python_only: force_uninstall_python deps_python \
229        clean_python clean distclean \
230        build_python \
231        install_python \
232        test_python \
233        list_installed_python
234
235test_python_only_clean: test_python_only \
236        uninstall_python \
237        check_clean_python
238
239coverage_cycle: coverage_zero_counters coverage_report
240
241coverage_zero_counters:
242        lcov --zerocounters --directory .
243
244coverage: export CFLAGS=--coverage
245coverage: export LDFLAGS=--coverage
246coverage: export PYTHONPATH=$(PWD)/python/lib
247coverage: export LD_LIBRARY_PATH=$(PWD)/build/src
248coverage: force_uninstall_python deps_python \
249        clean_python clean distclean build local_dylib
250        # capture coverage after running c tests
251        lcov $(LCOVOPTS) --capture --no-external --directory . \
252                --output-file build/coverage_lib.info
253        # build and test python
254        pip install -v -e .
255        # run tests, with python coverage
256        coverage run `which nose2`
257        # capture coverage again
258        lcov $(LCOVOPTS) --capture --no-external --directory . \
259                --output-file build/coverage_python.info
260        # merge both coverage info files
261        lcov $(LCOVOPTS) -a build/coverage_python.info -a build/coverage_lib.info \
262                --output-file build/coverage.info
263        # remove tests
264        lcov $(LCOVOPTS) --remove build/coverage.info '*/tests/*' '*/ooura_fft8g*' \
265                --output-file build/coverage_lib.info
266
267# make sure we don't build the doc, which builds a temporary python module
268coverage_report: export WAFOPTS += --disable-docs
269coverage_report: coverage
270        # create coverage report dir
271        mkdir -p build/coverage/
272        # generate report with lcov's genhtml
273        genhtml build/coverage_lib.info --output-directory build/coverage/lcov \
274                --branch-coverage --highlight --legend
275        # generate python report with coverage python package
276        coverage report
277        coverage html -d build/coverage/coverage
278        # show links to generated reports
279        for i in $$(ls build/coverage/*/index.html); do echo file://$(PWD)/$$i; done
280
281sphinx: configure
282        $(WAFCMD) sphinx $(WAFOPTS)
283
284doxygen: configure
285        $(WAFCMD) doxygen $(WAFOPTS)
286
287manpages: configure
288        $(WAFCMD) manpages $(WAFOPTS)
289
290html: doxygen sphinx
291
292docs: html manpages
293
294dist: distclean expandwaf
295        $(WAFCMD) dist
Note: See TracBrowser for help on using the repository browser.