[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pattern rules in an automake file?

From: Nick Bowler
Subject: Re: pattern rules in an automake file?
Date: Thu, 6 Mar 2014 10:05:08 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On 2014-03-06 13:21 +0100, tom fogal wrote:
> [in GNU make] ... I defined a custom pattern rule:
>   %.mpi.o: %.mpi.c
>     $(MPICC) -c $(CFLAGS) $^ -o $@
> I unfortunately cannot replicate this setup with automake.  It seems
> the generated makefile does not know of the rule if I included it as-is
> in my .am file.  I get:
>   make: *** No rule to make target `netz.mpi.lo', needed by `'.  
> Stop.

Since you are using Libtool, Automake is expecting a libtool object
which has a .lo extension.  You will probably need to write a rule
which invokes the compiler via libtool, and uses a .lo suffix.

> (I am using libtool as well; this is a pkglib_LTLIBRAR...y) I can't
> get a suffix rule to work as-is, perhaps due to all the '.'s.  I tried
> changing it to a '-' and using:
>   SUFFIXES = -mpi.o
>   -mpi.o.c:
>     $(MPICC) -c $(CFLAGS) $^ -o $@

There are a couple problems with this.  First, POSIX requires that all
suffixes start with a period and do not contain any other periods or
slashes (other than the one).  As a result, this target actually is not
an inference rule: it is a rule to create a file called literally


Second, suffix rules will look "backwards" if you are used to pattern
rules, the syntax is


where s1 is the suffix of the prerequisite file, and s2 is the suffix of
the target file.

I recommend changing the extension to one without a period.  For
example, you can use .mpic or similar.  Then you can write a rule like

  # Note: you do not need to set SUFFIXES for simple rules like this

which should work in GNU and non-GNU makes alike.  Integrating with
libtool is left as an exercise to the reader.

Nick Bowler, Elliptic Technologies (

reply via email to

[Prev in Thread] Current Thread [Next in Thread]