Makefile 5.6 KB
Newer Older
1 2 3
#
# NOTE: to build Avocado RPM packages extra deps not present out of the box
# are necessary. These packages are currently hosted at:
4 5 6 7
#
# https://repos-avocadoproject.rhcloud.com/static/avocado-fedora.repo
# or
# https://repos-avocadoproject.rhcloud.com/static/avocado-el.repo
8 9 10 11 12 13
#
# Since the RPM build steps are based on mock, edit your chroot config
# file (/etc/mock/<your-config>.cnf) and add the COPR repo configuration there.
#

PYTHON=$(shell which python)
14
PYTHON26=$(shell $(PYTHON) -V 2>&1 | grep 2.6 -q && echo true || echo false)
15
VERSION=$(shell $(PYTHON) $(CURDIR)/avocado/core/version.py)
16 17 18
DESTDIR=/
BUILDIR=$(CURDIR)/debian/avocado
PROJECT=avocado
L
Lukáš Doktor 已提交
19 20
AVOCADO_DIRNAME=$(shell echo $${PWD\#\#*/})
AVOCADO_PLUGINS=$(filter-out ../$(AVOCADO_DIRNAME), $(wildcard ../*))
21 22 23 24 25
RELEASE_COMMIT=$(shell git log --pretty=format:'%H' -n 1 $(VERSION))
RELEASE_SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1 $(VERSION))

COMMIT=$(shell git log --pretty=format:'%H' -n 1)
SHORT_COMMIT=$(shell git log --pretty=format:'%h' -n 1)
26 27

all:
28
	@echo
C
Cleber Rosa 已提交
29
	@echo "Development related targets:"
30 31 32 33
	@echo "check:      Runs tree static check, unittests and functional tests"
	@echo "link:       Runs 'python setup.py --develop' in all subprojects and links the needed resources"
	@echo "clean:      Get rid of scratch, byte files and removes the links to other subprojects"
	@echo "selfcheck:  Runs tree static check, unittests and functional tests using Avocado itself"
C
Cleber Rosa 已提交
34
	@echo
35 36 37 38
	@echo "Package requirements related targets"
	@echo "requirements:            Install runtime requirements"
	@echo "requirements-selftests:  Install runtime and selftests requirements"
	@echo
39 40 41 42 43 44 45 46 47 48 49 50 51
	@echo "Platform independent distribution/installtion related targets:"
	@echo "source:   Create source package"
	@echo "install:  Install on local system"
	@echo "man:      Generate the avocado man page"
	@echo
	@echo "RPM related targets:"
	@echo "srpm:  Generate a source RPM package (.srpm)"
	@echo "rpm:   Generate binary RPMs"
	@echo
	@echo "Debian related targets:"
	@echo "deb:      Generate both source and binary debian packages"
	@echo "deb-src:  Generate a source debian package"
	@echo "deb-bin:  Generate a binary debian package"
C
Cleber Rosa 已提交
52
	@echo
53
	@echo "Release related targets:"
C
Cleber Rosa 已提交
54 55 56
	@echo "source-release:  Create source package for the latest tagged release"
	@echo "srpm-release:    Generate a source RPM package (.srpm) for the latest tagged release"
	@echo "rpm-release:     Generate binary RPMs for the latest tagged release"
57
	@echo
58 59 60 61

source: clean
	if test ! -d SOURCES; then mkdir SOURCES; fi
	git archive --prefix="avocado-$(COMMIT)/" -o "SOURCES/avocado-$(VERSION)-$(SHORT_COMMIT).tar.gz" HEAD
62

63
source-release: clean
64
	if test ! -d SOURCES; then mkdir SOURCES; fi
65
	git archive --prefix="avocado-$(RELEASE_COMMIT)/" -o "SOURCES/avocado-$(VERSION)-$(RELEASE_SHORT_COMMIT).tar.gz" $(VERSION)
66 67 68 69

install:
	$(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)

C
Cleber Rosa 已提交
70
deb-prepare-source:
71 72
	# build the source package in the parent directory
	# then rename it to project_version.orig.tar.gz
73
	dch -D "vivid" -M -v "$(VERSION)" "Automated (make builddeb) build."
74
	$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../
75 76
	rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*

C
Cleber Rosa 已提交
77
deb-src: deb-prepare-source
78
	# build the source package
79
	dpkg-buildpackage -S -elookkas@gmail.com -rfakeroot
80

C
Cleber Rosa 已提交
81
deb-bin: deb-prepare-source
82 83 84
	# build binary package
	dpkg-buildpackage -b -rfakeroot

C
Cleber Rosa 已提交
85
deb: deb-prepare-source
86 87 88
	# build both source and binary packages
	dpkg-buildpackage -i -I -rfakeroot

89 90 91 92 93 94 95 96 97 98 99
srpm: source
	if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
	mock --resultdir BUILD/SRPM -D "commit $(COMMIT)" --buildsrpm --spec avocado.spec --sources SOURCES

rpm: srpm
	if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
	mock --resultdir BUILD/RPM -D "commit $(COMMIT)" --rebuild BUILD/SRPM/avocado-$(VERSION)-*.src.rpm

srpm-release: source-release
	if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
	mock --resultdir BUILD/SRPM -D "commit $(RELEASE_COMMIT)" --buildsrpm --spec avocado.spec --sources SOURCES
C
Cleber Rosa 已提交
100

101 102 103
rpm-release: srpm-release
	if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
	mock --resultdir BUILD/RPM -D "commit $(RELEASE_COMMIT)" --rebuild BUILD/SRPM/avocado-$(VERSION)-*.src.rpm
104

105 106
clean:
	$(PYTHON) setup.py clean
107
	$(MAKE) -f $(CURDIR)/debian/rules clean || true
108
	rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES
109
	rm -f man/avocado.1
110
	rm -f man/avocado-rest-client.1
111
	rm -rf docs/build
112
	find docs/source/api/ -name '*.rst' -delete
113
	for MAKEFILE in $(AVOCADO_PLUGINS);\
L
Lukáš Doktor 已提交
114
		do AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE unlink &>/dev/null && echo ">> UNLINK $$MAKEFILE" || echo ">> SKIP $$MAKEFILE";\
115
	done
116
	$(PYTHON) setup.py develop --uninstall $(shell $(PYTHON26) || echo --user)
117 118
	rm -rf /var/tmp/avocado*
	rm -rf /tmp/avocado*
119
	find . -name '*.pyc' -delete
120

121
requirements:
L
Lukáš Doktor 已提交
122
	- pip install "pip>=6.0.1"
123
	- pip install -r requirements.txt
124

125
requirements-selftests: requirements
126
	- pip install -r requirements-selftests.txt
127

128 129 130
smokecheck:
	./scripts/avocado run passtest

131
check: clean check_cyclical modules_boundaries
132
	selftests/checkall
133
	selftests/check_tmp_dirs
134

135 136 137 138
selfcheck: clean check_cyclical modules_boundaries
	AVOCADO_SELF_CHECK=1 selftests/checkall
	selftests/check_tmp_dirs

139 140 141
check_cyclical:
	selftests/cyclical_deps avocado

142 143 144
modules_boundaries:
	selftests/modules_boundaries

145
link:
146
	$(PYTHON) setup.py develop $(shell $(PYTHON26) || echo --user)
147
	for MAKEFILE in $(AVOCADO_PLUGINS);\
L
Lukáš Doktor 已提交
148
		do AVOCADO_DIRNAME=$(AVOCADO_DIRNAME) make -C $$MAKEFILE link &>/dev/null && echo ">> LINK $$MAKEFILE" || echo ">> SKIP $$MAKEFILE";\
149
	done
C
Cleber Rosa 已提交
150

151
man: man/avocado.1 man/avocado-rest-client.1
152

153 154 155 156 157
.PHONY: source install clean check link

# implicit rule/recipe for man page creation
%.1: %.rst
	rst2man $< $@