[c0c3f33] | 1 | #!/usr/bin/make -f |
---|
| 2 | # -*- makefile -*- |
---|
[4e56c55] | 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 |
---|
[c0c3f33] | 11 | |
---|
[81ad577] | 12 | WAFCMD=python waf |
---|
[6a6cb48] | 13 | |
---|
[5d9693c] | 14 | #WAFOPTS:= |
---|
| 15 | # turn on verbose mode |
---|
[1b2669a] | 16 | WAFOPTS += --verbose |
---|
[5d9693c] | 17 | # build wafopts |
---|
| 18 | WAFOPTS += --destdir $(DESTDIR) |
---|
| 19 | # multiple jobs |
---|
| 20 | WAFOPTS += --jobs 4 |
---|
[3d14829] | 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 ) |
---|
[5d9693c] | 24 | |
---|
[c0c3f33] | 25 | PIPOPTS += --verbose |
---|
| 26 | |
---|
[5d9693c] | 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 | |
---|
[8991aaf] | 38 | # default nose2 command |
---|
[5e56bbd] | 39 | NOSE2?=nose2 -N 4 --verbose |
---|
[8991aaf] | 40 | |
---|
[be06e53] | 41 | SOX=sox |
---|
| 42 | |
---|
[ceb884d] | 43 | TESTSOUNDS := python/tests/sounds |
---|
[6a6cb48] | 44 | |
---|
[9617edd] | 45 | LCOVOPTS += --rc lcov_branch_coverage=1 |
---|
| 46 | |
---|
[8e94af5] | 47 | all: build |
---|
| 48 | |
---|
| 49 | checkwaf: |
---|
| 50 | @[ -f waf ] || make getwaf |
---|
| 51 | |
---|
| 52 | getwaf: |
---|
[bab8e3d] | 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 |
---|
[5d9b03b] | 60 | chmod +x waf && chmod -R go-w waflib |
---|
[bab8e3d] | 61 | |
---|
| 62 | cleanwaf: |
---|
| 63 | rm -rf waf waflib .waf* |
---|
[8e94af5] | 64 | |
---|
[e372a0f] | 65 | configure: checkwaf |
---|
[3d14829] | 66 | $(WAFCMD) configure $(WAFOPTS) |
---|
[e372a0f] | 67 | |
---|
| 68 | build: configure |
---|
[3fc5696] | 69 | $(WAFCMD) build $(WAFOPTS) |
---|
[8e94af5] | 70 | |
---|
[5d9693c] | 71 | install: |
---|
| 72 | # install |
---|
| 73 | $(WAFCMD) install $(WAFOPTS) |
---|
[972a326] | 74 | |
---|
[5d9693c] | 75 | list_installed: |
---|
[f1fc216] | 76 | find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|' |
---|
[5d9693c] | 77 | |
---|
| 78 | list_installed_python: |
---|
[1b2669a] | 79 | pip show -f aubio |
---|
| 80 | |
---|
| 81 | list_all_installed: list_installed list_installed_python |
---|
[5d9693c] | 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 |
---|
[3d14829] | 92 | python ./setup.py build |
---|
[5d9693c] | 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 \ |
---|
[1b2669a] | 100 | CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \ |
---|
| 101 | LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \ |
---|
[5d9693c] | 102 | make build_python |
---|
| 103 | |
---|
| 104 | deps_python: |
---|
| 105 | # install or upgrade python requirements |
---|
[c0c3f33] | 106 | pip install $(PIPOPTS) --requirement requirements.txt |
---|
[5d9693c] | 107 | |
---|
| 108 | # use pip or distutils? |
---|
[4e56c55] | 109 | install_python: install_python_with_pip |
---|
[5d9693c] | 110 | uninstall_python: uninstall_python_with_pip |
---|
[4e56c55] | 111 | #install_python: install_python_with_distutils |
---|
[5d9693c] | 112 | #uninstall_python: uninstall_python_with_distutils |
---|
| 113 | |
---|
| 114 | install_python_with_pip: |
---|
[e56ac16] | 115 | # install package |
---|
[c0c3f33] | 116 | pip install $(PIPOPTS) . |
---|
[5d9693c] | 117 | |
---|
| 118 | uninstall_python_with_pip: |
---|
[e56ac16] | 119 | # uninstall package |
---|
[3762cdb] | 120 | ( pip show aubio | grep -l aubio > /dev/null ) && \ |
---|
| 121 | pip uninstall -y -v aubio || echo "info: aubio package is not installed" |
---|
[5d9693c] | 122 | |
---|
| 123 | install_python_with_distutils: |
---|
[c0c3f33] | 124 | ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS) |
---|
[5d9693c] | 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 |
---|
[39122f0] | 133 | |
---|
[e56ac16] | 134 | local_dylib: |
---|
[5d9693c] | 135 | # DYLD_LIBRARY_PATH is no more on mac os |
---|
[1167631] | 136 | # create links from ~/lib/lib* to build/src/lib* |
---|
[5d9693c] | 137 | [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true |
---|
[e56ac16] | 138 | |
---|
[5d9693c] | 139 | test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR) |
---|
| 140 | test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR) |
---|
| 141 | test_python: local_dylib |
---|
[e56ac16] | 142 | # run test with installed package |
---|
[5e56bbd] | 143 | # ./python/tests/run_all_tests --verbose |
---|
| 144 | # run with nose2, multiple processes |
---|
[8991aaf] | 145 | $(NOSE2) |
---|
[f465088] | 146 | |
---|
[5d9693c] | 147 | clean_python: |
---|
| 148 | ./setup.py clean |
---|
[a2ae70a] | 149 | |
---|
[5d9693c] | 150 | check_clean_python: |
---|
| 151 | # check cleaning a second time works |
---|
| 152 | make clean_python |
---|
| 153 | make clean_python |
---|
[a2ae70a] | 154 | |
---|
[0799252] | 155 | clean: checkwaf |
---|
[5d9693c] | 156 | # optionnaly clean before build |
---|
| 157 | -$(WAFCMD) clean |
---|
[1b2669a] | 158 | # remove possible left overs |
---|
| 159 | -rm -rf doc/_build |
---|
[5d9693c] | 160 | |
---|
| 161 | check_clean: |
---|
| 162 | # check cleaning after build works |
---|
| 163 | $(WAFCMD) clean |
---|
| 164 | # check cleaning a second time works |
---|
[81ad577] | 165 | $(WAFCMD) clean |
---|
[ddd9861] | 166 | |
---|
[5864b43] | 167 | distclean: |
---|
| 168 | $(WAFCMD) distclean |
---|
[e9df0108] | 169 | -rm -rf doc/_build/ |
---|
| 170 | -rm -rf doc/web/ |
---|
[5864b43] | 171 | |
---|
[5d9693c] | 172 | check_distclean: |
---|
| 173 | make distclean |
---|
| 174 | |
---|
[e372a0f] | 175 | distcheck: checkwaf |
---|
[3d14829] | 176 | $(WAFCMD) distcheck $(WAFOPTS) |
---|
[8e94af5] | 177 | |
---|
| 178 | help: |
---|
[81ad577] | 179 | $(WAFCMD) --help |
---|
[be06e53] | 180 | |
---|
| 181 | create_test_sounds: |
---|
[3a7b7c6] | 182 | -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true |
---|
| 183 | -mkdir -p $(TESTSOUNDS) |
---|
[90581a8] | 184 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" trim 0 1s |
---|
[ceb884d] | 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 |
---|
[90581a8] | 187 | -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" trim 0 30 |
---|
[ceb884d] | 188 | -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9 |
---|
[9e36acd] | 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 |
---|
[e48b072] | 191 | |
---|
[5d9693c] | 192 | # build only libaubio, no python-aubio |
---|
[1b2669a] | 193 | test_lib_only: clean distclean configure build install list_installed |
---|
[5d9693c] | 194 | # additionally, clean after a fresh build |
---|
| 195 | test_lib_only_clean: test_lib_only uninstall check_clean check_distclean |
---|
| 196 | |
---|
| 197 | # build libaubio, build and test python-aubio against it |
---|
| 198 | test_lib_python: force_uninstall_python deps_python \ |
---|
| 199 | clean_python clean distclean \ |
---|
| 200 | configure build build_python \ |
---|
| 201 | install install_python \ |
---|
[1b2669a] | 202 | test_python \ |
---|
| 203 | list_all_installed |
---|
[5d9693c] | 204 | |
---|
| 205 | test_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 |
---|
| 212 | test_lib_install_python: force_uninstall_python deps_python \ |
---|
| 213 | clean_python distclean \ |
---|
| 214 | configure build \ |
---|
| 215 | install \ |
---|
| 216 | build_python_extlib \ |
---|
| 217 | install_python \ |
---|
[1b2669a] | 218 | test_python \ |
---|
| 219 | list_all_installed |
---|
[5d9693c] | 220 | |
---|
| 221 | test_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 |
---|
| 228 | test_python_only: force_uninstall_python deps_python \ |
---|
| 229 | clean_python clean distclean \ |
---|
| 230 | build_python \ |
---|
| 231 | install_python \ |
---|
[1b2669a] | 232 | test_python \ |
---|
| 233 | list_installed_python |
---|
[5d9693c] | 234 | |
---|
| 235 | test_python_only_clean: test_python_only \ |
---|
| 236 | uninstall_python \ |
---|
| 237 | check_clean_python |
---|
| 238 | |
---|
[adde1ba] | 239 | coverage_cycle: coverage_zero_counters coverage_report |
---|
| 240 | |
---|
| 241 | coverage_zero_counters: |
---|
| 242 | lcov --zerocounters --directory . |
---|
| 243 | |
---|
[639bf5e] | 244 | coverage: export CFLAGS=--coverage |
---|
| 245 | coverage: export LDFLAGS=--coverage |
---|
[d85e16f] | 246 | coverage: export PYTHONPATH=$(PWD)/python/lib |
---|
[a2b6523] | 247 | coverage: export LD_LIBRARY_PATH=$(PWD)/build/src |
---|
[639bf5e] | 248 | coverage: force_uninstall_python deps_python \ |
---|
[a2b6523] | 249 | clean_python clean distclean build local_dylib |
---|
[9617edd] | 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 |
---|
[639bf5e] | 254 | pip install -v -e . |
---|
[9617edd] | 255 | # run tests, with python coverage |
---|
[639bf5e] | 256 | coverage run `which nose2` |
---|
[9617edd] | 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 |
---|
[bde4f641] | 264 | lcov $(LCOVOPTS) --remove build/coverage.info '*/ooura_fft8g*' \ |
---|
[9617edd] | 265 | --output-file build/coverage_lib.info |
---|
[639bf5e] | 266 | |
---|
[adde1ba] | 267 | # make sure we don't build the doc, which builds a temporary python module |
---|
| 268 | coverage_report: export WAFOPTS += --disable-docs |
---|
[639bf5e] | 269 | coverage_report: coverage |
---|
[9617edd] | 270 | # generate report with lcov's genhtml |
---|
[2b242af] | 271 | genhtml build/coverage_lib.info --output-directory build/coverage_c \ |
---|
[9617edd] | 272 | --branch-coverage --highlight --legend |
---|
| 273 | # generate python report with coverage python package |
---|
[639bf5e] | 274 | coverage report |
---|
[2b242af] | 275 | coverage html -d build/coverage_python |
---|
[9617edd] | 276 | # show links to generated reports |
---|
[2b242af] | 277 | for i in $$(ls build/coverage_*/index.html); do echo file://$(PWD)/$$i; done |
---|
[639bf5e] | 278 | |
---|
[f1fc216] | 279 | sphinx: configure |
---|
| 280 | $(WAFCMD) sphinx $(WAFOPTS) |
---|
| 281 | |
---|
| 282 | doxygen: configure |
---|
| 283 | $(WAFCMD) doxygen $(WAFOPTS) |
---|
| 284 | |
---|
| 285 | manpages: configure |
---|
| 286 | $(WAFCMD) manpages $(WAFOPTS) |
---|
| 287 | |
---|
| 288 | html: doxygen sphinx |
---|
[5d9693c] | 289 | |
---|
[f1fc216] | 290 | docs: html manpages |
---|
[e48b072] | 291 | |
---|
| 292 | dist: distclean expandwaf |
---|
| 293 | $(WAFCMD) dist |
---|