Re: Confused about gram.y referencs in Makefile?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Confused about gram.y referencs in Makefile?
Date: 2023-09-25 03:17:50
Message-ID: 65504.1695611870@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Japin Li <japinli(at)hotmail(dot)com> writes:
> I find src/backend/utils/mb/Unicode/Makefile has the following comments:

>> # Note that while each script call produces two output files, to be
>> # parallel-make safe we need to split this into two rules. (See for
>> # example gram.y for more explanation.)

> I could not find the explanation in gram.y easily. Would someone point
> it out for me? Thanks in advance!

It's referring to this bit in src/backend/parser/Makefile:

-----
# There is no correct way to write a rule that generates two files.
# Rules with two targets don't have that meaning, they are merely
# shorthand for two otherwise separate rules. If we have an action
# that in fact generates two or more files, we must choose one of them
# as primary and show it as the action's output, then make all of the
# other output files dependent on the primary, like this. Furthermore,
# the "touch" action is essential, because it ensures that gram.h is
# marked as newer than (or at least no older than) gram.c. Without that,
# make is likely to try to rebuild gram.h in subsequent runs, which causes
# failures in VPATH builds from tarballs.

gram.h: gram.c
touch $@

gram.c: BISONFLAGS += -d
gram.c: BISON_CHECK_CMD = $(PERL) $(srcdir)/check_keywords.pl $< $(top_srcdir)/src/include/parser/kwlist.h
-----

This is indeed kind of confusing, because there's no explicit
reference to gram.y here --- the last two lines just tweak
the behavior of the default .y to .c rule.

Maybe we should adjust the comment in Unicode/Makefile, but
I'm not sure what would be a better reference.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii.Yuki@df.MitsubishiElectric.co.jp 2023-09-25 03:18:13 RE: Partial aggregates pushdown
Previous Message Japin Li 2023-09-25 02:41:05 Confused about gram.y referencs in Makefile?