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