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

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

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

%:
	dh $@

override_dh_auto_build:
	echo "# Compiling types"
	cd types && tsc -p src
	set -e; for p in jsonrpc protocol server; do \
		echo "# Compiling $$p"; \
		(cd $$p && tsc -p src/common && tsc -p src/node && tsc -p src/browser); \
	done
	echo "# Compiling tools"
	cd tools && tsc
	echo "# Compiling textDocument"
	cd textDocument && tsc -p src

override_dh_installdocs:
	dh_installdocs
	dh_nodejs_autodocs auto_dispatch

# Fix versions of components
override_dh_gencontrol:
	set -e; for p in `pkgjs-utils root_components_list;cat debian/nodejs/main`; do \
		VERSION=`pkgjs-pjson $$p version | sed -e 's/-/~/g'`; \
		NAME=node-`pkgjs-pjson $$p name`; \
		dh_gencontrol -p$$NAME -- -v$$VERSION~$(DEB_VERSION); \
	done
