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# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.142 2008-11-22 17:30:24 guy Exp $ (LBL)
21
22#
23# Various configurable paths (remember to edit Makefile.in, not Makefile)
24#
25
26# Top level hierarchy
27prefix = @prefix@
28exec_prefix = @exec_prefix@
29datarootdir = @datarootdir@
30# Pathname of directory to install the configure program
31bindir = @bindir@
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@
53INCLS = -I. @V_INCLS@
54DEFS = @DEFS@ @V_DEFS@
55ADDLOBJS = @ADDLOBJS@
56ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
57LIBS = @LIBS@
58CFLAGS = @CFLAGS@
59LDFLAGS = @LDFLAGS@
60DYEXT = @DYEXT@
61V_RPATH_OPT = @V_RPATH_OPT@
62DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
63PROG=libpcap
64
65# Standard CFLAGS
66FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
67
68INSTALL = @INSTALL@
69INSTALL_PROGRAM = @INSTALL_PROGRAM@
70INSTALL_DATA = @INSTALL_DATA@
71RANLIB = @RANLIB@
72
73#
74# Flex and bison allow you to specify the prefixes of the global symbols
75# used by the generated parser.  This allows programs to use lex/yacc
76# and link against libpcap.  If you don't have flex or bison, get them.
77#
78LEX = @V_LEX@
79YACC = @V_YACC@
80
81# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
82# Also, gcc does not remove the .o before forking 'as', which can be a
83# problem if you don't own the file but can write to the directory.
84.c.o:
85	@rm -f $@
86	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
87
88PSRC =	pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@
89FSRC =  fad-@V_FINDALLDEVS@.c
90SSRC =  @SSRC@
91CSRC =	pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
92	savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
93	bpf_image.c bpf_dump.c
94GENSRC = scanner.c grammar.c bpf_filter.c version.c
95LIBOBJS = @LIBOBJS@
96
97SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
98
99# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
100# hack the extra indirection
101OBJ =	$(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
102PUBHDR = \
103	pcap.h \
104	pcap-bpf.h \
105	pcap-namedb.h \
106	pcap/bpf.h \
107	pcap/bluetooth.h \
108	pcap/ipnet.h \
109	pcap/namedb.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	filtertest \
133	findalldevstest \
134	nonblocktest \
135	opentest \
136	selpolltest \
137	valgrindtest
138
139TESTS_SRC = \
140	tests/filtertest.c \
141	tests/findalldevstest.c \
142	tests/nonblocktest.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	packaging/pcap.spec.in \
296	pcap-bpf.c \
297	pcap-bt-linux.c \
298	pcap-bt-linux.h \
299	pcap-can-linux.c \
300	pcap-can-linux.h \
301	pcap-canusb-linux.c \
302	pcap-canusb-linux.h \
303	pcap-config.in \
304	pcap-dag.c \
305	pcap-dag.h \
306	pcap-dbus.c \
307	pcap-dbus.h \
308	pcap-dlpi.c \
309	pcap-dos.c \
310	pcap-dos.h \
311	pcap-enet.c \
312	pcap-int.h \
313	pcap-libdlpi.c \
314	pcap-linux.c \
315	pcap-namedb.h \
316	pcap-netfilter-linux.c \
317	pcap-netfilter-linux.h \
318	pcap-nit.c \
319	pcap-null.c \
320	pcap-pf.c \
321	pcap-septel.c \
322	pcap-septel.h \
323	pcap-sita.h \
324	pcap-sita.c \
325	pcap-sita.html \
326	pcap-snf.c \
327	pcap-snf.h \
328	pcap-snit.c \
329	pcap-snoop.c \
330	pcap-usb-linux.c \
331	pcap-usb-linux.h \
332	pcap-win32.c \
333	runlex.sh \
334	scanner.l \
335	Win32/Include/Gnuc.h \
336	Win32/Include/addrinfo.h \
337	Win32/Include/bittypes.h \
338	Win32/Include/cdecl_ext.h \
339	Win32/Include/inetprivate.h \
340	Win32/Include/ip6_misc.h \
341	Win32/Include/sockstorage.h \
342	Win32/Include/arpa/nameser.h \
343	Win32/Include/net/if.h \
344	Win32/Include/net/netdb.h \
345	Win32/Include/net/paths.h \
346	Win32/Prj/libpcap.dsp \
347	Win32/Prj/libpcap.dsw \
348	Win32/Src/ffs.c \
349	Win32/Src/gai_strerror.c \
350	Win32/Src/getaddrinfo.c \
351	Win32/Src/getnetbynm.c \
352	Win32/Src/getnetent.c \
353	Win32/Src/getopt.c \
354	Win32/Src/getservent.c \
355	Win32/Src/inet_aton.c \
356	Win32/Src/inet_net.c \
357	Win32/Src/inet_pton.c
358
359all: libpcap.a shared pcap-config
360
361libpcap.a: $(OBJ)
362	@rm -f $@
363	$(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
364	$(RANLIB) $@
365
366shared: libpcap.$(DYEXT)
367
368libpcap.so: $(OBJ)
369	@rm -f $@
370	VER=`cat $(srcdir)/VERSION`; \
371	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
372	@V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
373	    -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
374
375#
376# The following rule succeeds, but the result is untested.
377#
378# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with
379# its full path as the install_name, and with the compatibility and
380# current version both set to 1.  The compatibility version is set to
381# 1 so that programs built with a newer version of the library will run
382# against older versions; multi-platform software probably will fail if
383# it uses APIs added in the newer version, but Mac OS X-specific software
384# will use weak linking and check at run time whether those APIs are
385# available.
386#
387# We also use "A" as the major version, and 1 as the compatibility version,
388# but set the current version to the value in VERSION, with any non-numeric
389# stuff stripped off (the compatibility and current version must be of the
390# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
391# numeric).
392#
393libpcap.dylib: $(OBJ)
394	rm -f libpcap*.dylib
395	VER=`cat $(srcdir)/VERSION`; \
396	MAJOR_VER=A; \
397	COMPAT_VER=1; \
398	CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
399	$(CC) -dynamiclib -undefined error $(LDFLAGS) \
400	    -o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
401	    -install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
402	    -compatibility_version $$COMPAT_VER \
403	    -current_version $$CURRENT_VER
404
405#
406# The HP-UX linker manual says that the convention for a versioned library
407# is libXXX.{number}, not libXXX.sl.{number}.  That appears to be the case
408# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
409# libXXX.{number}.
410#
411# The manual also says "library-level versioning" (think "sonames") was
412# added in HP-UX 10.0.
413#
414# XXX - this assumes we're using the HP linker, rather than the GNU
415# linker, even with GCC.
416#
417libpcap.sl: $(OBJ)
418	@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
419	rm -f libpcap.$$MAJOR_VER
420	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
421	ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
422	    $(OBJ) $(ADDLOBJS) $(LIBS)
423
424#
425# AIX is different from everybody else.  A shared library is an archive
426# library with one or more shared-object components.  We still build a
427# normal static archive library on AIX, for the benefit of the traditional
428# scheme of building libpcap and tcpdump in subdirectories of the
429# same directory, with tcpdump statically linked with the libpcap
430# in question, but we also build a shared library as "libpcap.shareda"
431# and install *it*, rather than the static library, as "libpcap.a".
432#
433libpcap.shareda: $(OBJ)
434	@rm -f $@ shr.o
435	$(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
436	$(AR) rc $@ shr.o
437
438#
439# For platforms that don't support shared libraries (or on which we
440# don't support shared libraries).
441#
442libpcap.none:
443
444scanner.c: $(srcdir)/scanner.l
445	@rm -f $@
446	$(srcdir)/runlex.sh $(LEX) -o$@ $<
447
448scanner.o: scanner.c tokdefs.h
449	$(CC) $(FULL_CFLAGS) -c scanner.c
450
451pcap.o: version.h
452
453tokdefs.h: grammar.c
454grammar.c: $(srcdir)/grammar.y
455	@rm -f grammar.c tokdefs.h
456	$(YACC) -d $<
457	mv y.tab.c grammar.c
458	mv y.tab.h tokdefs.h
459
460grammar.o: grammar.c
461	@rm -f $@
462	$(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
463
464version.o: version.c
465	$(CC) $(FULL_CFLAGS) -c version.c
466
467snprintf.o: $(srcdir)/missing/snprintf.c
468	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
469
470version.c: $(srcdir)/VERSION
471	@rm -f $@
472	if grep GIT ${srcdir}/VERSION >/dev/null; then \
473		read ver <${srcdir}/VERSION; \
474		echo $$ver | tr -d '\012'; \
475		date +_%Y_%m_%d; \
476	else \
477		cat ${srcdir}/VERSION; \
478	fi | sed -e 's/.*/char pcap_version[] = "&";/' > $@
479
480#
481# NOTE: this really is supposed to be static; importing a string
482# from a shared library does not work very well on many
483# versions of UNIX (Solaris, Linux, and the BSDs, for example),
484# so we make the version string static and return it from
485# a function, which does work.
486#
487version.h: $(srcdir)/VERSION
488	@rm -f $@
489	if grep GIT ${srcdir}/VERSION >/dev/null; then \
490		read ver <${srcdir}/VERSION; \
491		echo $$ver | tr -d '\012'; \
492		date +_%Y_%m_%d; \
493	else \
494		cat ${srcdir}/VERSION; \
495	fi | sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' > $@
496
497bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
498	rm -f bpf_filter.c
499	ln -s $(srcdir)/bpf/net/bpf_filter.c bpf_filter.c
500
501bpf_filter.o: bpf_filter.c
502	$(CC) $(FULL_CFLAGS) -c bpf_filter.c
503
504#
505# Generate the pcap-config script.
506#
507# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<";
508# for example, the Solaris 9 make man page says
509#
510#	Because make assigns $< and $* as it would for implicit rules
511#	(according to the suffixes list and the directory contents),
512#	they may be unreliable when used within explicit target entries.
513#
514# and this is an explicit target entry.
515#
516# Therefore, instead of using $<, we explicitly put in $(srcdir)/pcap-config.in.
517#
518pcap-config: $(srcdir)/pcap-config.in ./config.status
519	@rm -f $@ $@.tmp
520	./config.status --file=$@.tmp:$(srcdir)/pcap-config.in
521	mv $@.tmp $@
522	chmod a+x $@
523
524#
525# Test programs - not built by default, and not installed.
526#
527tests: $(TESTS)
528
529filtertest: tests/filtertest.c libpcap.a
530	$(CC) $(FULL_CFLAGS) -I. -L. -o filtertest $(srcdir)/tests/filtertest.c libpcap.a $(LIBS)
531
532findalldevstest: tests/findalldevstest.c libpcap.a
533	$(CC) $(FULL_CFLAGS) -I. -L. -o findalldevstest $(srcdir)/tests/findalldevstest.c libpcap.a $(LIBS)
534
535nonblocktest: tests/nonblocktest.c libpcap.a
536	$(CC) $(FULL_CFLAGS) -I. -L. -o nonblocktest $(srcdir)/tests/nonblocktest.c libpcap.a $(LIBS)
537
538opentest: tests/opentest.c libpcap.a
539	$(CC) $(FULL_CFLAGS) -I. -L. -o opentest $(srcdir)/tests/opentest.c libpcap.a $(LIBS)
540
541selpolltest: tests/selpolltest.c libpcap.a
542	$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
543
544valgrindtest: tests/valgrindtest.c libpcap.a
545	$(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS)
546
547install: install-shared install-archive pcap-config
548	[ -d $(DESTDIR)$(libdir) ] || \
549	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
550	[ -d $(DESTDIR)$(includedir) ] || \
551	    (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
552	[ -d $(DESTDIR)$(includedir)/pcap ] || \
553	    (mkdir -p $(DESTDIR)$(includedir)/pcap; chmod 755 $(DESTDIR)$(includedir)/pcap)
554	[ -d $(DESTDIR)$(mandir)/man1 ] || \
555	    (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
556	[ -d $(DESTDIR)$(mandir)/man3 ] || \
557	    (mkdir -p $(DESTDIR)$(mandir)/man3; chmod 755 $(DESTDIR)$(mandir)/man3)
558	[ -d $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@ ] || \
559	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
560	[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
561	    (mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
562	for i in $(PUBHDR); do \
563		$(INSTALL_DATA) $(srcdir)/$$i \
564		    $(DESTDIR)$(includedir)/$$i; done
565	[ -d $(DESTDIR)$(bindir) ] || \
566	    (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
567	$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
568	for i in $(MAN1); do \
569		$(INSTALL_DATA) $(srcdir)/$$i \
570		    $(DESTDIR)$(mandir)/man1/$$i; done
571	for i in $(MAN3PCAP_NOEXPAND); do \
572		$(INSTALL_DATA) $(srcdir)/$$i \
573		    $(DESTDIR)$(mandir)/man3/$$i; done
574	for i in $(MAN3PCAP_EXPAND:.in=); do \
575		$(INSTALL_DATA) $$i \
576		    $(DESTDIR)$(mandir)/man3/$$i; done
577	(cd $(DESTDIR)$(mandir)/man3 && \
578	rm -f pcap_datalink_val_to_description.3pcap && \
579	$(LN_S) pcap_datalink_val_to_name.3pcap \
580		 pcap_datalink_val_to_description.3pcap && \
581	rm -f pcap_dump_fopen.3pcap && \
582	$(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
583	rm -f pcap_freealldevs.3pcap && \
584	$(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
585	rm -f pcap_perror.3pcap && \
586	$(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
587	rm -f pcap_sendpacket.3pcap && \
588	$(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
589	rm -f pcap_free_datalinks.3pcap && \
590	$(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
591	rm -f pcap_free_tstamp_types.3pcap && \
592	$(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
593	rm -f pcap_dispatch.3pcap && \
594	$(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
595	rm -f pcap_minor_version.3pcap && \
596	$(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
597	rm -f pcap_next.3pcap && \
598	$(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
599	rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
600	$(LN_S) pcap_open_dead.3pcap \
601		 pcap_open_dead_with_tstamp_precision.3pcap && \
602	rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
603	$(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
604	rm -f pcap_fopen_offline.3pcap && \
605	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
606	rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
607	$(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
608	rm -f pcap_getnonblock.3pcap && \
609	$(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
610	for i in $(MANFILE); do \
611		$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
612		    $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
613	for i in $(MANMISC); do \
614		$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
615		    $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
616
617install-shared: install-shared-$(DYEXT)
618install-shared-so: libpcap.so
619	[ -d $(DESTDIR)$(libdir) ] || \
620	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
621	VER=`cat $(srcdir)/VERSION`; \
622	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
623	$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
624	ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
625	ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
626install-shared-dylib: libpcap.dylib
627	[ -d $(DESTDIR)$(libdir) ] || \
628	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
629	VER=`cat $(srcdir)/VERSION`; \
630	MAJOR_VER=A; \
631	$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
632	ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
633	ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
634install-shared-sl: libpcap.sl
635	[ -d $(DESTDIR)$(libdir) ] || \
636	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
637	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
638	$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
639	ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
640install-shared-shareda: libpcap.shareda
641	#
642	# AIX shared libraries are weird.  They're archive libraries
643	# with one or more shared object components.
644	#
645	[ -d $(DESTDIR)$(libdir) ] || \
646	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
647	$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
648install-shared-none:
649
650install-archive: install-archive-$(DYEXT)
651install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
652	#
653	# Most platforms have separate suffixes for shared and
654	# archive libraries, so we install both.
655	#
656	[ -d $(DESTDIR)$(libdir) ] || \
657	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
658	$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
659	$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
660install-archive-shareda:
661	#
662	# AIX, however, doesn't, so we don't install the archive
663	# library on AIX.
664	#
665
666uninstall: uninstall-shared
667	rm -f $(DESTDIR)$(libdir)/libpcap.a
668	for i in $(PUBHDR); do \
669		rm -f $(DESTDIR)$(includedir)/$$i; done
670	-rmdir $(DESTDIR)$(includedir)/pcap
671	rm -f $(DESTDIR)/$(bindir)/pcap-config
672	for i in $(MAN1); do \
673		rm -f $(DESTDIR)$(mandir)/man1/$$i; done
674	for i in $(MAN3PCAP); do \
675		rm -f $(DESTDIR)$(mandir)/man3/$$i; done
676	rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
677	rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
678	rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
679	rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
680	rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
681	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
682	rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
683	rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
684	rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
685	rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
686	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
687	rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
688	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
689	rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
690	rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
691	for i in $(MANFILE); do \
692		rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
693	for i in $(MANMISC); do \
694		rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
695
696uninstall-shared: uninstall-shared-$(DYEXT)
697uninstall-shared-so:
698	VER=`cat $(srcdir)/VERSION`; \
699	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
700	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
701	rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
702	rm -f $(DESTDIR)$(libdir)/libpcap.so
703uninstall-shared-dylib:
704	VER=`cat $(srcdir)/VERSION`; \
705	MAJOR_VER=A; \
706	rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
707	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
708	rm -f $(DESTDIR)$(libdir)/libpcap.dylib
709uninstall-shared-sl:
710	MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
711	rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
712	rm -f $(DESTDIR)$(libdir)/libpcap.sl
713uninstall-shared-shareda:
714	rm -f $(DESTDIR)$(libdir)/libpcap.a
715uninstall-shared-none:
716
717clean:
718	rm -f $(CLEANFILES)
719
720distclean: clean
721	rm -f Makefile config.cache config.log config.status \
722	    config.h gnuc.h net os-proto.h bpf_filter.c pcap-config \
723	    stamp-h stamp-h.in
724	rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=)
725	rm -rf autom4te.cache
726
727tags: $(TAGFILES)
728	ctags -wtd $(TAGFILES)
729
730packaging/pcap.spec: packaging/pcap.spec.in VERSION
731	RPMVERSION=`cat VERSION | sed s/-.*//g`; \
732		sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $<   > $@
733
734releasetar:
735	@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
736	   mkdir $$name; \
737	   tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
738	      $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \
739	      (cd $$name; tar xf -); \
740	   tar -c -z -f $$name.tar.gz $$name; \
741	   rm -rf $$name
742
743depend:	$(GENSRC) $(GENHDR) bpf_filter.c
744	$(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
745