#!/usr/bin/make -f

export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -DOBEXFTP_DEBUG=5
endif

PERL_ARCHLIB := $(shell perl -MConfig -e 'print $$Config{vendorarch}')
RUBY_DEPENDS := -Vruby:Depends="lib$(firstword $(shell dh_ruby --print-supported))"

%:
	dh $@ --parallel --with python2

override_dh_gencontrol:
	dh_gencontrol -- $(RUBY_DEPENDS)

override_dh_auto_build:
	dh_auto_build
	doxygen

override_dh_install:
	sed -e 's;@PERL_ARCHLIB@;$(PERL_ARCHLIB);g;' $(CURDIR)/debian/libobexftp-perl.install.in > $(CURDIR)/debian/libobexftp-perl.install
	dh_install --fail-missing -X.la

override_dh_installdocs:
	dh_installdocs -XCOPYING -XINSTALL -Xobexftp.1

override_dh_installexamples:
	dh_installexamples -plibobexftp0-dev examples/c_example*.c
	#dh_installexamples -plibobexftp0-dev examples/tcl_*.tcl  # tcl is currently disabled
	dh_installexamples -plibobexftp-perl examples/perl_*.pl
	dh_installexamples -ppython-obexftp examples/python_*.py
	dh_installexamples -pruby-obexftp examples/ruby_*.rb

override_dh_fixperms:
	dh_fixperms
	chmod 0644 debian/libobexftp0-dev/usr/share/doc/libobexftp0-dev/examples/c_example*.c
