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