Fix YumDependency: clean packages.tar before archiving
[nepi.git] / Makefile
1 SRCDIR      = $(CURDIR)/src
2 TESTDIR     = $(CURDIR)/test
3 TESTLIB     = $(TESTDIR)/lib
4 BUILDDIR    = $(CURDIR)/build
5 DISTDIR     = $(CURDIR)/dist
6
7 # stupid distutils, it's broken in so many ways
8 SUBBUILDDIR = $(shell python -c 'import distutils.util, sys; \
9               print "lib.%s-%s" % (distutils.util.get_platform(), \
10               sys.version[0:3])')
11 PYTHON25 := $(shell python -c 'import sys; v = sys.version_info; \
12     print (1 if v[0] <= 2 and v[1] <= 5 else 0)')
13
14 ifeq ($(PYTHON25),0)
15 BUILDDIR := $(BUILDDIR)/$(SUBBUILDDIR)
16 else
17 BUILDDIR := $(BUILDDIR)/lib
18 endif
19
20 PYPATH = $(BUILDDIR):$(TESTLIB):$(PYTHONPATH)
21 COVERAGE = $(or $(shell which coverage), $(shell which python-coverage), \
22            coverage)
23
24 all:
25         ./setup.py build
26
27 install: all
28         ./setup.py install
29
30 test: all
31         retval=0; \
32                for i in `find "$(TESTDIR)" -iname '*.py' -perm -u+x -type f`; do \
33                echo $$i; \
34                TESTLIBPATH="$(TESTLIB)" PYTHONPATH="$(PYPATH)" $$i -v || retval=$$?; \
35                done; exit $$retval
36
37 coverage: all
38         rm -f .coverage
39         for i in `find "$(TESTDIR)" -perm -u+x -type f`; do \
40                 set -e; \
41                 TESTLIBPATH="$(TESTLIB)" PYTHONPATH="$(PYPATH)" $(COVERAGE) -x $$i -v; \
42                 done
43         $(COVERAGE) -c
44         $(COVERAGE) -r -m `find "$(BUILDDIR)" -name \\*.py -type f`
45         rm -f .coverage
46
47 clean:
48         ./setup.py clean
49         rm -f `find -name \*.pyc` .coverage *.pcap
50
51 distclean: clean
52         rm -rf "$(DISTDIR)"
53
54 MANIFEST:
55         find . -path ./.hg\* -prune -o -path ./build -prune -o \
56                 -name \*.pyc -prune -o -name \*.swp -prune -o \
57                 -name MANIFEST -prune -o -type f -print | \
58                 sed 's#^\./##' | sort > MANIFEST
59
60 dist: MANIFEST
61         ./setup.py sdist
62
63 .PHONY: all clean distclean dist test coverage install MANIFEST