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