Greg Minshall (29 March 2022 06:38) wrote:
> hi.  sorry.  i'm not sure if this is a bug.

I'm fairly sure it isn't.

> (but, i'm guessing that dependencies are built when the makefile is read, then
> not updated?)

The assignment of variables happens when the Makefile is read, but there
are two kinds of assignment: the plain = you're using causes each
evaluation of INFILES to invoke the shell command that gets you the list
of files in ./input; likewise for INFILESASOUT and OUTFILES, as they
reference it.  The dependencies are indeed set up also during reading of
the makefile, at which time OUTFILES only lists the files inferred from
the initial contents of ./inputs, so b.input isn't seen and b.output
isn't declared as a prerequisite of processoutputs.  However, when the
rule for that gets run, after setup, OUTFILES is re-evaluated so you get
an updated version of it, that doesn't match the prerequisites list.

> INFILES = $(notdir $(shell ls ${INDIR}/*.input))

Note: make has a builtin wildcard function, that can save you the need
to run a shell:

INFILES = $(notdir $(wildcard ${INDIR}/*.input))

However, see the note below, on your "something" rule.

> INFILESASOUT = $(INFILES:.input=.output)
> OUTFILES = $(addprefix ${OUTDIR}/,$(notdir ${INFILESASOUT}))

Note that you can do this by pattern-matching substitutions:

OUTFILES = $(INFILES:%.input=$(OUTDIR)/%.output)

> something:
>       @touch ${NEWIN}

Because ${NEWIN}'s creation isn't flagged by it being an actual target,
make doesn't know it's been created, so its cached information about the
file-system won't be updated, with the result that $(wildcard ...) might
still not include it, where $(shell ls ...) would.

It is generally good to let make know what files a rule creates, rather
than creating files as a side-effect of making a phony target.


Reply via email to