#!/usr/bin/make -f

# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

include /usr/share/dpkg/architecture.mk

ifeq ($(DEB_HOST_ARCH),amd64)
export instantclientdir = instantclient-sqlplus_x86_64
export ARCH = 64
else
export instantclientdir = instantclient-sqlplus_i386
export ARCH =
endif

export LIB_VERSION = 19.6

%:
	dh $@

override_dh_dwz:
	# don't run tools on binaries files. We just want to install the
	# upstream binaries files

override_dh_shlibdeps:
	# dh_shlibdeps fails with libaio, as libaio.so.1 -> libaio.so.1t64, hence SONAME is libaio.so.1t64,
	# however the oracle libraries where linked against libaio.so.1, so we need to pass
	# --ignore-missing-info to dpkg-shlibdeps, and then add the libaio dependency manually...
	dh_shlibdeps -l/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/lib -- --ignore-missing-info
	constraint=$$(grep -o 'libaio-dev ([^)]*)' debian/control | cut -d' ' -f2-); \
	sed -i "s/$$/, libaio1t64 $$constraint/" debian/oracle-instantclient-sqlplus.substvars; \
	cat debian/oracle-instantclient-sqlplus.substvars;
