OpenBSD CVS

CVS log for src/share/mk/bsd.dep.mk


[BACK] Up to [local] / src / share / mk

Request diff between arbitrary revisions


Default branch: MAIN
Current tag: OPENBSD_7_3_BASE


Revision 1.25 / (download) - annotate - [select for diffs], Sat Jan 8 17:05:30 2022 UTC (2 years, 4 months ago) by patrick
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, HEAD
Changes since 1.24: +2 -2 lines
Diff to previous 1.24 (colored)

Use ${.ALLSRC:M*.y} instead of ${.IMPSRC} as the input file for yacc,
to fix a bug where ${.IMPSRC} (aka $<) is used in a context where it
is not neccessarily defined by OpenBSD make.  This would sometime show
up trying to build libpcap with the following error message:

Using $< in a non-suffix rule context is a GNUmake idiom (<bsd.dep.mk>:47)

The issue is with the rule for the grammar.h file that is generated
by yacc from grammar.c. You can easily reproduce the bug with the
following steps:

- build libpcap from scratch: cd src/lib/libpcap && make clean all
- remove the generated grammar.h file: rm obj*/grammar.h
- build libpcap again (incremental build): make

In normal builds this does not trigger as grammar.h is implicitly
generated by the rule for grammar.c and when make checks for
dependencies it simply finds grammar.h uptodate. However, incremental
or parallel builds might decide to make grammar.h from grammar.y.

Now, why is this only a problem for grammar.h but not for grammar.c?
The answer to this question is burried deeply in OpenBSD's mk files.

The snippet in bsd.dep.mk that triggers the error is a single rule
statement that generates foo.c and foo.h from foo.y with a call to
yacc -d. The rule is generated with a loop, i.e. it is not a prefix
rule. However, a prefix rule context is required for the use of
${.IMPSRC} aka $<. For the .c file such a prefix rule is provided by
bsd.sys.mk and this rule is in scope when make evaluates the yacc rule.
However, for .h file generation from a .y file there is no such prefix
rule defined in any of the Makefiles. Even if it were the .h suffix is
missing from .SUFFIXES and the rule would not be considered.

The obvious way to fix this would be to use $f instead of ${.IMPSRC}.
However, this does not work as $f is then missing the path prefix and
yacc won't find it if an obj directory is used. This is probably the
reason for the use of ${.IMPSRC} in the first place.

Committing on behalf of ehrhardt@
"I like the diff" deraadt@
ok guenther@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.