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 rpcapd daemon
31sbindir = @sbindir@
32# Pathname of directory to install the include files
33includedir = @includedir@
34# Pathname of directory to install the library
35libdir =  @libdir@
36# Pathname of directory to install the man pages
37mandir = @mandir@
38
39# VPATH
40srcdir = @srcdir@
41VPATH = @srcdir@
42
43#
44# You shouldn't need to edit anything below.
45#
46
47LD = /usr/bin/ld
48CC = @CC@
49AR = @AR@
50LN_S = @LN_S@
51MKDEP = @MKDEP@
52CCOPT = @V_CCOPT@
53SHLIB_CCOPT = @V_SHLIB_CCOPT@
54INCLS = -I. @V_INCLS@
55DEFS = -DBUILDING_PCAP -Dpcap_EXPORTS @DEFS@ @V_DEFS@
56ADDLOBJS = @ADDLOBJS@
57ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
58LIBS = @LIBS@
59CROSSFLAGS=
60CFLAGS = @CFLAGS@   ${CROSSFLAGS}
61LDFLAGS = @LDFLAGS@ ${CROSSFLAGS}
62DYEXT = @DYEXT@
63V_RPATH_OPT = @V_RPATH_OPT@
64DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
65PROG=libpcap
66PTHREAD_LIBS=@PTHREAD_LIBS@
67BUILD_RPCAPD=@BUILD_RPCAPD@
68INSTALL_RPCAPD=@INSTALL_RPCAPD@
69EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
70
71# Standard CFLAGS for building members of a shared library
72FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
73
74INSTALL = @INSTALL@
75INSTALL_PROGRAM = @INSTALL_PROGRAM@
76INSTALL_DATA = @INSTALL_DATA@
77RANLIB = @RANLIB@
78
79LEX = @LEX@
80YACC = @YACC@
81
82# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
83# Also, gcc does not remove the .o before forking 'as', which can be a
84# problem if you don't own the file but can write to the directory.
85.c.o:
86	@rm -f $@
87	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
88
89PSRC =	pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@
90FSRC =  @V_FINDALLDEVS@
91SSRC =  @SSRC@
92CSRC =	pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
93	fmtutils.c \
94	savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
95	bpf_image.c bpf_filter.c bpf_dump.c
96GENSRC = scanner.c grammar.c
97LIBOBJS = @LIBOBJS@
98
99SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
100
101# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
102# hack the extra indirection
103OBJ =	$(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
104PUBHDR = \
105	pcap.h \
106	pcap-bpf.h \
107	pcap-namedb.h \
108	pcap/bpf.h \
109	pcap/bluetooth.h \
110	pcap/can_socketcan.h \
111	pcap/compiler-tests.h \
112	pcap/dlt.h \
113	pcap/funcattrs.h \
114	pcap/pcap-inttypes.h \
115	pcap/ipnet.h \
116	pcap/namedb.h \
117	pcap/nflog.h \
118	pcap/pcap.h \
119	pcap/sll.h \
120	pcap/vlan.h \
121	pcap/usb.h
122
123HDR = $(PUBHDR) \
124	arcnet.h \
125	atmuni31.h \
126	diag-control.h \
127	ethertype.h \
128	extract.h \
129	fmtutils.h \
130	ftmacros.h \
131	gencode.h \
132	ieee80211.h \
133	llc.h \
134	nametoaddr.h \
135	nlpid.h \
136	optimize.h \
137	pcap-common.h \
138	pcap-int.h \
139	pcap-rpcap.h \
140	pcap-types.h \
141	portability.h \
142	ppp.h \
143	rpcap-protocol.h \
144	sf-pcap.h \
145	sf-pcapng.h \
146	sunatmpos.h \
147	varattrs.h
148
149GENHDR = \
150	scanner.h grammar.h
151
152TAGFILES = \
153	$(SRC) $(HDR)
154
155CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \
156	$(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
157	lex.yy.c pcap-config libpcap.pc
158
159MAN1 = pcap-config.1
160
161MAN3PCAP_EXPAND = \
162	pcap.3pcap.in \
163	pcap_compile.3pcap.in \
164	pcap_datalink.3pcap.in \
165	pcap_dump_open.3pcap.in \
166	pcap_get_tstamp_precision.3pcap.in \
167	pcap_list_datalinks.3pcap.in \
168	pcap_list_tstamp_types.3pcap.in \
169	pcap_open_dead.3pcap.in \
170	pcap_open_offline.3pcap.in \
171	pcap_set_tstamp_precision.3pcap.in \
172	pcap_set_tstamp_type.3pcap.in
173
174MAN3PCAP_NOEXPAND = \
175	pcap_activate.3pcap \
176	pcap_breakloop.3pcap \
177	pcap_can_set_rfmon.3pcap \
178	pcap_close.3pcap \
179	pcap_create.3pcap \
180	pcap_datalink_name_to_val.3pcap \
181	pcap_datalink_val_to_name.3pcap \
182	pcap_dump.3pcap \
183	pcap_dump_close.3pcap \
184	pcap_dump_file.3pcap \
185	pcap_dump_flush.3pcap \
186	pcap_dump_ftell.3pcap \
187	pcap_file.3pcap \
188	pcap_fileno.3pcap \
189	pcap_findalldevs.3pcap \
190	pcap_freecode.3pcap \
191	pcap_get_required_select_timeout.3pcap \
192	pcap_get_selectable_fd.3pcap \
193	pcap_geterr.3pcap \
194	pcap_inject.3pcap \
195	pcap_is_swapped.3pcap \
196	pcap_lib_version.3pcap \
197	pcap_lookupdev.3pcap \
198	pcap_lookupnet.3pcap \
199	pcap_loop.3pcap \
200	pcap_major_version.3pcap \
201	pcap_next_ex.3pcap \
202	pcap_offline_filter.3pcap \
203	pcap_open_live.3pcap \
204	pcap_set_buffer_size.3pcap \
205	pcap_set_datalink.3pcap \
206	pcap_set_immediate_mode.3pcap \
207	pcap_set_promisc.3pcap \
208	pcap_set_protocol_linux.3pcap \
209	pcap_set_rfmon.3pcap \
210	pcap_set_snaplen.3pcap \
211	pcap_set_timeout.3pcap \
212	pcap_setdirection.3pcap \
213	pcap_setfilter.3pcap \
214	pcap_setnonblock.3pcap \
215	pcap_snapshot.3pcap \
216	pcap_stats.3pcap \
217	pcap_statustostr.3pcap \
218	pcap_strerror.3pcap \
219	pcap_tstamp_type_name_to_val.3pcap \
220	pcap_tstamp_type_val_to_name.3pcap
221
222MAN3PCAP = $(MAN3PCAP_NOEXPAND) $(MAN3PCAP_EXPAND:.in=)
223
224MANFILE = \
225	pcap-savefile.manfile.in
226
227MANMISC = \
228	pcap-filter.manmisc.in \
229	pcap-linktype.manmisc.in \
230	pcap-tstamp.manmisc.in
231
232EXTRA_DIST = \
233	CHANGES \
234	ChmodBPF/ChmodBPF \
235	ChmodBPF/StartupParameters.plist \
236	CREDITS \
237	CMakeLists.txt \
238	INSTALL.md \
239	LICENSE \
240	Makefile.in \
241	Makefile-devel-adds \
242	README.md \
243	doc \
244	CONTRIBUTING.md \
245	TODO \
246	VERSION \
247	aclocal.m4 \
248	chmod_bpf \
249	cmake_uninstall.cmake.in \
250	cmakeconfig.h.in \
251	cmake/Modules/FindDAG.cmake \
252	cmake/Modules/FindFseeko.cmake \
253	cmake/Modules/FindLFS.cmake \
254	cmake/Modules/FindPacket.cmake \
255	cmake/Modules/FindSNF.cmake \
256	cmake/Modules/FindTC.cmake \
257	cmake/have_siocglifconf.c \
258	config.guess \
259	config.h.in \
260	config.sub \
261	configure \
262	configure.ac \
263	dlpisubs.c \
264	dlpisubs.h \
265	fad-getad.c \
266	fad-gifc.c \
267	fad-glifc.c \
268	grammar.y \
269	install-sh \
270	lbl/os-aix4.h \
271	lbl/os-aix7.h \
272	lbl/os-hpux11.h \
273	lbl/os-osf4.h \
274	lbl/os-osf5.h \
275	lbl/os-solaris2.h \
276	lbl/os-sunos4.h \
277	lbl/os-ultrix4.h \
278	libpcap.pc.in \
279	missing/getopt.c \
280	missing/getopt.h \
281	missing/snprintf.c \
282	missing/strtok_r.c \
283	missing/win_snprintf.c \
284	mkdep \
285	msdos/bin2c.c \
286	msdos/makefile \
287	msdos/makefile.dj \
288	msdos/makefile.wc \
289	msdos/pkt_rx0.asm \
290	msdos/pkt_rx1.s \
291	msdos/pktdrvr.c \
292	msdos/pktdrvr.h \
293	msdos/readme.dos \
294	nomkdep \
295	org.tcpdump.chmod_bpf.plist \
296	pcap-bpf.c \
297	pcap-bt-linux.c \
298	pcap-bt-linux.h \
299	pcap-bt-monitor-linux.c \
300	pcap-bt-monitor-linux.h \
301	pcap-config.in \
302	pcap-dag.c \
303	pcap-dag.h \
304	pcap-dbus.c \
305	pcap-dbus.h \
306	pcap-dll.rc \
307	pcap-dlpi.c \
308	pcap-dos.c \
309	pcap-dos.h \
310	pcap-enet.c \
311	pcap-int.h \
312	pcap-libdlpi.c \
313	pcap-linux.c \
314	pcap-namedb.h \
315	pcap-new.c \
316	pcap-netfilter-linux.c \
317	pcap-netfilter-linux.h \
318	pcap-netmap.c \
319	pcap-netmap.h \
320	pcap-nit.c \
321	pcap-npf.c \
322	pcap-null.c \
323	pcap-pf.c \
324	pcap-rdmasniff.c \
325	pcap-rdmasniff.h \
326	pcap-rpcap.c \
327	pcap-rpcap-int.h \
328	pcap-septel.c \
329	pcap-septel.h \
330	pcap-sita.h \
331	pcap-sita.c \
332	pcap-sita.html \
333	pcap-snf.c \
334	pcap-snf.h \
335	pcap-snit.c \
336	pcap-snoop.c \
337	pcap-tc.c \
338	pcap-tc.h \
339	pcap-usb-linux.c \
340	pcap-usb-linux.h \
341	rpcap-protocol.c \
342	rpcapd/CMakeLists.txt \
343	rpcapd/Makefile.in \
344	rpcapd/config_params.h \
345	rpcapd/daemon.h \
346	rpcapd/daemon.c \
347	rpcapd/fileconf.c \
348	rpcapd/fileconf.h \
349	rpcapd/log.h \
350	rpcapd/log-stderr.c \
351	rpcapd/org.tcpdump.rpcapd.plist \
352	rpcapd/rpcapd.c \
353	rpcapd/rpcapd.h \
354	rpcapd/rpcapd.inetd.conf \
355	rpcapd/rpcapd.manadmin.in \
356	rpcapd/rpcapd.rc \
357	rpcapd/rpcapd.socket \
358	rpcapd/rpcapd.xinetd.conf \
359	rpcapd/rpcapd@.service \
360	rpcapd/win32-svc.c \
361	rpcapd/win32-svc.h \
362	sockutils.c \
363	sockutils.h \
364	scanner.l \
365	testprogs/CMakeLists.txt \
366	testprogs/Makefile.in \
367	testprogs/can_set_rfmon_test.c \
368	testprogs/capturetest.c \
369	testprogs/filtertest.c \
370	testprogs/findalldevstest.c \
371	testprogs/opentest.c \
372	testprogs/reactivatetest.c \
373	testprogs/selpolltest.c \
374	testprogs/threadsignaltest.c \
375	testprogs/unix.h \
376	testprogs/valgrindtest.c \
377	tests/shb-option-too-long.pcapng \
378	Win32/Prj/wpcap.sln \
379	Win32/Prj/wpcap.vcxproj \
380	Win32/Prj/wpcap.vcxproj.filters
381
382all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config
383
384libpcap.a: $(OBJ)
385	@rm -f $@
386	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
387	$(RANLIB) $@
388
389shared: libpcap.$(DYEXT)
390
391libpcap.so: $(OBJ)
392	@rm -f $@
393	VER=`cat $(srcdir)/VERSION`; \
394	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
395	@V_SHLIB_CMD@ $(LDFLAGS) @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER \
396	    -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
397
398#
399# The following rule succeeds, but the result is untested.
400#
401# In macOS, the libpcap dylib has the name "libpcap.A.dylib", with its
402# full path as the install_name, and with the compatibility and current
403# version both set to 1.  The compatibility version is set to 1 so that
404# programs built with a newer version of the library will run against
405# older versions if they don't use APIs available in the newer version
406# but not in the older version.
407#
408# We also use "A" as the major version, and 1 as the compatibility version,
409# but set the current version to the value in VERSION, with any non-numeric
410# stuff stripped off (the compatibility and current version must be of the
411# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
412# numeric).
413#
414libpcap.dylib: $(OBJ)
415	rm -f libpcap*.dylib
416	VER=`cat $(srcdir)/VERSION`; \
417	MAJOR_VER=A; \
418	COMPAT_VER=1; \
419	CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
420	$(CC) -dynamiclib -undefined error $(LDFLAGS) \
421	    -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
422	    -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
423	    -compatibility_version $$COMPAT_VER \
424	    -current_version $$CURRENT_VER
425
426#
427# The HP-UX linker manual says that the convention for a versioned library
428# is libXXX.{number}, not libXXX.sl.{number}.  That appears to be the case
429# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
430# libXXX.{number}.
431#
432# The manual also says "library-level versioning" (think "sonames") was
433# added in HP-UX 10.0.
434#
435# XXX - this assumes we're using the HP linker, rather than the GNU
436# linker, even with GCC.
437#
438libpcap.sl: $(OBJ)
439	@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
440	rm -f libpcap.$$MAJOR_VER
441	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
442	ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
443	    $(OBJ) $(ADDLOBJS) $(LIBS)
444
445#
446# AIX is different from everybody else.  A shared library is an archive
447# library with one or more shared-object components.  We still build a
448# normal static archive library on AIX, for the benefit of the traditional
449# scheme of building libpcap and tcpdump in subdirectories of the
450# same directory, with tcpdump statically linked with the libpcap
451# in question, but we also build a shared library as "libpcap.shareda"
452# and install *it*, rather than the static library, as "libpcap.a".
453#
454libpcap.shareda: $(OBJ)
455	@rm -f $@ shr.o
456	$(CC) $(LDFLAGS) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LIBS)
457	$(AR) rc $@ shr.o
458
459#
460# For platforms that don't support shared libraries (or on which we
461# don't support shared libraries).
462#
463libpcap.none:
464
465scanner.c: $(srcdir)/scanner.l
466	$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
467scanner.h: scanner.c
468## Recover from the removal of $@
469	@if test -f $@; then :; else \
470		rm -f scanner.c; \
471		$(MAKE) $(MAKEFLAGS) scanner.c; \
472	fi
473
474scanner.o: scanner.c grammar.h
475	$(CC) $(FULL_CFLAGS) -c scanner.c
476
477grammar.c: $(srcdir)/grammar.y
478	$(YACC) -p pcap_ -o grammar.c -d $<
479grammar.h: grammar.c
480## Recover from the removal of $@
481	@if test -f $@; then :; else \
482		rm -f grammar.c; \
483		$(MAKE) $(MAKEFLAGS) grammar.c; \
484	fi
485
486grammar.o: grammar.c scanner.h
487	$(CC) $(FULL_CFLAGS) -c grammar.c
488
489gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
490	$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
491
492snprintf.o: $(srcdir)/missing/snprintf.c
493	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
494
495strtok_r.o: $(srcdir)/missing/strtok_r.c
496	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
497
498#
499# Generate the libpcap.pc file.
500#
501# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
502# for example, the Solaris 9 make man page says
503#
504#	Because make assigns $< and $* as it would for implicit rules
505#	(according to the suffixes list and the directory contents),
506#	they may be unreliable when used within explicit target entries.
507#
508# and this is an explicit target entry.
509#
510# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in.
511#
512libpcap.pc: $(srcdir)/libpcap.pc.in ./config.status
513	@rm -f $@ $@.tmp
514	./config.status --file=$@.tmp:$(srcdir)/libpcap.pc.in
515	mv $@.tmp $@
516	chmod a+x $@
517
518#
519# Generate the pcap-config script.  See above.
520#
521pcap-config: $(srcdir)/pcap-config.in ./config.status
522	@rm -f $@ $@.tmp
523	./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
524	mv $@.tmp $@
525	chmod a+x $@
526
527#
528# Remote pcap daemon.
529#
530build-rpcapd: libpcap.a
531	cd rpcapd; $(MAKE)
532
533#
534# Test programs - not built by default, and not installed.
535#
536testprogs: FORCE
537	cd testprogs; $(MAKE)
538
539FORCE:
540
541install: install-shared install-archive libpcap.pc pcap-config @INSTALL_RPCAPD@
542	[ -d $(DESTDIR)$(libdir) ] || \
543	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
544	[ -d $(DESTDIR)$(includedir) ] || \
545	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
546	[ -d $(DESTDIR)$(includedir)/pcap ] || \
547	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
548	[ -d $(DESTDIR)$(mandir)/man1 ] || \
549	    (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
550	[ -d $(DESTDIR)$(mandir)/man3 ] || \
551	    (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
552	[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
553	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
554	[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
555	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
556	for i in $(PUBHDR); do \
557		$(INSTALL_DATA) $(srcdir)/$$i \
558		    $(DESTDIR)$(includedir)/$$i; done
559	[ -d $(DESTDIR)$(bindir) ] || \
560	    (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
561	$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
562	[ -d $(DESTDIR)$(libdir)/pkgconfig ] || \
563	    (mkdir -p $(DESTDIR)$(libdir)/pkgconfig; chmod 755 $(DESTDIR)$(libdir)/pkgconfig)
564	$(INSTALL_DATA) libpcap.pc $(DESTDIR)$(libdir)/pkgconfig/libpcap.pc
565	for i in $(MAN1); do \
566		$(INSTALL_DATA) $(srcdir)/$$i \
567		    $(DESTDIR)$(mandir)/man1/$$i; done
568	for i in $(MAN3PCAP_NOEXPAND); do \
569		$(INSTALL_DATA) $(srcdir)/$$i \
570		    $(DESTDIR)$(mandir)/man3/$$i; done
571	for i in $(MAN3PCAP_EXPAND:.in=); do \
572		$(INSTALL_DATA) $$i \
573		    $(DESTDIR)$(mandir)/man3/$$i; done
574	(cd $(DESTDIR)$(mandir)/man3 && \
575	rm -f pcap_datalink_val_to_description.3pcap && \
576	$(LN_S) pcap_datalink_val_to_name.3pcap \
577		 pcap_datalink_val_to_description.3pcap && \
578	rm -f pcap_dump_fopen.3pcap && \
579	$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
580	rm -f pcap_freealldevs.3pcap && \
581	$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
582	rm -f pcap_perror.3pcap && \
583	$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
584	rm -f pcap_sendpacket.3pcap && \
585	$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
586	rm -f pcap_free_datalinks.3pcap && \
587	$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
588	rm -f pcap_free_tstamp_types.3pcap && \
589	$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
590	rm -f pcap_dispatch.3pcap && \
591	$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
592	rm -f pcap_minor_version.3pcap && \
593	$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
594	rm -f pcap_next.3pcap && \
595	$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
596	rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
597	$(LN_S) pcap_open_dead.3pcap \
598		 pcap_open_dead_with_tstamp_precision.3pcap && \
599	rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
600	$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
601	rm -f pcap_fopen_offline.3pcap && \
602	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
603	rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
604	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
605	rm -f pcap_tstamp_type_val_to_description.3pcap && \
606	$(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \
607	rm -f pcap_getnonblock.3pcap && \
608	$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
609	for i in $(MANFILE); do \
610		$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
611		    $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
612	for i in $(MANMISC); do \
613		$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
614		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
615
616install-shared: install-shared-$(DYEXT)
617install-shared-so: libpcap.so
618	[ -d $(DESTDIR)$(libdir) ] || \
619	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
620	VER=`cat $(srcdir)/VERSION`; \
621	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
622	$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
623	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
624	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
625install-shared-dylib: libpcap.dylib
626	[ -d $(DESTDIR)$(libdir) ] || \
627	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
628	VER=`cat $(srcdir)/VERSION`; \
629	MAJOR_VER=A; \
630	$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
631	ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
632	ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
633install-shared-sl: libpcap.sl
634	[ -d $(DESTDIR)$(libdir) ] || \
635	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
636	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
637	$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
638	ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
639install-shared-shareda: libpcap.shareda
640	#
641	# AIX shared libraries are weird.  They're archive libraries
642	# with one or more shared object components.
643	#
644	[ -d $(DESTDIR)$(libdir) ] || \
645	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
646	$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
647install-shared-none:
648
649install-archive: install-archive-$(DYEXT)
650install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
651	#
652	# Most platforms have separate suffixes for shared and
653	# archive libraries, so we install both.
654	#
655	[ -d $(DESTDIR)$(libdir) ] || \
656	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
657	$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
658	$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
659install-archive-shareda:
660	#
661	# AIX, however, doesn't, so we don't install the archive
662	# library on AIX.
663	#
664
665install-rpcapd:
666	cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install
667
668uninstall: uninstall-shared uninstall-rpcapd
669	rm -f $(DESTDIR)$(libdir)/libpcap.a
670	for i in $(PUBHDR); do \
671		rm -f $(DESTDIR)$(includedir)/$$i; done
672	-rmdir $(DESTDIR)$(includedir)/pcap
673	rm -f $(DESTDIR)/$(libdir)/pkgconfig/libpcap.pc
674	rm -f $(DESTDIR)/$(bindir)/pcap-config
675	for i in $(MAN1); do \
676		rm -f $(DESTDIR)$(mandir)/man1/$$i; done
677	for i in $(MAN3PCAP); do \
678		rm -f $(DESTDIR)$(mandir)/man3/$$i; done
679	rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
680	rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
681	rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
682	rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
683	rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
684	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
685	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
686	rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
687	rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
688	rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
689	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
690	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
691	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
692	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
693	rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
694	rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.3pcap
695	for i in $(MANFILE); do \
696		rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
697	for i in $(MANMISC); do \
698		rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
699
700uninstall-shared: uninstall-shared-$(DYEXT)
701uninstall-shared-so:
702	VER=`cat $(srcdir)/VERSION`; \
703	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
704	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
705	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
706	rm -f $(DESTDIR)$(libdir)/libpcap.so
707uninstall-shared-dylib:
708	VER=`cat $(srcdir)/VERSION`; \
709	MAJOR_VER=A; \
710	rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
711	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
712	rm -f $(DESTDIR)$(libdir)/libpcap.dylib
713uninstall-shared-sl:
714	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
715	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
716	rm -f $(DESTDIR)$(libdir)/libpcap.sl
717uninstall-shared-shareda:
718	rm -f $(DESTDIR)$(libdir)/libpcap.a
719uninstall-shared-none:
720
721uninstall-rpcapd:
722	cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall
723
724clean:
725	rm -f $(CLEANFILES)
726	cd rpcapd; $(MAKE) clean
727	cd testprogs; $(MAKE) clean
728
729distclean: clean
730	rm -f Makefile config.cache config.log config.status \
731	    config.h gnuc.h net os-proto.h libpcap.pc \
732	    pcap-config stamp-h stamp-h.in
733	rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
734	rm -rf autom4te.cache
735	cd rpcapd; $(MAKE) distclean
736	cd testprogs; $(MAKE) distclean
737
738extags: $(TAGFILES)
739	ctags $(TAGFILES)
740
741tags: $(TAGFILES)
742	ctags -wtd $(TAGFILES)
743
744releasetar:
745	@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
746	   mkdir $$name; \
747	   tar -c --exclude='*~' -f - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
748	      $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
749	      (cd $$name; tar xf -); \
750	   tar -c -z -f $$name.tar.gz $$name; \
751	   rm -rf $$name
752
753depend:	$(GENSRC) $(GENHDR)
754	$(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC)
755	cd rpcapd; $(MAKE) depend
756	cd testprogs; $(MAKE) depend
757