euglug.org

[Eug-lug] How to program GNU “make”?

작성자

카테고리:



Allen BrownMon Dec 27 15:09:27 PST 2004

Thank you.  That gave me the hints I needed.
I ended up with a rule that looked more like

file1_t file2_t:  %_t:	%_t.o %.o
		rules

The reason I need this additional qualification is that the
dependencies and rules are not quite the same for different
target files.
--
Allen Brown
  work: Agilent Technologies      non-work: http://www.peak.org/~abrown/
        allen_brown at agilent.com             abrown at peak.org
   o      o     o    o     o    <o     <o>    o>    o
  .|.    \|.   \|/   //    X     \      |    <|    <|>
   /\     >\   /<    >\   /<     >\    /<     >\    /<



On Mon, 27 Dec 2004, Bob Miller wrote:

> Allen Brown wrote:
> 
> > I'm having trouble expressing a rule using GNU make.
> > This is what I want:
> > 
> > file1_t file2_t:		$(@:_t=_t.o) $(@:_t=.o)
> > 			rules to compile and test file*_t
> > 
> > The problem is that $(@) type constructs don't seem to work in
> > the dependency list.  For instance
> > 
> > file:				$(@).o
> > 
> > causes make to try to create ".o" from ".c".  So evidently
> > in the dependency list $(@) is a null string.
> > 
> > What is the right way to express this?
> 
> Take a look at Pattern Rules in the info pages.  Your example
> should look like this.
> 
> 	%_t:	%_t.o %.o
> 		@echo linking $^ into $@
> 		$(CC) -o $@ $^
> 	
> 	default: file1_t file2_t ;
> 
> -- 
> Bob Miller                              K<bob>
> kbobsoft software consulting
> http://kbobsoft.com                     kbob at jogger-egg.com
> _______________________________________________
> EUGLUG mailing list
> euglug at euglug.org
> http://www.euglug.org/mailman/listinfo/euglug
>