%% Charles Owen <[EMAIL PROTECTED]> writes:

  co> I wonder if there is a simpler, more direct way to do the following:

  co> package := example

  co> $(classfiles)/$(package)/%.class: $(src)/$(package)/%.java
  co>   @echo "Compiling $@..."
  co>   @$(javac) $^

  co> $(classfiles)/$(package)/%.class: $(tests)/$(package)/%.java
  co>   @echo "Compiling $@..."
  co>   @$(javac) $^

  co> package := util

  co> $(classfiles)/$(package)/%.class: $(src)/$(package)/%.java
  co>   @echo "Compiling $@..."
  co>   @$(javac) $^

  co> $(classfiles)/$(package)/%.class: $(tests)/$(package)/%.java
  co>   @echo "Compiling $@..."
  co>   @$(javac) $^


Since $(package) is the same in the target and prerequisite, why not
just write:

  $(classfiles)/%.class : $(src)/%.java
          @echo "Compiling $@..."
          @$(javac) $^

  $(classfiles)/%.class : $(tests)/%.java
          @echo "Compiling $@..."
          @$(javac) $^

?  Now these rules will work regardless of the value of $(package) for a
particular target.

Remember that "%" is a text matching token; it doesn't know anything
about directory separators and is not limited by them.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          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


_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to