#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

COMPONENTS=core colors icons select

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_auto_build:
	ln -s ../../packages/core node_modules/@blueprintjs/core || true
	for p in `cat debian/nodejs/build_order`; do \
		if test -e $$p; then \
		(cd $$p && \
			echo "Compiling $$p"; \
			tsc -p src; \
			tsc -p src -m commonjs --outDir lib/cjs; \
			tsc -p src -t esnext --outDir lib/esnext \
		); \
		fi; \
	done

override_dh_installdocs:
	dh_installdocs
	# Auto-generate components docs
	dh_nodejs_autodocs auto_dispatch

# Fix versions and homepage of components
override_dh_gencontrol:
	dh_gencontrol -pnode-blueprintjs-core -- -v$(DEB_VERSION)
	dh_gencontrol -pnode-blueprintjs-popover2 -- \
		-v$(shell pkgjs-pjson packages/popover2/ version)~$(DEB_VERSION)
	dh_gencontrol -pnode-blueprintjs-select -- \
		-v$(shell pkgjs-pjson packages/select/ version)~$(DEB_VERSION) \
