#!/usr/bin/make -f

export JAVA_HOME = /usr/lib/jvm/default-java

B = $(CURDIR)/debian/build
D = debian/scala-js

%:
	dh $@

override_dh_auto_build:
	sh debian/build-driver.sh $(CURDIR) $(B)

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
	sh debian/tests/hello-link $(B)
endif

override_dh_auto_install:
	# The jars and POMs of both packages are installed by maven-repo-helper
	# (debian/*.poms); here only the scalajs-link command.
	install -D -m644 $(B)/jars/scalajs-link.jar $(D)/usr/share/scala-js/lib/scalajs-link.jar
	install -D -m755 debian/scalajs-link $(D)/usr/bin/scalajs-link

execute_after_dh_installdocs:
	# The scalalib IR is compiled from the Scala 2.13 library sources.
	install -m644 scala213-library/NOTICE \
	  debian/scala-js-library/usr/share/doc/scala-js-library/NOTICE.scala-library

override_dh_auto_clean:
	rm -rf $(B)
