#!/usr/bin/make -f

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

include /usr/share/cdbs/1/rules/debhelper.mk
# include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/ruby-pkg-tools/1/class/ruby-setup-rb.mk

docdir := /usr/share/doc/librmagick-ruby-doc/html
DEB_RUBY_CONFIG_ARGS += --doc-dir=$(CURDIR)/debian/librmagick-ruby-doc/$(docdir)

# Workaround buggy buildds on sparc
ifeq ($(DEB_BUILD_ARCH),sparc)
DEB_RUBY_CONFIG_ARGS +=  --allow-example-errors
endif

# upstream uses a "post-clean" hook, but no "post-distclean", so we have to
# override DEB_RUBY_CLEAN_TARGET.
DEB_RUBY_CLEAN_TARGET = clean

# avoid compressing examples
DEB_COMPRESS_EXCLUDE := .rb

# this is a hack: we need to "install" librmagick-ruby1.8, since it will
# generate the HTML doc for librmagick-ruby-doc. This should probably be
# fixed in ruby-pkg-tools instead.
install/librmagick-ruby-doc:: install/librmagick-ruby1.8

# generate rdoc documentation
install/librmagick-ruby-doc::
	dh_rdoc -plibrmagick-ruby-doc ext lib
	find $(CURDIR)/debian/librmagick-ruby-doc/$(docdir) -name .rmagick -exec rm {} +
	find $(CURDIR)/debian/librmagick-ruby-doc/$(docdir) -name .cvsignore -exec rm {} +

clean::
	rm -f ext/RMagick/Makefile ext/RMagick/extconf.h
