-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (49 loc) · 1.61 KB
/
Makefile
File metadata and controls
64 lines (49 loc) · 1.61 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
PLOT_OWNERS_COUNT=20
PLOT_COUNTRIES_COUNT=20
all: plot-owners plot-countries plot-map
# Check if the gnuplot command is available
check_gnuplot:
@if ! command -v gnuplot &> /dev/null; then \
echo "Please install GNU plot! (command: gnuplot)"; \
exit 1; \
fi
# Check if the geoiplookup command is available
check_geoip:
@if ! command -v geoiplookup &> /dev/null; then \
echo "Please install the GeoIP command & databases! (command: geoiplookup)"; \
exit 1; \
fi
# Create plot: owners/companies
companies: plot-owners
owners: plot-owners
plot-owners: check_geoip cidrs-oneline.txt
@sort plot/cidrs-oneline.txt | uniq -c | sort -nr | head -n ${PLOT_OWNERS_COUNT} > plot/owners.txt
@GNUPLOT_LIB="plot" gnuplot plot/owners.gnu
@echo "owners.png"
cidrs-oneline.txt:
@awk '{print $$2}' CIDRs.txt > plot/cidrs-oneline.txt
# Create plot: countries
countries: plot-countries
plot-countries: check_geoip check_gnuplot countries-list.txt
@sort plot/countries-list.txt | uniq -c | sort -nr | head -n ${PLOT_COUNTRIES_COUNT} > plot/countries.txt
@GNUPLOT_LIB="plot" gnuplot plot/countries.gnu
@echo "countries.png"
countries-list.txt:
plot/fetch_countries.sh
# Create plot: world map
map: plot-map
plot-map: check_gnuplot points.txt
@GNUPLOT_LIB="plot" gnuplot plot/world_map.gnu
@echo "world_map.png"
points.txt: check_geoip
plot/fetch_ip_locations.sh
# Clean stuff
clean:
rm -f *.png
rm -f plot/cidrs-oneline.txt
rm -f plot/countries-list.txt
rm -f plot/countries.txt
rm -f plot/country.txt
rm -f plot/owners.txt
rm -f plot/points.txt
.PHONY: all companies plot-owners countries plot-countries map plot-map clean