Skip to content

Using Makefiles to build PostgreSQL

For a long time I was using a Makefile to quickly build, start, stop and then wipe a predefined PostgreSQL version. That comes handy if you just want to test something on an older version, without actually installing the software. Everything happens in a single directory, even a different port is assigned.

When I needed that setup recently, I ran into unrelated build errors:

relpath.c:21:10: fatal error: catalog/pg_tablespace_d.h: No such file or directory
 #include "catalog/pg_tablespace_d.h"
compilation terminated.

Can't be - pg_tablespace_d.h is included in the tarball I'm using.



Turns out, the Makefile PostgreSQL is using doesn't really like the fact that it is called from another Makefile.

Andres pointed this out to me on IRC, and he also mentioned that it is mentioned in the documentation. But only starting with version 11, documentation versions before that do not have this hint.

Anyway, the proper way to work around that problem is by using "make MAKELEVEL=0":

$(MAKE) -C postgresql MAKELEVEL=0 all


This way, the build goes through and everything works as expected. I can keep my Makefiles around a bit longer.


No Trackbacks


Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options