#!/usr/bin/make -f
# -*- makefile -*-
+#
+# This makefile contains simple rules to prepare, compile, test, and install
+# aubio. Try one of the following rules:
+#
+# $ make configure
+# $ make build
+# $ make install
+# $ make test_python
WAFCMD=python waf
-WAFURL=https://waf.io/waf-1.8.22
#WAFOPTS:=
# turn on verbose mode
DATAROOTDIR?=$(PREFIX)/share
MANDIR?=$(DATAROOTDIR)/man
+# default nose2 command
+NOSE2?=nose2 -N 4 --verbose
+
SOX=sox
TESTSOUNDS := python/tests/sounds
+LCOVOPTS += --rc lcov_branch_coverage=1
+
all: build
checkwaf:
$(WAFCMD) --help > /dev/null
mv .waf*/waflib . && rm -fr .waf*
sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
- chmod +x waf
+ chmod +x waf && chmod -R go-w waflib
cleanwaf:
rm -rf waf waflib .waf*
$(WAFCMD) install $(WAFOPTS)
list_installed:
- find $(DESTDIR) -ls | \
- sed 's|$(DESTDIR)|/«destdir»|'
+ find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
list_installed_python:
- ( find $(PYDESTDIR) -ls || make list_installed_python_package ) | \
- sed 's|$(PYDESTDIR)|/«pydestdir»|'
-
-list_installed_python_package:
pip show -f aubio
- PACKAGE_LOCATION=$(shell pip show -f aubio | grep ^Location | cut -d \ -f 2) \
- make list_installed_python_package_content
-
-list_installed_python_package_content:
- ( [ -d $(PACKAGE_LOCATION) ] && find $(PACKAGE_LOCATION) -ls ) || \
- unzip -l $(PACKAGE_LOCATION)
list_all_installed: list_installed list_installed_python
pip install $(PIPOPTS) --requirement requirements.txt
# use pip or distutils?
-#install_python: install_python_with_pip
+install_python: install_python_with_pip
uninstall_python: uninstall_python_with_pip
-install_python: install_python_with_distutils
+#install_python: install_python_with_distutils
#uninstall_python: uninstall_python_with_distutils
install_python_with_pip:
uninstall_python_with_pip:
# uninstall package
- pip uninstall -y -v aubio || make uninstall_python_with_distutils
+ ( pip show aubio | grep -l aubio > /dev/null ) && \
+ pip uninstall -y -v aubio || echo "info: aubio package is not installed"
install_python_with_distutils:
./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
test_python: local_dylib
# run test with installed package
- ./python/tests/run_all_tests --verbose
- # also run with nose, multiple processes
- nose2 -N 4
+ # ./python/tests/run_all_tests --verbose
+ # run with nose2, multiple processes
+ $(NOSE2)
clean_python:
./setup.py clean
distclean:
$(WAFCMD) distclean
+ -rm -rf doc/_build/
+ -rm -rf doc/web/
check_distclean:
make distclean
create_test_sounds:
-[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
-mkdir -p $(TESTSOUNDS)
- -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" synth 1s silence 0 dcshift .01
+ -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" trim 0 1s
-$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav" synth 5 brownnoise vol 0.9
-$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav" synth 127s sine 440 vol 0.9
- -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" synth 30 silence 0 vol 0.9
+ -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" trim 0 30
-$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9
-$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav" synth 44100s sine 441 vol 0.9
-$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav" synth 100s sine 441 vol 0.9
uninstall_python \
check_clean_python
-
-html:
- cd doc && make html
+coverage_cycle: coverage_zero_counters coverage_report
+
+coverage_zero_counters:
+ lcov --zerocounters --directory .
+
+coverage: export CFLAGS=--coverage
+coverage: export LDFLAGS=--coverage
+coverage: export PYTHONPATH=$(PWD)/python/lib
+coverage: export LD_LIBRARY_PATH=$(PWD)/build/src
+coverage: force_uninstall_python deps_python \
+ clean_python clean distclean build local_dylib
+ # capture coverage after running c tests
+ lcov $(LCOVOPTS) --capture --no-external --directory . \
+ --output-file build/coverage_lib.info
+ # build and test python
+ pip install -v -e .
+ # run tests, with python coverage
+ coverage run `which nose2`
+ # capture coverage again
+ lcov $(LCOVOPTS) --capture --no-external --directory . \
+ --output-file build/coverage_python.info
+ # merge both coverage info files
+ lcov $(LCOVOPTS) -a build/coverage_python.info -a build/coverage_lib.info \
+ --output-file build/coverage.info
+ # remove tests
+ lcov $(LCOVOPTS) --remove build/coverage.info '*/ooura_fft8g*' \
+ --output-file build/coverage_lib.info
+
+# make sure we don't build the doc, which builds a temporary python module
+coverage_report: export WAFOPTS += --disable-docs
+coverage_report: coverage
+ # generate report with lcov's genhtml
+ genhtml build/coverage_lib.info --output-directory build/coverage_c \
+ --branch-coverage --highlight --legend
+ # generate python report with coverage python package
+ coverage report
+ coverage html -d build/coverage_python
+ # show links to generated reports
+ for i in $$(ls build/coverage_*/index.html); do echo file://$(PWD)/$$i; done
+
+sphinx: configure
+ $(WAFCMD) sphinx $(WAFOPTS)
+
+doxygen: configure
+ $(WAFCMD) doxygen $(WAFOPTS)
+
+manpages: configure
+ $(WAFCMD) manpages $(WAFOPTS)
+
+html: doxygen sphinx
+
+docs: html manpages
dist: distclean expandwaf
$(WAFCMD) dist