implement confirmation/rollback for --shell --interactive
[ferm.git] / Makefile
blob34b0fa0e6f8e5bfb9af670bc013ab132113a6e61
2 # Makefile for ferm
5 TOPDIR = .
6 include $(TOPDIR)/config.mk
8 VERSION := $(shell $(PERL) src/ferm --version | awk '{print $$2}' | head -1 | tr -d ',')
10 DISTDIR = build/ferm-$(VERSION)
12 .PHONY: all clean
14 all: doc/ferm.txt doc/ferm.html doc/ferm.1 doc/import-ferm.1
16 clean:
17 rm -rf build
18 rm -f doc/ferm.txt doc/ferm.html doc/{import-,}ferm.1 *.tmp
21 # documentation
24 doc/ferm.txt: doc/ferm.pod
25 pod2text $< > $@
27 doc/ferm.html: doc/ferm.pod
28 pod2html $< --netscape --flush > $@
30 doc/ferm.1: doc/ferm.pod
31 pod2man --section=1 --release="ferm $(VERSION)" \
32 --center="FIREWALL RULES MADE EASY" \
33 --official $< > $@
35 doc/import-ferm.1: src/import-ferm
36 pod2man --section=1 --release="ferm $(VERSION)" \
37 --center="FIREWALL RULES MADE EASY" \
38 --official $< > $@
41 # test suite
44 STAMPDIR = $(TOPDIR)/build/test
45 STAMPDIR_20 = $(TOPDIR)/build/test2
47 # a list of all ferm scripts which should be tested with iptables
48 FERM_SCRIPTS =
49 FERM_SCRIPTS += $(wildcard test/modules/*.ferm) $(wildcard test/targets/*.ferm)
50 FERM_SCRIPTS += $(wildcard test/protocols/*.ferm) $(wildcard test/misc/*.ferm)
51 FERM_SCRIPTS += $(wildcard test/ipv6/*.ferm)
52 FERM_SCRIPTS += $(wildcard test/arptables/*.ferm) $(wildcard test/ebtables/*.ferm)
54 EXCLUDE_IMPORT = test/misc/subchain-domains.ferm
55 IMPORT_SCRIPTS = $(filter-out $(EXCLUDE_IMPORT) test/arptables/% test/ebtables/%,$(FERM_SCRIPTS))
57 # just a hack
58 RESULT_SED += -e 's,--protocol,-p,g'
59 RESULT_SED += -e 's,--in-interface,-i,g'
60 RESULT_SED += -e 's,--out-interface,-o,g'
61 RESULT_SED += -e 's,--destination ,-d ,g'
62 RESULT_SED += -e 's,--source ,-s ,g'
63 RESULT_SED += -e 's,--match,-m,g'
64 RESULT_SED += -e 's,--jump,-j,g'
65 RESULT_SED += -e 's,--goto,-g,g'
66 RESULT_SED += -e 's,--fragment,-f,g'
68 EB_ARP_RESULT_SED = -e 's,--jump,-j,g'
70 $(STAMPDIR)/test/arptables/%.result: test/arptables/%.ferm src/ferm
71 @mkdir -p $(dir $@)
72 $(PERL) src/ferm --test --slow $< |sed $(EB_ARP_RESULT_SED) >$@
74 $(STAMPDIR)/test/ebtables/%.result: test/ebtables/%.ferm src/ferm
75 @mkdir -p $(dir $@)
76 $(PERL) src/ferm --test --slow $< |sed $(EB_ARP_RESULT_SED) >$@
78 $(STAMPDIR)/%.result: %.ferm src/ferm
79 @mkdir -p $(dir $@)
80 $(PERL) src/ferm --test --slow --noflush $< |sed $(RESULT_SED) >$@
82 $(STAMPDIR)/%.SAVE: %.ferm src/ferm
83 @mkdir -p $(dir $@)
84 $(PERL) src/ferm --test $< >$@.tmp
85 grep -v '^#' <$@.tmp >$@
87 $(STAMPDIR)/test/ipv6/%.IMPORT: export FERM_DOMAIN=ip6
88 $(STAMPDIR)/%.IMPORT: $(STAMPDIR)/%.SAVE src/import-ferm
89 $(PERL) src/import-ferm $< >$@
91 $(STAMPDIR)/%.SAVE2: $(STAMPDIR)/%.IMPORT src/ferm
92 $(PERL) src/ferm --test --fast $< |grep -v '^#' >$@
94 $(STAMPDIR)/%.check: %.result $(STAMPDIR)/%.result
95 diff -u $^
96 @touch $@
98 $(STAMPDIR)/%.check-import: $(STAMPDIR)/%.SAVE $(STAMPDIR)/%.SAVE2
99 diff -u $^
100 @touch $@
102 .PHONY : check-ferm check-import check
104 check-ferm: $(patsubst %.ferm,$(STAMPDIR)/%.check,$(FERM_SCRIPTS))
106 check-import: $(patsubst %.ferm,$(STAMPDIR)/%.check-import,$(IMPORT_SCRIPTS))
108 check: check-ferm check-import
111 # distribution
114 .PHONY: dist
116 build/ferm-$(VERSION).tar.gz: all
117 rm -rf $(DISTDIR)
118 install -d -m 755 $(DISTDIR) $(DISTDIR)/src $(DISTDIR)/doc $(DISTDIR)/examples
119 install -m 755 src/{import-,}ferm $(DISTDIR)/src
120 install -m 644 doc/ferm.pod doc/ferm.txt doc/ferm.html doc/{import-,}ferm.1 $(DISTDIR)/doc
121 install -m 644 config.mk Makefile AUTHORS COPYING NEWS README TODO $(DISTDIR)
122 install -m 644 $(wildcard examples/*.ferm) $(DISTDIR)/examples
123 cd build && tar czf ferm-$(VERSION).tar.gz ferm-$(VERSION)
125 dist: build/ferm-$(VERSION).tar.gz
128 # installation
131 .PHONY: install uninstall
133 install: all
134 install -d -m 755 $(DOCDIR)/examples $(PREFIX)/sbin
135 install -m 644 AUTHORS COPYING NEWS README TODO $(DOCDIR)
136 install -m 644 examples/*.ferm $(DOCDIR)/examples
137 install -m 755 src/{import-,}ferm $(PREFIX)/sbin/
139 install -d -m 755 $(DOCDIR) $(MANDIR)
140 install -m 644 doc/ferm.txt doc/ferm.html $(DOCDIR)
141 install -m 644 doc/{import-,}ferm.1 $(MANDIR)
142 gzip -f9 $(MANDIR)/{import-,}ferm.1
144 uninstall:
145 rm -rf $(DOCDIR)
146 rm -f $(MANDIR)/{import-,}ferm.1{,.gz}
147 rm -f $(PREFIX)/sbin/{import-,}ferm
150 # misc targets
153 .PHONY: upload
155 upload: doc/ferm.html
156 scp NEWS doc/ferm.html foo-projects.org:/var/www/ferm.foo-projects.org/download/2.0/
157 scp examples/*.ferm foo-projects.org:/var/www/ferm.foo-projects.org/download/examples/