-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
128 lines (102 loc) · 4.15 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# vim: set noet sw=4 ts=4:
# External utilities
PYTHON=python
PYFLAGS=
DEST_DIR=/
# Calculate the base names of the distribution, the location of all source,
# documentation and executable script files
NAME:=$(shell $(PYTHON) $(PYFLAGS) setup.py --name)
VER:=$(shell $(PYTHON) $(PYFLAGS) setup.py --version)
PYVER:=$(shell $(PYTHON) $(PYFLAGS) -c "import sys; print 'py%d.%d' % sys.version_info[:2]")
PY_SOURCES:=$(shell \
$(PYTHON) $(PYFLAGS) setup.py egg_info >/dev/null 2>&1 && \
cat $(NAME).egg-info/SOURCES.txt)
DOC_SOURCES:=$(wildcard docs/*.rst)
# Calculate the name of all outputs
DIST_EGG=dist/$(NAME)-$(VER)-$(PYVER).egg
DIST_EXE=dist/$(NAME)-$(VER).win32.exe
DIST_RPM=dist/$(NAME)-$(VER)-1.src.rpm
DIST_TAR=dist/$(NAME)-$(VER).tar.gz
DIST_DEB=dist/$(NAME)_$(VER)-1~ppa1_all.deb
MAN_DIR=build/sphinx/man
MAN_PAGES=$(MAN_DIR)/dbexec.1 $(MAN_DIR)/dbmakedoc.1 $(MAN_DIR)/dbgrepdoc.1 $(MAN_DIR)/dbtidysql.1
# Default target
all:
@echo "make install - Install on local system"
@echo "make doc - Generate HTML and PDF documentation"
@echo "make source - Create source package"
@echo "make buildegg - Generate a PyPI egg package"
@echo "make buildrpm - Generate an RedHat package"
@echo "make builddeb - Generate a Debian package"
@echo "make buildexe - Generate a Windows exe installer"
@echo "make dist - Generate all packages"
@echo "make clean - Get rid of all generated files"
@echo "make release - Create, tag, and upload a new release"
install:
$(PYTHON) $(PYFLAGS) setup.py install --root $(DEST_DIR)
doc: $(DOC_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b html
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b latex
$(MAKE) -C build/sphinx/latex all-pdf
source: $(DIST_TAR) $(DIST_ZIP)
buildexe: $(DIST_EXE)
buildegg: $(DIST_EGG)
buildrpm: $(DIST_RPM)
builddeb: $(DIST_DEB)
dist: $(DIST_EXE) $(DIST_EGG) $(DIST_RPM) $(DIST_DEB) $(DIST_TAR) $(DIST_ZIP)
develop: tags
$(PYTHON) $(PYFLAGS) setup.py develop
test:
nosetests -w tests/
clean:
$(PYTHON) $(PYFLAGS) setup.py clean
$(MAKE) -f $(CURDIR)/debian/rules clean
rm -fr build/ dist/ $(NAME).egg-info/ tags distribute-*.egg distribute-*.tar.gz
find $(CURDIR) -name "*.pyc" -delete
tags: $(PY_SOURCES)
ctags -R --exclude="build/*" --exclude="docs/*" --languages="Python"
$(MAN_PAGES): $(DOC_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b man
$(DIST_TAR): $(PY_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py sdist --formats gztar
$(DIST_ZIP): $(PY_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py sdist --formats zip
$(DIST_EGG): $(PY_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py bdist_egg
$(DIST_EXE): $(PY_SOURCES)
$(PYTHON) $(PYFLAGS) setup.py bdist_wininst
$(DIST_RPM): $(PY_SOURCES) $(MAN_PAGES)
$(PYTHON) $(PYFLAGS) setup.py bdist_rpm \
--source-only \
--doc-files README.rst,LICENSE.txt \
--requires python,python-pgraphviz,python-imaging
# XXX Add man-pages to RPMs ... how?
$(DIST_DEB): $(PY_SOURCES) $(MAN_PAGES)
# build the source package in the parent directory then rename it to
# project_version.orig.tar.gz
$(PYTHON) $(PYFLAGS) setup.py sdist --dist-dir=../
rename -f 's/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
debuild -b -i -I -Idist -Idocs -Ibuild/sphinx/doctrees -rfakeroot
mkdir -p dist/
cp ../$(NAME)_$(VER)-1~ppa1_all.deb dist/
release: $(PY_SOURCES) $(DOC_SOURCES)
$(MAKE) clean
# ensure there are no current uncommitted changes
test -z "$(shell git status --porcelain)"
# update the changelog with new release information
dch --newversion $(VER)-1~ppa1 --controlmaint
# commit the changes and add a new tag
git commit debian/changelog -m "Updated changelog for release $(VER)"
git tag -s release-$(VER) -m "Release $(VER)"
upload: $(PY_SOURCES) $(DOC_SOURCES)
$(MAKE) clean
# build a source archive and upload to PyPI
$(PYTHON) $(PYFLAGS) setup.py sdist upload
# build the deb source archive
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b man
$(PYTHON) $(PYFLAGS) setup.py sdist --dist-dir=../
rename -f 's/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
debuild -S -i -I -Idist -Idocs -Ibuild/sphinx/doctrees -rfakeroot
# prompt the user to upload it to the PPA
@echo "Now run 'dput waveform-ppa $(NAME)_$(VER)-1~ppa1_source.changes'"
@echo "from the home directory"