xref: /freebsd/lib/libpcap/Makefile (revision 8ef24a0d4b28fe230e20637f56869cc4148cd2ca)
1# Makefile for libpcap
2# $FreeBSD$
3
4SHLIBDIR?= /lib
5
6.include <src.opts.mk>
7
8PACKAGE=lib${LIB}
9LIB=	pcap
10SRCS=	grammar.y tokdefs.h version.h pcap-bpf.c \
11	pcap-netmap.c \
12	pcap.c pcap-common.c inet.c fad-getad.c gencode.c optimize.c nametoaddr.c \
13	etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
14	scanner.l sf-pcap.c sf-pcap-ng.c version.c
15
16# Old compatibility headers
17INCS=	pcap.h pcap-int.h pcap-namedb.h pcap-bpf.h
18
19PCAPINCS=	pcap/pcap.h pcap/namedb.h pcap/bpf.h
20PCAPINCSDIR=	${INCLUDEDIR}/pcap
21INCSGROUPS=	INCS PCAPINCS
22
23MAN=	pcap.3 \
24	pcap_activate.3 \
25	pcap_breakloop.3 \
26	pcap_can_set_rfmon.3 \
27	pcap_close.3 \
28	pcap_compile.3 \
29	pcap_create.3 \
30	pcap_datalink.3 \
31	pcap_datalink_name_to_val.3 \
32	pcap_datalink_val_to_name.3 \
33	pcap_dump.3 \
34	pcap_dump_close.3 \
35	pcap_dump_file.3 \
36	pcap_dump_flush.3 \
37	pcap_dump_ftell.3 \
38	pcap_dump_open.3 \
39	pcap_file.3 \
40	pcap_fileno.3 \
41	pcap_findalldevs.3 \
42	pcap_freecode.3 \
43	pcap_get_selectable_fd.3 \
44	pcap_get_tstamp_precision.3 \
45	pcap_geterr.3 \
46	pcap_inject.3 \
47	pcap_is_swapped.3 \
48	pcap_lib_version.3 \
49	pcap_list_datalinks.3 \
50	pcap_list_tstamp_types.3 \
51	pcap_lookupdev.3 \
52	pcap_lookupnet.3 \
53	pcap_loop.3 \
54	pcap_major_version.3 \
55	pcap_next_ex.3 \
56	pcap_offline_filter.3 \
57	pcap_open_dead.3 \
58	pcap_open_live.3 \
59	pcap_open_offline.3 \
60	pcap_set_buffer_size.3 \
61	pcap_set_datalink.3 \
62	pcap_set_immediate_mode.3 \
63	pcap_set_promisc.3 \
64	pcap_set_rfmon.3 \
65	pcap_set_snaplen.3 \
66	pcap_set_timeout.3 \
67	pcap_set_tstamp_precision.3 \
68	pcap_set_tstamp_type.3 \
69	pcap_setdirection.3 \
70	pcap_setfilter.3 \
71	pcap_setnonblock.3 \
72	pcap_snapshot.3 \
73	pcap_stats.3 \
74	pcap_statustostr.3 \
75	pcap_strerror.3 \
76	pcap-savefile.5 \
77	pcap_tstamp_type_name_to_val.3 \
78	pcap_tstamp_type_val_to_name.3 \
79	pcap-filter.7 \
80	pcap-linktype.7
81MLINKS=	pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \
82	pcap_dump_open.3 pcap_dump_fopen.3 \
83	pcap_findalldevs.3 pcap_freealldevs.3 \
84	pcap_geterr.3 pcap_perror.3 \
85	pcap_inject.3 pcap_sendpacket.3 \
86	pcap_list_datalinks.3 pcap_free_datalinks.3 \
87	pcap_list_tstamp_types.3 pcap_free_tstamp_types.3 \
88	pcap_loop.3 pcap_dispatch.3 \
89	pcap_major_version.3 pcap_minor_version.3 \
90	pcap_next_ex.3 pcap_next.3 \
91	pcap_open_offline.3 pcap_fopen_offline.3 \
92	pcap_setnonblock.3 pcap_getnonblock.3
93
94# Our man pages are a special copy from the distdir. See below.
95CLEANFILES+=${MAN}
96CLEANFILES+=tokdefs.h version.h version.c
97
98YFLAGS+=-p pcapyy
99LFLAGS+=-Ppcapyy
100CFLAGS+=-DHAVE_CONFIG_H -Dyylval=pcapyylval -I${.CURDIR} -I.
101CFLAGS+=-D_U_="__attribute__((unused))"
102CFLAGS+=-DHAVE_SNPRINTF -DHAVE_VSNPRINTF
103.if ${MK_INET6_SUPPORT} != "no"
104CFLAGS+=-DINET6
105.endif
106.if ${MK_PF} != "no"
107CFLAGS+=-DHAVE_NET_PFVAR_H
108.endif
109
110WARNS?=	0
111
112SHLIB_MAJOR=	8
113
114#
115# Magic to grab sources out of src/contrib
116#
117PCAP_DISTDIR?=${.CURDIR}/../../contrib/libpcap
118CFLAGS+=-I${PCAP_DISTDIR}
119.PATH:	${PCAP_DISTDIR}
120.PATH:	${PCAP_DISTDIR}/bpf/net
121
122version.c: ${PCAP_DISTDIR}/VERSION
123	@rm -f $@
124	sed 's/.*/char pcap_version[] = "&";/' ${PCAP_DISTDIR}/VERSION > $@
125
126version.h: ${PCAP_DISTDIR}/VERSION
127	@rm -f $@
128	sed 's/.*/char pcap_version_string[] = "libpcap version &";/' ${PCAP_DISTDIR}/VERSION > $@
129
130tokdefs.h: grammar.h .NOMETA
131	ln -sf ${.ALLSRC} ${.TARGET}
132
133#
134# Magic to convert the man pages to something non Solarish
135#
136.for _page in ${MAN}
137${_page}:
138	if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then		\
139		F=${_page:S/3$/3pcap/}; 				\
140	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile/} ]; then	\
141		F=${_page:S/5$/manfile/};				\
142	else								\
143		F=${_page:S/7$/manmisc/};				\
144	fi;								\
145	sed -e 's/3PCAP/3/g' ${PCAP_DISTDIR}/$$F > ${_page}
146.endfor
147
148.include <bsd.lib.mk>
149