summaryrefslogtreecommitdiff
path: root/Mk/Uses/nodejs.mk
blob: 004b6ccf03fdca5603d445c09d09cdbcaeabc807 (plain) (blame)
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
# Provide support for Node.js
#
# Feature:	nodejs
#
# Usage:	USES=nodejs[:args]
#   Valid args:
#   - build     use node as build-time dependency
#   - run       use node as runtime dependency
#   - env       set the environment (NODEJS_VERSION and NODEJS_SUFFIX)
#   - version   available version: lts, current, 18, 20, 22, 23
#
# Note:
# - The supported versions follow upstream release schedule
#   https://github.com/nodejs/Release/blob/main/README.md#release-schedule
#   - lts is 20 now
#   - current is 23 now
# - USES=nodejs means USES=nodejs:build,run
# - If you define a version, you must provide run and/or build
#
# MAINTAINER: sunpoet@FreeBSD.org

.if !defined(_INCLUDE_USES_NODEJS_MK)
_INCLUDE_USES_NODEJS_MK=	yes

_VALID_NODEJS_VERSIONS=	18 20 22 23 current lts

.  if ! ${_VALID_NODEJS_VERSIONS:M${NODEJS_DEFAULT}}
IGNORE=	Invalid default nodejs version ${NODEJS_DEFAULT}; valid versions are ${_VALID_NODEJS_VERSIONS}
.  endif

.  if !empty(nodejs_ARGS:Nbuild:Nenv:Nrun:Nlts:Ncurrent:N18:N20:N22:N23)
IGNORE=		USES=nodejs has invalid arguments ${nodejs_ARGS}
.  endif

.  if empty(nodejs_ARGS)
nodejs_ARGS=	build,run
.  endif

.undef _NODEJS_VER
.  for version in ${_VALID_NODEJS_VERSIONS}
.    if ${nodejs_ARGS:M${version}}
_NODEJS_VER=	${version}
.    endif
.  endfor

.  if !defined(_NODEJS_VER)
_NODEJS_VER=	${NODEJS_DEFAULT}
.  endif

NODEJS_VERSION=	${_NODEJS_VER:S|current|23|:S|lts|20|}
NODEJS_SUFFIX=	-node${NODEJS_VERSION}

.  if ${nodejs_ARGS:M*build*}
BUILD_DEPENDS+=	node:www/node${NODEJS_VERSION}
.  endif
.  if ${nodejs_ARGS:M*run*}
RUN_DEPENDS+=	node:www/node${NODEJS_VERSION}
.  endif

.endif