f0b02117 |
#!/usr/bin/make |
83d1028a |
# WARN: gmake syntax |
9d0f2a6e |
########################################################
# Makefile for Ansible
#
# useful targets:
# make sdist ---------------- produce a tarball
# make rpm ----------------- produce RPMs |
e3b2521f |
# make deb ------------------ produce a DEB |
9d0f2a6e |
# make docs ----------------- rebuild the manpages (results are checked in)
# make tests ---------------- run the tests |
85fb7c6d |
# make pyflakes, make pep8 -- source code checks |
9d0f2a6e |
########################################################
# variable section
|
3f245498 |
NAME = "ansible" |
83d1028a |
OS = $(shell uname -s) |
9d0f2a6e |
# Manpages are currently built with asciidoc -- would like to move to markdown |
3f9a41b2 |
# This doesn't evaluate until it's called. The -D argument is the
# directory of the target file ($@), kinda like `dirname`. |
badb4139 |
MANPAGES := docs/man/man1/ansible.1 docs/man/man1/ansible-playbook.1 docs/man/man1/ansible-pull.1 docs/man/man1/ansible-doc.1
ifneq ($(shell which a2x 2>/dev/null),) |
f0b02117 |
ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
ASCII2HTMLMAN = a2x -D docs/html/man/ -d manpage -f xhtml |
badb4139 |
else
ASCII2MAN = @echo "ERROR: AsciiDoc 'a2x' command is not installed but is required to build $(MANPAGES)" && exit 1
endif |
9d0f2a6e |
|
785068df |
PYTHON=python
SITELIB = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()") |
9d0f2a6e |
# VERSION file provides one place to update the software version |
3f9a41b2 |
VERSION := $(shell cat VERSION) |
9d0f2a6e |
|
a162fa70 |
# Get the branch information from git |
ec7c8eb8 |
ifneq ($(shell which git),)
GIT_DATE := $(shell git log -n 1 --format="%ai")
endif |
83d1028a |
|
338ecdd5 |
ifeq ($(shell echo $(OS) | egrep -c 'Darwin|FreeBSD|OpenBSD'),1)
DATE := $(shell date -j -r $(shell git log -n 1 --format="%at") +%Y%m%d%H%M) |
5072ed3b |
else |
765061d4 |
DATE := $(shell date --utc --date="$(GIT_DATE)" +%Y%m%d%H%M) |
83d1028a |
endif |
ec7c8eb8 |
|
9d0f2a6e |
# RPM build parameters |
66f294d5 |
RPMSPECDIR= packaging/rpm
RPMSPEC = $(RPMSPECDIR)/ansible.spec |
a37b6a2a |
RPMDIST = $(shell rpm --eval '%{?dist}') |
ec7c8eb8 |
RPMRELEASE = 1
ifeq ($(OFFICIAL),)
RPMRELEASE = 0.git$(DATE)
endif
RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)$(RPMDIST)" |
f0b02117 |
|
a0678771 |
NOSETESTS := nosetests
|
9d0f2a6e |
########################################################
|
55d256d8 |
all: clean python
|
85fb7c6d |
tests: |
7a220e3b |
PYTHONPATH=./lib ANSIBLE_LIBRARY=./library $(NOSETESTS) -d -v |
05c5c852 |
|
3f9a41b2 |
# To force a rebuild of the docs run 'touch VERSION && make docs' |
e2c1b34d |
docs: $(MANPAGES) modulepages |
fa550f3d |
authors:
sh hacking/authors.sh |
f0b02117 |
|
d43cf592 |
# Regenerate %.1.asciidoc if %.1.asciidoc.in has been modified more
# recently than %.1.asciidoc.
%.1.asciidoc: %.1.asciidoc.in |
3f9a41b2 |
sed "s/%VERSION%/$(VERSION)/" $< > $@ |
f0b02117 |
|
3f9a41b2 |
# Regenerate %.1 if %.1.asciidoc or VERSION has been modified more
# recently than %.1. (Implicitly runs the %.1.asciidoc recipe)
%.1: %.1.asciidoc VERSION |
f0b02117 |
$(ASCII2MAN)
|
3ad9db49 |
loc:
sloccount lib library bin
|
f0b02117 |
pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests"
@echo "#############################################" |
00c28e28 |
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 lib/ bin/
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 --filename "*" library/ |
f0b02117 |
|
6541f338 |
pyflakes: |
906f7fd8 |
pyflakes lib/ansible/*.py lib/ansible/*/*.py bin/* |
6541f338 |
|
f0b02117 |
clean: |
2d052fce |
@echo "Cleaning up distutils stuff" |
3f9a41b2 |
rm -rf build
rm -rf dist |
2d052fce |
@echo "Cleaning up byte compiled python stuff" |
3f9a41b2 |
find . -type f -regex ".*\.py[co]$$" -delete |
2d052fce |
@echo "Cleaning up editor backup files"
find . -type f \( -name "*~" -or -name "#*" \) -delete |
de3cff8c |
find . -type f \( -name "*.swp" \) -delete |
9541b47b |
@echo "Cleaning up manpage stuff" |
f1c8fc63 |
find ./docs/man -type f -name "*.xml" -delete |
d43cf592 |
find ./docs/man -type f -name "*.asciidoc" -delete |
9541b47b |
find ./docs/man/man3 -type f -name "*.3" -delete |
e835cd6f |
@echo "Cleaning up output from test runs" |
3f9a41b2 |
rm -rf test/test_data |
3f245498 |
@echo "Cleaning up RPM building stuff" |
3f9a41b2 |
rm -rf MANIFEST rpm-build |
21269a84 |
@echo "Cleaning up Debian building stuff"
rm -rf debian
rm -rf deb-build |
ee679c01 |
rm -rf docs/json
rm -rf docs/js |
ec6236a1 |
@echo "Cleaning up authors file"
rm -f AUTHORS.TXT |
f0b02117 |
|
9049b0e7 |
python: |
785068df |
$(PYTHON) setup.py build |
55d256d8 |
|
9049b0e7 |
install: |
785068df |
$(PYTHON) setup.py install |
55d256d8 |
|
2dcd0846 |
sdist: clean docs |
785068df |
$(PYTHON) setup.py sdist -t MANIFEST.in |
3f245498 |
rpmcommon: sdist
@mkdir -p rpm-build
@cp dist/*.gz rpm-build/ |
ec7c8eb8 |
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)%{?dist}#' $(RPMSPEC) >rpm-build/$(NAME).spec |
3f245498 |
srpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \ |
66f294d5 |
--define "_specdir $(RPMSPECDIR)" \ |
3f245498 |
--define "_sourcedir %{_topdir}" \ |
ec7c8eb8 |
-bs rpm-build/$(NAME).spec
@rm -f rpm-build/$(NAME).spec |
3f245498 |
@echo "#############################################"
@echo "Ansible SRPM is built:"
@echo " rpm-build/$(RPMNVR).src.rpm"
@echo "#############################################"
rpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \ |
66f294d5 |
--define "_specdir $(RPMSPECDIR)" \ |
3f245498 |
--define "_sourcedir %{_topdir}" \ |
d4b6aecd |
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ |
40ca1d4b |
--define "__python `which $(PYTHON)`" \ |
ec7c8eb8 |
-ba rpm-build/$(NAME).spec
@rm -f rpm-build/$(NAME).spec |
3f245498 |
@echo "#############################################"
@echo "Ansible RPM is built:" |
6b774f8c |
@echo " rpm-build/$(RPMNVR).noarch.rpm" |
3f245498 |
@echo "#############################################" |
f72114c6 |
|
21269a84 |
debian: sdist
deb: debian
cp -r packaging/debian ./
chmod 755 debian/rules
fakeroot debian/rules clean
fakeroot dh_install
fakeroot debian/rules binary |
f72114c6 |
# for arch or gentoo, read instructions in the appropriate 'packaging' subdirectory directory
|
53d24ef0 |
modulepages: |
8050110b |
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t man -o docs/man/man3/ --module-dir=library --template-dir=hacking/templates # --verbose |
ee679c01 |
|
110244d7 |
# because this requires Sphinx it is not run as part of every build, those building the RPM and so on can ignore this
|
d5bb7258 |
webdocs: |
0cd09dd5 |
(cd docsite/; make docs) |
148d8859 |
|