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