Re: makdep


Subject: Re: makdep
From: Bill Peterson (bill@essc.psu.edu)
Date: Fri Feb 26 1999 - 15:37:19 MST


Christine,
There is no need to have any rule that makes a .f file depend on a .F
file. The 1st rule from your letter:

prgm.o : prgm.F incl1.h incl2.h

combined with any of the below implicit rules does what you want (note
these are GNU make pattern rules -- for make the target is ".o .F :")

rule 1) -- Let the FORTRAN compiler invoke the preprocessor:

%.o : %.F
        ${FC} -c ${FFLAGS} ${FPPFLAGS} $<

rule 2) -- Invoke the preprocessor explicitly and always remove the .f file:

%.o : %.F
        ${FPP} ${FPPFLAGS} $< $*.f
        ${FC} -c ${FFLAGS} $*.f || (rm -f $*.f; exit 1)
        -rm -f $*.f

rule 3) -- Invoke the preprocessor explicitly, leave .f file behind:

%.o : %.F
        ${FPP} ${FPPFLAGS} $< $*.f
        ${FC} -c ${FFLAGS} $*.f

The point is there is no dependence (explicit or implicit) on the .f file.
It is just a byproduct of the compile. One can make various arguments
over whether rule 1 or rule 2 is better. The default make rules for Sun
(Solaris 2.6) and the Cray (PE 3.0.2.0) are essentially rule 1. You can
see the default rules on your machine with something like: "make -p |& less".

Furthermore you can entirely avoid makedep by using the preprocessor to
generate the dependencies -- see the GNU make manual (end of chap 4) for
a way to have the dependencies generated automatically by the makefile.
Hope this helps, cheers.
-- Bill

   --------------------------------------------------------------------
   Bill Peterson
   EMSEI Computing Facility Director EMS Environment Institue
   bill@essc.psu.edu 248 Deike Bldg
   +1 814 865 0294 Penn State
   FAX: 865 3191 University Park, PA 16802-2711

Christine Delire writes:
>
>
> Does anyone know why makedep makes a Depends file that has the syntax
>
> prgm.o : prgm.F incl1.h incl2.h
>
> instead of
>
> prgm.o : prgm.f
> prgm.f : prgm.F incl1.h incl2.h
>
> ?
>
> The second syntax is nicer because the makefile understands that it has to
> use the preprocessor whenever a common block has changed. In the first
> case, the makefile compiles the subroutine that includes the modified
> common block but uses the old copy of the common block ( the preprocessor
> is not used in that case).
>
>
>
> Christine Delire
>
> Climate, People and Environment Program,
> 1225 West Dayton Street,
> Madison, Wi, 53706, USA.
>
> Tel: +01-608-262-5961
> Fax: +01-608-263-4190
>
>



This archive was generated by hypermail 2b27 : Thu Jun 01 2000 - 09:27:09 MDT