source: Makefile @ 7b38f3f

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

Makefile: use pip to install, add a brief intro

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