[81ad577] | 1 | WAFCMD=python waf |
---|
[7f35041] | 2 | WAFURL=https://waf.io/waf-1.8.22 |
---|
[6a6cb48] | 3 | |
---|
[5d9693c] | 4 | #WAFOPTS:= |
---|
| 5 | # turn on verbose mode |
---|
[1b2669a] | 6 | WAFOPTS += --verbose |
---|
[5d9693c] | 7 | # build wafopts |
---|
| 8 | WAFOPTS += --destdir $(DESTDIR) |
---|
| 9 | # multiple jobs |
---|
| 10 | WAFOPTS += --jobs 4 |
---|
| 11 | |
---|
| 12 | DESTDIR:=$(PWD)/build/dist |
---|
| 13 | PYDESTDIR:=$(PWD)/build/pydist |
---|
| 14 | |
---|
[1b2669a] | 15 | BUILDID=$(shell mktemp -d -p $(PWD)/dist/) |
---|
| 16 | |
---|
[5d9693c] | 17 | # default install locations |
---|
| 18 | PREFIX?=/usr/local |
---|
| 19 | EXEC_PREFIX?=$(PREFIX) |
---|
| 20 | LIBDIR?=$(PREFIX)/lib |
---|
| 21 | INCLUDEDIR?=$(PREFIX)/include |
---|
| 22 | DATAROOTDIR?=$(PREFIX)/share |
---|
| 23 | MANDIR?=$(DATAROOTDIR)/man |
---|
| 24 | |
---|
[be06e53] | 25 | SOX=sox |
---|
| 26 | |
---|
[6a6cb48] | 27 | ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double ) |
---|
[ceb884d] | 28 | TESTSOUNDS := python/tests/sounds |
---|
[6a6cb48] | 29 | |
---|
[8e94af5] | 30 | all: build |
---|
| 31 | |
---|
| 32 | checkwaf: |
---|
| 33 | @[ -f waf ] || make getwaf |
---|
| 34 | |
---|
| 35 | getwaf: |
---|
[bab8e3d] | 36 | ./scripts/get_waf.sh |
---|
| 37 | |
---|
| 38 | expandwaf: getwaf |
---|
| 39 | [ -d wafilb ] || rm -fr waflib |
---|
| 40 | $(WAFCMD) --help > /dev/null |
---|
| 41 | mv .waf*/waflib . && rm -fr .waf* |
---|
| 42 | sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf |
---|
| 43 | chmod +x waf |
---|
| 44 | |
---|
| 45 | cleanwaf: |
---|
| 46 | rm -rf waf waflib .waf* |
---|
[8e94af5] | 47 | |
---|
[e372a0f] | 48 | configure: checkwaf |
---|
[6a6cb48] | 49 | $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE) |
---|
[e372a0f] | 50 | |
---|
| 51 | build: configure |
---|
[3fc5696] | 52 | $(WAFCMD) build $(WAFOPTS) |
---|
[8e94af5] | 53 | |
---|
[5d9693c] | 54 | install: |
---|
| 55 | # install |
---|
| 56 | $(WAFCMD) install $(WAFOPTS) |
---|
[972a326] | 57 | |
---|
[5d9693c] | 58 | list_installed: |
---|
[1b2669a] | 59 | find $(DESTDIR) -ls | \ |
---|
| 60 | sed 's|$(DESTDIR)|/«destdir»|' |
---|
| 61 | tar --full-time --mtime=$(PWD)/src/aubio.h -jcvf $(BUILDID)/aubio-dist.tar.bz2 -C $(DESTDIR)/ . |
---|
[5d9693c] | 62 | |
---|
| 63 | list_installed_python: |
---|
[1b2669a] | 64 | ( find $(PYDESTDIR) -ls || make list_installed_python_package ) | \ |
---|
| 65 | sed 's|$(PYDESTDIR)|/«pydestdir»|' |
---|
| 66 | [ -d $(PYDESTDIR) ] && \ |
---|
| 67 | tar --full-time --mtime=$(PWD)/src/aubio.h -jcvf $(BUILDID)/python-aubio-dist.tar.bz2 -C $(PYDESTDIR)/ . || \ |
---|
| 68 | true |
---|
| 69 | |
---|
| 70 | list_installed_python_package: |
---|
| 71 | pip show -f aubio |
---|
| 72 | PACKAGE_LOCATION=$(shell pip show -f aubio | grep ^Location | cut -d \ -f 2) \ |
---|
| 73 | make list_installed_python_package_content |
---|
| 74 | |
---|
| 75 | list_installed_python_package_content: |
---|
| 76 | ( [ -d $(PACKAGE_LOCATION) ] && find $(PACKAGE_LOCATION) -ls ) || \ |
---|
| 77 | unzip -l $(PACKAGE_LOCATION) |
---|
| 78 | cp -prv $(PACKAGE_LOCATION) $(BUILDID) |
---|
| 79 | |
---|
| 80 | list_all_installed: list_installed list_installed_python |
---|
[5d9693c] | 81 | |
---|
| 82 | uninstall: |
---|
| 83 | # uninstall |
---|
| 84 | $(WAFCMD) uninstall $(WAFOPTS) |
---|
| 85 | |
---|
| 86 | delete_install: |
---|
| 87 | rm -rf $(PWD)/dist/test |
---|
| 88 | |
---|
| 89 | build_python: |
---|
| 90 | # build python-aubio, using locally built libaubio if found |
---|
[1b2669a] | 91 | python ./setup.py build_ext $(ENABLE_DOUBLE) |
---|
[5d9693c] | 92 | |
---|
| 93 | build_python_extlib: |
---|
| 94 | # build python-aubio using (locally) installed libaubio |
---|
| 95 | [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ] |
---|
| 96 | [ -d $(DESTDIR)/$(LIBDIR) ] |
---|
| 97 | [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ] |
---|
| 98 | PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \ |
---|
[1b2669a] | 99 | CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \ |
---|
| 100 | LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \ |
---|
[5d9693c] | 101 | make build_python |
---|
| 102 | |
---|
| 103 | deps_python: |
---|
| 104 | # install or upgrade python requirements |
---|
[fe957ad] | 105 | pip install --verbose --requirement requirements.txt |
---|
[5d9693c] | 106 | |
---|
| 107 | # use pip or distutils? |
---|
| 108 | #install_python: install_python_with_pip |
---|
| 109 | uninstall_python: uninstall_python_with_pip |
---|
| 110 | install_python: install_python_with_distutils |
---|
| 111 | #uninstall_python: uninstall_python_with_distutils |
---|
| 112 | |
---|
| 113 | install_python_with_pip: |
---|
[e56ac16] | 114 | # install package |
---|
[5d9693c] | 115 | pip install --verbose . |
---|
| 116 | |
---|
| 117 | uninstall_python_with_pip: |
---|
[e56ac16] | 118 | # uninstall package |
---|
[5d9693c] | 119 | pip uninstall -y -v aubio || make uninstall_python_with_distutils |
---|
| 120 | |
---|
| 121 | install_python_with_distutils: |
---|
| 122 | ./setup.py install $(DISTUTILSOPTS) |
---|
| 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 |
---|
| 141 | ./python/tests/run_all_tests --verbose |
---|
[5d9693c] | 142 | # also run with nose, multiple processes |
---|
[f465088] | 143 | nose2 -N 4 |
---|
| 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 |
---|
| 167 | |
---|
[5d9693c] | 168 | check_distclean: |
---|
| 169 | make distclean |
---|
| 170 | |
---|
[e372a0f] | 171 | distcheck: checkwaf |
---|
[7aed123] | 172 | $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE) |
---|
[8e94af5] | 173 | |
---|
| 174 | help: |
---|
[81ad577] | 175 | $(WAFCMD) --help |
---|
[be06e53] | 176 | |
---|
| 177 | create_test_sounds: |
---|
[3a7b7c6] | 178 | -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true |
---|
| 179 | -mkdir -p $(TESTSOUNDS) |
---|
[9e36acd] | 180 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" synth 1s silence 0 dcshift .01 |
---|
[ceb884d] | 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" synth 30 silence 0 vol 0.9 |
---|
| 184 | -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9 |
---|
[9e36acd] | 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 |
---|
[e48b072] | 187 | |
---|
[5d9693c] | 188 | # build only libaubio, no python-aubio |
---|
[1b2669a] | 189 | test_lib_only: clean distclean configure build install list_installed |
---|
[5d9693c] | 190 | # additionally, clean after a fresh build |
---|
| 191 | test_lib_only_clean: test_lib_only uninstall check_clean check_distclean |
---|
| 192 | |
---|
| 193 | # build libaubio, build and test python-aubio against it |
---|
| 194 | test_lib_python: force_uninstall_python deps_python \ |
---|
| 195 | clean_python clean distclean \ |
---|
| 196 | configure build build_python \ |
---|
| 197 | install install_python \ |
---|
[1b2669a] | 198 | test_python \ |
---|
| 199 | list_all_installed |
---|
[5d9693c] | 200 | |
---|
| 201 | test_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 |
---|
| 208 | test_lib_install_python: force_uninstall_python deps_python \ |
---|
| 209 | clean_python distclean \ |
---|
| 210 | configure build \ |
---|
| 211 | install \ |
---|
| 212 | build_python_extlib \ |
---|
| 213 | install_python \ |
---|
[1b2669a] | 214 | test_python \ |
---|
| 215 | list_all_installed |
---|
[5d9693c] | 216 | |
---|
| 217 | test_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 |
---|
| 224 | test_python_only: force_uninstall_python deps_python \ |
---|
| 225 | clean_python clean distclean \ |
---|
| 226 | build_python \ |
---|
| 227 | install_python \ |
---|
[1b2669a] | 228 | test_python \ |
---|
| 229 | list_installed_python |
---|
[5d9693c] | 230 | |
---|
| 231 | test_python_only_clean: test_python_only \ |
---|
| 232 | uninstall_python \ |
---|
| 233 | check_clean_python |
---|
| 234 | |
---|
| 235 | |
---|
[e48b072] | 236 | html: |
---|
| 237 | cd doc && make html |
---|
| 238 | |
---|
| 239 | dist: distclean expandwaf |
---|
| 240 | $(WAFCMD) dist |
---|