MODULES+=	njs

MODULE_SUMMARY_njs=	njs dynamic modules

include $(CONTRIB)/src/njs/version

MODULE_VERSION_njs=	$(NJS_VERSION)
MODULE_RELEASE_njs=	1

MODULE_SOURCES_njs=	njs-$(NJS_VERSION).tar.gz

MODULE_CONFARGS_njs=	--with-stream \
			--add-dynamic-module=$(MODSRC_PREFIX)njs-$(NJS_VERSION)/nginx

.deps-module-njs:
	cd $(CONTRIB) && make .sum-njs
	touch $@

MODULE_VERSION_PREFIX_njs=$(MODULE_TARGET_PREFIX)
MODULE_BUILD_DEPENDS_njs=libedit-dev

define MODULE_ADD_CONTROL_TAGS_njs
replaces="nginx-mod-http-js"
endef
export MODULE_ADD_CONTROL_TAGS_njs

define MODULE_PREBUILD_njs
	cd ../njs-$(NJS_VERSION) \&\& ./configure \&\& make njs \&\& mv build build-cli
endef
export MODULE_PREBUILD_njs

define MODULE_PREINSTALL_njs
	mkdir -p "$$pkgdir"/usr/share/doc/nginx$(MODULE_SUFFIX)-module-njs
	install -m644 ../njs-$(NJS_VERSION)/CHANGES "$$pkgdir"/usr/share/doc/nginx$(MODULE_SUFFIX)-module-njs/
	mkdir -p "$$pkgdir"/usr/bin
	install -m755 -s ../njs-$(NJS_VERSION)/build-cli/njs "$$pkgdir"/usr/bin/
endef
export MODULE_PREINSTALL_njs

define MODULE_POST_njs
cat <<BANNER
----------------------------------------------------------------------

The $(MODULE_SUMMARY_njs) for $(MODULE_SUMMARY_PREFIX) have been installed.
To enable these modules, add the following to /etc/nginx/nginx.conf
and reload nginx:

    load_module modules/ngx_http_js_module.so;
    load_module modules/ngx_stream_js_module.so;

Please refer to the modules documentation for further details:
https://nginx.org/en/docs/njs/
https://nginx.org/en/docs/http/ngx_http_js_module.html
https://nginx.org/en/docs/stream/ngx_stream_js_module.html

----------------------------------------------------------------------
BANNER
endef
export MODULE_POST_njs
