1#  Copyright (c) 1993, 1994, 1995, 1996
2# 	The Regents of the University of California.  All rights reserved.
3#
4#  Redistribution and use in source and binary forms, with or without
5#  modification, are permitted provided that: (1) source code distributions
6#  retain the above copyright notice and this paragraph in its entirety, (2)
7#  distributions including binary code include the above copyright notice and
8#  this paragraph in its entirety in the documentation or other materials
9#  provided with the distribution, and (3) all advertising materials mentioning
10#  features or use of this software display the following acknowledgement:
11#  ``This product includes software developed by the University of California,
12#  Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13#  the University nor the names of its contributors may be used to endorse
14#  or promote products derived from this software without specific prior
15#  written permission.
16#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17#  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19
20#
21# Various configurable paths (remember to edit Makefile.in, not Makefile)
22#
23
24# Top level hierarchy
25prefix = @prefix@
26exec_prefix = @exec_prefix@
27datarootdir = @datarootdir@
28# Pathname of directory to install the configure program
29bindir = @bindir@
30# Pathname of directory to install the include files
31includedir = @includedir@
32# Pathname of directory to install the library
33libdir =  @libdir@
34# Pathname of directory to install the man pages
35mandir = @mandir@
36
37# VPATH
38srcdir = @srcdir@
39VPATH = @srcdir@
40
41#
42# You shouldn't need to edit anything below.
43#
44
45LD = /usr/bin/ld
46CC = @CC@
47AR = @AR@
48LN_S = @LN_S@
49MKDEP = @MKDEP@
50CCOPT = @V_CCOPT@
51INCLS = -I. @V_INCLS@
52DEFS = @DEFS@ @V_DEFS@
53ADDLOBJS = @ADDLOBJS@
54ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
55LIBS = @LIBS@
56CROSSFLAGS=
57CFLAGS = @CFLAGS@   ${CROSSFLAGS}
58LDFLAGS = @LDFLAGS@ ${CROSSFLAGS}
59DYEXT = @DYEXT@
60V_RPATH_OPT = @V_RPATH_OPT@
61DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
62PROG=libpcap
63
64# Standard CFLAGS
65FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
66
67INSTALL = @INSTALL@
68INSTALL_PROGRAM = @INSTALL_PROGRAM@
69INSTALL_DATA = @INSTALL_DATA@
70RANLIB = @RANLIB@
71
72#
73# Flex and bison allow you to specify the prefixes of the global symbols
74# used by the generated parser.  This allows programs to use lex/yacc
75# and link against libpcap.  If you don't have flex or bison, get them.
76#
77LEX = @V_LEX@
78YACC = @V_YACC@
79
80# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
81# Also, gcc does not remove the .o before forking 'as', which can be a
82# problem if you don't own the file but can write to the directory.
83.c.o:
84	@rm -f $@
85	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
86
87PSRC =	pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@
88FSRC =  fad-@V_FINDALLDEVS@.c
89SSRC =  @SSRC@
90CSRC =	pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
91	savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
92	bpf_image.c bpf_dump.c
93GENSRC = scanner.c grammar.c bpf_filter.c version.c
94LIBOBJS = @LIBOBJS@
95
96SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
97
98# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
99# hack the extra indirection
100OBJ =	$(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
101PUBHDR = \
102	pcap.h \
103	pcap-bpf.h \
104	pcap-namedb.h \
105	pcap/bpf.h \
106	pcap/bluetooth.h \
107	pcap/ipnet.h \
108	pcap/namedb.h \
109	pcap/nflog.h \
110	pcap/pcap.h \
111	pcap/sll.h \
112	pcap/vlan.h \
113	pcap/usb.h
114
115HDR = $(PUBHDR) \
116	arcnet.h \
117	atmuni31.h \
118	ethertype.h \
119	gencode.h \
120	ieee80211.h \
121	llc.h \
122	nlpid.h \
123	pcap-common.h \
124	pcap-int.h \
125	pcap-stdinc.h \
126	ppp.h \
127	sf-pcap.h \
128	sf-pcap-ng.h \
129	sunatmpos.h
130
131TESTS = \
132	capturetest \
133	filtertest \
134	findalldevstest \
135	opentest \
136	selpolltest \
137	valgrindtest
138
139TESTS_SRC = \
140	tests/capturetest.c \
141	tests/filtertest.c \
142	tests/findalldevstest.c \
143	tests/opentest.c \
144	tests/reactivatetest.c \
145	tests/selpolltest.c \
146	tests/valgrindtest.c
147
148GENHDR = \
149	scanner.h tokdefs.h version.h
150
151TAGFILES = \
152	$(SRC) $(HDR)
153
154CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
155	$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
156	lex.yy.c pcap-config
157
158MAN1 = pcap-config.1
159
160MAN3PCAP_EXPAND = \
161	pcap.3pcap.in \
162	pcap_compile.3pcap.in \
163	pcap_datalink.3pcap.in \
164	pcap_dump_open.3pcap.in \
165	pcap_get_tstamp_precision.3pcap.in \
166	pcap_list_datalinks.3pcap.in \
167	pcap_list_tstamp_types.3pcap.in \
168	pcap_open_dead.3pcap.in \
169	pcap_open_offline.3pcap.in \
170	pcap_set_tstamp_precision.3pcap.in \
171	pcap_set_tstamp_type.3pcap.in
172
173MAN3PCAP_NOEXPAND = \
174	pcap_activate.3pcap \
175	pcap_breakloop.3pcap \
176	pcap_can_set_rfmon.3pcap \
177	pcap_close.3pcap \
178	pcap_create.3pcap \
179	pcap_datalink_name_to_val.3pcap \
180	pcap_datalink_val_to_name.3pcap \
181	pcap_dump.3pcap \
182	pcap_dump_close.3pcap \
183	pcap_dump_file.3pcap \
184	pcap_dump_flush.3pcap \
185	pcap_dump_ftell.3pcap \
186	pcap_file.3pcap \
187	pcap_fileno.3pcap \
188	pcap_findalldevs.3pcap \
189	pcap_freecode.3pcap \
190	pcap_get_selectable_fd.3pcap \
191	pcap_geterr.3pcap \
192	pcap_inject.3pcap \
193	pcap_is_swapped.3pcap \
194	pcap_lib_version.3pcap \
195	pcap_lookupdev.3pcap \
196	pcap_lookupnet.3pcap \
197	pcap_loop.3pcap \
198	pcap_major_version.3pcap \
199	pcap_next_ex.3pcap \
200	pcap_offline_filter.3pcap \
201	pcap_open_live.3pcap \
202	pcap_set_buffer_size.3pcap \
203	pcap_set_datalink.3pcap \
204	pcap_set_immediate_mode.3pcap \
205	pcap_set_promisc.3pcap \
206	pcap_set_rfmon.3pcap \
207	pcap_set_snaplen.3pcap \
208	pcap_set_timeout.3pcap \
209	pcap_setdirection.3pcap \
210	pcap_setfilter.3pcap \
211	pcap_setnonblock.3pcap \
212	pcap_snapshot.3pcap \
213	pcap_stats.3pcap \
214	pcap_statustostr.3pcap \
215	pcap_strerror.3pcap \
216	pcap_tstamp_type_name_to_val.3pcap \
217	pcap_tstamp_type_val_to_name.3pcap
218
219MAN3PCAP = $(MAN3PCAP_NOEXPAND) $(MAN3PCAP_EXPAND:.in=)
220
221MANFILE = \
222	pcap-savefile.manfile.in
223
224MANMISC = \
225	pcap-filter.manmisc.in \
226	pcap-linktype.manmisc.in \
227	pcap-tstamp.manmisc.in
228
229EXTRA_DIST = \
230	$(TESTS_SRC) \
231	CHANGES \
232	ChmodBPF/ChmodBPF \
233	ChmodBPF/StartupParameters.plist \
234	CREDITS \
235	INSTALL.txt \
236	LICENSE \
237	Makefile.in \
238	Makefile-devel-adds \
239	README \
240	README.aix \
241	README.dag \
242	README.hpux \
243	README.linux \
244	README.macosx \
245	README.septel \
246	README.sita \
247	README.tru64 \
248	README.Win32 \
249	SUNOS4/nit_if.o.sparc \
250	SUNOS4/nit_if.o.sun3 \
251	SUNOS4/nit_if.o.sun4c.4.0.3c \
252	TODO \
253	VERSION \
254	aclocal.m4 \
255	bpf/net/bpf_filter.c \
256	chmod_bpf \
257	config.guess \
258	config.h.in \
259	config.sub \
260	configure \
261	configure.in \
262	dlpisubs.c \
263	dlpisubs.h \
264	fad-getad.c \
265	fad-gifc.c \
266	fad-glifc.c \
267	fad-null.c \
268	fad-sita.c \
269	fad-win32.c \
270	grammar.y \
271	install-sh \
272	lbl/os-aix4.h \
273	lbl/os-hpux11.h \
274	lbl/os-osf4.h \
275	lbl/os-osf5.h \
276	lbl/os-solaris2.h \
277	lbl/os-sunos4.h \
278	lbl/os-ultrix4.h \
279	missing/snprintf.c \
280	mkdep \
281	msdos/bin2c.c \
282	msdos/common.dj \
283	msdos/makefile \
284	msdos/makefile.dj \
285	msdos/makefile.wc \
286	msdos/ndis2.c \
287	msdos/ndis2.h \
288	msdos/ndis_0.asm \
289	msdos/pkt_rx0.asm \
290	msdos/pkt_rx1.s \
291	msdos/pktdrvr.c \
292	msdos/pktdrvr.h \
293	msdos/readme.dos \
294	org.tcpdump.chmod_bpf.plist \
295	pcap-bpf.c \
296	pcap-bt-linux.c \
297	pcap-bt-linux.h \
298	pcap-bt-monitor-linux.c \
299	pcap-bt-monitor-linux.h \
300	pcap-can-linux.c \
301	pcap-can-linux.h \
302	pcap-canusb-linux.c \
303	pcap-canusb-linux.h \
304	pcap-config.in \
305	pcap-dag.c \
306	pcap-dag.h \
307	pcap-dbus.c \
308	pcap-dbus.h \
309	pcap-dlpi.c \
310	pcap-dos.c \
311	pcap-dos.h \
312	pcap-enet.c \
313	pcap-int.h \
314	pcap-libdlpi.c \
315	pcap-linux.c \
316	pcap-namedb.h \
317	pcap-netfilter-linux.c \
318	pcap-netfilter-linux.h \
319	pcap-nit.c \
320	pcap-null.c \
321	pcap-pf.c \
322	pcap-septel.c \
323	pcap-septel.h \
324	pcap-sita.h \
325	pcap-sita.c \
326	pcap-sita.html \
327	pcap-snf.c \
328	pcap-snf.h \
329	pcap-snit.c \
330	pcap-snoop.c \
331	pcap-usb-linux.c \
332	pcap-usb-linux.h \
333	pcap-win32.c \
334	runlex.sh \
335	scanner.c.top \
336	scanner.l \
337	Win32/Include/Gnuc.h \
338	Win32/Include/addrinfo.h \
339	Win32/Include/bittypes.h \
340	Win32/Include/cdecl_ext.h \
341	Win32/Include/inetprivate.h \
342	Win32/Include/ip6_misc.h \
343	Win32/Include/sockstorage.h \
344	Win32/Include/arpa/nameser.h \
345	Win32/Include/net/if.h \
346	Win32/Include/net/netdb.h \
347	Win32/Include/net/paths.h \
348	Win32/Prj/libpcap.dsp \
349	Win32/Prj/libpcap.dsw \
350	Win32/Src/ffs.c \
351	Win32/Src/gai_strerror.c \
352	Win32/Src/getaddrinfo.c \
353	Win32/Src/getnetbynm.c \
354	Win32/Src/getnetent.c \
355	Win32/Src/getopt.c \
356	Win32/Src/getservent.c \
357	Win32/Src/inet_aton.c \
358	Win32/Src/inet_net.c \
359	Win32/Src/inet_pton.c
360
361all: libpcap.a shared pcap-config
362
363libpcap.a: $(OBJ)
364	@rm -f $@
365	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
366	$(RANLIB) $@
367
368shared: libpcap.$(DYEXT)
369
370libpcap.so: $(OBJ)
371	@rm -f $@
372	VER=`cat $(srcdir)/VERSION`; \
373	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
374	@V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
375	    -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
376
377#
378# The following rule succeeds, but the result is untested.
379#
380# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with
381# its full path as the install_name, and with the compatibility and
382# current version both set to 1.  The compatibility version is set to
383# 1 so that programs built with a newer version of the library will run
384# against older versions; multi-platform software probably will fail if
385# it uses APIs added in the newer version, but Mac OS X-specific software
386# will use weak linking and check at run time whether those APIs are
387# available.
388#
389# We also use "A" as the major version, and 1 as the compatibility version,
390# but set the current version to the value in VERSION, with any non-numeric
391# stuff stripped off (the compatibility and current version must be of the
392# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
393# numeric).
394#
395libpcap.dylib: $(OBJ)
396	rm -f libpcap*.dylib
397	VER=`cat $(srcdir)/VERSION`; \
398	MAJOR_VER=A; \
399	COMPAT_VER=1; \
400	CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
401	$(CC) -dynamiclib -undefined error $(LDFLAGS) \
402	    -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
403	    -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
404	    -compatibility_version $$COMPAT_VER \
405	    -current_version $$CURRENT_VER
406
407#
408# The HP-UX linker manual says that the convention for a versioned library
409# is libXXX.{number}, not libXXX.sl.{number}.  That appears to be the case
410# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
411# libXXX.{number}.
412#
413# The manual also says "library-level versioning" (think "sonames") was
414# added in HP-UX 10.0.
415#
416# XXX - this assumes we're using the HP linker, rather than the GNU
417# linker, even with GCC.
418#
419libpcap.sl: $(OBJ)
420	@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
421	rm -f libpcap.$$MAJOR_VER
422	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
423	ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
424	    $(OBJ) $(ADDLOBJS) $(LIBS)
425
426#
427# AIX is different from everybody else.  A shared library is an archive
428# library with one or more shared-object components.  We still build a
429# normal static archive library on AIX, for the benefit of the traditional
430# scheme of building libpcap and tcpdump in subdirectories of the
431# same directory, with tcpdump statically linked with the libpcap
432# in question, but we also build a shared library as "libpcap.shareda"
433# and install *it*, rather than the static library, as "libpcap.a".
434#
435libpcap.shareda: $(OBJ)
436	@rm -f $@ shr.o
437	$(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
438	$(AR) rc $@ shr.o
439
440#
441# For platforms that don't support shared libraries (or on which we
442# don't support shared libraries).
443#
444libpcap.none:
445
446scanner.c: $(srcdir)/scanner.l
447	@rm -f $@ $@.bottom
448	$(srcdir)/runlex.sh $(LEX) -o$@ $<
449	mv $@ $@.bottom
450	cat $(srcdir)/$@.top $@.bottom > $@
451	@rm $@.bottom
452
453scanner.o: scanner.c tokdefs.h
454	$(CC) $(FULL_CFLAGS) -c scanner.c
455
456pcap.o: version.h
457
458tokdefs.h: grammar.c
459grammar.c: $(srcdir)/grammar.y
460	@rm -f grammar.c tokdefs.h
461	$(YACC) -d $<
462	mv y.tab.c grammar.c
463	mv y.tab.h tokdefs.h
464
465grammar.o: grammar.c
466	@rm -f $@
467	$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
468
469version.o: version.c
470	$(CC) $(FULL_CFLAGS) -c version.c
471
472snprintf.o: $(srcdir)/missing/snprintf.c
473	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
474
475version.c: $(srcdir)/VERSION
476	@rm -f $@
477	if grep GIT ${srcdir}/VERSION >/dev/null; then \
478		read ver <${srcdir}/VERSION; \
479		echo $$ver | tr -d '\012'; \
480		date +_%Y_%m_%d; \
481	else \
482		cat ${srcdir}/VERSION; \
483	fi | sed -e 's/.*/char pcap_version[] = "&";/' > $@
484
485#
486# NOTE: this really is supposed to be static; importing a string
487# from a shared library does not work very well on many
488# versions of UNIX (Solaris, Linux, and the BSDs, for example),
489# so we make the version string static and return it from
490# a function, which does work.
491#
492version.h: $(srcdir)/VERSION
493	@rm -f $@
494	if grep GIT ${srcdir}/VERSION >/dev/null; then \
495		read ver <${srcdir}/VERSION; \
496		echo $$ver | tr -d '\012'; \
497		date +_%Y_%m_%d; \
498	else \
499		cat ${srcdir}/VERSION; \
500	fi | sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' > $@
501
502bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
503	rm -f bpf_filter.c
504	ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
505
506bpf_filter.o: bpf_filter.c
507	$(CC) $(FULL_CFLAGS) -c bpf_filter.c
508
509#
510# Generate the pcap-config script.
511#
512# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
513# for example, the Solaris 9 make man page says
514#
515#	Because make assigns $< and $* as it would for implicit rules
516#	(according to the suffixes list and the directory contents),
517#	they may be unreliable when used within explicit target entries.
518#
519# and this is an explicit target entry.
520#
521# Therefore, instead of using $<, we explicitly put in $(srcdir)/pcap-config.in.
522#
523pcap-config: $(srcdir)/pcap-config.in ./config.status
524	@rm -f $@ $@.tmp
525	./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
526	mv $@.tmp $@
527	chmod a+x $@
528
529#
530# Test programs - not built by default, and not installed.
531#
532tests: $(TESTS)
533
534capturetest: tests/capturetest.c libpcap.a
535	$(CC) $(FULL_CFLAGS) -I. -L. -o capturetest $(srcdir)/tests/capturetest.c libpcap.a $(LIBS)
536
537filtertest: tests/filtertest.c libpcap.a
538	$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
539
540findalldevstest: tests/findalldevstest.c libpcap.a
541	$(CC) $(FULL_CFLAGS) -I. -L. -o findalldevstest $(srcdir)/tests/findalldevstest.c libpcap.a $(LIBS)
542
543opentest: tests/opentest.c libpcap.a
544	$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
545
546selpolltest: tests/selpolltest.c libpcap.a
547	$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
548
549valgrindtest: tests/valgrindtest.c libpcap.a
550	$(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS)
551
552install: install-shared install-archive pcap-config
553	[ -d $(DESTDIR)$(libdir) ] || \
554	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
555	[ -d $(DESTDIR)$(includedir) ] || \
556	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
557	[ -d $(DESTDIR)$(includedir)/pcap ] || \
558	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
559	[ -d $(DESTDIR)$(mandir)/man1 ] || \
560	    (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
561	[ -d $(DESTDIR)$(mandir)/man3 ] || \
562	    (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
563	[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
564	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
565	[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
566	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
567	for i in $(PUBHDR); do \
568		$(INSTALL_DATA) $(srcdir)/$$i \
569		    $(DESTDIR)$(includedir)/$$i; done
570	[ -d $(DESTDIR)$(bindir) ] || \
571	    (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
572	$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
573	for i in $(MAN1); do \
574		$(INSTALL_DATA) $(srcdir)/$$i \
575		    $(DESTDIR)$(mandir)/man1/$$i; done
576	for i in $(MAN3PCAP_NOEXPAND); do \
577		$(INSTALL_DATA) $(srcdir)/$$i \
578		    $(DESTDIR)$(mandir)/man3/$$i; done
579	for i in $(MAN3PCAP_EXPAND:.in=); do \
580		$(INSTALL_DATA) $$i \
581		    $(DESTDIR)$(mandir)/man3/$$i; done
582	(cd $(DESTDIR)$(mandir)/man3 && \
583	rm -f pcap_datalink_val_to_description.3pcap && \
584	$(LN_S) pcap_datalink_val_to_name.3pcap \
585		 pcap_datalink_val_to_description.3pcap && \
586	rm -f pcap_dump_fopen.3pcap && \
587	$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
588	rm -f pcap_freealldevs.3pcap && \
589	$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
590	rm -f pcap_perror.3pcap && \
591	$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
592	rm -f pcap_sendpacket.3pcap && \
593	$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
594	rm -f pcap_free_datalinks.3pcap && \
595	$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
596	rm -f pcap_free_tstamp_types.3pcap && \
597	$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
598	rm -f pcap_dispatch.3pcap && \
599	$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
600	rm -f pcap_minor_version.3pcap && \
601	$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
602	rm -f pcap_next.3pcap && \
603	$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
604	rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
605	$(LN_S) pcap_open_dead.3pcap \
606		 pcap_open_dead_with_tstamp_precision.3pcap && \
607	rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
608	$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
609	rm -f pcap_fopen_offline.3pcap && \
610	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
611	rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
612	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
613	rm -f pcap_tstamp_type_val_to_description.3pcap && \
614	$(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \
615	rm -f pcap_getnonblock.3pcap && \
616	$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
617	for i in $(MANFILE); do \
618		$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
619		    $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
620	for i in $(MANMISC); do \
621		$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
622		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
623
624install-shared: install-shared-$(DYEXT)
625install-shared-so: libpcap.so
626	[ -d $(DESTDIR)$(libdir) ] || \
627	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
628	VER=`cat $(srcdir)/VERSION`; \
629	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
630	$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
631	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
632	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
633install-shared-dylib: libpcap.dylib
634	[ -d $(DESTDIR)$(libdir) ] || \
635	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
636	VER=`cat $(srcdir)/VERSION`; \
637	MAJOR_VER=A; \
638	$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
639	ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
640	ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
641install-shared-sl: libpcap.sl
642	[ -d $(DESTDIR)$(libdir) ] || \
643	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
644	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
645	$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
646	ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
647install-shared-shareda: libpcap.shareda
648	#
649	# AIX shared libraries are weird.  They're archive libraries
650	# with one or more shared object components.
651	#
652	[ -d $(DESTDIR)$(libdir) ] || \
653	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
654	$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
655install-shared-none:
656
657install-archive: install-archive-$(DYEXT)
658install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
659	#
660	# Most platforms have separate suffixes for shared and
661	# archive libraries, so we install both.
662	#
663	[ -d $(DESTDIR)$(libdir) ] || \
664	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
665	$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
666	$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
667install-archive-shareda:
668	#
669	# AIX, however, doesn't, so we don't install the archive
670	# library on AIX.
671	#
672
673uninstall: uninstall-shared
674	rm -f $(DESTDIR)$(libdir)/libpcap.a
675	for i in $(PUBHDR); do \
676		rm -f $(DESTDIR)$(includedir)/$$i; done
677	-rmdir $(DESTDIR)$(includedir)/pcap
678	rm -f $(DESTDIR)/$(bindir)/pcap-config
679	for i in $(MAN1); do \
680		rm -f $(DESTDIR)$(mandir)/man1/$$i; done
681	for i in $(MAN3PCAP); do \
682		rm -f $(DESTDIR)$(mandir)/man3/$$i; done
683	rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
684	rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
685	rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
686	rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
687	rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
688	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
689	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
690	rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
691	rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
692	rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
693	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
694	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
695	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
696	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
697	rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
698	rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.3pcap
699	for i in $(MANFILE); do \
700		rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
701	for i in $(MANMISC); do \
702		rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
703
704uninstall-shared: uninstall-shared-$(DYEXT)
705uninstall-shared-so:
706	VER=`cat $(srcdir)/VERSION`; \
707	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
708	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
709	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
710	rm -f $(DESTDIR)$(libdir)/libpcap.so
711uninstall-shared-dylib:
712	VER=`cat $(srcdir)/VERSION`; \
713	MAJOR_VER=A; \
714	rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
715	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
716	rm -f $(DESTDIR)$(libdir)/libpcap.dylib
717uninstall-shared-sl:
718	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
719	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
720	rm -f $(DESTDIR)$(libdir)/libpcap.sl
721uninstall-shared-shareda:
722	rm -f $(DESTDIR)$(libdir)/libpcap.a
723uninstall-shared-none:
724
725clean:
726	rm -f $(CLEANFILES)
727
728distclean: clean
729	rm -f Makefile config.cache config.log config.status \
730	    config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \
731	    stamp-h stamp-h.in
732	rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
733	rm -rf autom4te.cache
734
735tags: $(TAGFILES)
736	ctags -wtd $(TAGFILES)
737
738releasetar:
739	@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
740	   mkdir $$name; \
741	   tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
742	      $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
743	      (cd $$name; tar xf -); \
744	   tar -c -z -f $$name.tar.gz $$name; \
745	   rm -rf $$name
746
747depend:	$(GENSRC) $(GENHDR) bpf_filter.c
748	$(MKDEP) -c $(CC) -m $(CFLAGS) $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
749