xref: /freebsd/lib/libpcap/Makefile (revision 3cbb4cc200f8a0ad7ed08233425ea54524a21f1c)
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.c \
24	savefile.c \
25	scanner.l \
26	sf-pcap.c \
27	sf-pcapng.c \
28	tokdefs.h
29
30# Old compatibility headers
31INCS=	fmtutils.h \
32	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_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+=tokdefs.h scanner.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
169tokdefs.h: grammar.h .NOMETA
170	ln -sf ${.ALLSRC} ${.TARGET}
171
172#
173# Magic to convert the man pages to something non Solarish
174#
175.for _page in ${MAN}
176${_page}:
177	if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then		\
178		F=${_page:S/3$/3pcap/}; 				\
179	elif [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap.in/} ]; then	\
180		F=${_page:S/3$/3pcap.in/}; 				\
181	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile.in/} ]; then	\
182		F=${_page:S/5$/manfile.in/};				\
183	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile/} ]; then	\
184		F=${_page:S/5$/manfile/};				\
185	else								\
186		F=${_page:S/7$/manmisc.in/};				\
187	fi;								\
188	sed \
189		-e 's/3PCAP/3/g' \
190		-e 's/@MAN_FILE_FORMATS@/5/g' \
191		-e 's/@MAN_MISC_INFO@/7/g' \
192		-e 's/@MAN_ADMIN_COMMANDS@/8/g' \
193		${PCAP_DISTDIR}/$$F > ${_page}
194.endfor
195
196.include <bsd.lib.mk>
197