[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 | |
---|
[8e94af5] | 45 | all: build |
---|
| 46 | |
---|
| 47 | checkwaf: |
---|
| 48 | @[ -f waf ] || make getwaf |
---|
| 49 | |
---|
| 50 | getwaf: |
---|
[bab8e3d] | 51 | ./scripts/get_waf.sh |
---|
| 52 | |
---|
| 53 | expandwaf: 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 |
---|
[5d9b03b] | 58 | chmod +x waf && chmod -R go-w waflib |
---|
[bab8e3d] | 59 | |
---|
| 60 | cleanwaf: |
---|
| 61 | rm -rf waf waflib .waf* |
---|
[8e94af5] | 62 | |
---|
[e372a0f] | 63 | configure: checkwaf |
---|
[3d14829] | 64 | $(WAFCMD) configure $(WAFOPTS) |
---|
[e372a0f] | 65 | |
---|
| 66 | build: configure |
---|
[3fc5696] | 67 | $(WAFCMD) build $(WAFOPTS) |
---|
[8e94af5] | 68 | |
---|
[5d9693c] | 69 | install: |
---|
| 70 | # install |
---|
| 71 | $(WAFCMD) install $(WAFOPTS) |
---|
[972a326] | 72 | |
---|
[5d9693c] | 73 | list_installed: |
---|
[f1fc216] | 74 | find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|' |
---|
[5d9693c] | 75 | |
---|
| 76 | list_installed_python: |
---|
[1b2669a] | 77 | pip show -f aubio |
---|
| 78 | |
---|
| 79 | list_all_installed: list_installed list_installed_python |
---|
[5d9693c] | 80 | |
---|
| 81 | uninstall: |
---|
| 82 | # uninstall |
---|
| 83 | $(WAFCMD) uninstall $(WAFOPTS) |
---|
| 84 | |
---|
| 85 | delete_install: |
---|
| 86 | rm -rf $(PWD)/dist/test |
---|
| 87 | |
---|
| 88 | build_python: |
---|
| 89 | # build python-aubio, using locally built libaubio if found |
---|
[3d14829] | 90 | python ./setup.py build |
---|
[5d9693c] | 91 | |
---|
| 92 | build_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 \ |
---|
[1b2669a] | 98 | CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \ |
---|
| 99 | LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \ |
---|
[5d9693c] | 100 | make build_python |
---|
| 101 | |
---|
| 102 | deps_python: |
---|
| 103 | # install or upgrade python requirements |
---|
[c0c3f33] | 104 | pip install $(PIPOPTS) --requirement requirements.txt |
---|
[5d9693c] | 105 | |
---|
| 106 | # use pip or distutils? |
---|
[4e56c55] | 107 | install_python: install_python_with_pip |
---|
[5d9693c] | 108 | uninstall_python: uninstall_python_with_pip |
---|
[4e56c55] | 109 | #install_python: install_python_with_distutils |
---|
[5d9693c] | 110 | #uninstall_python: uninstall_python_with_distutils |
---|
| 111 | |
---|
| 112 | install_python_with_pip: |
---|
[e56ac16] | 113 | # install package |
---|
[c0c3f33] | 114 | pip install $(PIPOPTS) . |
---|
[5d9693c] | 115 | |
---|
| 116 | uninstall_python_with_pip: |
---|
[e56ac16] | 117 | # uninstall package |
---|
[3762cdb] | 118 | ( pip show aubio | grep -l aubio > /dev/null ) && \ |
---|
| 119 | pip uninstall -y -v aubio || echo "info: aubio package is not installed" |
---|
[5d9693c] | 120 | |
---|
| 121 | install_python_with_distutils: |
---|
[c0c3f33] | 122 | ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS) |
---|
[5d9693c] | 123 | |
---|
| 124 | uninstall_python_with_distutils: |
---|
| 125 | #./setup.py uninstall |
---|
| 126 | [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true |
---|
| 127 | |
---|
| 128 | force_uninstall_python: |
---|
| 129 | # ignore failure if not installed |
---|
| 130 | -make uninstall_python |
---|
[39122f0] | 131 | |
---|
[e56ac16] | 132 | local_dylib: |
---|
[5d9693c] | 133 | # DYLD_LIBRARY_PATH is no more on mac os |
---|
[1167631] | 134 | # create links from ~/lib/lib* to build/src/lib* |
---|
[5d9693c] | 135 | [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true |
---|
[e56ac16] | 136 | |
---|
[5d9693c] | 137 | test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR) |
---|
| 138 | test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR) |
---|
| 139 | test_python: local_dylib |
---|
[e56ac16] | 140 | # run test with installed package |
---|
[5e56bbd] | 141 | # ./python/tests/run_all_tests --verbose |
---|
| 142 | # run with nose2, multiple processes |
---|
[8991aaf] | 143 | $(NOSE2) |
---|
[f465088] | 144 | |
---|
[5d9693c] | 145 | clean_python: |
---|
| 146 | ./setup.py clean |
---|
[a2ae70a] | 147 | |
---|
[5d9693c] | 148 | check_clean_python: |
---|
| 149 | # check cleaning a second time works |
---|
| 150 | make clean_python |
---|
| 151 | make clean_python |
---|
[a2ae70a] | 152 | |
---|
[0799252] | 153 | clean: checkwaf |
---|
[5d9693c] | 154 | # optionnaly clean before build |
---|
| 155 | -$(WAFCMD) clean |
---|
[1b2669a] | 156 | # remove possible left overs |
---|
| 157 | -rm -rf doc/_build |
---|
[5d9693c] | 158 | |
---|
| 159 | check_clean: |
---|
| 160 | # check cleaning after build works |
---|
| 161 | $(WAFCMD) clean |
---|
| 162 | # check cleaning a second time works |
---|
[81ad577] | 163 | $(WAFCMD) clean |
---|
[ddd9861] | 164 | |
---|
[5864b43] | 165 | distclean: |
---|
| 166 | $(WAFCMD) distclean |
---|
[e9df0108] | 167 | -rm -rf doc/_build/ |
---|
| 168 | -rm -rf doc/web/ |
---|
[5864b43] | 169 | |
---|
[5d9693c] | 170 | check_distclean: |
---|
| 171 | make distclean |
---|
| 172 | |
---|
[e372a0f] | 173 | distcheck: checkwaf |
---|
[3d14829] | 174 | $(WAFCMD) distcheck $(WAFOPTS) |
---|
[8e94af5] | 175 | |
---|
| 176 | help: |
---|
[81ad577] | 177 | $(WAFCMD) --help |
---|
[be06e53] | 178 | |
---|
| 179 | create_test_sounds: |
---|
[3a7b7c6] | 180 | -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true |
---|
| 181 | -mkdir -p $(TESTSOUNDS) |
---|
[90581a8] | 182 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" trim 0 1s |
---|
[ceb884d] | 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 |
---|
[90581a8] | 185 | -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" trim 0 30 |
---|
[ceb884d] | 186 | -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9 |
---|
[9e36acd] | 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 |
---|
[e48b072] | 189 | |
---|
[5d9693c] | 190 | # build only libaubio, no python-aubio |
---|
[1b2669a] | 191 | test_lib_only: clean distclean configure build install list_installed |
---|
[5d9693c] | 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 \ |
---|
[1b2669a] | 200 | test_python \ |
---|
| 201 | list_all_installed |
---|
[5d9693c] | 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 \ |
---|
[1b2669a] | 216 | test_python \ |
---|
| 217 | list_all_installed |
---|
[5d9693c] | 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 \ |
---|
[1b2669a] | 230 | test_python \ |
---|
| 231 | list_installed_python |
---|
[5d9693c] | 232 | |
---|
| 233 | test_python_only_clean: test_python_only \ |
---|
| 234 | uninstall_python \ |
---|
| 235 | check_clean_python |
---|
| 236 | |
---|
[adde1ba] | 237 | coverage_cycle: coverage_zero_counters coverage_report |
---|
| 238 | |
---|
| 239 | coverage_zero_counters: |
---|
| 240 | lcov --zerocounters --directory . |
---|
| 241 | |
---|
[639bf5e] | 242 | coverage: export CFLAGS=--coverage |
---|
| 243 | coverage: export LDFLAGS=--coverage |
---|
[d85e16f] | 244 | coverage: export PYTHONPATH=$(PWD)/python/lib |
---|
[a2b6523] | 245 | coverage: export LD_LIBRARY_PATH=$(PWD)/build/src |
---|
[639bf5e] | 246 | coverage: force_uninstall_python deps_python \ |
---|
[a2b6523] | 247 | clean_python clean distclean build local_dylib |
---|
| 248 | lcov --capture --no-external --directory . --output-file build/coverage_lib.info |
---|
[639bf5e] | 249 | pip install -v -e . |
---|
| 250 | coverage run `which nose2` |
---|
[a2b6523] | 251 | lcov --capture --no-external --directory . --output-file build/coverage_python.info |
---|
| 252 | lcov -a build/coverage_python.info -a build/coverage_lib.info -o build/coverage.info |
---|
[639bf5e] | 253 | |
---|
[adde1ba] | 254 | # make sure we don't build the doc, which builds a temporary python module |
---|
| 255 | coverage_report: export WAFOPTS += --disable-docs |
---|
[639bf5e] | 256 | coverage_report: coverage |
---|
| 257 | genhtml build/coverage.info --output-directory lcov_html |
---|
| 258 | mkdir -p gcovr_html/ |
---|
| 259 | gcovr -r . --html --html-details \ |
---|
| 260 | --output gcovr_html/index.html \ |
---|
| 261 | --exclude ".*tests/.*" --exclude ".*examples/.*" |
---|
| 262 | coverage report |
---|
| 263 | coverage html |
---|
| 264 | |
---|
[f1fc216] | 265 | sphinx: configure |
---|
| 266 | $(WAFCMD) sphinx $(WAFOPTS) |
---|
| 267 | |
---|
| 268 | doxygen: configure |
---|
| 269 | $(WAFCMD) doxygen $(WAFOPTS) |
---|
| 270 | |
---|
| 271 | manpages: configure |
---|
| 272 | $(WAFCMD) manpages $(WAFOPTS) |
---|
| 273 | |
---|
| 274 | html: doxygen sphinx |
---|
[5d9693c] | 275 | |
---|
[f1fc216] | 276 | docs: html manpages |
---|
[e48b072] | 277 | |
---|
| 278 | dist: distclean expandwaf |
---|
| 279 | $(WAFCMD) dist |
---|