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
17 all: doc
/ferm.txt doc
/ferm.html doc
/ferm
.1 doc
/import-ferm
.1
21 rm -f doc
/ferm.txt doc
/ferm.html doc
/{import-
,}ferm
.1 *.tmp
27 doc
/ferm.txt
: doc
/ferm.pod
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" \
38 doc
/import-ferm
.1: src
/import-ferm
39 pod2man
--section
=1 --release
="ferm $(VERSION)" \
40 --center
="FIREWALL RULES MADE EASY" \
47 STAMPDIR
= $(TOPDIR
)/build
/test
48 STAMPDIR_20
= $(TOPDIR
)/build
/test2
50 # a list of all ferm scripts which should be tested with iptables
52 FERM_SCRIPTS
+= $(wildcard test/modules
/*.ferm
) $(wildcard test/targets
/*.ferm
)
53 FERM_SCRIPTS
+= $(wildcard test/protocols
/*.ferm
) $(wildcard test/misc
/*.ferm
)
54 FERM_SCRIPTS
+= $(wildcard test/ipv6
/*.ferm
)
56 EXCLUDE_IMPORT
= test/misc
/subchain-domains.ferm
57 IMPORT_SCRIPTS
= $(filter-out $(EXCLUDE_IMPORT
),$(FERM_SCRIPTS
))
59 # just a hack because ferm/import-ferm scramble the keyword order
60 SAVE2_SED
= -e
's,--start 2 --counter 1,--counter 1 --start 2,'
61 SAVE2_SED
+= -e
's,-m mh -p ipv6-mh,-p ipv6-mh -m mh,'
62 SAVE2_SED
+= -e
's,--connlimit-above 4 --connlimit-mask 24,--connlimit-mask 24 --connlimit-above 4,'
63 SAVE2_SED
+= -e
's,--hashlimit 10/minute --hashlimit-mode dstip,--hashlimit-mode dstip --hashlimit 10/minute,'
64 SAVE2_SED
+= -e
's,--packet 1 --every 3 --counter 1,--packet 1 --counter 1 --every 3,'
65 SAVE2_SED
+= -e
's!--rt-0-addrs ::1,::2 --rt-0-not-strict!--rt-0-not-strict --rt-0-addrs ::1,::2!'
67 FERM_20_SCRIPTS
:= $(wildcard test/arptables
/*.ferm
) $(wildcard test/ebtables
/*.ferm
)
69 $(STAMPDIR
)/%.OLD
: %.result
test/canonical.pl
71 $(PERL
) test/canonical.pl
<$< >$@
73 $(STAMPDIR
)/%.result
: %.ferm
$(NEW_FERM
)
75 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< >$@
77 $(STAMPDIR
)/%.NEW
: $(STAMPDIR
)/%.result
test/canonical.pl
78 $(PERL
) test/canonical.pl
<$< >$@
80 $(STAMPDIR
)/%.SAVE
: %.ferm
$(NEW_FERM
)
82 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) --fast
$< |grep
-v
'^#' >$@
84 $(STAMPDIR
)/test/ipv6
/%.IMPORT
: export FERM_DOMAIN
=ip6
85 $(STAMPDIR
)/%.IMPORT
: $(STAMPDIR
)/%.SAVE src
/import-ferm
86 $(PERL
) src
/import-ferm
$< >$@
88 $(STAMPDIR
)/%.SAVE2
: $(STAMPDIR
)/%.IMPORT
$(NEW_FERM
)
89 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) --fast
$< |grep
-v
'^#' |sed
$(SAVE2_SED
) >$@
91 $(STAMPDIR
)/%.
check: $(STAMPDIR
)/%.OLD
$(STAMPDIR
)/%.NEW
95 $(STAMPDIR
)/%.check-import
: $(STAMPDIR
)/%.SAVE
$(STAMPDIR
)/%.SAVE2
99 $(STAMPDIR_20
)/%.result
: %.ferm
$(NEW_FERM
)
101 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< >$@
103 $(STAMPDIR_20
)/%.
check: %.result
$(STAMPDIR_20
)/%.result
107 .PHONY
: check-ferm check-import
check
109 check-ferm
: $(patsubst %.ferm
,$(STAMPDIR
)/%.
check,$(FERM_SCRIPTS
)) $(patsubst %.ferm
,$(STAMPDIR_20
)/%.
check,$(FERM_20_SCRIPTS
))
111 check-import
: $(patsubst %.ferm
,$(STAMPDIR
)/%.check-import
,$(IMPORT_SCRIPTS
))
113 check: check-ferm check-import
121 build
/ferm-
$(VERSION
).
tar.gz
: all
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
136 .PHONY
: install uninstall
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
151 rm -f
$(MANDIR
)/{import-
,}ferm
.1{,.gz
}
152 rm -f
$(PREFIX
)/sbin
/{import-
,}ferm
161 @echo
"Publishing tarfiles in $(WEBDIR)..."
162 rm -f
$(WEBDIR
)/$(notdir $(TARFILE
))
163 cp
$(TARFILE
) $(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
173 @echo
"Publishing tarfiles in $(FTPDIR)..."
174 rm -f
$(FTPDIR
)/$(notdir $(TARFILE
))
175 cp
$(TARFILE
) $(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
185 $(LSMFILE
): DATE
= `date '+%Y-%m-%d'`
186 $(LSMFILE
): SIZE
= $(shell du
-h
-D
$(TARFILE
) | awk
'{print $$1}')
188 @echo
"Making lsm entry file..."
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" >> $@
204 # @echo "Sending lsm entry..."
205 # @mailx -s "add" lsm@execpc.com < $@