Using Makefiles to build PostgreSQL

Posted by ads on Saturday, 2018-11-03
Posted in [Postgresql][Postgresql-News]

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.

Categories: [Postgresql] [Postgresql-News]