On Tue, 2005-02-08 at 09:28, Bj�rn Lindstr�m wrote:
> CLASSPATH=.:/usr/share/java/junit.jar
> 
> JAVAC=javac -classpath $(CLASSPATH)
> JUNIT=java -classpath $(CLASSPATH) junit.textui.TestRunner
> 
> CLASSES=A.class B.class C.class
> 
> all: $(CLASSES)
> 
> %.class: %.java
>         $(JAVAC) $<
> 
> test: $(CLASSES:%=Test%)
>         $(JUNIT) $(patsubst %.class,%,$<)
> 
> .PHONY: clean
> clean:
>         -rm $(CLASSES) $(CLASSES:%=Test%)
> ----
> 
> My question is how to get the test rule to make A.class a prerequisite
> for TestA.class, B.class a prerequisite for TestB.class, and so on.

Check out static pattern rules in the GNU Make manual.  The actual
syntax you want to add to your Makefile is:

    $(CLASSES:%=Test%): Test%: % 

Since you are repeating the substitution reference in many places it's
probably a good idea to define

    TESTCLASSES := $(CLASSES:%=Test%)

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to