Debian Codegraph @

Makefile

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