[Top][All Lists]

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

Re: Dynamics files managed by Makefile

From: Tim Murphy
Subject: Re: Dynamics files managed by Makefile
Date: Tue, 18 Oct 2022 11:34:40 +0100

Fundamentally the wildcard is being evaluated at a time when the files
aren't yet there.

Your makefile has to be parsed and then some rules run to create the *.f90
files and THEN you want your wildcard to get evaluated.

You might need to experiment with a "toy" makefile (or pair of  makefiles
like Paul suggested) to see how to achieve this before you go to try and
achieve it in your huge application.

In my case I had a similar(ish) situation and I did something different:

LIST_OF_F90_FILES: =  #immediate assignment, starts empty

then in the makefile wherever I had a rule to generate an f90 file I would
append to the list:

<TAB>echo "blablah" >$@
LIST_OF_F90_FILES += bob.f90

<TAB>echo "blablah" >$@
LIST_OF_F90_FILES += bob.f90

dosomething_rule: $(LIST_OF_F90_FILES)
<TAB>echo "DO something to all the files - or something to each one"

I'm only mentioning this because there's more than one way to get the
result and it might give you another idea.



On Tue, 18 Oct 2022 at 08:23, Patrick Begou <> wrote:

> Thanks Paul for your quick and detailed answer.
> I had build a small example to test my build process, but unfortunately
> it works fine with make 🙁 The application is very large (several
> hundreds of files) and complex (generating many intermediate files in
> the build process, but with known static names for most of them). May be
> all these steps can confuse Make tool.
> I will read more in detail the documentation and specially the 3.7
> section you suggest. I was just picking informations in the different
> sections, may be not fully understanding the Make strategy when
> processing a Makefile.
> Patrick
> Le 17/10/2022 à 18:49, Paul Smith a écrit :
> > On Mon, 2022-10-17 at 18:35 +0200, Patrick Begou wrote:
> >> This file will be splitted in master_1.f90, master_2.f90,
> >> master_3.f90.... etc (number of file not known), each of them is a
> >> fortran module and master will be rewritted to use these module. This
> >> is done by a special target and a bash script. It works.
> > I'm not 100% sure that I understand the situation; it would be much
> > better if you provided the rules you're trying to write, or even better
> > a small working example.
> >
> > But I suppose you mean that there is some tool that takes one input
> > file and generates a set of output files with an unknown set of names,
> > then you want to build all those output files.
> >
> > It turns out that make is not very good at handling this type of
> > problem: that's why languages such as for example Java, which generate
> > output files based on the class names rather than input files names, do
> > not use makefiles (most of the time).
> >
> > The most straightforward way to do this is to use a recursive
> > invocation of make: the top-level invocation would split the files,
> > then invoke a sub-make which would build the files; the sub-make could
> > use $(wildcard ...) etc. because it would only be invoked after the
> > spit completed.
> >
> >> But I'm unable with make to get a list of these new master_x.f90
> >> files for the compilation, seams that my variable:
> >>
> >> SPLIT_SRC=$(wildcard master_*.f90)
> >>
> >> is always empty and only evaluated at the startup.
> > That's not quite true.  The variable SPLIT_SRC is set to the string
> > "$(wildcard master_*.f90)".  It will be evaluated when the variable
> > "$(SPLIT_SRC)" is evaluated in your makefile.  The way in which
> > variables are evaluated is described here:
> >
> >
> >
> > So if you try to use this variable as a set of targets or
> > prerequisites, then it will be evaluated when those targets /
> > prerequisites are parsed (that is while the makefile is being read in)
> > and it will be empty.

reply via email to

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