Building an extension in a separate directory from the source files.

From: a(dot)mitrokhin(at)postgrespro(dot)ru
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Building an extension in a separate directory from the source files.
Date: 2024-12-03 09:38:39
Message-ID: 16f545728a966bffc9c272a312fb4901@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

1. Does postgresql support building an extension in a separate directory
from the source files? For example, is this design officially
supported?

~$ mkdir -p $(BUILDDIR)
~$ make -C $(BUILDDIR) -f $(SRCDIR)/Makefile USE_PGXS=1 all

2. If so, what is the correct way to build object files for .c files
that are
located in their own subdirectories inside $(SRCDIR)? For example, in
$(SRCDIR)/Makefile it is written:
OBJS = src/a.c src/b.c
I'm getting:
gcc ... -c -o src/a.o ../src/a.c
Assembler messages:
Fatal error: can't create src/a.o: No such file or directory

Patch which fixes this problem for me:

--- src/Makefile.global.in.orig 2024-11-29 16:26:14.350728880 +0700
+++ src/Makefile.global.in 2024-11-29 16:26:54.362809922 +0700
@@ -991,6 +991,7 @@
# GCC allows us to create object and dependency file in one invocation.
%.o : %.c
@if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
+ @if test ! -d $(@D); then mkdir -p $(@D); fi
$(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po

%.o : %.cpp

/foo

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2024-12-03 09:43:31 Re: processes stuck in shutdown following OOM/recovery
Previous Message Kirill Reshke 2024-12-03 09:28:33 Re: Fix for consume_xids advancing XIDs incorrectly