From: rjd15372 (@rjd15372) <noreply+rjd15372@github.com>
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Subject: [pgaudit/pgaudit] PR #326: Locate pgaudit.control relative to the Makefile.
Date: Wed, 15 Jul 2026 16:09:07 +0000
Message-ID: <gh-pgaudit-pgaudit-326@github.com> (raw)
`PGAUDIT_VERSION` is determined by grepping `pgaudit.control` with a path relative to the current working directory. That works for in-tree builds, but in out-of-tree PGXS builds (`make -f path/to/Makefile` with `VPATH`, as used e.g. by Debian's `pg_buildext`) the control file is not in the build directory: the grep fails, `PGAUDIT_VERSION` expands to an empty string, and the build breaks later when installing the version suffixed SQL file:
```
grep: pgaudit.control: No such file or directory
...
install: cannot stat '.../pgaudit--.sql': No such file or directory
```
Resolve the control file relative to the Makefile location instead, using `$(dir $(firstword $(MAKEFILE_LIST)))`, which yields the source directory in both in-tree and `VPATH` builds.
inline patch 1: Makefile (+1/-1 lines) download inline-1.patchdiff --git a/Makefile b/Makefileindex 8886980..207cf7a 100644--- a/Makefile+++ b/Makefile@@ -2,7 +2,7 @@ MODULE_big = pgaudit
OBJS = pgaudit.o $(WIN32RES)
# The version in the control file is the source of truth
-PGAUDIT_VERSION := $(shell grep default_version pgaudit.control | sed "s/.*'\(.*\)'/\1/")+PGAUDIT_VERSION := $(shell grep default_version $(dir $(firstword $(MAKEFILE_LIST)))pgaudit.control | sed "s/.*'\(.*\)'/\1/")
EXTENSION = pgaudit
DATA = pgaudit--$(PGAUDIT_VERSION).sql