xref: /freebsd/lib/libpcap/Makefile (revision a50d73d5782a351ad83e8d1f84d11720a12e70d3)
1# Makefile for libpcap
2# $FreeBSD$
3
4SHLIBDIR?= /lib
5
6.include <src.opts.mk>
7
8LIB=	pcap
9
10SRCS=	bpf_dump.c \
11	bpf_filter.c \
12	bpf_image.c \
13	etherent.c \
14	fad-getad.c \
15	fmtutils.c \
16	gencode.c \
17	grammar.y \
18	nametoaddr.c \
19	optimize.c \
20	pcap-bpf.c \
21	pcap-common.c \
22	pcap-netmap.c \
23	pcap-usb-linux-common.c \
24	pcap-util.c \
25	pcap.c \
26	savefile.c \
27	scanner.l \
28	sf-pcap.c \
29	sf-pcapng.c \
30	tokdefs.h
31
32# Old compatibility headers
33INCS=	pcap-bpf.h \
34	pcap-namedb.h \
35	pcap-netmap.h \
36	pcap.h
37
38PCAPINCS= \
39	pcap/bluetooth.h \
40	pcap/bpf.h \
41	pcap/can_socketcan.h \
42	pcap/compiler-tests.h \
43	pcap/dlt.h \
44	pcap/funcattrs.h \
45	pcap/ipnet.h \
46	pcap/namedb.h \
47	pcap/nflog.h \
48	pcap/pcap-inttypes.h \
49	pcap/pcap.h \
50	pcap/socket.h \
51	pcap/sll.h \
52	pcap/usb.h \
53	pcap/vlan.h
54
55PCAPINCSDIR=	${INCLUDEDIR}/pcap
56INCSGROUPS=	INCS PCAPINCS
57
58MAN=	pcap.3 \
59	pcap_activate.3 \
60	pcap_breakloop.3 \
61	pcap_can_set_rfmon.3 \
62	pcap_close.3 \
63	pcap_compile.3 \
64	pcap_create.3 \
65	pcap_datalink.3 \
66	pcap_datalink_name_to_val.3 \
67	pcap_datalink_val_to_name.3 \
68	pcap_dump.3 \
69	pcap_dump_close.3 \
70	pcap_dump_file.3 \
71	pcap_dump_flush.3 \
72	pcap_dump_ftell.3 \
73	pcap_dump_open.3 \
74	pcap_file.3 \
75	pcap_fileno.3 \
76	pcap_findalldevs.3 \
77	pcap_freecode.3 \
78	pcap_get_required_select_timeout.3 \
79	pcap_get_selectable_fd.3 \
80	pcap_get_tstamp_precision.3 \
81	pcap_geterr.3 \
82	pcap_init.3 \
83	pcap_inject.3 \
84	pcap_is_swapped.3 \
85	pcap_lib_version.3 \
86	pcap_list_datalinks.3 \
87	pcap_list_tstamp_types.3 \
88	pcap_lookupdev.3 \
89	pcap_lookupnet.3 \
90	pcap_loop.3 \
91	pcap_major_version.3 \
92	pcap_next_ex.3 \
93	pcap_offline_filter.3 \
94	pcap_open_dead.3 \
95	pcap_open_live.3 \
96	pcap_open_offline.3 \
97	pcap_set_buffer_size.3 \
98	pcap_set_datalink.3 \
99	pcap_set_promisc.3 \
100	pcap_set_rfmon.3 \
101	pcap_set_snaplen.3 \
102	pcap_set_timeout.3 \
103	pcap_set_tstamp_precision.3 \
104	pcap_set_tstamp_type.3 \
105	pcap_setdirection.3 \
106	pcap_setfilter.3 \
107	pcap_setnonblock.3 \
108	pcap_snapshot.3 \
109	pcap_stats.3 \
110	pcap_statustostr.3 \
111	pcap_strerror.3 \
112	pcap_tstamp_type_name_to_val.3 \
113	pcap_tstamp_type_val_to_name.3 \
114	pcap-savefile.5 \
115	pcap-filter.7 \
116	pcap-linktype.7 \
117	pcap-tstamp.7
118
119MLINKS= \
120	pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \
121	pcap_dump_open.3 pcap_dump_fopen.3 \
122	pcap_findalldevs.3 pcap_freealldevs.3 \
123	pcap_geterr.3 pcap_perror.3 \
124	pcap_inject.3 pcap_sendpacket.3 \
125	pcap_list_datalinks.3 pcap_free_datalinks.3 \
126	pcap_list_tstamp_types.3 pcap_free_tstamp_types.3 \
127	pcap_loop.3 pcap_dispatch.3 \
128	pcap_major_version.3 pcap_minor_version.3 \
129	pcap_next_ex.3 pcap_next.3 \
130	pcap_open_offline.3 pcap_fopen_offline.3 \
131	pcap_setnonblock.3 pcap_getnonblock.3
132
133# Our man pages are a special copy from the distdir. See below.
134CLEANFILES+=${MAN}
135CLEANFILES+=grammar.y scanner.h tokdefs.h
136
137YFLAGS+=-p pcap_
138LFLAGS+=-Ppcap_ --header-file=${.OBJDIR}/scanner.h --nounput
139CFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} -I${.OBJDIR}
140CFLAGS+=-D_U_="__attribute__((unused))"
141CFLAGS+=-DHAVE_SNPRINTF -DHAVE_VSNPRINTF
142CFLAGS+=-DBUILDING_PCAP
143.if ${MK_INET6_SUPPORT} != "no"
144CFLAGS+=-DINET6
145.endif
146.if ${MK_PF} != "no"
147CFLAGS+=-DHAVE_NET_PFVAR_H
148.endif
149
150CFLAGS+= -DPCAP_SUPPORT_NETMAP
151
152.if ${MK_OFED} != "no"
153SRCS+= pcap-rdmasniff.c
154LIBADD+= ibverbs
155LIBADD+= mlx5
156CFLAGS+= -DPCAP_SUPPORT_RDMASNIFF
157.endif
158
159WARNS?=	0
160
161SHLIB_MAJOR=	8
162
163#
164# Magic to grab sources out of src/contrib
165#
166PCAP_DISTDIR?=${SRCTOP}/contrib/libpcap
167CFLAGS+=-I${PCAP_DISTDIR}
168.PATH:	${PCAP_DISTDIR}
169.PATH:	${PCAP_DISTDIR}/bpf/net
170
171grammar.y: grammar.y.in
172	sed  -e 's/@REENTRANT_PARSER@/%pure-parser/' < ${.ALLSRC} > ${.TARGET}
173
174tokdefs.h: grammar.h .NOMETA
175	ln -sf ${.ALLSRC} ${.TARGET}
176
177#
178# Magic to convert the man pages to something non Solarish
179#
180.for _page in ${MAN}
181${_page}:
182	if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then		\
183		F=${_page:S/3$/3pcap/}; 				\
184	elif [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap.in/} ]; then	\
185		F=${_page:S/3$/3pcap.in/}; 				\
186	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile.in/} ]; then	\
187		F=${_page:S/5$/manfile.in/};				\
188	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile/} ]; then	\
189		F=${_page:S/5$/manfile/};				\
190	else								\
191		F=${_page:S/7$/manmisc.in/};				\
192	fi;								\
193	sed \
194		-e 's/3PCAP/3/g' \
195		-e 's/@MAN_FILE_FORMATS@/5/g' \
196		-e 's/@MAN_MISC_INFO@/7/g' \
197		-e 's/@MAN_ADMIN_COMMANDS@/8/g' \
198		${PCAP_DISTDIR}/$$F > ${_page}
199.endfor
200
201.include <bsd.lib.mk>
202