4 # This makefile contains simple rules to prepare, compile, test, and install
5 # aubio. Try one of the following rules:
13 WAFURL=https://waf.io/waf-1.8.22
16 # turn on verbose mode
19 WAFOPTS += --destdir $(DESTDIR)
22 # if HAVE_AUBIO_DOUBLE is defined, pass --enable-double to waf
23 # python/lib/moresetuptools.py also checks for HAVE_AUBIO_DOUBLE
24 WAFOPTS += $(shell [ -z $(HAVE_AUBIO_DOUBLE) ] || echo --enable-double )
28 DESTDIR:=$(PWD)/build/dist
29 PYDESTDIR:=$(PWD)/build/pydist
31 # default install locations
33 EXEC_PREFIX?=$(PREFIX)
35 INCLUDEDIR?=$(PREFIX)/include
36 DATAROOTDIR?=$(PREFIX)/share
37 MANDIR?=$(DATAROOTDIR)/man
41 TESTSOUNDS := python/tests/sounds
46 @[ -f waf ] || make getwaf
52 [ -d wafilb ] || rm -fr waflib
53 $(WAFCMD) --help > /dev/null
54 mv .waf*/waflib . && rm -fr .waf*
55 sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
59 rm -rf waf waflib .waf*
62 $(WAFCMD) configure $(WAFOPTS)
65 $(WAFCMD) build $(WAFOPTS)
69 $(WAFCMD) install $(WAFOPTS)
72 find $(DESTDIR) -ls | \
73 sed 's|$(DESTDIR)|/«destdir»|'
75 list_installed_python:
76 ( find $(PYDESTDIR) -ls || make list_installed_python_package ) | \
77 sed 's|$(PYDESTDIR)|/«pydestdir»|'
79 list_installed_python_package:
81 PACKAGE_LOCATION=$(shell pip show -f aubio | grep ^Location | cut -d \ -f 2) \
82 make list_installed_python_package_content
84 list_installed_python_package_content:
85 ( [ -d $(PACKAGE_LOCATION) ] && find $(PACKAGE_LOCATION) -ls ) || \
86 unzip -l $(PACKAGE_LOCATION)
88 list_all_installed: list_installed list_installed_python
92 $(WAFCMD) uninstall $(WAFOPTS)
95 rm -rf $(PWD)/dist/test
98 # build python-aubio, using locally built libaubio if found
99 python ./setup.py build
102 # build python-aubio using (locally) installed libaubio
103 [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ]
104 [ -d $(DESTDIR)/$(LIBDIR) ]
105 [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ]
106 PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \
107 CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \
108 LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \
112 # install or upgrade python requirements
113 pip install $(PIPOPTS) --requirement requirements.txt
115 # use pip or distutils?
116 install_python: install_python_with_pip
117 uninstall_python: uninstall_python_with_pip
118 #install_python: install_python_with_distutils
119 #uninstall_python: uninstall_python_with_distutils
121 install_python_with_pip:
123 pip install $(PIPOPTS) .
125 uninstall_python_with_pip:
127 pip uninstall -y -v aubio || make uninstall_python_with_distutils
129 install_python_with_distutils:
130 ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
132 uninstall_python_with_distutils:
133 #./setup.py uninstall
134 [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
136 force_uninstall_python:
137 # ignore failure if not installed
138 -make uninstall_python
141 # DYLD_LIBRARY_PATH is no more on mac os
142 # create links from ~/lib/lib* to build/src/lib*
143 [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
145 test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
146 test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
147 test_python: local_dylib
148 # run test with installed package
149 ./python/tests/run_all_tests --verbose
150 # also run with nose, multiple processes
157 # check cleaning a second time works
162 # optionnaly clean before build
164 # remove possible left overs
168 # check cleaning after build works
170 # check cleaning a second time works
180 $(WAFCMD) distcheck $(WAFOPTS)
186 -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
187 -mkdir -p $(TESTSOUNDS)
188 -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" synth 1s silence 0 dcshift .01
189 -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav" synth 5 brownnoise vol 0.9
190 -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav" synth 127s sine 440 vol 0.9
191 -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" synth 30 silence 0 vol 0.9
192 -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9
193 -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav" synth 44100s sine 441 vol 0.9
194 -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav" synth 100s sine 441 vol 0.9
196 # build only libaubio, no python-aubio
197 test_lib_only: clean distclean configure build install list_installed
198 # additionally, clean after a fresh build
199 test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
201 # build libaubio, build and test python-aubio against it
202 test_lib_python: force_uninstall_python deps_python \
203 clean_python clean distclean \
204 configure build build_python \
205 install install_python \
209 test_lib_python_clean: test_lib_python \
210 uninstall_python uninstall \
215 # build libaubio, install it, build python-aubio against it
216 test_lib_install_python: force_uninstall_python deps_python \
217 clean_python distclean \
220 build_python_extlib \
225 test_lib_install_python_clean: test_lib_install_python \
231 # build a python-aubio that includes libaubio
232 test_python_only: force_uninstall_python deps_python \
233 clean_python clean distclean \
237 list_installed_python
239 test_python_only_clean: test_python_only \
247 dist: distclean expandwaf