help-make
[Top][All Lists]
Advanced

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

Re: have a problem mixing Make and java.


From: Paul D. Smith
Subject: Re: have a problem mixing Make and java.
Date: Thu, 23 Feb 2006 11:52:12 -0500

%% richard t <address@hidden> writes:

  rt> here is an example showing multiple targets...

  rt> x.class y.class z.class : x.java y.java z.java
  rt>    javac -g $< 

  rt> I guess I understood that the "$<" would match each 
  rt> source file that needed to be compiled? 

No.  It matches the FIRST source file in each target's list of
prerequisites.  What you have written above is really shorthand for
writing three separate rules:

 x.class : x.java y.java z.java
    javac -g $< 
 y.class : x.java y.java z.java
    javac -g $< 
 z.class : x.java y.java z.java
    javac -g $< 

Note how each target has the SAME list of prerequisites.

So, in all cases $< will be the first one, which is always x.java.

  rt> now on to the other part that you mentioned... the
  rt> "$^" macro, so based on the make line toward the top
  rt> of this e-mail, it would match?:

  rt>   "$^" = x.java y.java z.java 

  rt> so this would produce the following command?:

  rt>    javac -g x.java y.java z.java

Yes.

  rt> I would also assume that I could use the "subst" to 
  rt> create the package names for each source file?
  rt> (that would be quite useful...)

Do not use "subst".  "subst" changes EVERY instance of the string
anywhere; this can lead to errors if you have multiple instances of the
same string in a single word.

Use patsubst instead; it's much safer.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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