help-make
[Top][All Lists]
Advanced

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

Problem regenerating file removed by rule


From: Darren Hiebert (Contractor)
Subject: Problem regenerating file removed by rule
Date: Wed, 6 Apr 2005 14:38:32 -0500 (CDT)

Hello,

I first posted this help request on the gnu.utils.help newsgroup,
but I suppose it would be better to post it here.

The following makefile (also attached) fails when recompiled using
the -j option (make-3.81beta1). It is a simplified example of a
more complicated makefile. What I am trying to do is create a set
of rules that complete the compilation of a files created by a
third-party compiler over whose actions I have no control. The
essential actions of this third-party compiler are reproduced in
the macro contained in the makefile.

To demonstrate the problem, issue the following commands using the
makefile below:

$ make -j
$ touch source
$ make -j

The problem is that the the config.sh created by the first
invocation of make is removed by the third-party compiler during the
second invocation of make, and make does not rebuild it from the
existing rules, even though I have a dependency to create it again
after the third-party compiler runs (indirectly via the dependency
upon sub/Makefile.SH; config.sh doesn't have to be regenerated if
Makefile.SH is newer--it only has to be sure that the file exists,
implying that the sub directory exists, which is guaranteed when
Makeifile.SH is brought up to date; thus the order-only dependency).

As much as I examime the rules I have written around this compiler,
I cannot see why config.sh is not regenerated by the makefile after
it is deleted by the compiler. It seems that when compiled using -j,
make believes that it already checked the existence of config.sh
before running the rule to run the third-party compiler and isn't
prepared for its deletion (despite the dependency, which should
check the file AFTER is order-only dependent is brought up to date).

Can someone please tell me what is wrong?
Your assistance is greatly appreciated.

Darren

-------------- Begin Makefile -------------
# I have no control over this action, performed by a third party compiler
define third_party_compiler
        rm -fr sub
        mkdir -p sub
        touch sub/Makefile.SH
        echo 'if [ ! -f config.sh ]; then echo "config.sh missing"; exit 1; fi' 
>> sub/Makefile.SH
        echo '. ./config.sh' >> sub/Makefile.SH
        echo 'echo "default: ; touch final" >>Makefile' >> sub/Makefile.SH
        touch $@
endef

sub/final: sub/Makefile
        $(MAKE) -C $(<D)

sub/Makefile: sub/Makefile.SH sub/config.sh
        cd $(<D) && sh Makefile.SH

sub/config.sh: | sub/Makefile.SH
        touch $@

sub/Makefile.SH: epr ;

epr: source
        $(third_party_compiler)

source:
        touch $@

clean:
        rm -f epr source
        rm -fr sub

-------------- End Makefile -------------

--
Darren Hiebert
Phone: 256-964-5830
Pager: 877-214-3485
XonTech Systems
Missle Defense Division
Northrop Grumman Mission Systems

Attachment: Makefile
Description: Makefile


reply via email to

[Prev in Thread] Current Thread [Next in Thread]