#!/usr/bin/make -f
# Debian rules for pg_vault_tde
# Uses debhelper 13 with manual PGXS overrides
#
# PG_MAJOR is set by build_deb.sh (default: 18).
# The variable is passed via environment and used in all pg_config paths.

# Allow the calling script to override the PostgreSQL major version.
PG_MAJOR ?= 18
PKG_NAME  = postgresql-$(PG_MAJOR)-pg-vault-tde

%:
	dh $@

override_dh_auto_build:
	$(MAKE) PG_CONFIG=/usr/lib/postgresql/$(PG_MAJOR)/bin/pg_config

override_dh_auto_install:
	$(MAKE) PG_CONFIG=/usr/lib/postgresql/$(PG_MAJOR)/bin/pg_config install \
		DESTDIR=$(CURDIR)/debian/$(PKG_NAME)

override_dh_auto_test:
	# The smoke test is `make check-standalone`, which starts its own throwaway
	# cluster and needs no external service — but it requires the extension to be
	# installed in the tree pg_config points at, and a package build stages into
	# debian/<pkg> instead. Redirecting a cluster at a staged tree needs
	# extension_control_path, which exists from PostgreSQL 18 only, so there is no
	# way to do this uniformly across the majors this package targets.
	# Run it against an installed build instead:  make install && make check-standalone
	: skipping tests during the package build

override_dh_installchangelogs:
	dh_installchangelogs

override_dh_compress:
	dh_compress -X.sql -X.control
