Fix indentations and update BUILDOPTS.
[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 storage-disk --without storage-iscsi --without storage-scsi \
42                 --without storage-fs --without storage-lvm \
43                 --without polkit --without sasl --without audit --with capng --with udev \
44                 --without netcf --without avahi \
45                 --without xen --without qemu --without hyperv --without phyp --without esx \
46             --define 'packager PlanetLab'
47
48 trees: sources
49         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
50
51 srpm: sources
52         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
53
54 TARGET ?= $(shell uname -m)
55 rpm: sources
56         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) $(BUILDOPTS) -bb $(SPECFILE)
57
58 clean:
59         rm -f *.rpm *.tgz *.bz2 *.gz
60
61 ++%: varname=$(subst +,,$@)
62 ++%:
63                 @echo "$(varname)=$($(varname))"
64 +%: varname=$(subst +,,$@)
65 +%:
66                 @echo "$($(varname))"
67