ccacabdf19aff865676d096794c9deebfc447efd
[tools/mic.git] / Makefile
1 PYTHON ?= python
2 VERSION = $(shell cat VERSION)
3 TAGVER = $(shell cat VERSION | sed -e "s/\([0-9\.]*\).*/\1/")
4
5 PKGNAME = mic
6
7 ifeq ($(VERSION), $(TAGVER))
8         TAG = $(TAGVER)
9 else
10         TAG = "HEAD"
11 endif
12
13 ifndef PREFIX
14     PREFIX = "/usr"
15 endif
16
17 all: build
18
19 build:
20         $(PYTHON) setup.py build
21
22 dist-common: man
23         git archive --format=tar --prefix=$(PKGNAME)-$(TAGVER)/ $(TAG) | tar xpf -
24         git show $(TAG) --oneline | head -1 > $(PKGNAME)-$(TAGVER)/commit-id
25         mkdir $(PKGNAME)-$(TAGVER)/doc; mv mic.1 $(PKGNAME)-$(TAGVER)/doc
26         rm -rf $(PKGNAME)-$(TAGVER)/tests
27
28 dist-bz2: dist-common
29         tar jcpf $(PKGNAME)-$(TAGVER).tar.bz2 $(PKGNAME)-$(TAGVER)
30         rm -rf $(PKGNAME)-$(TAGVER)
31
32 dist-gz: dist-common
33         tar zcpf $(PKGNAME)-$(TAGVER).tar.gz $(PKGNAME)-$(TAGVER)
34         rm -rf $(PKGNAME)-$(TAGVER)
35
36 man: USAGE.rst
37         rst2man $< >mic.1
38
39 install: build
40         $(PYTHON) setup.py install --prefix=$(DESTDIR)/$(PREFIX)
41
42 develop: build
43         $(PYTHON) setup.py develop
44
45 test:
46         cd tests/unittest/ && $(PYTHON) suite.py 
47
48 clean:
49         rm -f *.tar.gz
50         rm -f *.tar.bz2
51         rm -f mic/__version__.*
52         rm -f tools/*.py[co]
53         rm -f mic.1
54         rm -rf *.egg-info
55         rm -rf build/
56         rm -rf dist/