tech-pkg archive

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

Re: bmake .OODATE confusion



> Date: Fri, 30 Aug 2024 10:55:49 +0100
> From: Jonathan Perkin <jperkin%mnx.io@localhost>
> 
> With "mktool fetch" I am using different semantics for the do-fetch 
> target.  The target still depends on all distfiles, but instead of each 
> distfile target being a separate script that performs the download, I 
> download all of the targets in the do-fetch target to significantly 
> improve performance with parallel downloads.
> 
> This has the drawback of always running mktool, regardless of whether 
> the dependency targets exist or not.  I'd like for do-fetch to not 
> execute its commands if all of the dependencies are up-to-date.
> 
> While trying to find a solution for this, I came across .OODATE.  The 
> documentation states:
> 
>    "The list of sources for this target that were deemed out-of-date.."
> 
> This seems like it would be a possible workaround, i.e. only run mktool 
> if "${.OODATE}" != "" or whatever.

It seems what this means is:

- For a non-phony target that exists, .OODATE is the list of sources
  that are newer than the target.

  (The language in the man page is backwards: it's the target, not the
  sources, that's out-of-date.  But that error isn't germane to your
  issue.)

- For a non-phony target that does not exist, .OODATE is the list of
  all sources.

- For a phony target, .OODATE is _also_ the list of all sources, just
  as if it were a non-phony target that does not exist.

Here's an example I constructed to test this:

$ cat Makefile
z: x y
	@echo .OODATE="${.OODATE}" .IMPSRC="${.IMPSRC}" .ALLSRC="${.ALLSRC}"
	touch $@

w: x y .PHONY
	@echo .OODATE="${.OODATE}" .IMPSRC="${.IMPSRC}" .ALLSRC="${.ALLSRC}"
	touch $@
$ touch x; sleep 2; touch z; sleep 2; touch y; make z
.OODATE=y .IMPSRC= .ALLSRC=x y
touch z
$ make w
.OODATE=x y .IMPSRC= .ALLSRC=x y
touch w

General comment: make(1) is really designed for many-to-one recipes,
not for many-to-many recipes.  You can write `foo bar baz: quux' but
it's not actually many-to-many -- it's just multiple many-to-one
recipes and sometimes makes make(1) confused, especially in parallel.
gmake has syntax `&:' for a real many-to-many rule.  Perhaps if its
semantics is good we should adopt that, and you could use that instead
of the do-fetch kludge.


Home | Main Index | Thread Index | Old Index