summaryrefslogtreecommitdiff
path: root/lang/nodejs/nodeversion.mk
blob: db06dc85274e805ebc81951cc30a7d74dfb71aff (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
# $NetBSD: nodeversion.mk,v 1.5 2018/12/12 16:38:06 adam Exp $

# This file determins which nodejs version is used as a dependency for
# a package.
#
# === User-settable variables ===
#
# NODE_VERSION_DEFAULT
#	The preferred node version to use.
#
#	Possible values: 6 8 10
#	Default: 8
#
# === Infrastructure variables ===
#
# NODE_VERSION_REQD
#	node version to use. This variable should not be set by
#	packages. Normally it is used by bulk build tools.
#
#	Possible values: ${NODE_VERSIONS_ACCEPTED}
#	Default: ${NODE_VERSION_DEFAULT}
#
# === Package-settable variables ===
#
# NODE_VERSIONS_ACCEPTED
#	The node versions that the package can build against. Order
#	is significant; those listed earlier are preferred over those
#	listed later.
#
#	Possible values: 6 8 10
#	Default: 8 6 10
#
# NODE_VERSIONS_INCOMPATIBLE
#	The node versions that the package *cannot* build against.
#
#	Possible values: 6 8 10
#	Default: <empty>
#
# Keywords: node
#

.if !defined (NODEJS_NODEVERSION_MK)
NODEJS_NODEVERSION_MK=	# defined

# derive a node version from the package name if possible
# optionally handled quoted package names
.if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mnode[0-9]-*) || \
    defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-node[0-9]-*)
NODE_VERSION_REQD?=	${PKGNAME_REQD:C/(^.*-|^)node([0-9])-.*/\2/}
.elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mnode[0-9]-*) || \
    defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-node[0-9]-*)
NODE_VERSION_REQD?=	${PKGNAME_OLD:C/(^.*-|^)node([0-9])-.*/\2/}
.endif

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

BUILD_DEFS+=		NODE_VERSION_DEFAULT
BUILD_DEFS_EFFECTS+=	NODE_PACKAGE

NODE_VERSION_DEFAULT?=		8
NODE_VERSIONS_ACCEPTED?=	8 6 10
NODE_VERSIONS_INCOMPATIBLE?=	# empty

# Resolve NODE_VERSIONS_INCOMPATIBLE and generate the _OK vars.
.for v in ${NODE_VERSIONS_ACCEPTED}
.  if empty(NODE_VERSIONS_INCOMPATIBLE:M${v})
_NODE_VERSION_${v}_OK=		yes
_NODE_VERSIONS_ACCEPTED+=	${v}
.  endif
.endfor

# Pick a version
.if defined(NODE_VERSION_REQD)
.  if defined(_NODE_VERSION_${NODE_VERSION_REQD}_OK)
_NODE_VERSION=		${NODE_VERSION_REQD}
.  endif
.else
.  if defined(_NODE_VERSION_${NODE_VERSION_DEFAULT}_OK)
_NODE_VERSION?=		${NODE_VERSION_DEFAULT}
.  endif
.  for v in ${_NODE_VERSIONS_ACCEPTED}
.    if defined(_NODE_VERSION_${v}_OK)
_NODE_VERSION?=		${v}
.    endif
.  endfor
.endif

# In case nothing matched
_NODE_VERSION?=		none

.if ${_NODE_VERSION} == "8"
.include "../../lang/nodejs8/buildlink3.mk"
.elif ${_NODE_VERSION} == "6"
.include "../../lang/nodejs6/buildlink3.mk"
.elif ${_NODE_VERSION} == "10"
.include "../../lang/nodejs/buildlink3.mk"
.else
PKG_FAIL_REASON+=	"No valid node version found"
.endif

# Variable assignment for multi-node packages
MULTI+=	NODE_VERSION_REQD=${_NODE_VERSION}

.endif  # NODEJS_NODEVERSION_MK