#!/usr/bin/make -f

include /usr/share/postgresql-common/pgxs_debian_control.mk

%:
	dh $@

override_dh_builddeb:
	dh_builddeb -- -Zgzip

override_dh_auto_clean:
	rm -rf build

CODENAME := $(shell . /etc/os-release && echo $$VERSION_CODENAME)
override_dh_auto_build:
ifeq ($(filter $(CODENAME),trixie resolute),$(CODENAME))
	make USE_PGXS=1 \
	PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config \
	with_llvm=no
else
	make USE_PGXS=1 \
    CXX="clang++-21" \
    CXXFLAGS="-stdlib=libc++" \
    LDFLAGS="-L/usr/lib/llvm-21/lib" \
    PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config \
    USE_LIBCXX=1 \
    with_llvm=no
endif

override_dh_auto_install:
	make USE_PGXS=1 install DESTDIR=$(CURDIR)/debian/tmp \
	PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config \
	with_llvm=no

override_dh_auto_test:

override_dh_installdocs:
	dh_installdocs --all README.*
