Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting make To Recognize .f90 Suffixes

3 views
Skip to first unread message

David K Dean

unread,
Jan 4, 1994, 11:40:29 PM1/4/94
to
Any makefile gurus out there that can give me some advice? I have the
_Managing Projects with make_ book from O'Reilly & Associates and I'm trying
to write a makefile that will automate the compilation of a large Fortran 90
project. Below is a sample portion of my makefile. It works, but it seems
awful redundant to me. Is there a way that I can shorten this?

F90 = /bin/f90
F90FLAGS =

.SUFFIXES : .f90

.f90.o :
${F90} ${F90FLAGS} -c $<

supp_states.o : supp_states.f90 reqdprec.o
${F90} -c -p reqdprec.o supp_states.f90

supp_codes.o : supp_codes.f90 reqdprec.o
${F90} -c -p reqdprec.o supp_codes.f90

inner_product.o : inner_product.f90 num_constants.o reals.o reqdprec.o
${F90} -p num_constants.o -p reals.o -p reqdprec.o inner_product.f90

reals.o : reals.f90 reqdprec.o
${F90} -c -p reqdprec.o reals.f90

num_constants.o : num_constants.f90 reqdprec.o
${F90} -c -p reqdprec.o num_constants.f90

reqdprec.o : reqdprec.f90 normal.o
${F90} -c -p normal.o reqdprec.f90

true_false.o : true_false.f90
${F90} -c $<

normal.o : normal.f90
${F90} -c $<

The main difficulty I am having is that that all prerequisites except
for the .f90 file are Fortran 90 modules and these have to be listed on the
f90 command line with -p flag for each one. If the .f90 file didn't have to be
included in the prerequisite list could I use the following?

${F90} -c -p $<

Also, is the .SUFFIX rule I defined correct? I know I still need to
define a .f90~.o suffix rule to handle SCCS files, but I want to get this one
correct first.

Any help that you can give me would be greatly appreciated. I'll
repost the answers to comp.lang.fortran if I come up with a nice neat generic
makefile that adds the .f90 suffix to the make suffix rules. I'm sure this
will come in handy as more and more people use Fortran 90 and until vendors
update their versions of make. Thanks in advance.


Dave

Michel Olagnon, Ifremer DITI GO, 98.22.41.44

unread,
Jan 5, 1994, 12:13:43 PM1/5/94
to
In article 7577...@pv343f.vincent.iastate.edu, dkd...@iastate.edu (David K Dean) writes:
> Any makefile gurus out there that can give me some advice? I have the
>_Managing Projects with make_ book from O'Reilly & Associates and I'm trying
>to write a makefile that will automate the compilation of a large Fortran 90
>project. Below is a sample portion of my makefile. It works, but it seems
>awful redundant to me. Is there a way that I can shorten this?
>
> F90 = /bin/f90
> F90FLAGS =
>
> .SUFFIXES : .f90
>
> .f90.o :
> ${F90} ${F90FLAGS} -c $<
>
> supp_states.o : supp_states.f90 reqdprec.o
> ${F90} -c -p reqdprec.o supp_states.f90
>
>[...]

>
> The main difficulty I am having is that that all prerequisites except
>for the .f90 file are Fortran 90 modules and these have to be listed on the
>f90 command line with -p flag for each one. If the .f90 file didn't have to be
>included in the prerequisite list could I use the following?
>
> ${F90} -c -p $<
>
> Also, is the .SUFFIX rule I defined correct? I know I still need to
>define a .f90~.o suffix rule to handle SCCS files, but I want to get this one
>correct first.
>
> Any help that you can give me would be greatly appreciated. I'll
>repost the answers to comp.lang.fortran if I come up with a nice neat generic
>makefile that adds the .f90 suffix to the make suffix rules. I'm sure this
>will come in handy as more and more people use Fortran 90 and until vendors
>update their versions of make. Thanks in advance.
>

First the .SUFFIX rule: according to my version of make, it should read
SUFFIXES: .f90 .f90~ $(SUFFIXES)
otherwise, I have been told that one gets lots of problems with the previously
defined suffixes (I never tried to remove the $(SUFFIXES) :-))

I am still looking for an elegant solution to the combination of make and
modules. If someone has one, please post it.
If you want to know at which point I stand, look at the Makefile in my
rnflow benchmark (anonymous ftp molene.ifremer.fr, pub/ifremer.fortran90).

As I understand the problem, a F90 module may contain some information that
is needed by other procedures at compile time, and some information that is
only needed at link time.
With Nag compiler, the information is split into 2 files, .mod for compile
time and .o for link time. The dependency graph thus forks and joins, like
this:
program.f90 module.f90
| / \
| module.mod module.o
| / /
program.o /
\ /
program.exe

program.exe depends on module.f90 through 2 different pathes, but this can
be solved, though with some pain, because:
1) module.mod and module.o are generated with a single action
2) Nag compiler finds the module by itself if the directory is specified
in the command line.

If your compiler puts all the information in a single module.o file, perhaps
it would accept that you put these prerequisite files in a library and
use a single -p libreq.a option.
You would then have something like:
AR=ar
ARFLAGS=rv
RM=rm -f
#
SUFFIXES: .f90 .f90~ .a $(SUFFIXES)
#
PREREQ=libreq.a
F90FLAGS=
FC90=/usr/local/bin/f90
COMPILE.f90=$(FC90) $(F90FLAGS) -c
LINK.f90=$(FC90) $(F90FLAGS)
f90:
$(LINK.f90) -o $@ -p $(PREREQ) $<
f90.o:
$(COMPILE.f90) -p $(PREREQ) $<
f90.a:
$(COMPILE.f90) -o $% -p $(PREREQ) $<
$(AR) $(ARFLAGS) $@ $%
$(RM) $%
o.a:
$(AR) $(ARFLAGS) $@ $%

$(PREREQ):$(PREREQ)(reals.o redprec.o)
supp_states.o : supp_states.f90 $(PREREQ)
supp_codes.o : supp_codes.f90 $(PREREQ)
true_false.o : true_false.f90

Otherwise, I don't know.

Michel

---
| Michel OLAGNON email : Michel....@ifremer.fr|
| IFREMER: Institut Francais de Recherches pour l'Exploitation de la Mer|


0 new messages