#!/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-linux-x86_64
export ARCH = 64
else
export instantclientdir = instantclient-linux_i386
export ARCH =
endif

export LIB_VERSION = 19.6

DESTDIR = $(CURDIR)/debian/oracle-instantclient-basic

%:
	dh $@

execute_after_dh_install:
	$(shell (echo "/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/lib/" >$(DESTDIR)/etc/ld.so.conf.d/oracle.conf))
	# remove symlink for libclntsh.so and libocci.so:
	# it's provided by oracle-instantclient$(LIB_VERSION)-devel
	rm -v $(DESTDIR)/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/lib/libclntsh.so
	rm -v $(DESTDIR)/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/lib/libocci.so
	# patch binaries and libraries to use libaio.so.1t64 instead of libaio.so.1,
	# which is Ok since both are ABI-compatible for amd64 and i386,
	# cf. https://wiki.debian.org/ReleaseGoals/64bit-time
	debian/patch-libaio-t64.sh $(DESTDIR)/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/

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

override_dh_shlibdeps:
	dh_shlibdeps -l$(DESTDIR)/usr/lib/oracle/$(LIB_VERSION)/client$(ARCH)/lib
