tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make rules when creating multiple files



On Sat, 13 Aug 2011, Thomas Klausner wrote:

> Matthew Green provided the following analysis for PR 45126 (parallel
> build breakage in Kerberos):
>
> ----- Forwarded message from matthew green <mrg%eterna.com.au@localhost> -----
>
> i think i may have figured out the cause of this.  i noticed that
> my build tree had hdb_asn1.h as a zero length file.  after a little
> bit of red-herring with seeing a similar zero length file in the
> src/compat build, i come across the rules in
> src/crypto/external/bsd/heimdal/Makefile.rules.inc:
>
> ${ASN1_FILES.${src}} ${src:.asn1=_asn1.hx} ${src:.asn1=_asn1-priv.hx}: ${src} 
> \
>                                         ${src:.asn1=.opt} ${TOOL_ASN1_COMPILE}
>         ${TOOL_ASN1_COMPILE}                    \
>                 ${ASN1_OPTS.${src}}             \
>                 --option-file=${.ALLSRC:[2]}    \
>                 ${.ALLSRC:[1]} ${src:.asn1=_asn1}
>
>
> this rule will run the asn1_compile multiple times when it infact
> only wants to be run once.  i'm not sure how this is causing zero
> length files to be created but this rule is, AFAIK, broken.
>
> i don't have a fix.
>
>
> .mrg.
>
> ----- End forwarded message -----
>
> What is the correct fix?

rework it to provide a single target, with other files produced as
side-effects and rearrange any dependents to depend on that target rather
than the side-effect files

eg for things like cgram.y -> cgram.[ch] we don't do

cgram.c cgram.h: cgram.y
        yacc -d cgram.y
        mv yy.tab.c cgram.c
        mv yy.tab.h cgram.h

src.c: cgram.h

which will work for -j1 but will run it twice for -j2

but instead, use

cgram.c: cgram.y
        yacc -d cgram.y
        mv yy.tab.c cgram.c
        mv yy.tab.h cgram.h

src.c: cgram.c

and don't tell make about the cgram.h file. If the user edits it by hand,
well thats their mistake..

iain


Home | Main Index | Thread Index | Old Index