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