#!/usr/bin/make -f

export DEB_CFLAGS_MAINT_APPEND = -Wall -DDBLIB_UNIMPLEMENTED=1

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --with-gnu-ld \
		--with-unixodbc=/usr --sysconfdir=/etc/freetds \
		--enable-sybase-compat --with-gnutls --enable-krb5

override_dh_auto_install:
	dh_auto_install
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/odbc
	mv $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libtdsodbc.so.0.0.0 \
	   $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/odbc/libtdsodbc.so
	rm -f $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libtdsodbc*

override_dh_fixperms:
ifneq (,$(filter freetds-common, $(shell dh_listpackages)))
	chmod a-x $(CURDIR)/debian/freetds-common/usr/share/freetds/freetds.conf
endif
	dh_fixperms

override_dh_makeshlibs:
	dh_makeshlibs -Xtdsodbc -V
