removed lots of deprecated tests
[ferm.git] / Makefile
blobd0f9cdcf0af8d88aa2050c64e7491844062915c4
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 TARFILE = build/ferm-${VERSION}.tar.gz
13 LSMFILE = build/ferm-${VERSION}.lsm
15 .PHONY: all clean
17 all: doc/ferm.txt doc/ferm.html doc/ferm.1 doc/import-ferm.1
19 clean:
20 rm -rf build
21 rm -f doc/ferm.txt doc/ferm.html doc/{import-,}ferm.1 *.tmp
24 # documentation
27 doc/ferm.txt: doc/ferm.pod
28 pod2text $< > $@
30 doc/ferm.html: doc/ferm.pod
31 pod2html $< --netscape --flush > $@
33 doc/ferm.1: doc/ferm.pod
34 pod2man --section=1 --release="ferm $(VERSION)" \
35 --center="FIREWALL RULES MADE EASY" \
36 --official $< > $@
38 doc/import-ferm.1: src/import-ferm
39 pod2man --section=1 --release="ferm $(VERSION)" \
40 --center="FIREWALL RULES MADE EASY" \
41 --official $< > $@
44 # test suite
47 STAMPDIR = $(TOPDIR)/build/test
48 STAMPDIR_20 = $(TOPDIR)/build/test2
50 # a list of all ferm scripts which should be tested with iptables
51 FERM_SCRIPTS = test/positive/flush test/positive/multimod test/positive/policyorder
52 FERM_SCRIPTS += test/positive/masqto test/positive/ttlset
53 FERM_SCRIPTS += $(wildcard test/modules/*.ferm) $(wildcard test/targets/*.ferm)
54 FERM_SCRIPTS += $(wildcard test/protocols/*.ferm) $(wildcard test/misc/*.ferm)
55 FERM_SCRIPTS += $(wildcard test/ipv6/*.ferm)
57 EXCLUDE_IMPORT = test/misc/subchain-domains.ferm
58 IMPORT_SCRIPTS = $(filter-out $(EXCLUDE_IMPORT),$(FERM_SCRIPTS))
60 # just a hack because ferm/import-ferm scramble the keyword order
61 IMPORT_SED = -e 's,fragfirst fragres,fragres fragfirst,'
62 SAVE2_SED = -e 's,--start 2 --counter 1,--counter 1 --start 2,'
64 FERM_20_SCRIPTS := $(wildcard test/arptables/*.ferm) $(wildcard test/ebtables/*.ferm)
66 $(STAMPDIR)/%.OLD: PATCHFILE = $(shell test -f "test/patch/$(patsubst test/%,%,$(<)).iptables" && echo "test/patch/$(patsubst test/%,%,$(<)).iptables" )
67 $(STAMPDIR)/%.OLD: % $(OLD_FERM) test/canonical.pl
68 @mkdir -p $(dir $@)
69 if test -f $(basename $<).result; then cp $(basename $<).result $@.tmp1; else $(PERL) $(OLD_FERM) $(OLD_OPTIONS) $< >$@.tmp1; fi
70 if test -n "$(PATCHFILE)"; then patch -i$(PATCHFILE) $@.tmp1; fi
71 $(PERL) test/canonical.pl <$@.tmp1 >$@.tmp2
72 @mv $@.tmp2 $@
74 $(STAMPDIR)/%.NEW: % $(NEW_FERM) test/canonical.pl
75 @mkdir -p $(dir $@)
76 $(PERL) $(NEW_FERM) $(NEW_OPTIONS) $< >$@.tmp1
77 $(PERL) test/canonical.pl <$@.tmp1 >$@.tmp2
78 -mv $@.tmp2 $@
80 $(STAMPDIR)/%.SAVE: % $(NEW_FERM)
81 @mkdir -p $(dir $@)
82 $(PERL) $(NEW_FERM) $(NEW_OPTIONS) --fast $< |grep -v '^#' >$@
84 $(STAMPDIR)/%.IMPORT: $(STAMPDIR)/%.SAVE src/import-ferm
85 $(PERL) src/import-ferm $< |sed $(IMPORT_SED) >$@
87 $(STAMPDIR)/%.SAVE2: $(STAMPDIR)/%.IMPORT $(NEW_FERM)
88 $(PERL) $(NEW_FERM) $(NEW_OPTIONS) --fast $< |grep -v '^#' |sed $(SAVE2_SED) >$@
90 $(STAMPDIR)/%.check: $(STAMPDIR)/%.OLD $(STAMPDIR)/%.NEW
91 diff -u $^
92 @touch $@
94 $(STAMPDIR)/%.check-import: $(STAMPDIR)/%.SAVE $(STAMPDIR)/%.SAVE2
95 diff -u $^
96 @touch $@
98 $(STAMPDIR_20)/%.result: %.ferm $(NEW_FERM)
99 @mkdir -p $(dir $@)
100 $(PERL) $(NEW_FERM) $(NEW_OPTIONS) $< >$@.tmp
101 -mv $@.tmp $@
103 $(STAMPDIR_20)/%.check: %.result $(STAMPDIR_20)/%.result
104 diff -u $^
105 @touch $@
107 .PHONY : check-ferm check-import check
109 check-ferm: $(patsubst %,$(STAMPDIR)/%.check,$(FERM_SCRIPTS)) $(patsubst %.ferm,$(STAMPDIR_20)/%.check,$(FERM_20_SCRIPTS))
111 check-import: $(patsubst %,$(STAMPDIR)/%.check-import,$(IMPORT_SCRIPTS))
113 check: check-ferm check-import
116 # distribution
119 .PHONY: dist
121 build/ferm-$(VERSION).tar.gz: all
122 rm -rf $(DISTDIR)
123 install -d -m 755 $(DISTDIR) $(DISTDIR)/src $(DISTDIR)/doc $(DISTDIR)/examples
124 install -m 755 src/{import-,}ferm $(DISTDIR)/src
125 install -m 644 doc/ferm.pod doc/ferm.txt doc/ferm.html doc/{import-,}ferm.1 $(DISTDIR)/doc
126 install -m 644 config.mk Makefile AUTHORS COPYING NEWS README TODO $(DISTDIR)
127 install -m 644 $(wildcard examples/*.ferm) $(DISTDIR)/examples
128 cd build && tar czf ferm-$(VERSION).tar.gz ferm-$(VERSION)
130 dist: build/ferm-$(VERSION).tar.gz
133 # installation
136 .PHONY: install uninstall
138 install: all
139 install -d -m 755 $(DOCDIR)/examples $(PREFIX)/sbin
140 install -m 644 AUTHORS COPYING NEWS README TODO $(DOCDIR)
141 install -m 644 examples/*.ferm $(DOCDIR)/examples
142 install -m 755 src/{import-,}ferm $(PREFIX)/sbin/
144 install -d -m 755 $(DOCDIR) $(MANDIR)
145 install -m 644 doc/ferm.txt doc/ferm.html $(DOCDIR)
146 install -m 644 doc/{import-,}ferm.1 $(MANDIR)
147 gzip -f9 $(MANDIR)/{import-,}ferm.1
149 uninstall:
150 rm -rf $(DOCDIR)
151 rm -f $(MANDIR)/{import-,}ferm.1{,.gz}
152 rm -f $(PREFIX)/sbin/{import-,}ferm
155 # misc targets
158 .PHONY: www ftp pub
160 www: dist
161 @echo "Publishing tarfiles in $(WEBDIR)..."
162 rm -f $(WEBDIR)/$(notdir $(TARFILE))
163 cp $(TARFILE) $(WEBDIR)
164 cp NEWS $(WEBDIR)
165 cp doc/ferm.html $(WEBDIR)
166 echo $(VERSION) > $(WEBDIR)/VERSION
167 ln -s $(notdir $(TARFILE)) $(WEBDIR)/ferm.tar.gz
168 chmod ugo+r $(WEBDIR)/$(notdir $(TARFILE)) $(WEBDIR)/ferm.tar.gz \
169 $(WEBDIR)/NEWS $(WEBDIR)/VERSION $(WEBDIR)/ferm.html
170 @echo "Done."
172 ftp: dist
173 @echo "Publishing tarfiles in $(FTPDIR)..."
174 rm -f $(FTPDIR)/$(notdir $(TARFILE))
175 cp $(TARFILE) $(FTPDIR)
176 cp NEWS $(FTPDIR)
177 echo $(VERSION) > $(FTPDIR)/VERSION
178 ln -s $(notdir $(TARFILE)) $(FTPDIR)/ferm.tar.gz
179 chmod ugo+r $(FTPDIR)/$(notdir $(TARFILE)) $(FTPDIR)/ferm.tar.gz \
180 $(FTPDIR)/NEWS $(FTPDIR)/VERSION
181 @echo "Done."
183 pub: www ftp
185 $(LSMFILE): DATE = `date '+%Y-%m-%d'`
186 $(LSMFILE): SIZE = $(shell du -h -D $(TARFILE) | awk '{print $$1}')
187 $(LSMFILE): dist
188 @echo "Making lsm entry file..."
189 @echo "Begin4" > $@
190 @echo "Title: ferm" >> $@
191 @echo "Version: $(VERSION)" >> $@
192 @echo "Entered-date: $(DATE)" >> $@
193 @echo "Description: A tool for structured firewall-rule making" >> $@
194 @echo "Keywords: iptables ipchains ipfwadm firewall rules rule" >> $@
195 @echo "Author: sofar@foo-projects.org (A. Kok)" >> $@
196 @echo "Maintained-by: sofar@foo-projects.org (A. Kok)" >> $@
197 @echo "Primary-site: ferm.foo-projects.org /" >> $@
198 @echo " $(SIZE) $(TARFILE)" >> $@
199 @echo "Alternate-site:" >> $@
200 @echo "Original-site:" >> $@
201 @echo "Platforms: perl linux>=2.4" >> $@
202 @echo "Copying-policy: GPL" >> $@
203 @echo "End" >> $@
204 # @echo "Sending lsm entry..."
205 # @mailx -s "add" lsm@execpc.com < $@
206 @echo "Done."
208 .phony: lsm
209 lsm: $(LSMFILE)