Pullup ticket #2800.
[pkgsrc.git] / mk / pf.buildlink3.mk
1 # $NetBSD$
2 #
3 # Makefile fragment for packages using pf.
4 #
5 # The following variables are set by this file:
6 #
7 #   PFVAR_H     The path to the pfvar.h header file.
8 #   PFCTL       The path to the pfctl program.
9 #   PF_VERSION  The detected PF version (as in OpenBSD).
10 #
11
12 .if !defined(PF_BUILDLINK3_MK)
13 PF_BUILDLINK3_MK=       #defined
14
15 .include "../../mk/bsd.fast.prefs.mk"
16
17 # Platforms where pf is available on.
18 ONLY_FOR_PLATFORM?=     NetBSD-[3-9]*-* OpenBSD-[3-9]*-* FreeBSD-[5-9]*-* \
19                         DragonFly-*-*
20
21 # Detect the pfvar.h header.
22 .if exists(/usr/include/net/pfvar.h)
23 _PFVAR_H=       /usr/include/net/pfvar.h        
24 .elif exists(/usr/include/net/pf/pfvar.h)
25 _PFVAR_H=       /usr/include/net/pf/pfvar.h
26 .else
27 PKG_FAIL_REASON+=       "Couldn't find pfvar.h header; please make sure that this header is available in /usr/include/net."
28 .endif
29
30 PFVAR_H?=       ${_PFVAR_H}
31 PFCTL?=         /sbin/pfctl
32
33 # Compute the version number of the PF API by checking for the presence
34 # of symbols added in newer versions and store the result in ${PF_VERSION}.
35
36 # Default to the first version with PF, which was OpenBSD 3.0.
37 PF_VERSION=     3.0
38
39 .if !empty(PFVAR_H)
40 # OpenBSD 4.2: pf_statelist added
41 _PF_4_2!=       ${GREP} -c pf_statelist ${PFVAR_H} || ${TRUE}
42 # OpenBSD 4.1: PF_OSFP_INET6 added
43 _PF_4_1!=       ${GREP} -c PF_OSFP_INET6 ${PFVAR_H} || ${TRUE}
44 # OpenBSD 3.8: pf_socket_lookup added
45 _PF_3_8!=       ${GREP} -c pf_socket_lookup ${PFVAR_H} || ${TRUE}
46 # OpenBSD 3.7: pf_threshold added
47 _PF_3_7!=       ${GREP} -c pf_threshold ${PFVAR_H} || ${TRUE}
48 # OpenBSD 3.6: pf_cksum_fixup added
49 _PF_3_6!=       ${GREP} -c pf_cksum_fixup ${PFVAR_H} || ${TRUE}
50 # OpenBSD 3.5: pfi_lookup_if added
51 _PF_3_5!=       ${GREP} -c pfi_lookup_if ${PFVAR_H} || ${TRUE}
52
53 .    if ${_PF_4_2} != "0"
54 PF_VERSION=     4.2
55 .    elif ${_PF_4_1} != "0"
56 PF_VERSION=     4.1
57 .    elif ${_PF_3_8} != "0"
58 PF_VERSION=     3.8
59 .    elif ${_PF_3_7} != "0"
60 PF_VERSION=     3.7
61 .    elif ${_PF_3_6} != "0"
62 PF_VERSION=     3.6
63 .    elif ${_PF_3_5} != "0"
64 PF_VERSION=     3.5
65 .    endif
66 .endif
67
68 .endif  # PF_BUILDLINK3_MK