Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rfee4570 r5d9b03b  
     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
    112WAFCMD=python waf
    2 WAFURL=https://waf.io/waf-1.8.22
     13WAFURL=https://waf.io/waf-1.9.6
     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
    338
    439SOX=sox
    540
    6 ENABLE_DOUBLE := $(shell [ -z $(HAVE_DOUBLE) ] || echo --enable-double )
    741TESTSOUNDS := python/tests/sounds
    842
     
    1347
    1448getwaf:
    15         @./scripts/get_waf.sh
    16 
    17 expandwaf:
    18         @[ -d wafilb ] || rm -fr waflib
    19         @$(WAFCMD) --help > /dev/null
    20         @mv .waf*/waflib . && rm -fr .waf*
    21         @sed '/^#==>$$/,$$d' waf > waf2 && mv waf2 waf
    22         @chmod +x waf
     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 && chmod -R go-w waflib
     57
     58cleanwaf:
     59        rm -rf waf waflib .waf*
    2360
    2461configure: checkwaf
    25         $(WAFCMD) configure $(WAFOPTS) $(ENABLE_DOUBLE)
     62        $(WAFCMD) configure $(WAFOPTS)
    2663
    2764build: configure
    2865        $(WAFCMD) build $(WAFOPTS)
    2966
     67install:
     68        # install
     69        $(WAFCMD) install $(WAFOPTS)
     70
     71list_installed:
     72        find $(DESTDIR) -ls | sed 's|$(DESTDIR)|/«destdir»|'
     73
     74list_installed_python:
     75        pip show -f aubio
     76
     77list_all_installed: list_installed list_installed_python
     78
     79uninstall:
     80        # uninstall
     81        $(WAFCMD) uninstall $(WAFOPTS)
     82
     83delete_install:
     84        rm -rf $(PWD)/dist/test
     85
    3086build_python:
    31         python ./setup.py build_ext $(ENABLE_DOUBLE)
    32 
    33 test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
    34 test_python:
    35         pip install -v -r requirements.txt
    36         pip install -v .
    37         nose2 --verbose
    38         pip uninstall -y -v aubio
    39 
    40 test_python_osx:
     87        # build python-aubio, using locally built libaubio if found
     88        python ./setup.py build
     89
     90build_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 \
     96        CFLAGS="-I$(DESTDIR)/$(INCLUDEDIR)" \
     97        LDFLAGS="-L$(DESTDIR)/$(LIBDIR)" \
     98                make build_python
     99
     100deps_python:
     101        # install or upgrade python requirements
     102        pip install $(PIPOPTS) --requirement requirements.txt
     103
     104# use pip or distutils?
     105install_python: install_python_with_pip
     106uninstall_python: uninstall_python_with_pip
     107#install_python: install_python_with_distutils
     108#uninstall_python: uninstall_python_with_distutils
     109
     110install_python_with_pip:
     111        # install package
     112        pip install $(PIPOPTS) .
     113
     114uninstall_python_with_pip:
     115        # uninstall package
     116        ( pip show aubio | grep -l aubio > /dev/null ) && \
     117        pip uninstall -y -v aubio || echo "info: aubio package is not installed"
     118
     119install_python_with_distutils:
     120        ./setup.py install $(PIPOPTS) $(DISTUTILSOPTS)
     121
     122uninstall_python_with_distutils:
     123        #./setup.py uninstall
     124        [ -d $(PYDESTDIR)/$(LIBDIR) ] && echo Warning: did not clean $(PYDESTDIR)/$(LIBDIR) || true
     125
     126force_uninstall_python:
     127        # ignore failure if not installed
     128        -make uninstall_python
     129
     130local_dylib:
     131        # DYLD_LIBRARY_PATH is no more on mac os
    41132        # create links from ~/lib/lib* to build/src/lib*
    42         [ -f build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
    43         # then run the tests
    44         pip install --user -v -r requirements.txt
    45         pip install --user -v .
    46         nose2 --verbose
    47         pip uninstall -y -v aubio
     133        [ -f $(PWD)/build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
     134
     135test_python: export LD_LIBRARY_PATH=$(DESTDIR)/$(LIBDIR)
     136test_python: export PYTHONPATH=$(PYDESTDIR)/$(LIBDIR)
     137test_python: local_dylib
     138        # run test with installed package
     139        ./python/tests/run_all_tests --verbose
     140        # also run with nose, multiple processes
     141        nose2 -N 4
    48142
    49143clean_python:
    50144        ./setup.py clean
    51145
    52 test_pure_python:
    53         -pip uninstall -v -y aubio
    54         -rm -rf build/ python/gen/
    55         -rm -f dist/*.egg
    56         -pip install -v -r requirements.txt
    57         CFLAGS=-Os python setup.py build_ext $(ENABLE_DOUBLE) bdist_wheel
    58         pip install dist/aubio-*.whl
    59         nose2 -N 4
    60         pip uninstall -v -y aubio
    61 
    62 test_pure_python_wheel:
    63         -pip uninstall -v -y aubio
    64         -rm -rf build/ python/gen/
    65         -rm -f dist/*.whl
    66         -pip install -v -r requirements.txt
    67         -pip install -v wheel
    68         CFLAGS=-Os python setup.py build_ext $(ENABLE_DOUBLE) bdist_wheel --universal
    69         wheel install dist/*.whl
    70         nose2 -N 4
    71         pip uninstall -v -y aubio
    72 
    73 build_python3:
    74         python3 ./setup.py build_ext $(ENABLE_DOUBLE)
    75 
    76 clean_python3:
    77         python3 ./setup.py clean
    78 
    79 clean:
     146check_clean_python:
     147        # check cleaning a second time works
     148        make clean_python
     149        make clean_python
     150
     151clean: checkwaf
     152        # optionnaly clean before build
     153        -$(WAFCMD) clean
     154        # remove possible left overs
     155        -rm -rf doc/_build
     156
     157check_clean:
     158        # check cleaning after build works
     159        $(WAFCMD) clean
     160        # check cleaning a second time works
    80161        $(WAFCMD) clean
    81162
    82163distclean:
    83164        $(WAFCMD) distclean
     165        -rm -rf doc/_build/
     166        -rm -rf doc/web/
     167
     168check_distclean:
     169        make distclean
    84170
    85171distcheck: checkwaf
    86         $(WAFCMD) distcheck $(WAFOPTS) $(ENABLE_DOUBLE)
     172        $(WAFCMD) distcheck $(WAFOPTS)
    87173
    88174help:
     
    92178        -[ -z `which $(SOX)` ] && ( echo $(SOX) could not be found) || true
    93179        -mkdir -p $(TESTSOUNDS)
    94         -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      synth 1s   silence 0
     180        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_1f_silence.wav"      trim 0 1s
    95181        -$(SOX) -r 22050 -b 16 -n "$(TESTSOUNDS)/22050Hz_5s_brownnoise.wav"   synth 5    brownnoise      vol 0.9
    96182        -$(SOX) -r 32000 -b 16 -n "$(TESTSOUNDS)/32000Hz_127f_sine440.wav"    synth 127s sine 440        vol 0.9
    97         -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      synth 30   silence 0       vol 0.9
     183        -$(SOX) -r  8000 -b 16 -n "$(TESTSOUNDS)/8000Hz_30s_silence.wav"      trim 0 30
    98184        -$(SOX) -r 48000 -b 32 -n "$(TESTSOUNDS)/48000Hz_60s_sweep.wav"       synth 60   sine 100-20000  vol 0.9
     185        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_44100f_sine441.wav"  synth 44100s   sine 441   vol 0.9
     186        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav"    synth 100s sine 441       vol 0.9
     187
     188# build only libaubio, no python-aubio
     189test_lib_only: clean distclean configure build install list_installed
     190# additionally, clean after a fresh build
     191test_lib_only_clean: test_lib_only uninstall check_clean check_distclean
     192
     193# build libaubio, build and test python-aubio against it
     194test_lib_python: force_uninstall_python deps_python \
     195        clean_python clean distclean \
     196        configure build build_python \
     197        install install_python \
     198        test_python \
     199        list_all_installed
     200
     201test_lib_python_clean: test_lib_python \
     202        uninstall_python uninstall \
     203        check_clean_python \
     204        check_clean \
     205        check_distclean
     206
     207# build libaubio, install it, build python-aubio against it
     208test_lib_install_python: force_uninstall_python deps_python \
     209        clean_python distclean \
     210        configure build \
     211        install \
     212        build_python_extlib \
     213        install_python \
     214        test_python \
     215        list_all_installed
     216
     217test_lib_install_python_clean: test_lib_install_python \
     218        uninstall_python \
     219        delete_install \
     220        check_clean_python \
     221        check_distclean
     222
     223# build a python-aubio that includes libaubio
     224test_python_only: force_uninstall_python deps_python \
     225        clean_python clean distclean \
     226        build_python \
     227        install_python \
     228        test_python \
     229        list_installed_python
     230
     231test_python_only_clean: test_python_only \
     232        uninstall_python \
     233        check_clean_python
     234
     235sphinx: configure
     236        $(WAFCMD) sphinx $(WAFOPTS)
     237
     238doxygen: configure
     239        $(WAFCMD) doxygen $(WAFOPTS)
     240
     241manpages: configure
     242        $(WAFCMD) manpages $(WAFOPTS)
     243
     244html: doxygen sphinx
     245
     246docs: html manpages
     247
     248dist: distclean expandwaf
     249        $(WAFCMD) dist
Note: See TracChangeset for help on using the changeset viewer.