forked from fgont/ipv6toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
264 lines (216 loc) · 8.88 KB
/
GNUmakefile
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#
# SI6 Networks' IPv6 toolkit Makefile (for GNU make)
#
# Notes to package developers:
#
# By default, binaries will be installed in /usr/local/bin, manual pages in
# /usr/local/man, data files in /usr/local/share/ipv6toolkit, and configuration
# files in /etc
#
# The path of the binaries and data files can be overriden by setting "PREFIX"
# variable accordingly. The path of the manual pages can be overriden by setting
# the MANPREFIX variable. Typically, packages will set these variables as follows:
#
# PREFIX=/usr/
# MANPREFIX=/usr/share
#
# Finally, please note that this makefile supports the DESTDIR variable, as
# typically employed by package developers.
CC= gcc
CFLAGS+= -Wall
LDFLAGS+= -lpcap -lm
ifeq ($(shell uname),SunOS)
LDFLAGS+=-lsocket -lnsl
OS=SunOS
endif
ifndef PREFIX
PREFIX=/usr/local
ifndef MANPREFIX
MANPREFIX=/usr/local
endif
else
ifndef MANPREFIX
MANPREFIX=/usr/share
endif
endif
ETCPATH= $(DESTDIR)/etc
MANPATH= $(DESTDIR)$(MANPREFIX)/man
DATAPATH= $(DESTDIR)$(PREFIX)/share/ipv6toolkit
BINPATH= $(DESTDIR)$(PREFIX)/bin
SBINPATH= $(DESTDIR)$(PREFIX)/sbin
SRCPATH= tools
SBINTOOLS= blackhole6 flow6 frag6 icmp6 jumbo6 na6 ni6 ns6 path6 ra6 rd6 rs6 scan6 script6 tcp6 udp6
BINTOOLS= addr6
TOOLS= $(BINTOOLS) $(SBINTOOLS)
LIBS= libipv6.o
all: $(TOOLS) data/ipv6toolkit.conf
addr6: $(SRCPATH)/addr6.c $(SRCPATH)/addr6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o addr6 $(SRCPATH)/addr6.c $(LIBS) $(LDFLAGS)
blackhole6: $(SRCPATH)/blackhole6
cp $(SRCPATH)/blackhole6 ./
flow6: $(SRCPATH)/flow6.c $(SRCPATH)/flow6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o flow6 $(SRCPATH)/flow6.c $(LIBS) $(LDFLAGS)
frag6: $(SRCPATH)/frag6.c $(SRCPATH)/frag6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o frag6 $(SRCPATH)/frag6.c $(LIBS) $(LDFLAGS)
icmp6: $(SRCPATH)/icmp6.c $(SRCPATH)/icmp6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o icmp6 $(SRCPATH)/icmp6.c $(LIBS) $(LDFLAGS)
jumbo6: $(SRCPATH)/jumbo6.c $(SRCPATH)/jumbo6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o jumbo6 $(SRCPATH)/jumbo6.c $(LIBS) $(LDFLAGS)
na6: $(SRCPATH)/na6.c $(SRCPATH)/na6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o na6 $(SRCPATH)/na6.c $(LIBS) $(LDFLAGS)
ni6: $(SRCPATH)/ni6.c $(SRCPATH)/ni6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o ni6 $(SRCPATH)/ni6.c $(LIBS) $(LDFLAGS)
ns6: $(SRCPATH)/ns6.c $(SRCPATH)/ns6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o ns6 $(SRCPATH)/ns6.c $(LIBS) $(LDFLAGS)
path6: $(SRCPATH)/path6.c $(SRCPATH)/path6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o path6 $(SRCPATH)/path6.c $(LIBS) $(LDFLAGS)
ra6: $(SRCPATH)/ra6.c $(SRCPATH)/ra6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o ra6 $(SRCPATH)/ra6.c $(LIBS) $(LDFLAGS)
rd6: $(SRCPATH)/rd6.c $(SRCPATH)/rd6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o rd6 $(SRCPATH)/rd6.c $(LIBS) $(LDFLAGS)
rs6: $(SRCPATH)/rs6.c $(SRCPATH)/rs6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o rs6 $(SRCPATH)/rs6.c $(LIBS) $(LDFLAGS)
scan6: $(SRCPATH)/scan6.c $(SRCPATH)/scan6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o scan6 $(SRCPATH)/scan6.c $(LIBS) $(LDFLAGS)
script6: $(SRCPATH)/script6
cp $(SRCPATH)/script6 ./
tcp6: $(SRCPATH)/tcp6.c $(SRCPATH)/tcp6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o tcp6 $(SRCPATH)/tcp6.c $(LIBS) $(LDFLAGS)
udp6: $(SRCPATH)/udp6.c $(SRCPATH)/udp6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -o udp6 $(SRCPATH)/udp6.c $(LIBS) $(LDFLAGS)
libipv6.o: $(SRCPATH)/libipv6.c $(SRCPATH)/libipv6.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o libipv6.o $(SRCPATH)/libipv6.c
data/ipv6toolkit.conf:
echo "# SI6 Networks' IPv6 Toolkit Configuration File" > \
data/ipv6toolkit.conf
echo OUI-Database=$(PREFIX)/share/ipv6toolkit/oui.txt >> \
data/ipv6toolkit.conf
echo Ports-Database=$(PREFIX)/share/ipv6toolkit/service-names-port-numbers.csv >> \
data/ipv6toolkit.conf
echo Top-Ports-Database=$(PREFIX)/share/ipv6toolkit/top-port-numbers.csv >> \
data/ipv6toolkit.conf
clean:
rm -f $(TOOLS) $(LIBS)
rm -f data/ipv6toolkit.conf
install: all
ifneq ($(OS),SunOS)
# Install the binaries
install -m0755 -d $(BINPATH)
install -m0755 -d $(SBINPATH)
install -m0755 $(BINTOOLS) $(BINPATH)
install -m0755 $(SBINTOOLS) $(SBINPATH)
# Install the configuration file
install -m0755 -d $(ETCPATH)
install -m0644 data/ipv6toolkit.conf $(ETCPATH)
# Install the IEEE OUI database
install -m0755 -d $(DATAPATH)
install -m0644 data/oui.txt $(DATAPATH)
# Install the port numbers database
install -m0644 data/service-names-port-numbers.csv $(DATAPATH)
# Install the top port numbers database
install -m0644 data/top-port-numbers.csv $(DATAPATH)
# Install the manual pages
install -m0755 -d $(MANPATH)/man1
install -m0644 manuals/*.1 $(MANPATH)/man1
install -m0755 -d $(MANPATH)/man5
install -m0644 manuals/*.5 $(MANPATH)/man5
install -m0755 -d $(MANPATH)/man7
install -m0644 manuals/*.7 $(MANPATH)/man7
else
# Install the binaries
install -m 0755 -d $(BINPATH)
install -m 0755 -d $(SBINPATH)
install -m 0755 -f $(BINPATH) addr6
install -m 0755 -f $(SBINPATH) blackhole6
install -m 0755 -f $(SBINPATH) flow6
install -m 0755 -f $(SBINPATH) frag6
install -m 0755 -f $(SBINPATH) icmp6
install -m 0755 -f $(SBINPATH) jumbo6
install -m 0755 -f $(SBINPATH) script6
install -m 0755 -f $(SBINPATH) na6
install -m 0755 -f $(SBINPATH) ni6
install -m 0755 -f $(SBINPATH) ns6
install -m 0755 -f $(SBINPATH) path6
install -m 0755 -f $(SBINPATH) ra6
install -m 0755 -f $(SBINPATH) rd6
install -m 0755 -f $(SBINPATH) rs6
install -m 0755 -f $(SBINPATH) scan6
install -m 0755 -f $(SBINPATH) tcp6
install -m 0755 -f $(SBINPATH) udp6
# Install the configuration file
install -m 0755 -d $(ETCPATH)
install -m 0644 -f $(ETCPATH) data/ipv6toolkit.conf
# Install the IEEE OUI database
install -m 0755 -d $(DATAPATH)
install -m 0644 -f $(DATAPATH) data/oui.txt
# Install the port numbers database
install -m 0644 -f $(DATAPATH) data/service-names-port-numbers.csv
# Install the port numbers database
install -m 0644 -f $(DATAPATH) data/top-port-numbers.csv
# Install the manual pages
install -m 0755 -d $(MANPATH)/man1
install -m 0644 -f $(MANPATH)/man1 manuals/addr6.1
install -m 0644 -f $(MANPATH)/man1 manuals/blackhole6.1
install -m 0644 -f $(MANPATH)/man1 manuals/flow6.1
install -m 0644 -f $(MANPATH)/man1 manuals/frag6.1
install -m 0644 -f $(MANPATH)/man1 manuals/icmp6.1
install -m 0644 -f $(MANPATH)/man1 manuals/jumbo6.1
install -m 0644 -f $(MANPATH)/man1 manuals/na6.1
install -m 0644 -f $(MANPATH)/man1 manuals/ni6.1
install -m 0644 -f $(MANPATH)/man1 manuals/ns6.1
install -m 0644 -f $(MANPATH)/man1 manuals/path6.1
install -m 0644 -f $(MANPATH)/man1 manuals/ra6.1
install -m 0644 -f $(MANPATH)/man1 manuals/rd6.1
install -m 0644 -f $(MANPATH)/man1 manuals/rs6.1
install -m 0644 -f $(MANPATH)/man1 manuals/scan6.1
install -m 0644 -f $(MANPATH)/man1 manuals/script6.1
install -m 0644 -f $(MANPATH)/man1 manuals/tcp6.1
install -m 0644 -f $(MANPATH)/man1 manuals/udp6.1
install -m 0755 -d $(MANPATH)/man5
install -m 0644 -f $(MANPATH)/man5 manuals/ipv6toolkit.conf.5
install -m 0755 -d $(MANPATH)/man7
install -m 0644 -f $(MANPATH)/man7 manuals/ipv6toolkit.7
endif
uninstall:
# Remove the binaries
rm -f $(BINPATH)/addr6
rm -f $(SBINPATH)/blackhole6
rm -f $(SBINPATH)/flow6
rm -f $(SBINPATH)/frag6
rm -f $(SBINPATH)/icmp6
rm -f $(SBINPATH)/jumbo6
rm -f $(SBINPATH)/script6
rm -f $(SBINPATH)/na6
rm -f $(SBINPATH)/ni6
rm -f $(SBINPATH)/ns6
rm -f $(SBINPATH)/path6
rm -f $(SBINPATH)/ra6
rm -f $(SBINPATH)/rd6
rm -f $(SBINPATH)/rs6
rm -f $(SBINPATH)/scan6
rm -f $(SBINPATH)/tcp6
rm -f $(SBINPATH)/udp6
# Remove the configuration file
rm -f $(ETCPATH)/ipv6toolkit.conf
# Remove the IEEE OUI database, port number database and top port numbers database
rm -rf $(DATAPATH)
# Remove the manual pages
rm -f $(MANPATH)/man1/addr6.1
rm -f $(MANPATH)/man1/blackhole6.1
rm -f $(MANPATH)/man1/flow6.1
rm -f $(MANPATH)/man1/frag6.1
rm -f $(MANPATH)/man1/icmp6.1
rm -f $(MANPATH)/man1/jumbo6.1
rm -f $(MANPATH)/man1/na6.1
rm -f $(MANPATH)/man1/ni6.1
rm -f $(MANPATH)/man1/ns6.1
rm -f $(MANPATH)/man1/path6.1
rm -f $(MANPATH)/man1/ra6.1
rm -f $(MANPATH)/man1/rd6.1
rm -f $(MANPATH)/man1/rs6.1
rm -f $(MANPATH)/man1/scan6.1
rm -f $(MANPATH)/man1/script6.1
rm -f $(MANPATH)/man1/tcp6.1
rm -f $(MANPATH)/man1/udp6.1
rm -f $(MANPATH)/man5/ipv6toolkit.conf.5
rm -f $(MANPATH)/man7/ipv6toolkit.7