#!/usr/bin/make -f

export GEM2DEB_TEST_RUNNER = --check-dependencies
export DH_RUBY = --gem-install
ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

%:
	dh $@ --buildsystem=ruby --with ruby

override_dh_quilt_patch:
ifeq ($(DEB_HOST_ARCH),riscv64)
	dh_quilt_patch
else
	@quilt pop increase-test-threshold-for-riscv.patch || test $$? = 2
endif
    	

override_dh_auto_build:
	ragel ragel/redcloth_scan.c.rl -o ext/redcloth_scan/redcloth_scan.c
	ragel ragel/redcloth_inline.c.rl -o ext/redcloth_scan/redcloth_inline.c
	ragel ragel/redcloth_attributes.c.rl -o ext/redcloth_scan/redcloth_attributes.c
	ragel ragel/redcloth_common.c.rl -o ext/redcloth_scan/redcloth_common.c
	dh_auto_build

override_dh_installdocs:
	rdoc --inline-source --line-numbers --op rdoc \
		--main README.rdoc --title "RedCloth" \
		lib README.rdoc
	dh_installdocs

override_dh_clean:
	rm -rf rdoc
	dh_clean
