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