summaryrefslogtreecommitdiff
path: root/net/libpcap/builtin.mk
blob: 2d60f8e1a34dfb0a039867ff9336425eaade234a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# $NetBSD: builtin.mk,v 1.17 2011/01/29 21:17:48 markd Exp $

BUILTIN_PKG:=	libpcap

.include "../../mk/bsd.fast.prefs.mk"

BUILTIN_FIND_FILES_VAR:=	H_LIBPCAP
BUILTIN_FIND_FILES.H_LIBPCAP=	/usr/include/pcap/pcap.h
BUILTIN_FIND_FILES.H_LIBPCAP+=	/usr/include/pcap.h

.include "../../mk/buildlink3/bsd.builtin.mk"

###
### Determine if there is a built-in implementation of the package and
### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
###
.if !defined(IS_BUILTIN.libpcap)
IS_BUILTIN.libpcap=	no
.  if empty(H_LIBPCAP:M__nonexistent__) && empty(H_LIBPCAP:M${LOCALBASE}/*)
IS_BUILTIN.libpcap=	yes
.  endif
.endif
MAKEVARS+=	IS_BUILTIN.libpcap

###
### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
### a package name to represent the built-in package.
###
.if !defined(BUILTIN_PKG.libpcap) && \
    !empty(IS_BUILTIN.libpcap:M[yY][eE][sS]) && \
    empty(H_LIBPCAP:M__nonexistent__)
_BLTN_PCAP_111!=	\
	${GREP} -c PCAP_NETMASK_UNKNOWN ${H_LIBPCAP} || ${TRUE}
_BLTN_PCAP_100!=	\
	${GREP} -c pcap_offline_filter ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.9.3: pcap_setdirection added (don't use pcap_inject, this
#  was hacked into the NetBSD version of 0.8.3)
_BLTN_PCAP_093!=	\
	${GREP} -c pcap_setdirection ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.8.3: MODE_MON added
_BLTN_PCAP_083!=	\
	${GREP} -c MODE_MON ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.8.1: pcap_get_selectable_fd added
_BLTN_PCAP_081!=	\
	${GREP} -c pcap_get_selectable_fd ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.8.0: pcap_datalink_val_to_description added
_BLTN_PCAP_080!=	\
	${GREP} -c pcap_datalink_val_to_description ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.7.0: pcap_setnonblock added
_BLTN_PCAP_070!=	\
	${GREP} -c pcap_setnonblock ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.6.0: prototype change for pcap_freecode
_BLTN_PCAP_060!=	\
	${GREP} -c pcap_freecode.struct.bpf_program ${H_LIBPCAP} || ${TRUE}
# libpcap>=0.5.0: pcap_compile_nopcap added
_BLTN_PCAP_050!=	\
	${GREP} -c pcap_compile_nopcap ${H_LIBPCAP} || ${TRUE}

.  if ${_BLTN_PCAP_111} == "1"
BUILTIN_VERSION.libpcap=	1.1.1
.  elif ${_BLTN_PCAP_100} == "1"
BUILTIN_VERSION.libpcap=	1.0.0
.  elif ${_BLTN_PCAP_093} == "1"
BUILTIN_VERSION.libpcap=	0.9.3nb1
.  elif ${_BLTN_PCAP_083} == "1"
BUILTIN_VERSION.libpcap=	0.8.3
.  elif ${_BLTN_PCAP_081} == "1"
BUILTIN_VERSION.libpcap=	0.8.1
.  elif ${_BLTN_PCAP_080} == "1"
BUILTIN_VERSION.libpcap=	0.8.0
.  elif ${_BLTN_PCAP_070} == "1"
BUILTIN_VERSION.libpcap=	0.7.0
.  elif ${_BLTN_PCAP_060} == "1"
BUILTIN_VERSION.libpcap=	0.6.0
.  elif ${_BLTN_PCAP_050} == "1"
BUILTIN_VERSION.libpcap=	0.5.0
.  else
BUILTIN_VERSION.libpcap=	0.4.0
.  endif
BUILTIN_PKG.libpcap=	libpcap-${BUILTIN_VERSION.libpcap}
.endif
MAKEVARS+=	BUILTIN_PKG.libpcap

###
### Determine whether we should use the built-in implementation if it
### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
###
.if !defined(USE_BUILTIN.libpcap)
.  if ${PREFER.libpcap} == "pkgsrc"
USE_BUILTIN.libpcap=	no
.  else
USE_BUILTIN.libpcap=	${IS_BUILTIN.libpcap}
.    if defined(BUILTIN_PKG.libpcap) && \
        !empty(IS_BUILTIN.libpcap:M[yY][eE][sS])
USE_BUILTIN.libpcap=	yes
.      for _dep_ in ${BUILDLINK_API_DEPENDS.libpcap}
.        if !empty(USE_BUILTIN.libpcap:M[yY][eE][sS])
USE_BUILTIN.libpcap!=							\
	if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.libpcap:Q}; then \
		${ECHO} yes;						\
	else								\
		${ECHO} no;						\
	fi
.        endif
.      endfor
.    endif
.  endif  # PREFER.libpcap
.endif
MAKEVARS+=	USE_BUILTIN.libpcap