summaryrefslogtreecommitdiff
path: root/mk/pf.buildlink3.mk
blob: 5c00e2a14356e6c9f335fa16473078b095db4e3c (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
# $NetBSD: pf.buildlink3.mk,v 1.3 2015/01/14 20:40:32 rumko Exp $
#
# Makefile fragment for packages using pf.
#
# The following variables are set by this file:
#
#   PFVAR_H	The path to the pfvar.h header file.
#   PFCTL	The path to the pfctl program.
#   PF_VERSION	The detected PF version (as in OpenBSD).
#

.if !defined(PF_BUILDLINK3_MK)
PF_BUILDLINK3_MK=	#defined

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

# Platforms where pf is available on.
ONLY_FOR_PLATFORM?=	NetBSD-[3-9]*-* OpenBSD-[3-9]*-* FreeBSD-*-* \
			DragonFly-*-*

# Detect the pfvar.h header.
.if exists(/usr/include/net/pfvar.h)
_PFVAR_H=	/usr/include/net/pfvar.h	
.elif exists(/usr/include/net/pf/pfvar.h)
_PFVAR_H=	/usr/include/net/pf/pfvar.h
.else
PKG_FAIL_REASON+=	"Couldn't find pfvar.h header; please make sure that this header is available in /usr/include/net."
.endif

PFVAR_H?=	${_PFVAR_H}
PFCTL?=		/sbin/pfctl

# Compute the version number of the PF API by checking for the presence
# of symbols added in newer versions and store the result in ${PF_VERSION}.

# Default to the first version with PF, which was OpenBSD 3.0.
PF_VERSION=	3.0

.if !empty(PFVAR_H)
# OpenBSD 4.7: pf_state_rm_src_node added
_PF_4_7!=	${GREP} -c pf_state_rm_src_node ${PFVAR_H} || ${TRUE}
# OpenBSD 4.6: pf_normalize_mss added
_PF_4_6!=	${GREP} -c pf_normalize_mss ${PFVAR_H} || ${TRUE}
# OpenBSD 4.5: pf_send_deferred_syn added
_PF_4_5!=	${GREP} -c pf_send_deferred_syn ${PFVAR_H} || ${TRUE}
# OpenBSD 4.4: pf_match_tag added
_PF_4_4!=	${GREP} -c pf_match_tag ${PFVAR_H} || ${TRUE}
# OpenBSD 4.3: pf_match_addr_range added
_PF_4_3!=	${GREP} -c pf_match_addr_range ${PFVAR_H} || ${TRUE}
# OpenBSD 4.2: pf_statelist added
_PF_4_2!=	${GREP} -c pf_statelist ${PFVAR_H} || ${TRUE}
# OpenBSD 4.1: PF_OSFP_INET6 added
_PF_4_1!=	${GREP} -c PF_OSFP_INET6 ${PFVAR_H} || ${TRUE}
# OpenBSD 3.8: pf_socket_lookup added
_PF_3_8!=	${GREP} -c pf_socket_lookup ${PFVAR_H} || ${TRUE}
# OpenBSD 3.7: pf_threshold added
_PF_3_7!=	${GREP} -c pf_threshold ${PFVAR_H} || ${TRUE}
# OpenBSD 3.6: pf_cksum_fixup added
_PF_3_6!=	${GREP} -c pf_cksum_fixup ${PFVAR_H} || ${TRUE}
# OpenBSD 3.5: pfi_lookup_if added
_PF_3_5!=	${GREP} -c pfi_lookup_if ${PFVAR_H} || ${TRUE}

.    if ${_PF_4_7} != "0"
PF_VERSION=	4.7
.    elif ${_PF_4_6} != "0"
PF_VERSION=	4.6
.    elif ${_PF_4_5} != "0"
PF_VERSION=	4.5
.    elif ${_PF_4_4} != "0"
PF_VERSION=	4.4
.    elif ${_PF_4_3} != "0"
PF_VERSION=	4.3
.    elif ${_PF_4_2} != "0"
PF_VERSION=	4.2
.    elif ${_PF_4_1} != "0"
PF_VERSION=	4.1
.    elif ${_PF_3_8} != "0"
PF_VERSION=	3.8
.    elif ${_PF_3_7} != "0"
PF_VERSION=	3.7
.    elif ${_PF_3_6} != "0"
PF_VERSION=	3.6
.    elif ${_PF_3_5} != "0"
PF_VERSION=	3.5
.    endif
.endif

.endif  # PF_BUILDLINK3_MK