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
$< >$@.tmp
83 grep
-v
'^#' <$@.tmp
>$@
85 $(STAMPDIR
)/test/ipv6
/%.IMPORT
: export FERM_DOMAIN
=ip6
86 $(STAMPDIR
)/%.IMPORT
: $(STAMPDIR
)/%.SAVE src
/import-ferm
87 $(PERL
) src
/import-ferm
$< >$@
89 $(STAMPDIR
)/%.SAVE2
: $(STAMPDIR
)/%.IMPORT
$(NEW_FERM
)
90 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) --fast
$< >$@.tmp
91 grep
-v
'^#' <$@.tmp |sed
$(SAVE2_SED
) >$@
93 $(STAMPDIR
)/%.
check: $(STAMPDIR
)/%.OLD
$(STAMPDIR
)/%.NEW
97 $(STAMPDIR
)/%.check-import
: $(STAMPDIR
)/%.SAVE
$(STAMPDIR
)/%.SAVE2
101 $(STAMPDIR_20
)/%.result
: %.ferm
$(NEW_FERM
)
103 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< >$@
105 $(STAMPDIR_20
)/%.
check: %.result
$(STAMPDIR_20
)/%.result
109 .PHONY
: check-ferm check-import
check
111 check-ferm
: $(patsubst %.ferm
,$(STAMPDIR
)/%.
check,$(FERM_SCRIPTS
)) $(patsubst %.ferm
,$(STAMPDIR_20
)/%.
check,$(FERM_20_SCRIPTS
))
113 check-import
: $(patsubst %.ferm
,$(STAMPDIR
)/%.check-import
,$(IMPORT_SCRIPTS
))
115 check: check-ferm check-import
123 build
/ferm-
$(VERSION
).
tar.gz
: all
125 install -d
-m
755 $(DISTDIR
) $(DISTDIR
)/src
$(DISTDIR
)/doc
$(DISTDIR
)/examples
126 install -m
755 src
/{import-
,}ferm
$(DISTDIR
)/src
127 install -m
644 doc
/ferm.pod doc
/ferm.txt doc
/ferm.html doc
/{import-
,}ferm
.1 $(DISTDIR
)/doc
128 install -m
644 config.mk Makefile AUTHORS COPYING NEWS README TODO
$(DISTDIR
)
129 install -m
644 $(wildcard examples
/*.ferm
) $(DISTDIR
)/examples
130 cd build
&& tar czf ferm-
$(VERSION
).
tar.gz ferm-
$(VERSION
)
132 dist: build
/ferm-
$(VERSION
).
tar.gz
138 .PHONY
: install uninstall
141 install -d
-m
755 $(DOCDIR
)/examples
$(PREFIX
)/sbin
142 install -m
644 AUTHORS COPYING NEWS README TODO
$(DOCDIR
)
143 install -m
644 examples
/*.ferm
$(DOCDIR
)/examples
144 install -m
755 src
/{import-
,}ferm
$(PREFIX
)/sbin
/
146 install -d
-m
755 $(DOCDIR
) $(MANDIR
)
147 install -m
644 doc
/ferm.txt doc
/ferm.html
$(DOCDIR
)
148 install -m
644 doc
/{import-
,}ferm
.1 $(MANDIR
)
149 gzip
-f9
$(MANDIR
)/{import-
,}ferm
.1
153 rm -f
$(MANDIR
)/{import-
,}ferm
.1{,.gz
}
154 rm -f
$(PREFIX
)/sbin
/{import-
,}ferm
163 @echo
"Publishing tarfiles in $(WEBDIR)..."
164 rm -f
$(WEBDIR
)/$(notdir $(TARFILE
))
165 cp
$(TARFILE
) $(WEBDIR
)
167 cp doc
/ferm.html
$(WEBDIR
)
168 echo
$(VERSION
) > $(WEBDIR
)/VERSION
169 ln
-s
$(notdir $(TARFILE
)) $(WEBDIR
)/ferm.
tar.gz
170 chmod ugo
+r
$(WEBDIR
)/$(notdir $(TARFILE
)) $(WEBDIR
)/ferm.
tar.gz \
171 $(WEBDIR
)/NEWS
$(WEBDIR
)/VERSION
$(WEBDIR
)/ferm.html
175 @echo
"Publishing tarfiles in $(FTPDIR)..."
176 rm -f
$(FTPDIR
)/$(notdir $(TARFILE
))
177 cp
$(TARFILE
) $(FTPDIR
)
179 echo
$(VERSION
) > $(FTPDIR
)/VERSION
180 ln
-s
$(notdir $(TARFILE
)) $(FTPDIR
)/ferm.
tar.gz
181 chmod ugo
+r
$(FTPDIR
)/$(notdir $(TARFILE
)) $(FTPDIR
)/ferm.
tar.gz \
182 $(FTPDIR
)/NEWS
$(FTPDIR
)/VERSION
187 $(LSMFILE
): DATE
= `date '+%Y-%m-%d'`
188 $(LSMFILE
): SIZE
= $(shell du
-h
-D
$(TARFILE
) | awk
'{print $$1}')
190 @echo
"Making lsm entry file..."
192 @echo
"Title: ferm" >> $@
193 @echo
"Version: $(VERSION)" >> $@
194 @echo
"Entered-date: $(DATE)" >> $@
195 @echo
"Description: A tool for structured firewall-rule making" >> $@
196 @echo
"Keywords: iptables ipchains ipfwadm firewall rules rule" >> $@
197 @echo
"Author: sofar@foo-projects.org (A. Kok)" >> $@
198 @echo
"Maintained-by: sofar@foo-projects.org (A. Kok)" >> $@
199 @echo
"Primary-site: ferm.foo-projects.org /" >> $@
200 @echo
" $(SIZE) $(TARFILE)" >> $@
201 @echo
"Alternate-site:" >> $@
202 @echo
"Original-site:" >> $@
203 @echo
"Platforms: perl linux>=2.4" >> $@
204 @echo
"Copying-policy: GPL" >> $@
206 # @echo "Sending lsm entry..."
207 # @mailx -s "add" lsm@execpc.com < $@