-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
101 lines (83 loc) · 2.78 KB
/
Makefile
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/make
# WARN: gmake syntax
########################################################
# Makefile for rphm extension
#
# useful targets:
# make clean ----- cleans distutils
# make install --- installs python modules
# make pylint ---- source code checks
# make rpm ------ produce RPMs
# make sdist ----- builds a source distribution
# make tests ----- run the tests
# make coverage -- run the tests and analyze code coverage
#
########################################################
# variable section
NAME = "rphm"
PYTHON=python
SITELIB = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
# VERSION file provides one place to update the software version
VERSION := $(shell cat VERSION)
# RPM build parameters
RPMSPECDIR = .
RPMSPEC = $(RPMSPECDIR)/rphm.spec
RPMRELEASE = 1
RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)"
########################################################
all: clean python
pylint:
find . -name \*.py | xargs pylint --rcfile .pylintrc
clean:
@echo "---------------------------------------------"
@echo "Cleaning up distutils stuff"
@echo "---------------------------------------------"
rm -rf build
rm -rf dist
rm -rf MANIFEST
@echo "---------------------------------------------"
@echo "Cleaning up rpmbuild stuff"
@echo "---------------------------------------------"
rm -rf rpmbuild
@echo "---------------------------------------------"
@echo "Cleaning up byte compiled python stuff"
@echo "---------------------------------------------"
find . -type f -regex ".*\.py[co]$$" -delete
tests: clean
$(PYTHON) -m unittest discover ./test -v
coverage: clean
PYTHONPATH=. nosetests --verbosity=3 -x --with-xunit \
--xunit-file=junit-report.xml \
--with-coverage --cover-erase --cover-html \
--cover-package=rphm --cover-branches
report:
coverage report -m
coverageclean:
rm -rf cover
rm .coverage
python:
$(PYTHON) setup.py build
install:
$(PYTHON) setup.py install
sdist: clean
$(PYTHON) setup.py sdist
#$(PYTHON) setup.py sdist -t MANIFEST.in
rpmcommon: sdist
@mkdir -p rpmbuild
@cp dist/*.gz rpmbuild/
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)#' $(RPMSPEC) >rpmbuild/$(NAME).spec
rpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpmbuild" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.rpm" \
--define "__python /usr/bin/python" \
-ba rpmbuild/$(NAME).spec
@rm -f rpmbuild/$(NAME).spec
@echo "---------------------------------------------"
@echo "rphm RPM is built:"
@echo " rpmbuild/$(RPMNVR).rpm"
@echo "---------------------------------------------"