I need to be able to compile my program, then execute it 3 different times with a different .txt file as the first command line argument each time, and this all needs to be done with a single "make" command. The respective terminal commands for what I want my Makefile to do are as follows:
javac MainDriver.java FSA.java State.java Transition.java
java MainDriver test1.txt
java MainDriver test2.txt
java MainDriver test3.txt
Here's what I currently have:
JC = javac
JCR = java
.SUFFIXES: .java .class
.java.class:
$(JC) $*.java
CLASSES = \
MainDriver.java \
FSA.java \
State.java \
Transition.java
default: classes
classes: $(CLASSES:.java=.class)
clean:
$(RM) *.class *~
JC = javac
JCR = java
.SUFFIXES: .java .class
.java.class:
$(JC) $*.java
CLASSES = \
MainDriver.java \
FSA.java \
State.java \
Transition.java
TXT_FILES = \
test1.txt \
test2.txt \
test3.txt \
default: classes exec-tests
classes: $(CLASSES:.java=.class)
clean:
$(RM) *.class *~
exec-tests: classes
set -e; \
for file in $(TXT_FILES); do $(JCR) MainDriver $$file; done;
.PHONY: default clean classes exec-tests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With