telling 'make' to ignore dependencies when the top target has been created

前端 未结 5 489
天涯浪人
天涯浪人 2021-02-05 05:34

I\'m running the following kind of pipeline:

digestA: hugefileB hugefileC
    cat $^ > $@
    rm $^

hugefileB:
    touch $@

hugefileC:
    touch $@
<         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 05:56

    If you mark hugefileB and hugefileC as intermediate files, you will get the behavior you want:

    digestA: hugefileB hugefileC
            cat $^ > $@
    
    hugefileB:
            touch $@
    
    hugefileC:
            touch $@
    
    .INTERMEDIATE: hugefileB hugefileC
    

    For example:

    $ gmake
    touch hugefileB
    touch hugefileC
    cat hugefileB hugefileC > digestA
    rm hugefileB hugefileC
    $ gmake
    gmake: `digestA' is up to date.
    $ rm -f digestA
    $ gmake
    touch hugefileB
    touch hugefileC
    cat hugefileB hugefileC > digestA
    rm hugefileB hugefileC
    

    Note that you do not need the explicit rm $^ command anymore -- gmake automatically deletes intermediate files at the end of the build.

提交回复
热议问题