>
> Having worked on f90 projects on Windows platforms for a few years I have
> spared myself from learning much about 'make'. I am now working on unix
> (Tru64 - DEC Fortran) and have to pay more attention to makefiles. My
> question is really what is the best way to deal with module dependancies?
>
> If you just make the .o files dependent on the .f90 files then make knows
> nothing about module dependancies. In this case, unless the source files are
> compiled in a particular order, the compiler may fall over because it can't
> find a particular .mod file. Once the .mod files are in the build directory
> there are no problems on future builds. This is unsatisfactory, to me at
> least.
>
That's usually not a problem. The argumentation goes about like this:
- .o and .mod files are created at the same time.
- They are also deleted at the same time ("Make clean" or similar)
- They become out-of-date at the same time (by changing the source file)
- If your Makefile is to work on various platforms, you can't be sure
about the extension of the modules, or whether they are in the current
directory. This is much less the case for object files.
The only case where this fails is when the module file got deleted,
but the object file is still there. This doesn't happen under normal
circumstances. If it does, compilation fails and you have to delete
the object.
> The alternative seems to be to hand craft makefiles so that all module
> dependancies are taken care of.
This has to be done anyway, if not for module files, then for object
files.
> I may be a bit dum here - feel free to correct me - but I am sure you are
> dealing with this in a variety of ways. I would like to hear about some of
> them. Are there any automated ways of building f90 makefiles?
>
There are tools around to check for include files and modules used in
Fortran source files, and create the dependencies for inclusion in a
Makefile. I wrote my own script, but it depends on the include files
being in the correct directory, etc.. I'm sure somebody has a more
general one.
Hth,
Herbert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|