xref: /freebsd/lib/libpcap/Makefile (revision 0957b409a90fd597c1e9124cbaf3edd2b488f4ac)
1# Makefile for libpcap
2# $FreeBSD$
3
4SHLIBDIR?= /lib
5
6.include <src.opts.mk>
7
8PACKAGE=lib${LIB}
9LIB=	pcap
10
11SRCS=	bpf_dump.c \
12	bpf_filter.c \
13	bpf_image.c \
14	etherent.c \
15	fad-getad.c \
16	fmtutils.c \
17	gencode.c \
18	grammar.y \
19	nametoaddr.c \
20	optimize.c \
21	pcap-bpf.c \
22	pcap-common.c \
23	pcap-netmap.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=	fmtutils.h \
33	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/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_immediate_mode.3 \
98	pcap_set_promisc.3 \
99	pcap_set_protocol.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
115MLINKS= \
116	pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \
117	pcap_dump_open.3 pcap_dump_fopen.3 \
118	pcap_findalldevs.3 pcap_freealldevs.3 \
119	pcap_geterr.3 pcap_perror.3 \
120	pcap_inject.3 pcap_sendpacket.3 \
121	pcap_list_datalinks.3 pcap_free_datalinks.3 \
122	pcap_list_tstamp_types.3 pcap_free_tstamp_types.3 \
123	pcap_loop.3 pcap_dispatch.3 \
124	pcap_major_version.3 pcap_minor_version.3 \
125	pcap_next_ex.3 pcap_next.3 \
126	pcap_open_offline.3 pcap_fopen_offline.3 \
127	pcap_setnonblock.3 pcap_getnonblock.3
128
129# Our man pages are a special copy from the distdir. See below.
130CLEANFILES+=${MAN}
131CLEANFILES+=tokdefs.h scanner.h
132
133YFLAGS+=-p pcap_
134LFLAGS+=-Ppcap_ --header-file=${.OBJDIR}/scanner.h --nounput
135CFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} -I${.OBJDIR}
136CFLAGS+=-D_U_="__attribute__((unused))"
137CFLAGS+=-DHAVE_SNPRINTF -DHAVE_VSNPRINTF
138CFLAGS+=-DBUILDING_PCAP
139.if ${MK_INET6_SUPPORT} != "no"
140CFLAGS+=-DINET6
141.endif
142.if ${MK_PF} != "no"
143CFLAGS+=-DHAVE_NET_PFVAR_H
144.endif
145
146CFLAGS+= -DPCAP_SUPPORT_NETMAP
147
148.if ${MK_OFED} != "no"
149SRCS+= pcap-rdmasniff.c
150LIBADD+= ibverbs
151LIBADD+= mlx5
152CFLAGS+= -DPCAP_SUPPORT_RDMASNIFF
153.endif
154
155WARNS?=	0
156
157SHLIB_MAJOR=	8
158
159#
160# Magic to grab sources out of src/contrib
161#
162PCAP_DISTDIR?=${SRCTOP}/contrib/libpcap
163CFLAGS+=-I${PCAP_DISTDIR}
164.PATH:	${PCAP_DISTDIR}
165.PATH:	${PCAP_DISTDIR}/bpf/net
166
167tokdefs.h: grammar.h .NOMETA
168	ln -sf ${.ALLSRC} ${.TARGET}
169
170#
171# Magic to convert the man pages to something non Solarish
172#
173.for _page in ${MAN}
174${_page}:
175	if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then		\
176		F=${_page:S/3$/3pcap/}; 				\
177	elif [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap.in/} ]; then		\
178		F=${_page:S/3$/3pcap.in/}; 				\
179	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile.in/} ]; then	\
180		F=${_page:S/5$/manfile.in/};				\
181	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile/} ]; then	\
182		F=${_page:S/5$/manfile/};				\
183	else								\
184		F=${_page:S/7$/manmisc.in/};				\
185	fi;								\
186	sed -e 's/3PCAP/3/g' ${PCAP_DISTDIR}/$$F > ${_page}
187.endfor
188
189.include <bsd.lib.mk>
190