Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using make

Status
Not open for further replies.

salgerman

Programmer
Jan 14, 2010
520
US
So, this is probably best for the 'make' forum, except that there isn't one...I could try an e-mail to the group, but I figure I give it a try here, too.

For years, I have been working in Fortran 77 and using make files successfully to automate compilation and deployment...

...somewhere in my make files, I have a line to collect all Fortran sources that are meant to be compiled:

fsrc?=$(wildcard *.f *.F)

With Fortran 77, my common blocks were in *.inc files and "include"-ed into the *.f files, so, the common blocks were not picked up for compilation; and it was not needed, of course.

Now, I am trying to move on to Fortran 90 and use modules to collect global variables. Module files, though, need to be compiled to produce *.mod and *.o files and so, I have given them *.f90 extension. To collect them, I initially updated my line to:

fsrc?=$(wildcard *.f *.F *.f90 *.F90)

This line collects the *.f90 files (modules and other sources) in no particular order and I noticed that module sources need to be compiled first to make the corresponding *.mod and *.o available for compilation of the sources the use them...so, I thought I would add the suffix "_mod" to module files and collect them first:

fsrc?=$(wildcard *.f *.F *_mod.f90 *.f90 *.F90)

Except, that now they get collected twice, once under *_mod.f90 and again under *.f90...which then yields "multiple definition" errors.

If anybody knows gnu-make well, maybe a way to remove duplicates from my list variable fsrc would do...I just don't see how, just yet. Don't want to use sort, because that may not leave the *_mod.f90 files at the beginning of the list.

Anyway ideas on how to go about solving this logistics problem? It's been a long day and could use some new ideas.

Thanks in advance.

Germán



 
looks like make's filter-out did the trick...I filter them out and then put them back at the beginning...

fmodules?=$(wildcard *_mod.f90)
fall?=$(wildcard *.f *.F *.f90 *.F90)
fsources?=$(filter-out $(fmodules), $(fall))
fsrc?=$(fmodules) $(fsources)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top