xref: /src/contrib/libpcap/Makefile.in (revision 16cef5f7a65588def71db4fdfa961f959847e3b6)
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@
64RPATH = @RPATH@
65DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
66PROG=libpcap
67PTHREAD_LIBS=@PTHREAD_LIBS@
68BUILD_RPCAPD=@BUILD_RPCAPD@
69INSTALL_RPCAPD=@INSTALL_RPCAPD@
70
71# Standard CFLAGS for building members of a shared library
72FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
73
74INSTALL = @INSTALL@
75INSTALL_PROGRAM = @INSTALL_PROGRAM@
76INSTALL_DATA = @INSTALL_DATA@
77RANLIB = @RANLIB@
78
79LEX = @LEX@
80BISON_BYACC = @BISON_BYACC@
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
89PLATFORM_C_SRC =	@PLATFORM_C_SRC@
90MODULE_C_SRC =		@MODULE_C_SRC@
91REMOTE_C_SRC =		@REMOTE_C_SRC@
92COMMON_C_SRC =	pcap.c gencode.c optimize.c nametoaddr.c etherent.c \
93		fmtutils.c pcap-util.c \
94		savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \
95		bpf_image.c bpf_filter.c bpf_dump.c
96GENERATED_C_SRC = scanner.c grammar.c
97LIBOBJS = @LIBOBJS@
98
99SRC =	$(PLATFORM_C_SRC) \
100	$(MODULE_C_SRC) $(REMOTE_C_SRC) $(COMMON_C_SRC) \
101	$(GENERATED_C_SRC)
102
103# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
104# hack the extra indirection
105OBJ =	$(PLATFORM_C_SRC:.c=.o) \
106	$(MODULE_C_SRC:.c=.o) $(REMOTE_C_SRC:.c=.o) $(COMMON_C_SRC:.c=.o) \
107	$(GENERATED_C_SRC:.c=.o) \
108	$(LIBOBJS)
109
110PUBHDR = \
111	pcap.h \
112	pcap-bpf.h \
113	pcap-namedb.h \
114	pcap/bluetooth.h \
115	pcap/bpf.h \
116	pcap/can_socketcan.h \
117	pcap/compiler-tests.h \
118	pcap/dlt.h \
119	pcap/funcattrs.h \
120	pcap/ipnet.h \
121	pcap/namedb.h \
122	pcap/nflog.h \
123	pcap/pcap-inttypes.h \
124	pcap/pcap.h \
125	pcap/sll.h \
126	pcap/socket.h \
127	pcap/usb.h \
128	pcap/vlan.h
129
130HDR = $(PUBHDR) \
131	arcnet.h \
132	atmuni31.h \
133	diag-control.h \
134	ethertype.h \
135	extract.h \
136	fmtutils.h \
137	ftmacros.h \
138	gencode.h \
139	ieee80211.h \
140	llc.h \
141	nametoaddr.h \
142	nlpid.h \
143	optimize.h \
144	pcap-common.h \
145	pcap-int.h \
146	pcap-rpcap.h \
147	pcap-types.h \
148	pcap-usb-linux-common.h \
149	pcap-util.h \
150	pflog.h \
151	portability.h \
152	ppp.h \
153	rpcap-protocol.h \
154	sf-pcap.h \
155	sf-pcapng.h \
156	sunatmpos.h \
157	thread-local.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 libpcap.$(DYEXT)
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/README.aix \
256	doc/README.dag \
257	doc/README.haiku.md \
258	doc/README.hpux \
259	doc/README.linux \
260	doc/README.macos \
261	doc/README.septel \
262	doc/README.sita \
263	doc/README.solaris.md \
264	doc/README.windows.md \
265	CONTRIBUTING.md \
266	TODO \
267	VERSION \
268	aclocal.m4 \
269	autogen.sh \
270	charconv.c \
271	charconv.h \
272	chmod_bpf \
273	cmake_uninstall.cmake.in \
274	cmakeconfig.h.in \
275	cmake/Modules/FindAirPcap.cmake \
276	cmake/Modules/FindDAG.cmake \
277	cmake/Modules/Finddpdk.cmake \
278	cmake/Modules/FindFseeko.cmake \
279	cmake/Modules/FindLFS.cmake \
280	cmake/Modules/FindPacket.cmake \
281	cmake/Modules/FindSNF.cmake \
282	cmake/Modules/FindTC.cmake \
283	cmake/have_siocglifconf.c \
284	config.guess \
285	config.sub \
286	configure.ac \
287	dlpisubs.c \
288	dlpisubs.h \
289	fad-getad.c \
290	fad-gifc.c \
291	fad-glifc.c \
292	grammar.y.in \
293	install-sh \
294	instrument-functions.c \
295	lbl/os-aix4.h \
296	lbl/os-aix7.h \
297	lbl/os-hpux11.h \
298	lbl/os-osf4.h \
299	lbl/os-osf5.h \
300	lbl/os-solaris2.h \
301	lbl/os-sunos4.h \
302	lbl/os-ultrix4.h \
303	libpcap.pc.in \
304	missing/asprintf.c \
305	missing/getopt.c \
306	missing/getopt.h \
307	missing/strlcat.c \
308	missing/strlcpy.c \
309	missing/strtok_r.c \
310	missing/win_asprintf.c \
311	mkdep \
312	msdos/bin2c.c \
313	msdos/makefile \
314	msdos/makefile.dj \
315	msdos/makefile.wc \
316	msdos/pkt_rx0.asm \
317	msdos/pkt_rx1.s \
318	msdos/pktdrvr.c \
319	msdos/pktdrvr.h \
320	msdos/readme.dos \
321	nomkdep \
322	org.tcpdump.chmod_bpf.plist \
323	pcap-airpcap.c \
324	pcap-airpcap.h \
325	pcap-bpf.c \
326	pcap-bt-linux.c \
327	pcap-bt-linux.h \
328	pcap-bt-monitor-linux.c \
329	pcap-bt-monitor-linux.h \
330	pcap-config.in \
331	pcap-dag.c \
332	pcap-dag.h \
333	pcap-dbus.c \
334	pcap-dbus.h \
335	pcap-dll.rc \
336	pcap-dlpi.c \
337	pcap-dos.c \
338	pcap-dos.h \
339	pcap-dpdk.c \
340	pcap-dpdk.h \
341	pcap-enet.c \
342	pcap-haiku.c \
343	pcap-int.h \
344	pcap-libdlpi.c \
345	pcap-linux.c \
346	pcap-namedb.h \
347	pcap-new.c \
348	pcap-netfilter-linux.c \
349	pcap-netfilter-linux.h \
350	pcap-netmap.c \
351	pcap-netmap.h \
352	pcap-nit.c \
353	pcap-npf.c \
354	pcap-null.c \
355	pcap-pf.c \
356	pcap-rdmasniff.c \
357	pcap-rdmasniff.h \
358	pcap-rpcap.c \
359	pcap-septel.c \
360	pcap-septel.h \
361	pcap-sita.h \
362	pcap-sita.c \
363	pcap-sita.html \
364	pcap-snf.c \
365	pcap-snf.h \
366	pcap-snit.c \
367	pcap-snoop.c \
368	pcap-tc.c \
369	pcap-tc.h \
370	pcap-usb-linux.c \
371	pcap-usb-linux.h \
372	rpcap-protocol.c \
373	rpcapd/CMakeLists.txt \
374	rpcapd/Makefile.in \
375	rpcapd/config_params.h \
376	rpcapd/daemon.h \
377	rpcapd/daemon.c \
378	rpcapd/fileconf.c \
379	rpcapd/fileconf.h \
380	rpcapd/log.h \
381	rpcapd/log.c \
382	rpcapd/org.tcpdump.rpcapd.plist \
383	rpcapd/rpcapd.c \
384	rpcapd/rpcapd.h \
385	rpcapd/rpcapd.inetd.conf \
386	rpcapd/rpcapd.manadmin.in \
387	rpcapd/rpcapd-config.manfile.in \
388	rpcapd/rpcapd.rc \
389	rpcapd/rpcapd.socket \
390	rpcapd/rpcapd.xinetd.conf \
391	rpcapd/rpcapd@.service \
392	rpcapd/win32-svc.c \
393	rpcapd/win32-svc.h \
394	sockutils.c \
395	sockutils.h \
396	sslutils.c \
397	sslutils.h \
398	scanner.l \
399	testprogs/CMakeLists.txt \
400	testprogs/Makefile.in \
401	testprogs/can_set_rfmon_test.c \
402	testprogs/capturetest.c \
403	testprogs/filtertest.c \
404	testprogs/findalldevstest.c \
405	testprogs/findalldevstest-perf.c \
406	testprogs/nonblocktest.c \
407	testprogs/opentest.c \
408	testprogs/reactivatetest.c \
409	testprogs/selpolltest.c \
410	testprogs/threadsignaltest.c \
411	testprogs/unix.h \
412	testprogs/valgrindtest.c \
413	testprogs/versiontest.c \
414	testprogs/visopts.py \
415	testprogs/writecaptest.c
416
417TEST_DIST = `git -C "$$DIR" ls-files tests | grep -v 'tests/\..*'`
418
419RELEASE_FILES = $(COMMON_C_SRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
420	$(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) \
421	$(TEST_DIST)
422
423all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config
424
425libpcap.a: $(OBJ)
426	@rm -f $@
427	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
428	$(RANLIB) $@
429
430shared: libpcap.$(DYEXT)
431
432libpcap.so: $(OBJ)
433	@rm -f $@
434	VER=`cat $(srcdir)/VERSION`; \
435	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
436	@V_SHLIB_CMD@ $(LDFLAGS) @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER \
437	    -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
438
439#
440# The following rule succeeds, but the result is untested.
441#
442# In macOS, the libpcap dylib has the name "libpcap.A.dylib", with its
443# full path as the install_name, and with the compatibility and current
444# version both set to 1.  The compatibility version is set to 1 so that
445# programs built with a newer version of the library will run against
446# older versions if they don't use APIs available in the newer version
447# but not in the older version.
448#
449# We also use "A" as the major version, and 1 as the compatibility version,
450# but set the current version to the value in VERSION, with any non-numeric
451# stuff stripped off (the compatibility and current version must be of the
452# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
453# numeric).
454#
455libpcap.dylib: $(OBJ)
456	rm -f libpcap*.dylib
457	VER=`cat $(srcdir)/VERSION`; \
458	MAJOR_VER=A; \
459	COMPAT_VER=1; \
460	CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
461	$(CC) -dynamiclib -undefined error $(LDFLAGS) @V_LIB_LDFLAGS_FAT@ \
462	    -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
463	    -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
464	    -compatibility_version $$COMPAT_VER \
465	    -current_version $$CURRENT_VER
466
467#
468# The HP-UX linker manual says that the convention for a versioned library
469# is libXXX.{number}, not libXXX.sl.{number}.  That appears to be the case
470# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
471# libXXX.{number}.
472#
473# The manual also says "library-level versioning" (think "sonames") was
474# added in HP-UX 10.0.
475#
476# XXX - this assumes we're using the HP linker, rather than the GNU
477# linker, even with GCC.
478#
479libpcap.sl: $(OBJ)
480	@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
481	rm -f libpcap.$$MAJOR_VER
482	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
483	ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
484	    $(OBJ) $(ADDLOBJS) $(LIBS)
485
486#
487# AIX is different from everybody else.  A shared library is an archive
488# library with one or more shared-object components.  We still build a
489# normal static archive library on AIX, for the benefit of the traditional
490# scheme of building libpcap and tcpdump in subdirectories of the
491# same directory, with tcpdump statically linked with the libpcap
492# in question, but we also build a shared library as "libpcap.shareda"
493# and install *it*, rather than the static library, as "libpcap.a".
494#
495libpcap.shareda: $(OBJ)
496	@rm -f $@ shr.o
497	$(CC) $(LDFLAGS) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LIBS)
498	$(AR) rc $@ shr.o
499
500#
501# For platforms that don't support shared libraries (or on which we
502# don't support shared libraries).
503#
504libpcap.none:
505
506scanner.c: $(srcdir)/scanner.l
507	$(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
508scanner.h: scanner.c
509## Recover from the removal of $@
510	@if test -f $@; then :; else \
511		rm -f scanner.c; \
512		$(MAKE) $(MAKEFLAGS) scanner.c; \
513	fi
514
515scanner.o: scanner.c grammar.h
516	$(CC) $(FULL_CFLAGS) -c scanner.c
517
518#
519# Generate the grammar.y file.
520#
521# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
522# for example, the Solaris 9 make man page says
523#
524#	Because make assigns $< and $* as it would for implicit rules
525#	(according to the suffixes list and the directory contents),
526#	they may be unreliable when used within explicit target entries.
527#
528# and this is an explicit target entry.
529#
530# Therefore, instead of using $<, we explicitly put in $(srcdir)/grammar.y.in.
531#
532grammar.y: $(srcdir)/grammar.y.in ./config.status
533	@rm -f $@ $@.tmp
534	./config.status --file=$@.tmp:$(srcdir)/grammar.y.in
535	mv $@.tmp $@
536
537grammar.c: grammar.y
538	$(BISON_BYACC) -p pcap_ -o grammar.c -d $<
539grammar.h: grammar.c
540## Recover from the removal of $@
541	@if test -f $@; then :; else \
542		rm -f grammar.c; \
543		$(MAKE) $(MAKEFLAGS) grammar.c; \
544	fi
545
546grammar.o: grammar.c scanner.h
547	$(CC) $(FULL_CFLAGS) -c grammar.c
548
549gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
550	$(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
551
552asprintf.o: $(srcdir)/missing/asprintf.c
553	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/asprintf.c
554
555snprintf.o: $(srcdir)/missing/snprintf.c
556	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
557
558strlcat.o: $(srcdir)/missing/strlcat.c
559	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
560
561strlcpy.o: $(srcdir)/missing/strlcpy.c
562	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
563
564strtok_r.o: $(srcdir)/missing/strtok_r.c
565	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
566
567#
568# Generate the libpcap.pc file.
569#
570# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
571# for example, the Solaris 9 make man page says
572#
573#	Because make assigns $< and $* as it would for implicit rules
574#	(according to the suffixes list and the directory contents),
575#	they may be unreliable when used within explicit target entries.
576#
577# and this is an explicit target entry.
578#
579# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in.
580#
581libpcap.pc: $(srcdir)/libpcap.pc.in ./config.status
582	@rm -f $@ $@.tmp
583	./config.status --file=$@.tmp:$(srcdir)/libpcap.pc.in
584	mv $@.tmp $@
585
586#
587# Generate the pcap-config script.  See above.
588#
589pcap-config: $(srcdir)/pcap-config.in ./config.status
590	@rm -f $@ $@.tmp
591	./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
592	mv $@.tmp $@
593	chmod a+x $@
594
595#
596# Remote pcap daemon.
597#
598build-rpcapd: libpcap.a
599	(cd rpcapd; $(MAKE))
600
601#
602# Test programs - not built by default, and not installed.
603#
604testprogs: FORCE libpcap.a
605	(cd testprogs; $(MAKE) CFLAGS="$(CFLAGS)")
606
607FORCE:
608
609install: install-shared install-archive libpcap.pc pcap-config @INSTALL_RPCAPD@
610	[ -d $(DESTDIR)$(libdir) ] || \
611	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
612	[ -d $(DESTDIR)$(includedir) ] || \
613	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
614	[ -d $(DESTDIR)$(includedir)/pcap ] || \
615	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
616	[ -d $(DESTDIR)$(mandir)/man1 ] || \
617	    (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
618	[ -d $(DESTDIR)$(mandir)/man3 ] || \
619	    (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
620	[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
621	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
622	[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
623	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
624	for i in $(PUBHDR); do \
625		$(INSTALL_DATA) $(srcdir)/$$i \
626		    $(DESTDIR)$(includedir)/$$i; done
627	[ -d $(DESTDIR)$(bindir) ] || \
628	    (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
629	$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
630	[ -d $(DESTDIR)$(libdir)/pkgconfig ] || \
631	    (mkdir -p $(DESTDIR)$(libdir)/pkgconfig; chmod 755 $(DESTDIR)$(libdir)/pkgconfig)
632	$(INSTALL_DATA) libpcap.pc $(DESTDIR)$(libdir)/pkgconfig/libpcap.pc
633	for i in $(MAN1); do \
634		$(INSTALL_DATA) $(srcdir)/$$i \
635		    $(DESTDIR)$(mandir)/man1/$$i; done
636	for i in $(MAN3PCAP_NOEXPAND); do \
637		$(INSTALL_DATA) $(srcdir)/$$i \
638		    $(DESTDIR)$(mandir)/man3/$$i; done
639	for i in $(MAN3PCAP_EXPAND:.in=); do \
640		$(INSTALL_DATA) $$i \
641		    $(DESTDIR)$(mandir)/man3/$$i; done
642	(cd $(DESTDIR)$(mandir)/man3 && \
643	rm -f pcap_datalink_val_to_description.3pcap && \
644	$(LN_S) pcap_datalink_val_to_name.3pcap \
645		 pcap_datalink_val_to_description.3pcap && \
646	rm -f pcap_datalink_val_to_description_or_dlt.3pcap && \
647	$(LN_S) pcap_datalink_val_to_name.3pcap \
648		 pcap_datalink_val_to_description_or_dlt.3pcap && \
649	rm -f pcap_dump_fopen.3pcap && \
650	$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
651	rm -f pcap_freealldevs.3pcap && \
652	$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
653	rm -f pcap_perror.3pcap && \
654	$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
655	rm -f pcap_sendpacket.3pcap && \
656	$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
657	rm -f pcap_free_datalinks.3pcap && \
658	$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
659	rm -f pcap_free_tstamp_types.3pcap && \
660	$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
661	rm -f pcap_dispatch.3pcap && \
662	$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
663	rm -f pcap_minor_version.3pcap && \
664	$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
665	rm -f pcap_next.3pcap && \
666	$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
667	rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
668	$(LN_S) pcap_open_dead.3pcap \
669		 pcap_open_dead_with_tstamp_precision.3pcap && \
670	rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
671	$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
672	rm -f pcap_fopen_offline.3pcap && \
673	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
674	rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
675	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
676	rm -f pcap_tstamp_type_val_to_description.3pcap && \
677	$(LN_S) pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap && \
678	rm -f pcap_getnonblock.3pcap && \
679	$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
680	for i in $(MANFILE); do \
681		$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
682		    $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
683	for i in $(MANMISC); do \
684		$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
685		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
686
687install-shared: install-shared-$(DYEXT)
688install-shared-so: libpcap.so
689	[ -d $(DESTDIR)$(libdir) ] || \
690	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
691	VER=`cat $(srcdir)/VERSION`; \
692	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
693	$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
694	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
695	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
696install-shared-dylib: libpcap.dylib
697	[ -d $(DESTDIR)$(libdir) ] || \
698	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
699	VER=`cat $(srcdir)/VERSION`; \
700	MAJOR_VER=A; \
701	$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
702	ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
703	ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
704install-shared-sl: libpcap.sl
705	[ -d $(DESTDIR)$(libdir) ] || \
706	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
707	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
708	$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
709	ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
710#
711# AIX shared libraries are weird.  They're archive libraries
712# with one or more shared object components.
713#
714install-shared-shareda: libpcap.shareda
715	[ -d $(DESTDIR)$(libdir) ] || \
716	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
717	$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
718install-shared-none:
719
720install-archive: install-archive-$(DYEXT)
721#
722# Most platforms have separate suffixes for shared and
723# archive libraries, so we install both.
724#
725install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
726	[ -d $(DESTDIR)$(libdir) ] || \
727	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
728	$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
729	$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
730#
731# AIX, however, doesn't, so we don't install the archive
732# library on AIX.
733#
734install-archive-shareda:
735
736install-rpcapd:
737	(cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install)
738
739uninstall: uninstall-shared uninstall-rpcapd
740	rm -f $(DESTDIR)$(libdir)/libpcap.a
741	for i in $(PUBHDR); do \
742		rm -f $(DESTDIR)$(includedir)/$$i; done
743	-rmdir $(DESTDIR)$(includedir)/pcap
744	rm -f $(DESTDIR)/$(libdir)/pkgconfig/libpcap.pc
745	rm -f $(DESTDIR)/$(bindir)/pcap-config
746	for i in $(MAN1); do \
747		rm -f $(DESTDIR)$(mandir)/man1/$$i; done
748	for i in $(MAN3PCAP); do \
749		rm -f $(DESTDIR)$(mandir)/man3/$$i; done
750	rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
751	rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description_or_dlt.3pcap
752	rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
753	rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
754	rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
755	rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
756	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
757	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
758	rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
759	rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
760	rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
761	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
762	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
763	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
764	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
765	rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
766	rm -f $(DESTDIR)$(mandir)/man3/pcap_tstamp_type_val_to_description.3pcap
767	for i in $(MANFILE); do \
768		rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
769	for i in $(MANMISC); do \
770		rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
771
772uninstall-shared: uninstall-shared-$(DYEXT)
773uninstall-shared-so:
774	VER=`cat $(srcdir)/VERSION`; \
775	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
776	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
777	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
778	rm -f $(DESTDIR)$(libdir)/libpcap.so
779uninstall-shared-dylib:
780	VER=`cat $(srcdir)/VERSION`; \
781	MAJOR_VER=A; \
782	rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
783	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
784	rm -f $(DESTDIR)$(libdir)/libpcap.dylib
785uninstall-shared-sl:
786	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
787	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
788	rm -f $(DESTDIR)$(libdir)/libpcap.sl
789uninstall-shared-shareda:
790	rm -f $(DESTDIR)$(libdir)/libpcap.a
791uninstall-shared-none:
792
793uninstall-rpcapd:
794	(cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall)
795
796clean:
797	rm -f $(CLEANFILES) config.h.in~ configure~ configure.ac~
798	(cd rpcapd; $(MAKE) clean)
799	(cd testprogs; $(MAKE) clean)
800
801distclean: clean
802	rm -f Makefile grammar.y config.cache config.log config.status \
803	    config.h os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in
804	rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
805	rm -rf autom4te.cache
806	(cd rpcapd; $(MAKE) distclean)
807	(cd testprogs; $(MAKE) distclean)
808
809extags: $(TAGFILES)
810	ctags $(TAGFILES)
811
812tags: $(TAGFILES)
813	ctags -wtd $(TAGFILES)
814
815#
816# Use git archive piped to tar to construct a subdirectory whose name
817# is libpcap-{release}, containing all the checked-in source files,
818# and then run autoreconf in that directory to generate the configure
819# script and other files from that source. Then remove autom4te.cache,
820# construct the release tarball from that subdirectory, and remove
821# the subdirectory.
822#
823# The --format=tar is to force git archive to write a non-compressed
824# archive, in case the platform's tar command doesn't have built-in
825# decompression.
826#
827# The ^{tree} is there to force git archive not to write out the
828# "helpful" global extended pax header with a commit ID, as not all
829# versions of tar can handle that (Solaris tar can't, for example).
830# (It turns HEAD, or a tag, both of which are apparently "tree-ish"es,
831# into a tree; apparently, unlike HEAD, or a tag, which have a commit
832# ID associated with them, the tree associated with them doesn't have
833# a commit ID, so no commit ID is available to write, and thus
834# git archive doesn't write one.)
835#
836releasetar:
837	@TAG=$(PROG)-`cat VERSION` && \
838	if [ ! -d .git ]; then echo 'Not in a git clone, stop.'; exit 1; fi && \
839	TMPTESTFILE=`mktemp -t tmptestfile_XXXXXXXX` && \
840	rm -f "$$TMPTESTFILE" && \
841	AUTORECONF_DIR=`dirname "$$TMPTESTFILE"`/"$(PROG)"_build_autoreconf_$$$$ && \
842	DIR=`pwd` && \
843	rm -rf "$$AUTORECONF_DIR" && \
844	mkdir "$$AUTORECONF_DIR" && \
845	cd "$$AUTORECONF_DIR" && \
846	if git -C "$$DIR" show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \
847	    (git -C "$$DIR" archive --format=tar --prefix="$$TAG"/ "$$TAG^{tree}" $(RELEASE_FILES) | \
848	     tar xf -) && \
849	    echo "Archive build from tag $$TAG."; \
850	else \
851	    (git -C "$$DIR" archive --format=tar --prefix="$$TAG"/ "HEAD^{tree}" $(RELEASE_FILES) | \
852	     tar xf -) && \
853	    echo "No $$TAG tag. Archive build from HEAD."; \
854	fi && \
855	(cd "$$TAG" && ./autogen.sh && rm -rf autom4te.cache) && \
856	tar cf "$$DIR/$$TAG".tar "$$TAG" && \
857	rm -f "$$DIR/$$TAG".tar.gz && \
858	gzip --best "$$DIR/$$TAG".tar && \
859	cd "$$DIR" && \
860	rm -rf "$$AUTORECONF_DIR"
861
862releasecheck: releasetar
863	@TAG=$(PROG)-`cat VERSION` && \
864	INSTALL_DIR=/tmp/install_"$$TAG"_$$$$ && \
865	DIR=`pwd` && \
866	cd /tmp && \
867	rm -rf "$$TAG" && \
868	rm -rf "$$INSTALL_DIR" && \
869	tar xf "$$DIR"/"$$TAG".tar.gz && \
870	cd "$$TAG" && \
871	echo "[$@] $$ touch .devel" && \
872	touch .devel && \
873	echo "[$@] $$ ./configure --enable-remote --quiet --prefix=$$INSTALL_DIR" && \
874	./configure --enable-remote --quiet --prefix="$$INSTALL_DIR" && \
875	echo '[$@] $$ $(MAKE) -s all testprogs' && \
876	$(MAKE) -s all testprogs && \
877	echo '[$@] $$ $(MAKE) -s install' && \
878	$(MAKE) -s install && \
879	cd .. && \
880	rm -rf "$$TAG" && \
881	rm -rf "$$INSTALL_DIR" && \
882	tar xf "$$DIR"/"$$TAG".tar.gz && \
883	cd "$$TAG" && \
884	echo "[$@] $$ touch .devel" && \
885	touch .devel && \
886	mkdir build && \
887	cd build && \
888	echo '[$@] $$ cmake -DENABLE_REMOTE=yes [...] ..' && \
889	cmake -DENABLE_REMOTE=yes \
890	    -DCMAKE_INSTALL_PREFIX="$$INSTALL_DIR" \
891	    -DCMAKE_MESSAGE_LOG_LEVEL=NOTICE \
892	    -DCMAKE_RULE_MESSAGES=OFF \
893	    -DCMAKE_INSTALL_MESSAGE=NEVER \
894	    .. && \
895	echo '[$@] $$ $(MAKE) -s all testprogs' && \
896	$(MAKE) -s all testprogs && \
897	echo '[$@] $$ $(MAKE) -s install' && \
898	$(MAKE) -s install && \
899	cd ../.. && \
900	rm -rf "$$TAG" && \
901	rm -rf "$$INSTALL_DIR" && \
902	echo '[$@] Done.'
903
904whitespacecheck:
905	@# trailing space(s)?
906	@if git grep -I -n ' $$' $$(git ls-files|grep -v '^tests/'); then \
907	    echo 'Error: Trailing space(s).'; \
908	    exit 1; \
909	fi
910	@# trailing tab(s)?
911	@if git grep -I -n '	$$' $$(git ls-files|grep -v '^tests/'); then \
912	    echo 'Error: Trailing tabs(s).'; \
913	    exit 1; \
914	fi
915	@# space(s) before tab(s)?
916	@if git grep -I -n '[ ][	]' $$(git ls-files|grep -v '^tests/'); then \
917	    echo 'Error: space(s) before tab(s).'; \
918	    exit 1; \
919	fi
920
921depend:	$(GENERATED_C_SRC) $(GENHDR)
922	$(MKDEP) -c $(CC) -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC)
923	(cd rpcapd; $(MAKE) depend)
924	(cd testprogs; $(MAKE) depend)
925
926shellcheck:
927	shellcheck -f gcc -e SC2006 autogen.sh build.sh build_matrix.sh build_common.sh mkdep .ci-coverity-scan-build.sh
928