Building postgres from source throws "'utils/errcodes.h' file not found" when called from other makefile

Viewed 296

I am currently constructing a Makefile and one of the things it will be doing is downloading and building postgres from source. Before starting to write the makefile file I always used the following set of commands to do this:

curl -LJ https://github.com/postgres/postgres/archive/refs/tags/REL_13_3.zip -o postgres.zip
unzip postgres.zip
rm postgres.zip
cd postgres-REL_13_3
./configure --prefix "`pwd`" --without-readline --without-zlib
make
make install

Executing the above listed commands in the terminal results in the successful installation of postgres. Then I translated these into a makefile which looks as follows:

build:
    curl -LJ https://github.com/postgres/postgres/archive/refs/tags/REL_13_3.zip -o postgres.zip
    unzip postgres.zip
    rm postgres.zip

    cd postgres-REL_13_3 \
        && ./configure --prefix "`pwd`" --without-readline --without-zlib \
        && $(MAKE) \
        && $(MAKE) install

Running this Makefile results in the error:

../../src/include/utils/elog.h:71:10: fatal error: 'utils/errcodes.h' file not found

It seems that something about calling the make from another Makefile causes a referencing issue with the files during the build process, but I just can figure out for the life of me what I have to change to fix this.

1 Answers

It appears to be the influence of Makefile enviromental variables. I didn't discover the exact mechanism, but unsetting them helps.

build:
    curl -LJ https://github.com/postgres/postgres/archive/refs/tags/REL_13_3.zip -o postgres.zip
    unzip postgres.zip
    rm postgres.zip

    unset MAKELEVEL && unset MAKEFLAGS && unset MFLAGS && cd postgres-REL_13_3 \
        && ./configure --prefix "`pwd`" --without-readline --without-zlib \
        && $(MAKE) \
        && $(MAKE) install
Related