using 1.2.4
[libvirt-python.git] / Makefile
1 WEBFETCH                := wget
2 SHA1SUM                 := sha1sum
3
4 ALL                     += libvirt-python
5 libvirt-python-URL1    := http://mirror.onelab.eu/third-party/libvirt-python-1.2.4.tar.gz
6 libvirt-python-URL2    := http://planet-lab.org/third-party/libvirt-python-1.2.4.tar.gz
7 libvirt-python-SHA1SUM        := 1c41027fac688cd2d6e8ae01819acc4317352db5
8 libvirt-python                := $(notdir $(libvirt-python-URL1))
9
10 all: $(ALL)
11 .PHONY: all
12
13 ##############################
14 define download_target
15 $(1): $($(1))
16 .PHONY: $(1)
17 $($(1)): 
18         @if [ ! -e "$($(1))" ] ; then \
19         { echo Using primary; echo "$(WEBFETCH) $($(1)-URL1)" ; $(WEBFETCH) $($(1)-URL1) ; } || \
20         { echo Using secondary; echo "$(WEBFETCH) $($(1)-URL2)" ; $(WEBFETCH) $($(1)-URL2) ; } ; fi
21         @if [ ! -e "$($(1))" ] ; then echo "Could not download source file: $($(1)) does not exist" ; exit 1 ; fi
22         @if test "$$$$($(SHA1SUM) $($(1)) | awk '{print $$$$1}')" != "$($(1)-SHA1SUM)" ; then \
23             echo "sha1sum of the downloaded $($(1)) does not match the one from 'Makefile'" ; \
24             echo "Local copy: $$$$($(SHA1SUM) $($(1)))" ; \
25             echo "In Makefile: $($(1)-SHA1SUM)" ; \
26             false ; \
27         else \
28             ls -l $($(1)) ; \
29         fi
30 endef
31
32 $(eval $(call download_target,libvirt-python))
33
34 sources: $(ALL) 
35 .PHONY: sources
36
37 ####################
38 # default - overridden by the build
39 SPECFILE = libvirt-python.spec
40
41 PWD=$(shell pwd)
42 PREPARCH ?= noarch
43 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
44 BUILDOPTS = --with python3 --define 'packager PlanetLab'
45
46 trees: sources
47         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
48
49 srpm: sources
50         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
51
52 TARGET ?= $(shell uname -m)
53 rpm: sources
54         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) $(BUILDOPTS) -bb $(SPECFILE)
55
56 clean:
57         rm -f *.rpm *.tgz *.bz2 *.gz
58
59 ++%: varname=$(subst +,,$@)
60 ++%:
61                 @echo "$(varname)=$($(varname))"
62 +%: varname=$(subst +,,$@)
63 +%:
64                 @echo "$($(varname))"
65