GNUmakefile 8.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#
# 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:
#
14 15
# PREFIX=/usr/
# MANPREFIX=/usr/share
16 17 18 19 20 21 22 23 24
#
# Finally, please note that this makefile supports the DESTDIR variable, as 
# typically employed by package developers.


CC= gcc
CFLAGS+= -Wall
LDFLAGS+= -lpcap -lm

25 26 27
ifeq ($(shell uname),SunOS)
  LDFLAGS+=-lsocket -lnsl
  OS=SunOS
28
endif
29 30 31 32 33 34 35


ifndef PREFIX
	PREFIX=/usr/local
	ifndef MANPREFIX
		MANPREFIX=/usr/local
	endif
36
else
37 38 39
	ifndef MANPREFIX
		MANPREFIX=/usr/share
	endif
40
endif
41

42 43 44 45 46 47 48 49 50

ETCPATH= $(DESTDIR)/etc
MANPATH= $(DESTDIR)$(MANPREFIX)/man
DATAPATH= $(DESTDIR)$(PREFIX)/share/ipv6toolkit
BINPATH= $(DESTDIR)$(PREFIX)/bin
SBINPATH= $(DESTDIR)$(PREFIX)/sbin
SRCPATH= tools


51
SBINTOOLS= blackhole6 flow6 frag6 icmp6 jumbo6 na6 ni6 ns6 path6 ra6 rd6 rs6 scan6 script6 tcp6
52 53 54 55
BINTOOLS= addr6
TOOLS= $(BINTOOLS) $(SBINTOOLS)
LIBS= libipv6.o

56 57 58 59
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) 
60

61 62
blackhole6: $(SRCPATH)/blackhole6
	cp $(SRCPATH)/blackhole6 ./
63

Mati's avatar
Mati committed
64 65
flow6: $(SRCPATH)/flow6.c $(SRCPATH)/flow6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o flow6 $(SRCPATH)/flow6.c $(LIBS) $(LDFLAGS)
66

Mati's avatar
Mati committed
67 68
frag6: $(SRCPATH)/frag6.c $(SRCPATH)/frag6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o frag6 $(SRCPATH)/frag6.c $(LIBS) $(LDFLAGS) 
69

Mati's avatar
Mati committed
70 71
icmp6: $(SRCPATH)/icmp6.c $(SRCPATH)/icmp6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o icmp6 $(SRCPATH)/icmp6.c $(LIBS) $(LDFLAGS)
72

Mati's avatar
Mati committed
73 74
jumbo6: $(SRCPATH)/jumbo6.c $(SRCPATH)/jumbo6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o jumbo6 $(SRCPATH)/jumbo6.c $(LIBS) $(LDFLAGS)
75

Mati's avatar
Mati committed
76 77
na6: $(SRCPATH)/na6.c $(SRCPATH)/na6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o na6 $(SRCPATH)/na6.c $(LIBS) $(LDFLAGS)
78 79 80 81 82 83 84

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)

85 86 87
path6: $(SRCPATH)/path6.c $(SRCPATH)/path6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o path6 $(SRCPATH)/path6.c $(LIBS) $(LDFLAGS)

Mati's avatar
Mati committed
88 89
ra6: $(SRCPATH)/ra6.c $(SRCPATH)/ra6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o ra6 $(SRCPATH)/ra6.c $(LIBS) $(LDFLAGS)
90

Mati's avatar
Mati committed
91 92
rd6: $(SRCPATH)/rd6.c $(SRCPATH)/rd6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o rd6 $(SRCPATH)/rd6.c $(LIBS) $(LDFLAGS)
93 94 95 96

rs6: $(SRCPATH)/rs6.c $(SRCPATH)/rs6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o rs6 $(SRCPATH)/rs6.c $(LIBS) $(LDFLAGS)

Mati's avatar
Mati committed
97 98
scan6: $(SRCPATH)/scan6.c $(SRCPATH)/scan6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o scan6 $(SRCPATH)/scan6.c $(LIBS) $(LDFLAGS)
99

