[OpenIndiana-discuss] How do I get OpenIndana's make (not gmake) to accept the following
James Carlson
carlsonj at workingcode.com
Sun Jun 3 18:25:27 UTC 2012
On 6/3/2012 11:17 AM, Richard Sharpe wrote:
> Hmmm, that does not _seem_ to be the case. Regardless of whether I have
>
> .SUFFIXES: .o .so
>
> or
>
> .SUFFIXES: .so .o
>
> I still get the same message indicating that it does not know how to
> build a .so from a .o
>
> (The indent above is for exposition purposes, the .SUFFIXES: is hard
> up against the left hand column in the Makefile.)
That's not quite how the old-style implicit suffix rules work. They
don't chain together in arbitrary ways, so the match is between suffixes
and dependencies.
Note that this is true of all implementations of 'make' -- not just the
one in OpenIndiana, but also GNU make and BSD make and others.
In other words, if you need foo.so and have only foo.c, then 'make' will
look for an implicit rule of the form ".c.so". If such a rule exists,
it uses it. If not, it's done with the implicit rule search.
If you have a ".o.so" rule, then either the "foo.o" file must already
exist for that rule to fire, or you need a dependency from the .so to
the .o file; otherwise, it's ignored.
If you have another dependency to complete the chain, then 'make' will
find the rules you're specifying. For example, if you have this:
all: foo.so
foo.so: foo.o
Then make goes through these steps: first, it wants a target to build,
and it finds "all." "All" depends on "foo.so", so it needs that.
"foo.so" depends on "foo.o", so, even though "foo.o" doesn't exist, it
goes on to build "foo.o" from the existing "foo.c", then looks for the
".o.so" rule, and finds it.
You can see some of the subtleties of this if you remove the "foo.so:"
dependency rule above and do "make foo.o" then "make". The first run
will create "foo.o". The second will create "foo.so" as expected.
--
James Carlson 42.703N 71.076W <carlsonj at workingcode.com>
More information about the OpenIndiana-discuss
mailing list