use plain 0.10.2 for now, sounds like 0.10.2.2 is not published as ftp yet
[libvirt.git] / Makefile
1 WEBFETCH                := wget
2 SHA1SUM                 := sha1sum
3
4 # tried to download this on the fly using git archive at git://libvirt.org/libvirt.git
5 # but it feels like git archive is not supported/allowed there
6 ALL                     += libvirt
7 libvirt-URL            := ftp://libvirt.org/libvirt/libvirt-0.10.2.tar.gz
8 libvirt-SHA1SUM        := 1579fbd4272ede4a897143da666fe76b290b7767
9 libvirt                := $(notdir $(libvirt-URL))
10
11 all: $(ALL)
12 .PHONY: all
13
14 ##############################
15 define download_target
16 $(1): $($(1))
17 .PHONY: $($(1))
18 $($(1)): 
19                 @if [ ! -e "$($(1))" ] ; then echo "$(WEBFETCH) $($(1)-URL)" ; $(WEBFETCH) $($(1)-URL) ; fi
20                 @if [ ! -e "$($(1))" ] ; then echo "Could not download source file: $($(1)) does not exist" ; exit 1 ; fi
21                 @if test "$$$$($(SHA1SUM) $($(1)) | awk '{print $$$$1}')" != "$($(1)-SHA1SUM)" ; then \
22                         echo "sha1sum of the downloaded $($(1)) does not match the one from 'Makefile'" ; \
23                         echo "Local copy: $$$$($(SHA1SUM) $($(1)))" ; \
24                         echo "In Makefile: $($(1)-SHA1SUM)" ; \
25                         false ; \
26                 else \
27                         ls -l $($(1)) ; \
28                 fi
29 endef
30
31 $(eval $(call download_target,libvirt))
32
33 sources: $(ALL) 
34 .PHONY: sources
35
36 ####################
37 # default - overridden by the build
38 SPECFILE = libvirt.spec
39
40 PWD=$(shell pwd)
41 PREPARCH ?= noarch
42 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
43 BUILDOPTS = --without xen --without qemu --without hyperv --without phyp --without esx \
44                         --without netcf --without avahi --without polkit --without sasl --without audit \
45                         --without storage-iscsi --without storage-scsi --without storage-disk \
46                         --without storage-rbd --without selinux --without dtrace --without sanlock \
47                         --without libxl --with capng --with udev --with interface \
48                         --define 'packager PlanetLab'
49
50 trees: sources
51         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
52
53 srpm: sources
54         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
55
56 TARGET ?= $(shell uname -m)
57 rpm: sources
58         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) $(BUILDOPTS) -bb $(SPECFILE)
59
60 clean:
61         rm -f *.rpm *.tgz *.bz2 *.gz
62
63 ++%: varname=$(subst +,,$@)
64 ++%:
65                 @echo "$(varname)=$($(varname))"
66 +%: varname=$(subst +,,$@)
67 +%:
68                 @echo "$($(varname))"
69