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