[BACK]Return to nodeversion.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / lang / nodejs

File: [cvs.NetBSD.org] / pkgsrc / lang / nodejs / nodeversion.mk (download)

Revision 1.1, Wed May 2 16:33:02 2018 UTC (11 months, 2 weeks ago) by fhajny
Branch: MAIN

lang/nodejs*: Remove the npm package manager from nodejs packages. Introduce nodeversion.mk framework to pick and depend on one of the supported nodejs version packages. Bump respective PKGREVISIONs.

# $NetBSD: nodeversion.mk,v 1.1 2018/05/02 16:33:02 fhajny 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 9
#	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 9
#	Default: 8 6 9
#
# NODE_VERSIONS_INCOMPATIBLE
#	The node versions that the package *cannot* build against.
#
#	Possible values: 6 8 9
#	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 9
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"
DEPENDS+=	nodejs>=8<9:../../lang/nodejs8
.elif ${_NODE_VERSION} == "6"
DEPENDS+=	nodejs>=6<7:../../lang/nodejs6
.elif ${_NODE_VERSION} == "9"
DEPENDS+=	nodejs>=9:../../lang/nodejs
.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