java - Yet another "multiple target patterns" makefile error -
i tried looking around, of questions saw here high-level me understand.
here's makefile:
compile: bin src cmp bin: mkdir bin src: find src -name "*.java" > sources.txt cmp: javac -cp biuoop-1.4.jar -d bin @sources.txt run: java -cp biuoop-1.4.jar:bin:src/resources ass6game jar: jar -cmf ass6game.jar manifest.txt -c bin . -c src resources
when try run make compile
, "multiple target patterns" error. did wrong?
your makefile syntax incorrect.
the syntax of make rule is
in general, rule looks this:
targets : prerequisites recipe …
or this:
targets : prerequisites ; recipe recipe
whereas have recipe lines in prerequisite location , :
in java command confusing make.
your makefile should this
compile: bin src cmp bin: ; mkdir bin src: ; find src -name "*.java" > sources.txt cmp: ; javac -cp biuoop-1.4.jar -d bin @sources.txt run: ; java -cp biuoop-1.4.jar:bin:src/resources ass6game jar: ; jar -cmf ass6game.jar manifest.txt -c bin . -c src resources
or this
compile: bin src cmp bin: mkdir bin src: find src -name "*.java" > sources.txt cmp: javac -cp biuoop-1.4.jar -d bin @sources.txt run: java -cp biuoop-1.4.jar:bin:src/resources ass6game jar: jar -cmf ass6game.jar manifest.txt -c bin . -c src resources
or use make provides bit more more this
jar := biuoop-1.4.jar sources := $(shell find src -name '*.java') # or if src single directory without sub-directories #sources := $(wildcard src/*.java) gamejar := ass6game.jar .phony: all: $(jar) bin: mkdir bin $(jar): $(sources) | bin javac -cp $@ -d bin $^ # see http://www.gnu.org/software/make/manual/make.html#force-targets `force` doing here. $(gamejar): force jar -cmf $@ manifest.txt -c bin . -c src resources force: ; .phony: run run: $(gamejar) java -cp $(jar):bin:src/resources $(gamejar)
which follows rules of makefiles bit better , lets make intelligently rebuild files necessary.
Comments
Post a Comment