Makefile template target is not "up to date" when it has been performed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Makefile template target is not "up to date" when it has been performed

Larry Wilson Sr
I have the following:

In a generic template (Makefile.rules.mak):

BUILDPATHBASHLIBSCRIPTS = $(addprefix $(BUILDPATHDIR)/, $(BASHLIBSCRIPTS))

$(BUILDPATHBASHLIBSCRIPTS): $(BUILDPATHDIR)/%: %
        if test $< -nt $@; then \
                cp -f $< $@ \
                chmod a+rx $@; fi

In a local makefile:

BASHLIBSCRIPTS = revisionclass.sh

include $(MAKEUTILITYDIR)/Makefile.rules.mak

$(BUILDPATHDIR)/revisionopssingleton.sh: privateext

privateext: revisionopssingleton.sh
        ./compilerevision.sh $< $(BUILDPATHDIR)/$<

My issues are that the privateext rule is ALWAYS run
AND the $(BUILDPATHBASHLIBSCRIPTS) rule is always run

(PLEASE ignore the check for -nt as it was needed for the rule NOT to overwrite the BUILDPATHDIR/revisionopssingleton.sh file since the normal target is not being satisfied by the privateext rule)

The purpose of this sequence of rules is to allow a shell script to flow from source to local (production or debug) setup to staging setup (not shown); a shell script 99 out of 100 will not be changed but in this case I use the source as a template and edit it to have defaults that are the "current packages revision"
ie. if JUST the file list assignment is done then the source file will simply flow through a local copy then a staging copy.

So, when perform the make, I get the local rule run first then the template rule run ...

what I don't understand is WHY is the local rule ALWAYS runs ...
ie. once the BUILDPATHDIR/revisionopssingleton.sh has been created and is newer than the source why does a subsequent not see this as up to date

AND why does the template rule run regardless of the BUILDPATHDIR/revisionopssingleton.sh already having been staisfied ...

I have a feeling that the first issue is caused by the second issue but why are the targets not up to date once the BUILDPATHDIR/revisionopssingleton.sh has been created?

Any insight is appreciated ...
       
Reply | Threaded
Open this post in threaded view
|

Re: Makefile template target is not "up to date" when it has been performed

Larry Wilson Sr
oops, the above assignment is typed wrong (in this message not the makefile itself :) ...

BASHLIBSCRIPTS = revisionopssingleton.sh
Reply | Threaded
Open this post in threaded view
|

Re: Makefile template target is not "up to date" when it has been performed

Paul Smith-20
In reply to this post by Larry Wilson Sr
On Mon, 2016-08-22 at 06:33 -0700, Larry Wilson Sr wrote:

> I have the following:
>
> In a generic template (Makefile.rules.mak):
>
> BUILDPATHBASHLIBSCRIPTS = $(addprefix $(BUILDPATHDIR)/, $(BASHLIBSCRIPTS))
>
> $(BUILDPATHBASHLIBSCRIPTS): $(BUILDPATHDIR)/%: %
>         if test $< -nt $@; then \
>                 cp -f $< $@ \
>                 chmod a+rx $@; fi
>
> In a local makefile:
>
> BASHLIBSCRIPTS = revisionclass.sh
>
> include $(MAKEUTILITYDIR)/Makefile.rules.mak
>
> $(BUILDPATHDIR)/revisionopssingleton.sh: privateext
>
> privateext: revisionopssingleton.sh
>         ./compilerevision.sh $< $(BUILDPATHDIR)/$<
>
> My issues are that the privateext rule is ALWAYS run
> AND the $(BUILDPATHBASHLIBSCRIPTS) rule is always run

Well, sure.

Make needs to build the target privateext.    Make sees that target
doesn't exist so it tries to build it, and to do so make runs the recipe
"./compilerevision.sh $< $(BUILDPATHDIR)/$<".

That recipe succeeds but the file privateext has not been created.  So,
the next time make runs it tries to build the target privateext again.
And the next time it will try to build it again, etc.

Because your recipe doesn't follow the Second Rule of Makefiles (it
doesn't create the file $@), make will always try to run it, hoping this
time it will work.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make