3
########################################################
7
# make sdist ---------------- produce a tarball
8
# make rpm ----------------- produce RPMs
9
# make deb ------------------ produce a DEB
10
# make docs ----------------- rebuild the manpages (results are checked in)
11
# make tests ---------------- run the tests
12
# make pyflakes, make pep8 -- source code checks
14
########################################################
18
OS = $(shell uname -s)
20
# Manpages are currently built with asciidoc -- would like to move to markdown
21
# This doesn't evaluate until it's called. The -D argument is the
22
# directory of the target file ($@), kinda like `dirname`.
23
MANPAGES := docs/man/man1/ansible.1 docs/man/man1/ansible-playbook.1 docs/man/man1/ansible-pull.1 docs/man/man1/ansible-doc.1 docs/man/man1/ansible-galaxy.1
24
ifneq ($(shell which a2x 2>/dev/null),)
25
ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
26
ASCII2HTMLMAN = a2x -D docs/html/man/ -d manpage -f xhtml
28
ASCII2MAN = @echo "ERROR: AsciiDoc 'a2x' command is not installed but is required to build $(MANPAGES)" && exit 1
32
SITELIB = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
34
# VERSION file provides one place to update the software version
35
VERSION := $(shell cat VERSION)
37
# Get the branch information from git
38
ifneq ($(shell which git),)
39
GIT_DATE := $(shell git log -n 1 --format="%ai")
42
ifeq ($(shell echo $(OS) | egrep -c 'Darwin|FreeBSD|OpenBSD'),1)
43
DATE := $(shell date -j -r $(shell git log -n 1 --format="%at") +%Y%m%d%H%M)
45
DATE := $(shell date --utc --date="$(GIT_DATE)" +%Y%m%d%H%M)
48
# RPM build parameters
49
RPMSPECDIR= packaging/rpm
50
RPMSPEC = $(RPMSPECDIR)/ansible.spec
51
RPMDIST = $(shell rpm --eval '%{?dist}')
54
RPMRELEASE = 0.git$(DATE)
56
RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)$(RPMDIST)"
58
NOSETESTS ?= nosetests
60
########################################################
65
PYTHONPATH=./lib ANSIBLE_LIBRARY=./library $(NOSETESTS) -d -w test/units -v
70
# Regenerate %.1.asciidoc if %.1.asciidoc.in has been modified more
71
# recently than %.1.asciidoc.
72
%.1.asciidoc: %.1.asciidoc.in
73
sed "s/%VERSION%/$(VERSION)/" $< > $@
75
# Regenerate %.1 if %.1.asciidoc or VERSION has been modified more
76
# recently than %.1. (Implicitly runs the %.1.asciidoc recipe)
77
%.1: %.1.asciidoc VERSION
81
sloccount lib library bin
84
@echo "#############################################"
85
@echo "# Running PEP8 Compliance Tests"
86
@echo "#############################################"
87
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 lib/ bin/
88
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 --filename "*" library/
91
pyflakes lib/ansible/*.py lib/ansible/*/*.py bin/*
94
@echo "Cleaning up distutils stuff"
97
@echo "Cleaning up byte compiled python stuff"
98
find . -type f -regex ".*\.py[co]$$" -delete
99
@echo "Cleaning up editor backup files"
100
find . -type f \( -name "*~" -or -name "#*" \) -delete
101
find . -type f \( -name "*.swp" \) -delete
102
@echo "Cleaning up manpage stuff"
103
find ./docs/man -type f -name "*.xml" -delete
104
find ./docs/man -type f -name "*.asciidoc" -delete
105
find ./docs/man/man3 -type f -name "*.3" -delete
106
@echo "Cleaning up output from test runs"
107
rm -rf test/test_data
108
@echo "Cleaning up RPM building stuff"
109
rm -rf MANIFEST rpm-build
110
@echo "Cleaning up Debian building stuff"
115
@echo "Cleaning up authors file"
119
$(PYTHON) setup.py build
122
$(PYTHON) setup.py install
125
$(PYTHON) setup.py sdist -t MANIFEST.in
127
rpmcommon: $(MANPAGES) sdist
129
@cp dist/*.gz rpm-build/
130
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)%{?dist}#' $(RPMSPEC) >rpm-build/$(NAME).spec
133
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
134
--define "_builddir %{_topdir}" \
135
--define "_rpmdir %{_topdir}" \
136
--define "_srcrpmdir %{_topdir}" \
137
--define "_specdir $(RPMSPECDIR)" \
138
--define "_sourcedir %{_topdir}" \
139
-bs rpm-build/$(NAME).spec
140
@rm -f rpm-build/$(NAME).spec
141
@echo "#############################################"
142
@echo "Ansible SRPM is built:"
143
@echo " rpm-build/$(RPMNVR).src.rpm"
144
@echo "#############################################"
147
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
148
--define "_builddir %{_topdir}" \
149
--define "_rpmdir %{_topdir}" \
150
--define "_srcrpmdir %{_topdir}" \
151
--define "_specdir $(RPMSPECDIR)" \
152
--define "_sourcedir %{_topdir}" \
153
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
154
--define "__python `which $(PYTHON)`" \
155
-ba rpm-build/$(NAME).spec
156
@rm -f rpm-build/$(NAME).spec
157
@echo "#############################################"
158
@echo "Ansible RPM is built:"
159
@echo " rpm-build/$(RPMNVR).noarch.rpm"
160
@echo "#############################################"
164
cp -r packaging/debian ./
165
chmod 755 debian/rules
166
fakeroot debian/rules clean
168
fakeroot debian/rules binary
170
# for arch or gentoo, read instructions in the appropriate 'packaging' subdirectory directory
173
(cd docsite/; make docs)