forked from hectorm/hblock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·141 lines (119 loc) · 4.17 KB
/
Makefile
File metadata and controls
executable file
·141 lines (119 loc) · 4.17 KB
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
#!/usr/bin/make -f
DESTDIR =
PREFIX = $(DESTDIR)/usr/local
BINDIR = $(PREFIX)/bin
SYSCONFDIR = $(DESTDIR)/etc
SYSTEMCTL := $(shell which systemctl)
MKFILE_RELPATH := $(shell printf -- '%s' "$(MAKEFILE_LIST)" | sed 's|^\ ||')
MKFILE_ABSPATH := $(shell readlink -f -- '$(MKFILE_RELPATH)')
MKFILE_DIR := $(shell dirname -- '$(MKFILE_ABSPATH)')
define DEFAULT_HOSTS
127.0.0.1 localhost $(shell uname -n)
255.255.255.255 broadcasthost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
endef
export DEFAULT_HOSTS
.PHONY: all \
install uninstall \
build \
build-hosts \
build-domains \
build-adblock \
build-rpz \
build-dnsmasq \
build-unbound \
build-android \
build-windows \
stats \
stats-tlds \
stats-suffixes \
index \
clean
all: build index
build: \
build-hosts \
build-domains \
build-adblock \
build-rpz \
build-dnsmasq \
build-unbound \
build-android \
build-windows
build-hosts: dist/hosts
dist/hosts:
mkdir -p dist/
"$(MKFILE_DIR)"/hblock -O dist/hosts
build-domains: build-hosts dist/hosts_domains.txt
dist/hosts_domains.txt:
"$(MKFILE_DIR)"/resources/alt-formats/domains.sh dist/hosts > dist/hosts_domains.txt
build-adblock: build-hosts dist/hosts_adblock.txt
dist/hosts_adblock.txt:
"$(MKFILE_DIR)"/resources/alt-formats/adblock.sh dist/hosts > dist/hosts_adblock.txt
build-rpz: build-hosts dist/hosts_rpz.txt
dist/hosts_rpz.txt:
"$(MKFILE_DIR)"/resources/alt-formats/rpz.sh dist/hosts > dist/hosts_rpz.txt
build-dnsmasq: build-hosts dist/hosts_dnsmasq.conf
dist/hosts_dnsmasq.conf:
"$(MKFILE_DIR)"/resources/alt-formats/dnsmasq.sh dist/hosts > dist/hosts_dnsmasq.conf
build-unbound: build-hosts dist/hosts_unbound.conf
dist/hosts_unbound.conf:
"$(MKFILE_DIR)"/resources/alt-formats/unbound.sh dist/hosts > dist/hosts_unbound.conf
build-android: build-hosts dist/hosts_android.zip
dist/hosts_android.zip:
cd "$(MKFILE_DIR)"/resources/alt-formats/android/ && zip -r "$(CURDIR)"/dist/hosts_android.zip ./
cd dist/ && zip -r hosts_android.zip hosts
build-windows: build-hosts dist/hosts_windows.zip
dist/hosts_windows.zip:
cd "$(MKFILE_DIR)"/resources/alt-formats/windows/ && zip -rl "$(CURDIR)"/dist/hosts_windows.zip ./
cd dist/ && zip -rl hosts_windows.zip hosts
stats: stats-tlds stats-suffixes
stats-tlds: build-domains dist/most_abused_tlds.txt
dist/most_abused_tlds.txt:
"$(MKFILE_DIR)"/resources/stats/suffix.sh dist/hosts_domains.txt none > dist/most_abused_tlds.txt
stats-suffixes: build-domains dist/most_abused_suffixes.txt
dist/most_abused_suffixes.txt:
"$(MKFILE_DIR)"/resources/stats/suffix.sh dist/hosts_domains.txt > dist/most_abused_suffixes.txt
index: build-hosts dist/index.html
dist/index.html:
"$(MKFILE_DIR)"/resources/templates/index.sh dist/ > dist/index.html
install: build-hosts
mkdir -p -- "$(PREFIX)" "$(BINDIR)" "$(SYSCONFDIR)"
install -m 0755 -- dist/hosts "$(SYSCONFDIR)"/hosts
install -m 0755 -- "$(MKFILE_DIR)"/hblock "$(BINDIR)"/hblock
if test -x "$(SYSTEMCTL)" && test -d "$(SYSCONFDIR)"/systemd/system; then \
install -m 0644 -- "$(MKFILE_DIR)"/resources/systemd/hblock.service "$(SYSCONFDIR)"/systemd/system/hblock.service \
&& install -m 0644 -- "$(MKFILE_DIR)"/resources/systemd/hblock.timer "$(SYSCONFDIR)"/systemd/system/hblock.timer \
&& "$(SYSTEMCTL)" daemon-reload \
&& "$(SYSTEMCTL)" enable hblock.timer \
&& "$(SYSTEMCTL)" start hblock.timer; \
fi
uninstall:
rm -f -- "$(BINDIR)"/hblock
printf -- '%s\n' "$$DEFAULT_HOSTS" > "$(SYSCONFDIR)"/hosts
if test -x "$(SYSTEMCTL)" && test -d "$(SYSCONFDIR)"/systemd/system; then \
"$(SYSTEMCTL)" stop hblock.timer \
&& "$(SYSTEMCTL)" disable hblock.timer \
&& rm -f -- \
"$(SYSCONFDIR)"/systemd/system/hblock.service \
"$(SYSCONFDIR)"/systemd/system/hblock.timer \
&& "$(SYSTEMCTL)" daemon-reload; \
fi
clean:
rm -f \
dist/hosts \
dist/hosts_domains.txt \
dist/hosts_adblock.txt \
dist/hosts_rpz.txt \
dist/hosts_dnsmasq.conf \
dist/hosts_unbound.conf \
dist/hosts_android.zip \
dist/hosts_windows.zip \
dist/most_abused_tlds.txt \
dist/most_abused_suffixes.txt \
dist/index.html
-rmdir dist/