100 101 102
script6: $(SRCPATH)/script6
	cp $(SRCPATH)/script6 ./

103 104 105 106 107 108
tcp6: $(SRCPATH)/tcp6.c $(SRCPATH)/tcp6.h $(SRCPATH)/ipv6toolkit.h $(LIBS) $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -o tcp6 $(SRCPATH)/tcp6.c $(LIBS) $(LDFLAGS)

libipv6.o: $(SRCPATH)/libipv6.c $(SRCPATH)/libipv6.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o libipv6.o $(SRCPATH)/libipv6.c

109
data/ipv6toolkit.conf:
110 111 112 113
	echo "# SI6 Networks' IPv6 Toolkit Configuration File" > \
           data/ipv6toolkit.conf
	echo OUI-Database=$(PREFIX)/share/ipv6toolkit/oui.txt >> \
           data/ipv6toolkit.conf 
114 115
	echo Ports-Database=$(PREFIX)/share/ipv6toolkit/service-names-port-numbers.csv >> \
           data/ipv6toolkit.conf 
116 117 118 119 120 121

clean: 
	rm -f $(TOOLS) $(LIBS)
	rm -f data/ipv6toolkit.conf

install: all
122
ifneq ($(OS),SunOS)
123 124 125 126 127 128 129
	# Install the binaries
	install -m0755 -d $(BINPATH)
	install -m0755 -d $(SBINPATH)
	install -m0755 $(BINTOOLS) $(BINPATH)
	install -m0755 $(SBINTOOLS) $(SBINPATH)

	# Install the configuration file
130
	install -m0755 -d $(ETCPATH)
131 132 133 134 135 136
	install -m0644 data/ipv6toolkit.conf $(ETCPATH)

	# Install the IEEE OUI database
	install -m0755 -d $(DATAPATH)
	install -m0644 data/oui.txt $(DATAPATH)

137 138 139
	# Install the port numbers database
	install -m0644 data/service-names-port-numbers.csv $(DATAPATH)

140 141 142 143 144 145 146
	# 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
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
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 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 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 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

204 205 206 207

uninstall:
	# Remove the binaries
	rm -f $(BINPATH)/addr6
208
	rm -f $(SBINPATH)/blackhole6
209 210 211 212
	rm -f $(SBINPATH)/flow6
	rm -f $(SBINPATH)/frag6
	rm -f $(SBINPATH)/icmp6
	rm -f $(SBINPATH)/jumbo6
213
	rm -f $(SBINPATH)/script6
214 215 216
	rm -f $(SBINPATH)/na6
	rm -f $(SBINPATH)/ni6
	rm -f $(SBINPATH)/ns6
217
	rm -f $(SBINPATH)/path6
218 219 220 221 222 223 224 225 226
	rm -f $(SBINPATH)/ra6
	rm -f $(SBINPATH)/rd6
	rm -f $(SBINPATH)/rs6
	rm -f $(SBINPATH)/scan6
	rm -f $(SBINPATH)/tcp6

	# Remove the configuration file
	rm -f $(ETCPATH)/ipv6toolkit.conf

227
	# Remove the IEEE OUI database and port number database
228 229 230 231
	rm -rf $(DATAPATH)

	# Remove the manual pages
	rm -f $(MANPATH)/man1/addr6.1
232
	rm -f $(MANPATH)/man1/blackhole6.1
233 234 235 236 237 238 239
	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
240
	rm -f $(MANPATH)/man1/path6.1
241 242 243 244
	rm -f $(MANPATH)/man1/ra6.1
	rm -f $(MANPATH)/man1/rd6.1
	rm -f $(MANPATH)/man1/rs6.1
	rm -f $(MANPATH)/man1/scan6.1
245
	rm -f $(MANPATH)/man1/script6.1
246 247 248 249
	rm -f $(MANPATH)/man1/tcp6.1
	rm -f $(MANPATH)/man5/ipv6toolkit.conf.5
	rm -f $(MANPATH)/man7/ipv6toolkit.7