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
)
55 FERM_SCRIPTS
+= $(wildcard test/arptables
/*.ferm
) $(wildcard test/ebtables
/*.ferm
)
57 EXCLUDE_IMPORT
= test/misc
/subchain-domains.ferm
58 IMPORT_SCRIPTS
= $(filter-out $(EXCLUDE_IMPORT
) test/arptables
/% test/ebtables
/%,$(FERM_SCRIPTS
))
61 RESULT_SED
+= -e
's,--protocol tcp --match tcp,-p tcp,g'
62 RESULT_SED
+= -e
's,--protocol udp --match udp,-p udp,g'
63 RESULT_SED
+= -e
's,-p tcp -m tcp,-p tcp,g'
64 RESULT_SED
+= -e
's,-p udp -m udp,-p udp,g'
65 RESULT_SED
+= -e
's,--protocol,-p,g'
66 RESULT_SED
+= -e
's,--in-interface,-i,g'
67 RESULT_SED
+= -e
's,--out-interface,-o,g'
68 RESULT_SED
+= -e
's,--destination,-d,g'
69 RESULT_SED
+= -e
's,--source,-s,g'
70 RESULT_SED
+= -e
's,--match,-m,g'
71 RESULT_SED
+= -e
's,--jump,-j,g'
72 RESULT_SED
+= -e
's,--goto,-g,g'
73 RESULT_SED
+= -e
's,--fragment,-f,g'
75 $(STAMPDIR
)/test/arptables
/%.result
: test/arptables
/%.ferm
$(NEW_FERM
)
77 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< |sed
$(RESULT_SED
) >$@
79 $(STAMPDIR
)/test/ebtables
/%.result
: test/ebtables
/%.ferm
$(NEW_FERM
)
81 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< |sed
$(RESULT_SED
) >$@
83 $(STAMPDIR
)/%.result
: %.ferm
$(NEW_FERM
)
85 $(PERL
) $(NEW_FERM
) --noflush
$(NEW_OPTIONS
) $< |sed
$(RESULT_SED
) >$@
87 $(STAMPDIR
)/%.SAVE
: %.ferm
$(NEW_FERM
)
89 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) --fast
$< >$@.tmp
90 grep
-v
'^#' <$@.tmp
>$@
92 $(STAMPDIR
)/test/ipv6
/%.IMPORT
: export FERM_DOMAIN
=ip6
93 $(STAMPDIR
)/%.IMPORT
: $(STAMPDIR
)/%.SAVE src
/import-ferm
94 $(PERL
) src
/import-ferm
$< >$@
96 $(STAMPDIR
)/%.SAVE2
: $(STAMPDIR
)/%.IMPORT
$(NEW_FERM
)
97 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) --fast
$< |grep
-v
'^#' >$@
99 $(STAMPDIR
)/%.
check: %.result
$(STAMPDIR
)/%.result
100 sed
$(RESULT_SED
) $< |diff
-u
- $(STAMPDIR
)/$<
103 $(STAMPDIR
)/%.check-import
: $(STAMPDIR
)/%.SAVE
$(STAMPDIR
)/%.SAVE2
107 .PHONY
: check-ferm check-import
check
109 check-ferm
: $(patsubst %.ferm
,$(STAMPDIR
)/%.
check,$(FERM_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
160 upload
: doc
/ferm.html
161 scp NEWS doc
/ferm.html foo-projects.org
:/var
/www
/ferm.foo-projects.org
/download
/2.0/
162 scp examples
/*.ferm foo-projects.org
:/var
/www
/ferm.foo-projects.org
/download
/examples
/
165 @echo
"Publishing tarfiles in $(WEBDIR)..."
166 rm -f
$(WEBDIR
)/$(notdir $(TARFILE
))
167 cp
$(TARFILE
) $(WEBDIR
)
169 cp doc
/ferm.html
$(WEBDIR
)
170 echo
$(VERSION
) > $(WEBDIR
)/VERSION
171 ln
-s
$(notdir $(TARFILE
)) $(WEBDIR
)/ferm.
tar.gz
172 chmod ugo
+r
$(WEBDIR
)/$(notdir $(TARFILE
)) $(WEBDIR
)/ferm.
tar.gz \
173 $(WEBDIR
)/NEWS
$(WEBDIR
)/VERSION
$(WEBDIR
)/ferm.html
177 @echo
"Publishing tarfiles in $(FTPDIR)..."
178 rm -f
$(FTPDIR
)/$(notdir $(TARFILE
))
179 cp
$(TARFILE
) $(FTPDIR
)
181 echo
$(VERSION
) > $(FTPDIR
)/VERSION
182 ln
-s
$(notdir $(TARFILE
)) $(FTPDIR
)/ferm.
tar.gz
183 chmod ugo
+r
$(FTPDIR
)/$(notdir $(TARFILE
)) $(FTPDIR
)/ferm.
tar.gz \
184 $(FTPDIR
)/NEWS
$(FTPDIR
)/VERSION
189 $(LSMFILE
): DATE
= `date '+%Y-%m-%d'`
190 $(LSMFILE
): SIZE
= $(shell du
-h
-D
$(TARFILE
) | awk
'{print $$1}')
192 @echo
"Making lsm entry file..."
194 @echo
"Title: ferm" >> $@
195 @echo
"Version: $(VERSION)" >> $@
196 @echo
"Entered-date: $(DATE)" >> $@
197 @echo
"Description: A tool for structured firewall-rule making" >> $@
198 @echo
"Keywords: iptables ipchains ipfwadm firewall rules rule" >> $@
199 @echo
"Author: sofar@foo-projects.org (A. Kok)" >> $@
200 @echo
"Maintained-by: sofar@foo-projects.org (A. Kok)" >> $@
201 @echo
"Primary-site: ferm.foo-projects.org /" >> $@
202 @echo
" $(SIZE) $(TARFILE)" >> $@
203 @echo
"Alternate-site:" >> $@
204 @echo
"Original-site:" >> $@
205 @echo
"Platforms: perl linux>=2.4" >> $@
206 @echo
"Copying-policy: GPL" >> $@
208 # @echo "Sending lsm entry..."
209 # @mailx -s "add" lsm@execpc.com < $@