help-make
[Top][All Lists]
Advanced

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

Question on building a multple-target rule


From: Jeff Vincent
Subject: Question on building a multple-target rule
Date: Mon, 18 Jun 2001 10:32:35 -0600

<Is there a mailing list I need to subscribe to?>
 
Hey,
 
I have a (hopefully) simple question about make as I am a bit rusty (too much Windoze and NetWare ;-).
 
We are using GNU make as a cross platform build tool to build a Java application with many classes.  I have a situation where I use the $(shell ...) command to build up a list of .java files from the source directory tree and when they get built, they are placed in a different directory tree.  For example,  ./src/<pkg_name>/myclass.java gets put into ./classes/<pkg_name>/myclass.class
 
I want to build all of the out-of-date targets at once as the javac compiler will allow this through multiple items on the command line.  My rules look like this:
 
#Windows shell cmd
SRC_JAVA := $(shell dir .\src\*.java /s /b)
 
#RULE 1
all: javaClasses
 
#RULE 2
javaClasses : $(subst $(SRC_DIR),$(DEST_DIR),$(SRC_JAVA:.java=.class))
 
#RULE 3
$(subst $(SRC_DIR),$(DEST_DIR),$(SRC_JAVA:.java=.class)) : $(SRC_JAVA)
 
$(JAVA_C_TOOL) $(JAVA_C_OPTS) -d $(DEST_PATH) $?
The problem is that because the way multiple target rules and multiple dependencies are expanded,  RULE 3 gets called for EACH item in the dependency list for RULE 2. 
 
Is there a way for RULE 3 to get called ONLY ONCE for ALL out-of-date targets?  Please explain how.  In other words, I want to send only out-of-date ./src/<pkg_name>/*.java files to javac in one call and let javac build the ./classes/<pkg_name>/*.class files with one rule invokation instead of calling javac for each .java file individually.
 
Hope this makes some sense.  Thanks for any input.
 
Jeff

reply via email to

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