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