source: Makefile @ ab8e838

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

Merge branch 'master' into feature/pytest

  • Property mode set to 100644
File size: 7.2 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 python test command
39PYTEST?=pytest --verbose
40
41SOX=sox
42
43TESTSOUNDS := python/tests/sounds
44
45all: build
46
47checkwaf:
48        @[ -f waf ] || make getwaf
49
50getwaf:
51        ./scripts/get_waf.sh
52
53expandwaf: getwaf
54        [ -d wafilb ] || rm -fr waflib
55        $(WAFCMD) --help > /dev/null
56        mv .waf*/waflib . && rm -fr .waf*
57        sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
58        chmod +x waf && chmod -R go-w waflib
59
60cleanwaf:
61        rm -rf waf waflib .waf*
62
63configure: checkwaf
64        $(WAFCMD) configure $(WAFOPTS)
65
66build: configure
67        $(WAFCMD) build $(WAFOPTS)
68
69install:
70        # install
71        $(WAFCMD) install $(WAFOPTS)
72
73list_installed:
74        find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
75
76list_installed_python:
77        pip show -f aubio
78
79list_all_installed: list_installed list_installed_python
80
81uninstall:
82        # uninstall
83        $(WAFCMD) uninstall $(WAFOPTS)
84
85delete_install:
86        rm -rf $(PWD)/dist/test
87
88build_python:
89        # build python-aubio, using locally built libaubio if found
90        python ./setup.py build
91
92build_python_extlib:
93        # build python-aubio using (locally) installed libaubio
94        [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ]
95        [ -d $(DESTDIR)/$(LIBDIR) ]
96        [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ]
97        PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \
98        CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \
99        LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \
100                make build_python
101
102deps_python:
103        # install or upgrade python requirements
104        pip install $(PIPOPTS) --requirement requirements.txt
105
106# use pip or distutils?
107install_python: install_python_with_pip
108uninstall_python: uninstall_python_with_pip
109#install_python: install_python_with_distutils
110#uninstall_python: uninstall_python_with_distutils
111
112install_python_with_pip:
113        # install package
114        pip install $(PIPOPTS) .
115
116uninstall_python_with_pip:
117        # uninstall package
118        ( pip show aubio | grep -l aubio > /dev/null ) && \
119        pip uninstall -y -v aubio || echo "info: aubio package is not installed"
120
121install_python_with_distutils:
122        ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
123
124uninstall_python_with_distutils:
125        #./setup.py uninstall
126        [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
127
128force_uninstall_python:
129        # ignore failure if not installed
130        -make uninstall_python
131
132local_dylib:
133        # DYLD_LIBRARY_PATH is no more on mac os
134        # create links from ~/lib/lib* to build/src/lib*
135        [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
136
137test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
138test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
139test_python: local_dylib
140        # run test with installed package
141        $(PYTEST)
142
143clean_python:
144        ./setup.py clean
145
146check_clean_python:
147        # check cleaning a second time works
148        make clean_python
149        make clean_python
150
151clean: checkwaf
152        # optionnaly clean before build
153        -$(WAFCMD) clean
154        # remove possible left overs
155        -rm -rf doc/_build
156
157check_clean:
158        # check cleaning after build works
159        $(WAFCMD) clean
160        # check cleaning a second time works
161        $(WAFCMD) clean
162
163distclean:
164        $(WAFCMD) distclean
165        -rm -rf doc/_build/
166        -rm -rf doc/web/
167
168check_distclean:
169        make distclean
170
171distcheck: checkwaf
172        $(WAFCMD) distcheck $(WAFOPTS)
173
174help:
175        $(WAFCMD) --help
176
177create_test_sounds:
178        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
179        -mkdir -p $(TESTSOUNDS)
180        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      trim 0 1s
181        -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav"   synth 5    brownnoise      vol 0.9
182        -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav"    synth 127s sine 440        vol 0.9
183        -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      trim 0 30
184        -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav"       synth 60   sine 100-20000  vol 0.9
185        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav"  synth 44100s   sine 441   vol 0.9
186        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav"    synth 100s sine 441       vol 0.9
187
188# build only libaubio, no python-aubio
189test_lib_only: clean distclean configure build install list_installed
190# additionally, clean after a fresh build
191test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
192
193# build libaubio, build and test python-aubio against it
194test_lib_python: force_uninstall_python deps_python \
195        clean_python clean distclean \
196        configure build build_python \
197        install install_python \
198        test_python \
199        list_all_installed
200
201test_lib_python_clean: test_lib_python \
202        uninstall_python uninstall \
203        check_clean_python \
204        check_clean \
205        check_distclean
206
207# build libaubio, install it, build python-aubio against it
208test_lib_install_python: force_uninstall_python deps_python \
209        clean_python distclean \
210        configure build \
211        install \
212        build_python_extlib \
213        install_python \
214        test_python \
215        list_all_installed
216
217test_lib_install_python_clean: test_lib_install_python \
218        uninstall_python \
219        delete_install \
220        check_clean_python \
221        check_distclean
222
223# build a python-aubio that includes libaubio
224test_python_only: force_uninstall_python deps_python \
225        clean_python clean distclean \
226        build_python \
227        install_python \
228        test_python \
229        list_installed_python
230
231test_python_only_clean: test_python_only \
232        uninstall_python \
233        check_clean_python
234
235coverage_cycle: coverage_zero_counters coverage_report
236
237coverage_zero_counters:
238        lcov --zerocounters --directory .
239
240coverage: export CFLAGS=--coverage
241coverage: export LDFLAGS=--coverage
242coverage: export PYTHONPATH=$(PWD)/python/lib
243coverage: export LD_LIBRARY_PATH=$(PWD)/build/src
244coverage: force_uninstall_python deps_python \
245        clean_python clean distclean build local_dylib
246        lcov --capture --no-external --directory . --output-file build/coverage_lib.info
247        pip install -v -e .
248        coverage run `which pytest`
249        lcov --capture --no-external --directory . --output-file build/coverage_python.info
250        lcov -a build/coverage_python.info -a build/coverage_lib.info -o build/coverage.info
251
252# make sure we don't build the doc, which builds a temporary python module
253coverage_report: export WAFOPTS += --disable-docs
254coverage_report: coverage
255        genhtml build/coverage.info --output-directory lcov_html
256        mkdir -p gcovr_html/
257        gcovr -r . --html --html-details \
258                --output gcovr_html/index.html \
259                --exclude ".*tests/.*" --exclude ".*examples/.*"
260        coverage report
261        coverage html
262
263sphinx: configure
264        $(WAFCMD) sphinx $(WAFOPTS)
265
266doxygen: configure
267        $(WAFCMD) doxygen $(WAFOPTS)
268
269manpages: configure
270        $(WAFCMD) manpages $(WAFOPTS)
271
272html: doxygen sphinx
273
274docs: html manpages
275
276dist: distclean expandwaf
277        $(WAFCMD) dist
Note: See TracBrowser for help on using the repository browser.