[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with prerequisites for unit testing rule
From: |
John Graham-Cumming |
Subject: |
Re: Help with prerequisites for unit testing rule |
Date: |
Tue, 08 Feb 2005 10:34:06 -0500 |
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/