[comp.sys.sun] Sun make peculiarities

bernhold@orange.qtp.ufl.edu (David E. Bernholdt) (10/12/89)

I have noticed an annoying peculiarity of Sun's make (OS 4.0.1).

I use a home-grown proprocessor for Fortran.  The source files are .u and
running the preprocessor over them yields a compilable .f file.

In my makefile, I add .u to the suffix list via ".SUFFIXES: .u" and I
provide implicit rules for .u.a, .u.o, and .u.f.  The first two are
essentially the default .f.a and .f.o rules preceeded by running the
preprocessor over the .u file.  The .u.f rule just runs the preprocessor.

What I want to do is keep the .u files around and the library archive of
the .o files.  The .u.f rule allows me to easily generate the actual
Fortran source to use with the debugger, etc.  So I have (for example) a
file adm.u which should give a corresponding .o file in the archive
libjoda.a.  The .f file does *not* exist, nor does the .o file.

Here is what 'make -dd' has to say about this:
>   doname(../sun3-fpa/libjoda.a(adm.o))
>    Looking for % rule for ../sun3-fpa/libjoda.a(adm.o)
>    find_ar_suffix_rule(adm.o)
>    find_suffix_rule(../sun3-fpa/libjoda.a(adm.o),adm,.a)
>    build_suffix_list(.a) .o.a .c.a .s.a .S.a .f.a .F.a .mod.a .p.a .r.a .u.a
>    Trying adm.o
>    Trying adm.c
>    Trying adm.s
>    Trying adm.S
>    Trying adm.f

Fine so far, but now it appears to take a detour...  Remember, adm.f does
*not* exist!

>    stat(adm.f)
>    doname(adm.f)
>     Looking for % rule for adm.f
>     find_double_suffix_rule(adm.f)
>     find_suffix_rule(adm.f,adm,.f)
>     build_suffix_list(.f) .u.f
>     Trying adm.u
>     stat(adm.u)
>     doname(adm.u)
>      Looking for % rule for adm.u
>      find_double_suffix_rule(adm.u)
>      find_suffix_rule(adm.u,adm,.u)
>      build_suffix_list(.u)
>     Found adm.u
>     Date(adm.u)=Wed Oct 11 01:48:47 1989 
>                                 Date-dependencies(adm.f)=File does not exist
>     Building adm.f using suffix rule for .u.f 
>                                 because it is out of date relative to adm.u

So instead of searching the whole list, it decided at .f.a to check out
how it might be able to make the .f file.  It decides to make adm.f with
the .u.f rule and then proceeds to use the .f.a rule to finish the job.

The troublesome part of this is that it always wants the .f file and I
don't want to keep it around (it is removed after the .o is produced) so
it has to rebuild the .o file every time because its always out of date
with respect to the (non-existant) .f file.

If I get rid of the .u.f rule, it can't figure out how to make the .f file
and doesn't get detoured.  Of course then I don't have a good way of
making the Fortran source files.

If I create a dummy adm.c (notice .c.a appears before .f.a in the
"build_suffix_list(.a)" above) it uses the .c.a rule to make the object
file.

It appears that Sun has attempted to put some (very selected) transitivity
into their rule processing, but failed to properly account for the
possibility of missing intermediates.

I can't find this behavior documented anywhere in Sun's manuals.  Has
anyone seen this before?  Is it a bug or a "feature"?  It sure breaks my
makefiles.

Any help would be appreciated.

David Bernholdt			bernhold@qtp.ufl.edu
Quantum Theory Project		bernhold@ufpine.bitnet
University of Florida
Gainesville, FL  32611		904/392 6365