source: Makefile @ 4cdef00

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampleryinfft+
Last change on this file since 4cdef00 was 5d9693c, checked in by Paul Brossier <piem@piem.org>, 7 years ago

Makefile: rewrite, improve test targets

  • Property mode set to 100644
File size: 5.7 KB
Line 
1WAFCMD=python waf
2WAFURL=https://waf.io/waf-1.8.22
3
4#WAFOPTS:=
5# turn on verbose mode
6#WAFOPTS += --verbose
7# build wafopts
8WAFOPTS += --destdir $(DESTDIR)
9# multiple jobs
10WAFOPTS += --jobs 4
11
12DESTDIR:=$(PWD)/build/dist
13PYDESTDIR:=$(PWD)/build/pydist
14
15# default install locations
16PREFIX?=/usr/local
17EXEC_PREFIX?=$(PREFIX)
18LIBDIR?=$(PREFIX)/lib
19INCLUDEDIR?=$(PREFIX)/include
20DATAROOTDIR?=$(PREFIX)/share
21MANDIR?=$(DATAROOTDIR)/man
22
23SOX=sox
24
25ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double )
26TESTSOUNDS := python/tests/sounds
27
28all: build
29
30checkwaf:
31        @[ -f waf ] || make getwaf
32
33getwaf:
34        ./scripts/get_waf.sh
35
36expandwaf: 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
43cleanwaf:
44        rm -rf waf waflib .waf*
45
46configure: checkwaf
47        $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE)
48
49build: configure
50        $(WAFCMD) build $(WAFOPTS)
51
52install:
53        # install
54        $(WAFCMD) install $(WAFOPTS)
55        make list_installed
56
57list_installed:
58        find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
59
60list_installed_python:
61        find $(PYDESTDIR) -ls | sed 's|$(PYDESTDIR)|/«pydestdir»|'
62
63uninstall:
64        # uninstall
65        $(WAFCMD) uninstall $(WAFOPTS)
66
67delete_install:
68        rm -rf $(PWD)/dist/test
69
70build_python:
71        # build python-aubio, using locally built libaubio if found
72        python ./setup.py build $(ENABLE_DOUBLE)
73
74build_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
86deps_python:
87        # install or upgrade python requirements
88        pip install --verbose --upgrade --requirement requirements.txt
89
90# use pip or distutils?
91#install_python: install_python_with_pip
92uninstall_python: uninstall_python_with_pip
93install_python: install_python_with_distutils
94#uninstall_python: uninstall_python_with_distutils
95
96install_python_with_pip:
97        # install package
98        pip install --verbose .
99
100uninstall_python_with_pip:
101        # uninstall package
102        pip uninstall -y -v aubio || make uninstall_python_with_distutils
103
104install_python_with_distutils:
105        ./setup.py install $(DISTUTILSOPTS)
106
107uninstall_python_with_distutils:
108        #./setup.py uninstall
109        [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
110
111force_uninstall_python:
112        # ignore failure if not installed
113        -make uninstall_python
114
115local_dylib:
116        # DYLD_LIBRARY_PATH is no more on mac os
117        # create links from ~/lib/lib* to build/src/lib*
118        [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
119
120test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
121test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
122test_python: local_dylib
123        # run test with installed package
124        ./python/tests/run_all_tests --verbose
125        # also run with nose, multiple processes
126        nose2 -N 4
127        # list installed files
128        #find $(DESTDIR) -ls | sed 's|$(DESTDIR)||'
129        make list_installed_python
130
131clean_python:
132        ./setup.py clean
133
134check_clean_python:
135        # check cleaning a second time works
136        make clean_python
137        make clean_python
138
139clean:
140        # optionnaly clean before build
141        -$(WAFCMD) clean
142
143check_clean:
144        # check cleaning after build works
145        $(WAFCMD) clean
146        # check cleaning a second time works
147        $(WAFCMD) clean
148
149distclean:
150        $(WAFCMD) distclean
151
152check_distclean:
153        make distclean
154
155distcheck: checkwaf
156        $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE)
157
158help:
159        $(WAFCMD) --help
160
161create_test_sounds:
162        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
163        -mkdir -p $(TESTSOUNDS)
164        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"          synth 1s   silence 0        dcshift .01
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
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
171
172# build only libaubio, no python-aubio
173test_lib_only: clean distclean configure build install
174# additionally, clean after a fresh build
175test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
176
177# build libaubio, build and test python-aubio against it
178test_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
184test_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
191test_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
199test_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
206test_python_only: force_uninstall_python deps_python \
207        clean_python clean distclean \
208        build_python \
209        install_python \
210        test_python
211
212test_python_only_clean: test_python_only \
213        uninstall_python \
214        check_clean_python
215
216
217html:
218        cd doc && make html
219
220dist: distclean expandwaf
221        $(WAFCMD) dist
Note: See TracBrowser for help on using the repository browser.