File: Makefile

package info (click to toggle)
ferm 2.1-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 620 kB
  • sloc: perl: 2,252; sh: 147; makefile: 129
file content (157 lines) | stat: -rw-r--r-- 4,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#
# Makefile for ferm
#

TOPDIR = .
include $(TOPDIR)/config.mk

VERSION := $(shell $(PERL) src/ferm --version | awk '{print $$2}' | head -1 | tr -d ',')

DISTDIR = build/ferm-$(VERSION)

.PHONY: all clean

all: doc/ferm.txt doc/ferm.html doc/ferm.1 doc/import-ferm.1

clean:
	rm -rf build
	rm -f doc/ferm.txt doc/ferm.html doc/ferm.1 doc/import-ferm.1 *.tmp

#
# documentation
#

doc/ferm.txt: doc/ferm.pod
	pod2text $< > $@

doc/ferm.html: doc/ferm.pod
	pod2html $< --netscape --flush > $@

doc/ferm.1: doc/ferm.pod
	pod2man --section=1 --release="ferm $(VERSION)" \
		--center="FIREWALL RULES MADE EASY" \
		--official $< > $@

doc/import-ferm.1: src/import-ferm
	pod2man --section=1 --release="ferm $(VERSION)" \
		--center="FIREWALL RULES MADE EASY" \
		--official $< > $@

#
# test suite
#

STAMPDIR = $(TOPDIR)/build/test
STAMPDIR_20 = $(TOPDIR)/build/test2

# a list of all ferm scripts which should be tested with iptables
FERM_SCRIPTS =
FERM_SCRIPTS += $(wildcard test/modules/*.ferm) $(wildcard test/targets/*.ferm)
FERM_SCRIPTS += $(wildcard test/protocols/*.ferm) $(wildcard test/misc/*.ferm)
FERM_SCRIPTS += $(wildcard test/ipv6/*.ferm)
FERM_SCRIPTS += $(wildcard test/arptables/*.ferm) $(wildcard test/ebtables/*.ferm)

EXCLUDE_IMPORT = test/misc/subchain-domains.ferm test/misc/ipfilter.ferm test/ipv6/mixed.ferm
IMPORT_SCRIPTS = $(filter-out $(EXCLUDE_IMPORT) test/arptables/% test/ebtables/%,$(FERM_SCRIPTS))

# just a hack
RESULT_SED += -e 's,--protocol,-p,g'
RESULT_SED += -e 's,--in-interface,-i,g'
RESULT_SED += -e 's,--out-interface,-o,g'
RESULT_SED += -e 's,--destination ,-d ,g'
RESULT_SED += -e 's,--source ,-s ,g'
RESULT_SED += -e 's,--match ,-m ,g'
RESULT_SED += -e 's,--jump,-j,g'
RESULT_SED += -e 's,--goto,-g,g'
RESULT_SED += -e 's,--fragment,-f,g'

EB_ARP_RESULT_SED = -e 's,--jump,-j,g'

$(STAMPDIR)/test/arptables/%.result: test/arptables/%.ferm src/ferm
	@mkdir -p $(dir $@)
	$(PERL) src/ferm --test --slow $< |sed $(EB_ARP_RESULT_SED) >$@

$(STAMPDIR)/test/ebtables/%.result: test/ebtables/%.ferm src/ferm
	@mkdir -p $(dir $@)
	$(PERL) src/ferm --test --slow $< |sed $(EB_ARP_RESULT_SED) >$@

$(STAMPDIR)/%.result: %.ferm src/ferm
	@mkdir -p $(dir $@)
	$(PERL) src/ferm --test --slow --noflush $< |sed $(RESULT_SED) >$@

$(STAMPDIR)/%.SAVE: %.ferm src/ferm
	@mkdir -p $(dir $@)
	$(PERL) src/ferm --test $< >$@.tmp
	grep -v '^#' <$@.tmp >$@

$(STAMPDIR)/test/ipv6/%.IMPORT: export FERM_DOMAIN=ip6
$(STAMPDIR)/%.IMPORT: $(STAMPDIR)/%.SAVE src/import-ferm
	$(PERL) src/import-ferm $< >$@

$(STAMPDIR)/%.SAVE2: $(STAMPDIR)/%.IMPORT src/ferm
	$(PERL) src/ferm --test --fast $< |grep -v '^#' >$@

$(STAMPDIR)/%.check: %.result $(STAMPDIR)/%.result
	diff -u $^
	@touch $@

$(STAMPDIR)/%.check-import: $(STAMPDIR)/%.SAVE $(STAMPDIR)/%.SAVE2
	diff -u $^
	@touch $@

.PHONY : check-ferm check-import check

check-ferm: $(patsubst %.ferm,$(STAMPDIR)/%.check,$(FERM_SCRIPTS))

check-import: $(patsubst %.ferm,$(STAMPDIR)/%.check-import,$(IMPORT_SCRIPTS))

check: check-ferm check-import

#
# distribution
#

.PHONY: dist

build/ferm-$(VERSION).tar.gz: all
	rm -rf $(DISTDIR)
	install -d -m 755 $(DISTDIR) $(DISTDIR)/src $(DISTDIR)/doc $(DISTDIR)/examples
	install -m 755 src/{import-,}ferm $(DISTDIR)/src
	install -m 644 doc/ferm.pod doc/ferm.txt doc/ferm.html doc/{import-,}ferm.1 $(DISTDIR)/doc
	install -m 644 config.mk Makefile AUTHORS COPYING NEWS README TODO $(DISTDIR)
	install -m 644 $(wildcard examples/*.ferm) $(DISTDIR)/examples
	cd build && tar czf ferm-$(VERSION).tar.gz ferm-$(VERSION)

dist: build/ferm-$(VERSION).tar.gz

#
# installation
#

.PHONY: install uninstall

install: all
	install -d -m 755 $(DOCDIR)/examples $(PREFIX)/sbin
	install -m 644 AUTHORS COPYING NEWS README TODO $(DOCDIR)
	install -m 644 examples/*.ferm $(DOCDIR)/examples
	install -m 755 src/{import-,}ferm $(PREFIX)/sbin/

	install -d -m 755 $(DOCDIR) $(MANDIR)
	install -m 644 doc/ferm.txt doc/ferm.html $(DOCDIR)
	install -m 644 doc/{import-,}ferm.1 $(MANDIR)
	gzip -f9 $(MANDIR)/{import-,}ferm.1

uninstall:
	rm -rf $(DOCDIR)
	rm -f $(MANDIR)/{import-,}ferm.1{,.gz}
	rm -f $(PREFIX)/sbin/{import-,}ferm

#
# misc targets
#

.PHONY: upload

upload: doc/ferm.html
	scp NEWS doc/ferm.html foo-projects.org:/var/www/ferm.foo-projects.org/download/2.0/
	scp examples/*.ferm foo-projects.org:/var/www/ferm.foo-projects.org/download/examples/