Changeset 5d9693c for Makefile


Ignore:
Timestamp:
Dec 1, 2016, 7:57:40 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, sampler, yinfft+
Children:
4cdef00
Parents:
a028a04
Message:

Makefile: rewrite, improve test targets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    ra028a04 r5d9693c  
    11WAFCMD=python waf
    22WAFURL=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
    322
    423SOX=sox
     
    3150        $(WAFCMD) build $(WAFOPTS)
    3251
     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
    3370build_python:
    34         python ./setup.py build_ext $(ENABLE_DOUBLE)
    35 
    36 test_python: export LD_LIBRARY_PATH=$(PWD)/build/src
     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)
    37122test_python: local_dylib
    38         # clean
    39         -pip uninstall -v -y aubio
    40         ./setup.py clean
    41         $(WAFCMD) distclean
    42         # build library
    43         $(WAFCMD) configure build
    44         # install python requirements
    45         pip install -v -r requirements.txt
    46         # install package
    47         pip install -v .
    48         # can clean twice
    49         ./setup.py clean
    50         ./setup.py clean
    51123        # run test with installed package
    52124        ./python/tests/run_all_tests --verbose
    53         nose2 -N 4 #--verbose
    54         # uninstall package
    55         pip uninstall -y -v aubio
    56 
    57 local_dylib:
    58         # create links from ~/lib/lib* to build/src/lib*
    59         [ -f build/src/libaubio.[0-9].dylib ] && ( mkdir -p ~/lib && cp -prv build/src/libaubio.[0-9].dylib ~/lib ) || true
     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
    60130
    61131clean_python:
    62132        ./setup.py clean
    63133
    64 test_pure_python:
    65         # clean
    66         -pip uninstall -v -y aubio
    67         -$(WAFCMD) distclean
    68         ./setup.py clean
    69         # install python requirements
    70         pip install --verbose --requirement requirements.txt
    71         # compile
    72         CFLAGS=-Os python setup.py build $(ENABLE_DOUBLE)
    73         # needs recompile, disabled
    74         #./setup.py test
    75         # install package
    76         pip install --verbose .
    77         # can clean twice
    78         ./setup.py clean
    79         ./setup.py clean
    80         # run test with installed package
    81         ./python/tests/run_all_tests --verbose
    82         nose2 -N 4 #--verbose
    83         # uninstall
    84         pip uninstall -v -y aubio
    85 
    86 test_pure_python_wheel:
    87         -pip uninstall -v -y aubio
    88         -rm -rf build/ python/gen/
    89         -rm -f dist/*.whl
    90         -pip install -v -r requirements.txt
    91         -pip install -v wheel
    92         CFLAGS=-Os python setup.py build_ext $(ENABLE_DOUBLE) bdist_wheel --universal
    93         wheel install dist/*.whl
    94         nose2 -N 4
    95         pip uninstall -v -y aubio
    96 
    97 build_python3:
    98         python3 ./setup.py build_ext $(ENABLE_DOUBLE)
    99 
    100 clean_python3:
    101         python3 ./setup.py clean
     134check_clean_python:
     135        # check cleaning a second time works
     136        make clean_python
     137        make clean_python
    102138
    103139clean:
     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
    104147        $(WAFCMD) clean
    105148
    106149distclean:
    107150        $(WAFCMD) distclean
     151
     152check_distclean:
     153        make distclean
    108154
    109155distcheck: checkwaf
     
    124170        -$(SOX) -r 44100 -b 16 -n "$(TESTSOUNDS)/44100Hz_100f_sine441.wav"    synth 100s sine 441       vol 0.9
    125171
     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
    126217html:
    127218        cd doc && make html
Note: See TracChangeset for help on using the changeset viewer.