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
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
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
74 $(STAMPDIR
)/%.NEW
: % $(NEW_FERM
) test/canonical.pl
76 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< >$@.tmp1
77 $(PERL
) test/canonical.pl
<$@.tmp1
>$@.tmp2
80 $(STAMPDIR
)/%.SAVE
: % $(NEW_FERM
)
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
94 $(STAMPDIR
)/%.check-import
: $(STAMPDIR
)/%.SAVE
$(STAMPDIR
)/%.SAVE2
98 $(STAMPDIR_20
)/%.result
: %.ferm
$(NEW_FERM
)
100 $(PERL
) $(NEW_FERM
) $(NEW_OPTIONS
) $< >$@.tmp
103 $(STAMPDIR_20
)/%.
check: %.result
$(STAMPDIR_20
)/%.result
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
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 < $@