[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 |
---|
| 6 | #WAFOPTS += --verbose |
---|
| 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 | |
---|
| 15 | # default install locations |
---|
| 16 | PREFIX?=/usr/local |
---|
| 17 | EXEC_PREFIX?=$(PREFIX) |
---|
| 18 | LIBDIR?=$(PREFIX)/lib |
---|
| 19 | INCLUDEDIR?=$(PREFIX)/include |
---|
| 20 | DATAROOTDIR?=$(PREFIX)/share |
---|
| 21 | MANDIR?=$(DATAROOTDIR)/man |
---|
| 22 | |
---|
[be06e53] | 23 | SOX=sox |
---|
| 24 | |
---|
[6a6cb48] | 25 | ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double ) |
---|
[ceb884d] | 26 | TESTSOUNDS := python/tests/sounds |
---|
[6a6cb48] | 27 | |
---|
[8e94af5] | 28 | all: build |
---|
| 29 | |
---|
| 30 | checkwaf: |
---|
| 31 | @[ -f waf ] || make getwaf |
---|
| 32 | |
---|
| 33 | getwaf: |
---|
[bab8e3d] | 34 | ./scripts/get_waf.sh |
---|
| 35 | |
---|
| 36 | expandwaf: getwaf |
---|
| 37 | [ -d wafilb ] || rm -fr waflib |
---|
| 38 | $(WAFCMD) --help > /dev/null |
---|
| 39 | mv .waf*/waflib . && rm -fr .waf* |
---|
| 40 | sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf |
---|
| 41 | chmod +x waf |
---|
| 42 | |
---|
| 43 | cleanwaf: |
---|
| 44 | rm -rf waf waflib .waf* |
---|
[8e94af5] | 45 | |
---|
[e372a0f] | 46 | configure: checkwaf |
---|
[6a6cb48] | 47 | $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE) |
---|
[e372a0f] | 48 | |
---|
| 49 | build: configure |
---|
[3fc5696] | 50 | $(WAFCMD) build $(WAFOPTS) |
---|
[8e94af5] | 51 | |
---|
[5d9693c] | 52 | install: |
---|
| 53 | # install |
---|
| 54 | $(WAFCMD) install $(WAFOPTS) |
---|
| 55 | make list_installed |
---|
[972a326] | 56 | |
---|
[5d9693c] | 57 | list_installed: |
---|
| 58 | find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|' |
---|
| 59 | |
---|
| 60 | list_installed_python: |
---|
| 61 | find $(PYDESTDIR) -ls | sed 's|$(PYDESTDIR)|/«pydestdir»|' |
---|
| 62 | |
---|
| 63 | uninstall: |
---|
| 64 | # uninstall |
---|
| 65 | $(WAFCMD) uninstall $(WAFOPTS) |
---|
| 66 | |
---|
| 67 | delete_install: |
---|
| 68 | rm -rf $(PWD)/dist/test |
---|
| 69 | |
---|
| 70 | build_python: |
---|
| 71 | # build python-aubio, using locally built libaubio if found |
---|
| 72 | python ./setup.py build $(ENABLE_DOUBLE) |
---|
| 73 | |
---|
| 74 | build_python_extlib: |
---|
| 75 | # build python-aubio using (locally) installed libaubio |
---|
| 76 | [ -f $(DESTDIR)/$(INCLUDEDIR)/aubio/aubio.h ] |
---|
| 77 | [ -d $(DESTDIR)/$(LIBDIR) ] |
---|
| 78 | [ -f $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc ] |
---|
| 79 | PKG_CONFIG_PATH=$(DESTDIR)/$(LIBDIR)/pkgconfig \ |
---|
| 80 | CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR) $(CFLAGS)" \ |
---|
| 81 | LDFLAGS="-L$(DESTDIR)/$(LIBDIR) $(CFLAGS)" \ |
---|
| 82 | make build_python |
---|
| 83 | make list_installed |
---|
| 84 | cat $(DESTDIR)/$(LIBDIR)/pkgconfig/aubio.pc |
---|
| 85 | |
---|
| 86 | deps_python: |
---|
| 87 | # install or upgrade python requirements |
---|
[fe957ad] | 88 | pip install --verbose --requirement requirements.txt |
---|
[5d9693c] | 89 | |
---|
| 90 | # use pip or distutils? |
---|
| 91 | #install_python: install_python_with_pip |
---|
| 92 | uninstall_python: uninstall_python_with_pip |
---|
| 93 | install_python: install_python_with_distutils |
---|
| 94 | #uninstall_python: uninstall_python_with_distutils |
---|
| 95 | |
---|
| 96 | install_python_with_pip: |
---|
[e56ac16] | 97 | # install package |
---|
[5d9693c] | 98 | pip install --verbose . |
---|
| 99 | |
---|
| 100 | uninstall_python_with_pip: |
---|
[e56ac16] | 101 | # uninstall package |
---|
[5d9693c] | 102 | pip uninstall -y -v aubio || make uninstall_python_with_distutils |
---|
| 103 | |
---|
| 104 | install_python_with_distutils: |
---|
| 105 | ./setup.py install $(DISTUTILSOPTS) |
---|
| 106 | |
---|
| 107 | uninstall_python_with_distutils: |
---|
| 108 | #./setup.py uninstall |
---|
| 109 | [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true |
---|
| 110 | |
---|
| 111 | force_uninstall_python: |
---|
| 112 | # ignore failure if not installed |
---|
| 113 | -make uninstall_python |
---|
[39122f0] | 114 | |
---|
[e56ac16] | 115 | local_dylib: |
---|
[5d9693c] | 116 | # DYLD_LIBRARY_PATH is no more on mac os |
---|
[1167631] | 117 | # create links from ~/lib/lib* to build/src/lib* |
---|
[5d9693c] | 118 | [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true |
---|
[e56ac16] | 119 | |
---|
[5d9693c] | 120 | test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR) |
---|
| 121 | test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR) |
---|
| 122 | test_python: local_dylib |
---|
[e56ac16] | 123 | # run test with installed package |
---|
| 124 | ./python/tests/run_all_tests --verbose |
---|
[5d9693c] | 125 | # also run with nose, multiple processes |
---|
[f465088] | 126 | nose2 -N 4 |
---|
[5d9693c] | 127 | # list installed files |
---|
| 128 | #find $(DESTDIR) -ls | sed 's|$(DESTDIR)||' |
---|
| 129 | make list_installed_python |
---|
[f465088] | 130 | |
---|
[5d9693c] | 131 | clean_python: |
---|
| 132 | ./setup.py clean |
---|
[a2ae70a] | 133 | |
---|
[5d9693c] | 134 | check_clean_python: |
---|
| 135 | # check cleaning a second time works |
---|
| 136 | make clean_python |
---|
| 137 | make clean_python |
---|
[a2ae70a] | 138 | |
---|
[0799252] | 139 | clean: checkwaf |
---|
[5d9693c] | 140 | # optionnaly clean before build |
---|
| 141 | -$(WAFCMD) clean |
---|
| 142 | |
---|
| 143 | check_clean: |
---|
| 144 | # check cleaning after build works |
---|
| 145 | $(WAFCMD) clean |
---|
| 146 | # check cleaning a second time works |
---|
[81ad577] | 147 | $(WAFCMD) clean |
---|
[ddd9861] | 148 | |
---|
[5864b43] | 149 | distclean: |
---|
| 150 | $(WAFCMD) distclean |
---|
| 151 | |
---|
[5d9693c] | 152 | check_distclean: |
---|
| 153 | make distclean |
---|
| 154 | |
---|
[e372a0f] | 155 | distcheck: checkwaf |
---|
[7aed123] | 156 | $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE) |
---|
[8e94af5] | 157 | |
---|
| 158 | help: |
---|
[81ad577] | 159 | $(WAFCMD) --help |
---|
[be06e53] | 160 | |
---|
| 161 | create_test_sounds: |
---|
[3a7b7c6] | 162 | -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true |
---|
| 163 | -mkdir -p $(TESTSOUNDS) |
---|
[9e36acd] | 164 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav" synth 1s silence 0 dcshift .01 |
---|
[ceb884d] | 165 | -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav" synth 5 brownnoise vol 0.9 |
---|
| 166 | -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav" synth 127s sine 440 vol 0.9 |
---|
| 167 | -$(SOX) -r 8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav" synth 30 silence 0 vol 0.9 |
---|
| 168 | -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav" synth 60 sine 100-20000 vol 0.9 |
---|
[9e36acd] | 169 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav" synth 44100s sine 441 vol 0.9 |
---|
| 170 | -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav" synth 100s sine 441 vol 0.9 |
---|
[e48b072] | 171 | |
---|
[5d9693c] | 172 | # build only libaubio, no python-aubio |
---|
| 173 | test_lib_only: clean distclean configure build install |
---|
| 174 | # additionally, clean after a fresh build |
---|
| 175 | test_lib_only_clean: test_lib_only uninstall check_clean check_distclean |
---|
| 176 | |
---|
| 177 | # build libaubio, build and test python-aubio against it |
---|
| 178 | test_lib_python: force_uninstall_python deps_python \ |
---|
| 179 | clean_python clean distclean \ |
---|
| 180 | configure build build_python \ |
---|
| 181 | install install_python \ |
---|
| 182 | test_python |
---|
| 183 | |
---|
| 184 | test_lib_python_clean: test_lib_python \ |
---|
| 185 | uninstall_python uninstall \ |
---|
| 186 | check_clean_python \ |
---|
| 187 | check_clean \ |
---|
| 188 | check_distclean |
---|
| 189 | |
---|
| 190 | # build libaubio, install it, build python-aubio against it |
---|
| 191 | test_lib_install_python: force_uninstall_python deps_python \ |
---|
| 192 | clean_python distclean \ |
---|
| 193 | configure build \ |
---|
| 194 | install \ |
---|
| 195 | build_python_extlib \ |
---|
| 196 | install_python \ |
---|
| 197 | test_python |
---|
| 198 | |
---|
| 199 | test_lib_install_python_clean: test_lib_install_python \ |
---|
| 200 | uninstall_python \ |
---|
| 201 | delete_install \ |
---|
| 202 | check_clean_python \ |
---|
| 203 | check_distclean |
---|
| 204 | |
---|
| 205 | # build a python-aubio that includes libaubio |
---|
| 206 | test_python_only: force_uninstall_python deps_python \ |
---|
| 207 | clean_python clean distclean \ |
---|
| 208 | build_python \ |
---|
| 209 | install_python \ |
---|
| 210 | test_python |
---|
| 211 | |
---|
| 212 | test_python_only_clean: test_python_only \ |
---|
| 213 | uninstall_python \ |
---|
| 214 | check_clean_python |
---|
| 215 | |
---|
| 216 | |
---|
[e48b072] | 217 | html: |
---|
| 218 | cd doc && make html |
---|
| 219 | |
---|
| 220 | dist: distclean expandwaf |
---|
| 221 | $(WAFCMD) dist |
---|