xref: /freebsd/lib/libpcap/Makefile (revision cbd30a72ca196976c1c700400ecd424baa1b9c16)
1# Makefile for libpcap
2# $FreeBSD$
3
4SHLIBDIR?= /lib
5
6.include <src.opts.mk>
7
8PACKAGE=lib${LIB}
9LIB=	pcap
10SRCS=	grammar.y tokdefs.h pcap_version.h pcap-bpf.c \
11	pcap-netmap.c fad-helpers.c \
12	pcap.c pcap-common.c inet.c fad-getad.c gencode.c optimize.c nametoaddr.c \
13	etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
14	scanner.l sf-pcap.c sf-pcap-ng.c version.c
15
16# Old compatibility headers
17INCS=	pcap.h pcap-namedb.h pcap-bpf.h
18
19PCAPINCS=	pcap/pcap.h pcap/namedb.h pcap/bpf.h pcap/dlt.h pcap/export-defs.h
20PCAPINCSDIR=	${INCLUDEDIR}/pcap
21INCSGROUPS=	INCS PCAPINCS
22
23MAN=	pcap.3 \
24	pcap_activate.3 \
25	pcap_breakloop.3 \
26	pcap_can_set_rfmon.3 \
27	pcap_close.3 \
28	pcap_compile.3 \
29	pcap_create.3 \
30	pcap_datalink.3 \
31	pcap_datalink_name_to_val.3 \
32	pcap_datalink_val_to_name.3 \
33	pcap_dump.3 \
34	pcap_dump_close.3 \
35	pcap_dump_file.3 \
36	pcap_dump_flush.3 \
37	pcap_dump_ftell.3 \
38	pcap_dump_open.3 \
39	pcap_file.3 \
40	pcap_fileno.3 \
41	pcap_findalldevs.3 \
42	pcap_freecode.3 \
43	pcap_get_selectable_fd.3 \
44	pcap_get_tstamp_precision.3 \
45	pcap_geterr.3 \
46	pcap_inject.3 \
47	pcap_is_swapped.3 \
48	pcap_lib_version.3 \
49	pcap_list_datalinks.3 \
50	pcap_list_tstamp_types.3 \
51	pcap_lookupdev.3 \
52	pcap_lookupnet.3 \
53	pcap_loop.3 \
54	pcap_major_version.3 \
55	pcap_next_ex.3 \
56	pcap_offline_filter.3 \
57	pcap_open_dead.3 \
58	pcap_open_live.3 \
59	pcap_open_offline.3 \
60	pcap_set_buffer_size.3 \
61	pcap_set_datalink.3 \
62	pcap_set_immediate_mode.3 \
63	pcap_set_promisc.3 \
64	pcap_set_rfmon.3 \
65	pcap_set_snaplen.3 \
66	pcap_set_timeout.3 \
67	pcap_set_tstamp_precision.3 \
68	pcap_set_tstamp_type.3 \
69	pcap_setdirection.3 \
70	pcap_setfilter.3 \
71	pcap_setnonblock.3 \
72	pcap_snapshot.3 \
73	pcap_stats.3 \
74	pcap_statustostr.3 \
75	pcap_strerror.3 \
76	pcap-savefile.5 \
77	pcap_tstamp_type_name_to_val.3 \
78	pcap_tstamp_type_val_to_name.3 \
79	pcap-filter.7 \
80	pcap-linktype.7
81MLINKS=	pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \
82	pcap_dump_open.3 pcap_dump_fopen.3 \
83	pcap_findalldevs.3 pcap_freealldevs.3 \
84	pcap_geterr.3 pcap_perror.3 \
85	pcap_inject.3 pcap_sendpacket.3 \
86	pcap_list_datalinks.3 pcap_free_datalinks.3 \
87	pcap_list_tstamp_types.3 pcap_free_tstamp_types.3 \
88	pcap_loop.3 pcap_dispatch.3 \
89	pcap_major_version.3 pcap_minor_version.3 \
90	pcap_next_ex.3 pcap_next.3 \
91	pcap_open_offline.3 pcap_fopen_offline.3 \
92	pcap_setnonblock.3 pcap_getnonblock.3
93
94# Our man pages are a special copy from the distdir. See below.
95CLEANFILES+=${MAN}
96CLEANFILES+=tokdefs.h scanner.h pcap_version.h version.c
97
98YFLAGS+=-p pcap_
99LFLAGS+=-Ppcap_ --header-file=${.OBJDIR}/scanner.h --nounput
100CFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} -I${.OBJDIR}
101CFLAGS+=-D_U_="__attribute__((unused))"
102CFLAGS+=-DHAVE_SNPRINTF -DHAVE_VSNPRINTF
103CFLAGS+=-DBUILDING_PCAP
104.if ${MK_INET6_SUPPORT} != "no"
105CFLAGS+=-DINET6
106.endif
107.if ${MK_PF} != "no"
108CFLAGS+=-DHAVE_NET_PFVAR_H
109.endif
110
111WARNS?=	0
112
113SHLIB_MAJOR=	8
114
115#
116# Magic to grab sources out of src/contrib
117#
118PCAP_DISTDIR?=${SRCTOP}/contrib/libpcap
119CFLAGS+=-I${PCAP_DISTDIR}
120.PATH:	${PCAP_DISTDIR}
121.PATH:	${PCAP_DISTDIR}/bpf/net
122
123version.c: ${PCAP_DISTDIR}/VERSION
124	@rm -f $@
125	sed 's/.*/char pcap_version[] = "&";/' ${PCAP_DISTDIR}/VERSION > $@
126
127pcap_version.h: ${PCAP_DISTDIR}/VERSION
128	@rm -f $@
129	sed 's/.*/char pcap_version_string[] = "libpcap version &";/' ${PCAP_DISTDIR}/VERSION > $@
130
131tokdefs.h: grammar.h .NOMETA
132	ln -sf ${.ALLSRC} ${.TARGET}
133
134#
135# Magic to convert the man pages to something non Solarish
136#
137.for _page in ${MAN}
138${_page}:
139	if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then		\
140		F=${_page:S/3$/3pcap/}; 				\
141	elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile/} ]; then	\
142		F=${_page:S/5$/manfile/};				\
143	else								\
144		F=${_page:S/7$/manmisc/};				\
145	fi;								\
146	sed -e 's/3PCAP/3/g' ${PCAP_DISTDIR}/$$F > ${_page}
147.endfor
148
149.include <bsd.lib.mk>
150