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

export prefix := /usr
export LUA := lua5.3

# Snapshot builds are performed using source packages generated by git-buildpackage, which lack
# the .git/ directory. The Buildkite job does a changelog bump using the Git commit SHA, which we
# must then pull back out and stick in the environment for the Makefile.
#
# This hack is better or worse than maintaining upstream tar in the Git repo and import-orig'ing
# the result of 'make dist' before kicking off the snapshot build, depending on your point of view.

GIT_COMMIT_SHA = $(shell dpkg-parsechangelog --show-field Version | grep + | cut -d+ -f2 | cut -d- -f1)
ifneq ($(GIT_COMMIT_SHA),)
	export GIT_COMMIT_SHA
endif

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKE_J_FLAG = -j$(NUMJOBS)
endif

LLVM_CONFIG := llvm-config-7
export LLVM_CONFIG

%:
	dh $@

override_dh_auto_test:
	xvfb-run -a -e /dev/stdout make $(MAKE_J_FLAG) check
