Make .o withe the same rule for both C and C++ files (newbie question)

2005-10-05 Thread Stefan Karlsson

Hello all,

I want to use the same rule for compiling both C and C++ files. Since I 
have a compiler with some peculiarities I cannot get away with just 
changing some variables and rely on the default rules.


Basically, instead of writing

 %.o: %.c
 the-rule

 %.o: %.cpp
 the-rule

I want to write something like

 %.o: %.c
 %.o: %.cpp
 the-rule


Is this possible? I'm a newbie, so please forgive me if this question is 
ultra-stupid.


--
Stefan Karlsson | [EMAIL PROTECTED]




___
Help-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make


Re: Make .o withe the same rule for both C and C++ files (newbie question)

2005-10-05 Thread Ken Smith
On Wed, Oct 05, 2005 at 09:44:07PM +0200, Stefan Karlsson wrote:
 Hello all,
 
 I want to use the same rule for compiling both C and C++ files. Since I 
 have a compiler with some peculiarities I cannot get away with just 
 changing some variables and rely on the default rules.
 
 Basically, instead of writing
 
  %.o: %.c
  the-rule
 
  %.o: %.cpp
  the-rule
 
 I want to write something like
 
  %.o: %.c
  %.o: %.cpp
  the-rule
 
 
 Is this possible? I'm a newbie, so please forgive me if this question is 
 ultra-stupid.

You could do something like this

define c-and-c++-rule
the-rule
endef

%.o: %.c
$(c-and-c++-rule)

%.o: %.cpp
$(c-and-c++-rule) 


  Ken


___
Help-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make