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