Re: BUG #5665: catalog/schemapg.h: No such file or directory - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5665: catalog/schemapg.h: No such file or directory
Date
Msg-id 2695.1296412031@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5665: catalog/schemapg.h: No such file or directory  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I wrote:
> Dylan Alex Simon <dylan@dylex.net> writes:
>> I'm seeing this problem too, so I might be able to shed some light on it.

> Hm.  I can't replicate this at all.
> ...

>> GNU Make 3.82

> Mine is 3.81 (Fedora 13).  Is it possible this is a bug introduced in
> 3.82?  The symlink is made this way:

> $(top_builddir)/src/include/catalog/schemapg.h: catalog/schemapg.h
>     prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
>       cd $(dir $@) && rm -f $(notdir $@) && \
>       $(LN_S) "$$prereqdir/$(notdir $<)" .

Ah-hah: when I try it on Fedora 14 (with make 3.82), it fails just as
Dylan describes.  Doing it manually in builddir/src/backend shows that
"dir $<" is indeed the culprit:

$ rm ../../src/include/catalog/schemapg.h
$ make ../../src/include/catalog/schemapg.h
make -C catalog schemapg.h
make[1]: Entering directory `/home/tgl/tmp/postgresql-9.0.2/obj-x86_64/src/backend/catalog'
make[1]: `/home/tgl/tmp/postgresql-9.0.2/src/src/backend/catalog/schemapg.h' is up to date.
make[1]: Leaving directory `/home/tgl/tmp/postgresql-9.0.2/obj-x86_64/src/backend/catalog'
prereqdir=`cd catalog/ >/dev/null && pwd` && \
  cd ../../src/include/catalog/ && rm -f schemapg.h && \
  ln -s "$prereqdir/schemapg.h" .
$ ls -l ../../src/include/catalog/schemapg.h
lrwxrwxrwx. 1 tgl tgl 72 Jan 30 13:03 ../../src/include/catalog/schemapg.h ->
/home/tgl/tmp/postgresql-9.0.2/obj-x86_64/src/backend/catalog/schemapg.h

Now, this make rule looks exactly like the one for parser/gram.h, and
that's not misbehaving.  The problem appears to be caused by the
other rule for schemapg.h:

# run this unconditionally to avoid needing to know its dependencies here:
submake-schemapg:
    $(MAKE) -C catalog schemapg.h

.PHONY: submake-schemapg

catalog/schemapg.h: submake-schemapg

If I comment this out entirely, or change it to a simple rule

catalog/schemapg.h:
    $(MAKE) -C catalog schemapg.h

then the symlink is built correctly.  Apparently, the use of a phony
dependency causes make to decide that "catalog/schemapg.h" must refer to
a file in the build tree not the source tree.

I'm not sure whether the gmake boys will think this is a bug.  It's
certainly a behavior change from pre-3.82 releases.  In any case,
I think the rule for catalog/schemapg.h is a bit too cute (and even more
so in HEAD ... WTF is that "|" in there now?).  We need to be less
bleeding edge here.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5665: catalog/schemapg.h: No such file or directory
Next
From: Robert Haas
Date:
Subject: Re: BUG #5851: ROHS (read only hot standby) needs to be restarted manually in somecases.