1PORTNAME=	node
2PORTVERSION=	${NODEJS_PORTVERSION}
3DISTVERSIONPREFIX=	v
4CATEGORIES=	www
5MASTER_SITES=	https://nodejs.org/dist/v${PORTVERSION}/
6PKGNAMESUFFIX=	20
7
8MAINTAINER=	ports@MidnightBSD.org
9COMMENT=	V8 JavaScript for client and server
10WWW=		https://nodejs.org/ \
11		https://github.com/nodejs/node
12
13LICENSE=	mit
14LICENSE_FILE=	${WRKSRC}/LICENSE
15
16BROKEN_SSL=	libressl libressl-devel
17BROKEN_SSL_REASON=	Node.js ${PORTVERSION:R:R}.x requires OpenSSL or the BUNDLED_SSL option enabled
18
19BUILD_DEPENDS=	brotli>=1.0.9,1:archivers/brotli \
20		c-ares>=1.17.2:dns/c-ares \
21		libnghttp2>=1.45.1:www/libnghttp2 \
22		libuv>=1.42.0:devel/libuv \
23		objdump:devel/binutils
24LIB_DEPENDS=	libbrotlidec.so:archivers/brotli \
25		libcares.so:dns/c-ares \
26		libnghttp2.so:www/libnghttp2 \
27		libuv.so:devel/libuv
28
29USES=		compiler:c++11-lib gmake localbase pkgconfig python:build shebangfix tar:xz
30
31CONFIGURE_ARGS=	--prefix=${PREFIX:S|^${DESTDIR}||} \
32		--shared-brotli \
33		--shared-cares \
34		--shared-libuv \
35		--shared-nghttp2 \
36		--shared-zlib \
37		--without-npm \
38		--dest-os=freebsd
39HAS_CONFIGURE=	yes
40MAKE_ENV=	CC.host="${CCACHE_BIN} ${CC}" \
41		CFLAGS.host="${CFLAGS}" \
42		CXX.host="${CCACHE_BIN} ${CXX}" \
43		CXXFLAGS.host="${CXXFLAGS}" \
44		LDFLAGS.host="${LDFLAGS}" \
45		LINK.host="${CXX}"
46REINPLACE_ARGS=	-i ''
47
48CONFLICTS_INSTALL=	node[0-9][0-9]
49
50SHEBANG_FILES=	deps/v8/third_party/inspector_protocol/*.py \
51		deps/v8/tools/*.py \
52		tools/*.py \
53		tools/inspector_protocol/*.py
54
55OPTIONS_DEFINE=	BUNDLED_SSL DOCS NLS
56OPTIONS_SUB=	yes
57BUNDLED_SSL_DESC=	Use bundled OpenSSL implementation from node.js
58
59BUNDLED_SSL_CONFIGURE_OFF=	--openssl-use-def-ca-store --shared-openssl
60BUNDLED_SSL_RUN_DEPENDS_OFF=	ca_root_nss>=0:security/ca_root_nss
61BUNDLED_SSL_USES_OFF=	ssl
62NLS_BUILD_DEPENDS=	icu>=69.1:devel/icu
63NLS_CONFIGURE_ON=	--with-intl=system-icu
64NLS_LIB_DEPENDS=	libicui18n.so:devel/icu
65
66.include "Makefile.version"
67.include <bsd.mport.options.mk>
68
69.if ${PORT_OPTIONS:MBUNDLED_SSL} && ${ARCH} != amd64
70CONFIGURE_ARGS+=--openssl-no-asm
71.endif
72
73post-patch:
74	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' ${WRKSRC}/tools/v8_gypfiles/v8.gyp
75
76post-configure:
77	# Post-process Makefile and *.mk files created by node-gyp and remove
78	# all occurrences of -I${LOCALBASE}/include. C*FLAGS include this
79	# before all -I../deps/* for bundled code. This can cause build
80	# breakages if the dependency is installed in ${LOCALBASE}. The
81	# USES+=localbase # above will ensure that we pick up includes for real
82	# external dependencies.
83	${FIND} ${WRKSRC}/out -type f -print0 | ${XARGS} -0 ${REINPLACE_CMD} -e "s|-I${LOCALBASE}/include||g"
84
85post-install:
86	${STRIP_CMD} ${PREFIX}/bin/node
87
88.include <bsd.port.mk>
89