File: Makefile

package info (click to toggle)
python-nemu 0.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 280 kB
  • ctags: 440
  • sloc: python: 3,501; makefile: 62
file content (76 lines) | stat: -rw-r--r-- 1,955 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
SRC = src
TEST = test
BUILDDIR = build
DISTDIR = dist
COVERDIR = coverage
SRCFILES := $(shell find $(SRC) -type f)

# stupid distutils, it's broken in so many ways
SUBBUILDDIR := $(shell python -c 'import distutils.util, sys; \
	      print "lib.%s-%s" % (distutils.util.get_platform(), \
	      	sys.version[0:3])')
PYTHON25 := $(shell python -c 'import sys; v = sys.version_info; \
	print (1 if v[0] <= 2 and v[1] <= 5 else 0)')

ifeq ($(PYTHON25),0)
BUILDDIR := $(BUILDDIR)/$(SUBBUILDDIR)
else
BUILDDIR := $(BUILDDIR)/lib
endif

COVERAGE := $(or $(shell which coverage), $(shell which python-coverage), \
	    coverage)

all: build_stamp
build_stamp: $(SRCFILES)
	./setup.py build
	touch $@

install: all
	./setup.py install

test: all
	retval=0; \
	for i in `find "$(TEST)" -perm -u+x -type f`; do \
		echo $$i; \
		PYTHONPATH="$(BUILDDIR)" $$i || retval=$$?; \
		done; exit $$retval

coverage: coverage_stamp
	$(COVERAGE) -r -m `find "$(BUILDDIR)" -name \\*.py -type f`

coverage-report: coverage_stamp
	rm -rf $(COVERDIR)
	$(COVERAGE) -b -d $(COVERDIR) `find "$(BUILDDIR)" -name \\*.py -type f`
	@echo "Coverage report created in $(COVERDIR)/index.html"

coverage_stamp: build_stamp
	if [ `id -u` -ne 0 ]; then \
		echo "Coverage needs to be run as root."; false; fi
	for i in `find "$(TEST)" -perm -u+x -type f`; do \
		set -e; \
		PYTHONPATH="$(BUILDDIR)" $(COVERAGE) -x $$i; \
		done
	$(COVERAGE) -c
	touch $@

clean:
	./setup.py clean
	rm -f `find -name \*.pyc` .coverage *.pcap *_stamp
	rm -rf $(COVERDIR)
	#$(MAKE) -C $(CURDIR)/benchmarks/ clean

distclean: clean
	rm -rf "$(DISTDIR)"

MANIFEST: distclean
	find . -path ./.hg -prune -o -path ./build -prune -o \
		-path ./benchmarks -prune -o \
		-name \*.pyc -prune -o -name \*.swp -prune -o \
		-name MANIFEST -prune -o -name .hg\* -prune -o \
		-type f -print | sed 's#^\./##' | sort > MANIFEST

dist: MANIFEST
	./setup.py sdist

.PHONY: clean distclean dist test coverage install MANIFEST